KAGUYA_TEST_FUNCTION_DEF(load_string)(kaguya::State& state) { kaguya::LuaRef luafun = state.loadstring("assert(11 == 11);return true"); TEST_CHECK(luafun() != false); state.setErrorHandler(ignore_error_fun); kaguya::LuaRef errorref = state.loadstring("function() e");//syntax error TEST_CHECK(!errorref); }
KAGUYA_TEST_FUNCTION_DEF(lua_resume_test)(kaguya::State& s) { using namespace kaguya; LuaThread t = s.newThread(s.loadstring("v={...}")); lua_State* co = t.get<lua_State*>(); lua_pushnumber(co, 2); lua_pushnumber(co, 3); lua_resume(co,s.state(),2); TEST_EQUAL(s["v"][1], 2); TEST_EQUAL(s["v"][2], 3); }