diff options
author | Peter Drahoš <drahosp@gmail.com> | 2010-10-01 03:22:32 +0200 |
---|---|---|
committer | Peter Drahoš <drahosp@gmail.com> | 2010-10-01 03:22:32 +0200 |
commit | 89d9c98af1ac352ba4d49d660e61b0853d6e1a86 (patch) | |
tree | 15c56d2ce66b4ab147171c0f674cdb4a435ff13f /tests/require.lua | |
download | lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.gz lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.bz2 lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.zip |
Import to git
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 ) | ||