diff options
Diffstat (limited to 'tests/require.lua')
-rw-r--r-- | tests/require.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/require.lua b/tests/require.lua new file mode 100644 index 0000000..2cfe780 --- /dev/null +++ b/tests/require.lua | |||
@@ -0,0 +1,30 @@ | |||
1 | -- | ||
2 | -- REQUIRE.LUA | ||
3 | -- | ||
4 | -- Test that 'require' works from sublanes | ||
5 | -- | ||
6 | require 'lanes' | ||
7 | |||
8 | local function a_lane() | ||
9 | -- To require 'math' we still actually need to have it initialized for | ||
10 | -- the lane. | ||
11 | -- | ||
12 | require "math" | ||
13 | assert( math and math.sqrt ) | ||
14 | assert( math.sqrt(4)==2 ) | ||
15 | |||
16 | assert( lanes==nil ) | ||
17 | require "lanes" | ||
18 | assert( lanes and lanes.gen ) | ||
19 | |||
20 | local h= lanes.gen( function() return 42 end ) () | ||
21 | local v= h[1] | ||
22 | |||
23 | return v==42 | ||
24 | end | ||
25 | |||
26 | local gen= lanes.gen( "math,package,string,table", a_lane ) | ||
27 | |||
28 | local h= gen() | ||
29 | local ret= h[1] | ||
30 | assert( ret==true ) | ||