|
|
@@ -41,3 +41,32 @@ TEST_CASE("stack_interaction") {
|
|
|
|
|
|
lua_close(state);
|
|
|
}
|
|
|
+
|
|
|
+TEST_CASE("stack_register_global") {
|
|
|
+ lua_State* state = luaL_newstate();
|
|
|
+
|
|
|
+ luwra::register_global(state, "test", 1338);
|
|
|
+
|
|
|
+ REQUIRE(luaL_dostring(state, "return test") == LUA_OK);
|
|
|
+ REQUIRE(luwra::read<int>(state, -1) == 1338);
|
|
|
+
|
|
|
+ lua_close(state);
|
|
|
+}
|
|
|
+
|
|
|
+TEST_CASE("stack_set_fields") {
|
|
|
+ lua_State* state = luaL_newstate();
|
|
|
+
|
|
|
+ lua_newtable(state);
|
|
|
+ luwra::set_fields(
|
|
|
+ state, -1,
|
|
|
+ "test", 1338,
|
|
|
+ 123, 456
|
|
|
+ );
|
|
|
+ lua_setglobal(state, "test");
|
|
|
+
|
|
|
+ REQUIRE(luaL_dostring(state, "return test.test, test[123]") == LUA_OK);
|
|
|
+ REQUIRE(luwra::read<int>(state, -2) == 1338);
|
|
|
+ REQUIRE(luwra::read<int>(state, -1) == 456);
|
|
|
+
|
|
|
+ lua_close(state);
|
|
|
+}
|