diff options
Diffstat (limited to '')
-rw-r--r-- | unit_tests/shared.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp index 023e917..0c9516f 100644 --- a/unit_tests/shared.cpp +++ b/unit_tests/shared.cpp | |||
@@ -52,6 +52,11 @@ namespace | |||
52 | return 0; | 52 | return 0; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | // a function that returns immediately (so that LuaJIT issues a function call for it) | ||
56 | lua_CFunction sGiveMeBack = +[](lua_State* L_) { | ||
57 | return lua_gettop(L_); | ||
58 | }; | ||
59 | |||
55 | lua_CFunction sNewLightUserData = +[](lua_State* const L_) { | 60 | lua_CFunction sNewLightUserData = +[](lua_State* const L_) { |
56 | lua_pushlightuserdata(L_, std::bit_cast<void*>(static_cast<uintptr_t>(42))); | 61 | lua_pushlightuserdata(L_, std::bit_cast<void*>(static_cast<uintptr_t>(42))); |
57 | return 1; | 62 | return 1; |
@@ -71,8 +76,9 @@ namespace | |||
71 | 76 | ||
72 | static luaL_Reg const sFixture[] = { | 77 | static luaL_Reg const sFixture[] = { |
73 | { "forever", sForever }, | 78 | { "forever", sForever }, |
79 | { "give_me_back()", sGiveMeBack }, | ||
74 | { "newlightuserdata", sNewLightUserData }, | 80 | { "newlightuserdata", sNewLightUserData }, |
75 | { "newuserdata", sNewUserData }, | 81 | { "newuserdata", sNewUserData }, |
76 | { "on_state_create", sOnStateCreate }, | 82 | { "on_state_create", sOnStateCreate }, |
77 | { "throwing_finalizer", sThrowingFinalizer }, | 83 | { "throwing_finalizer", sThrowingFinalizer }, |
78 | { "yielding_finalizer", sYieldingFinalizer }, | 84 | { "yielding_finalizer", sYieldingFinalizer }, |
@@ -163,7 +169,15 @@ LuaState::LuaState(WithBaseLibs const withBaseLibs_, WithFixture const withFixtu | |||
163 | STACK_CHECK_START_REL(L, 0); | 169 | STACK_CHECK_START_REL(L, 0); |
164 | if (withBaseLibs_) { | 170 | if (withBaseLibs_) { |
165 | luaL_openlibs(L); | 171 | luaL_openlibs(L); |
172 | } else { | ||
173 | #if LUAJIT_FLAVOR() | ||
174 | // lanes.core relies on the presence of jit to detect LuaJIT/PUC-Lua mismatches | ||
175 | luaL_requiref(L, LUA_JITLIBNAME, luaopen_jit, 1); | ||
176 | lua_pop(L, 1); | ||
177 | #endif // LUAJIT_FLAVOR | ||
166 | } | 178 | } |
179 | |||
180 | |||
167 | if (withFixture_) { | 181 | if (withFixture_) { |
168 | // make require "fixture" call luaopen_fixture | 182 | // make require "fixture" call luaopen_fixture |
169 | local::PreloadModule(L, "fixture", luaopen_fixture); | 183 | local::PreloadModule(L, "fixture", luaopen_fixture); |