aboutsummaryrefslogtreecommitdiff
path: root/unit_tests/embedded_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--unit_tests/embedded_tests.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/unit_tests/embedded_tests.cpp b/unit_tests/embedded_tests.cpp
index a0a7bb2..388548d 100644
--- a/unit_tests/embedded_tests.cpp
+++ b/unit_tests/embedded_tests.cpp
@@ -2,6 +2,7 @@
2#include "shared.h" 2#include "shared.h"
3#include "lanes/src/lanes.hpp" 3#include "lanes/src/lanes.hpp"
4 4
5#if defined __has_include && __has_include(<windows.h>)
5#include <windows.h> 6#include <windows.h>
6 7
7// ################################################################################################# 8// #################################################################################################
@@ -138,13 +139,13 @@ namespace
138 139
139// ################################################################################################# 140// #################################################################################################
140 141
141TEST_CASE("lanes.embedding.with default allocator") 142TEST_CASE("lanes.embedding.with_default_allocator")
142{ 143{
143 local::EmbeddedLuaState S; 144 local::EmbeddedLuaState S;
144 145
145 // --------------------------------------------------------------------------------------------- 146 // ---------------------------------------------------------------------------------------------
146 147
147 SECTION("single state") 148 SECTION("single_state")
148 { 149 {
149 // this sends data in a linda. current contents: 150 // this sends data in a linda. current contents:
150 // key: short string 151 // key: short string
@@ -171,7 +172,7 @@ TEST_CASE("lanes.embedding.with default allocator")
171 172
172 // --------------------------------------------------------------------------------------------- 173 // ---------------------------------------------------------------------------------------------
173 174
174 SECTION("manual registration") 175 SECTION("manual_registration")
175 { 176 {
176 S.requireSuccess("require 'lanes'.configure{with_timers = false}"); 177 S.requireSuccess("require 'lanes'.configure{with_timers = false}");
177 178
@@ -191,7 +192,7 @@ TEST_CASE("lanes.embedding.with default allocator")
191 192
192 // try again after manual registration 193 // try again after manual registration
193 lua_pushcfunction(S, S.get_lanes_register()); // S: lanes_register 194 lua_pushcfunction(S, S.get_lanes_register()); // S: lanes_register
194 luaG_pushstring(S, LUA_IOLIBNAME); // S: lanes_register "io" 195 luaW_pushstring(S, LUA_IOLIBNAME); // S: lanes_register "io"
195 luaL_requiref(S, LUA_IOLIBNAME, luaopen_io, 1); // S: lanes_register "io" io 196 luaL_requiref(S, LUA_IOLIBNAME, luaopen_io, 1); // S: lanes_register "io" io
196 lua_call(S, 2, 0); // S: 197 lua_call(S, 2, 0); // S:
197 S.stackCheck(0); 198 S.stackCheck(0);
@@ -203,7 +204,7 @@ TEST_CASE("lanes.embedding.with default allocator")
203 204
204// this is not really a test yet, just something sitting here until it is converted properly 205// this is not really a test yet, just something sitting here until it is converted properly
205// currently it crashes with moonjit (but maybe I just need a more recent moonjit version) 206// currently it crashes with moonjit (but maybe I just need a more recent moonjit version)
206TEST_CASE("lanes.embedding.with custom allocator") 207TEST_CASE("lanes.embedding.with_custom_allocator")
207{ 208{
208 static constexpr auto logPrint = +[](lua_State* L) { 209 static constexpr auto logPrint = +[](lua_State* L) {
209 lua_getglobal(L, "ID"); // ID 210 lua_getglobal(L, "ID"); // ID
@@ -219,7 +220,7 @@ TEST_CASE("lanes.embedding.with custom allocator")
219 220
220 static constexpr auto launch_lane = +[](lua_CFunction on_state_create_, int id_, int n_) { 221 static constexpr auto launch_lane = +[](lua_CFunction on_state_create_, int id_, int n_) {
221 char script[500]; 222 char script[500];
222 lua_State* L = lua_newstate(local::allocf, nullptr); 223 lua_State* L = luaW_newstate(local::allocf, nullptr, luaL_makeseed(nullptr));
223 // _G.ID = id_ 224 // _G.ID = id_
224 luaL_openlibs(L); 225 luaL_openlibs(L);
225 luaL_dostring(L, "lanes = require 'lanes'"); 226 luaL_dostring(L, "lanes = require 'lanes'");
@@ -265,4 +266,6 @@ TEST_CASE("lanes.embedding.with custom allocator")
265 lua_close(L3); 266 lua_close(L3);
266 lua_close(L2); 267 lua_close(L2);
267 lua_close(L1); 268 lua_close(L1);
268} \ No newline at end of file 269}
270
271#endif // windows.h