diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/manual_register.lua | 6 | ||||
| -rw-r--r-- | tests/package.lua | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/manual_register.lua b/tests/manual_register.lua index 23b33c1..a8f2098 100644 --- a/tests/manual_register.lua +++ b/tests/manual_register.lua | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | ||
| 2 | local register_func = true | 2 | local register_func = true |
| 3 | 3 | ||
| 4 | local RequireAModuleThatExportsGlobalFunctions = function() | 4 | local RequireAModuleThatExportsGlobalFunctions = function(type_) |
| 5 | -- grab some module that exports C functions, this is good enough for our purpose | 5 | -- grab some module that exports C functions, this is good enough for our purpose |
| 6 | local lfs = require "lfs" | 6 | local lfs = require "lfs" |
| 7 | -- make one of these a global | 7 | -- make one of these a global |
| @@ -11,14 +11,14 @@ local RequireAModuleThatExportsGlobalFunctions = function() | |||
| 11 | if register_func then | 11 | if register_func then |
| 12 | lanes.register( "GlobalFunc", GlobalFunc) | 12 | lanes.register( "GlobalFunc", GlobalFunc) |
| 13 | end | 13 | end |
| 14 | print("RequireAModuleThatExportsGlobalFunctions done:", lanes.nameof(GlobalFunc)) | 14 | print(type_, "RequireAModuleThatExportsGlobalFunctions done:", lanes.nameof(GlobalFunc)) |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | local lanes = require "lanes".configure{ with_timers = false, on_state_create = RequireAModuleThatExportsGlobalFunctions} | 18 | local lanes = require "lanes".configure{ with_timers = false, on_state_create = RequireAModuleThatExportsGlobalFunctions} |
| 19 | 19 | ||
| 20 | -- load some module that adds C functions to the global space | 20 | -- load some module that adds C functions to the global space |
| 21 | RequireAModuleThatExportsGlobalFunctions() | 21 | RequireAModuleThatExportsGlobalFunctions("main") |
| 22 | 22 | ||
| 23 | local GlobalFuncUpval = GlobalFunc | 23 | local GlobalFuncUpval = GlobalFunc |
| 24 | 24 | ||
diff --git a/tests/package.lua b/tests/package.lua index de11c9e..4e8b59f 100644 --- a/tests/package.lua +++ b/tests/package.lua | |||
| @@ -2,21 +2,21 @@ local loaders = package.loaders or package.searchers | |||
| 2 | 2 | ||
| 3 | assert(nil == loaders[5]) | 3 | assert(nil == loaders[5]) |
| 4 | 4 | ||
| 5 | local configure_loaders = function() | 5 | local configure_loaders = function(type_) |
| 6 | table.insert(loaders, 4, function() end) | 6 | table.insert(loaders, 4, function() end) |
| 7 | assert(loaders[1]) | 7 | assert(loaders[1]) |
| 8 | assert(loaders[2]) | 8 | assert(loaders[2]) |
| 9 | assert(loaders[3]) | 9 | assert(loaders[3]) |
| 10 | assert(loaders[4]) | 10 | assert(loaders[4]) |
| 11 | assert(loaders[5]) | 11 | assert(loaders[5]) |
| 12 | print "loaders configured!" | 12 | print(type_, "loaders configured!") |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | configure_loaders() | 15 | configure_loaders("main") |
| 16 | 16 | ||
| 17 | for k,v in pairs(loaders) do | 17 | for k,v in pairs(loaders) do |
| 18 | print( k, type(v)) | 18 | print( k, type(v)) |
| 19 | end | 19 | end |
| 20 | 20 | ||
| 21 | lanes = require "lanes" | 21 | lanes = require "lanes" |
| 22 | lanes.configure{with_timers=false, on_state_create = configure_loaders} \ No newline at end of file | 22 | lanes.configure{on_state_create = configure_loaders} \ No newline at end of file |
