diff options
Diffstat (limited to 'tests/protectproxy.lua')
-rw-r--r-- | tests/protectproxy.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/protectproxy.lua b/tests/protectproxy.lua new file mode 100644 index 0000000..57ca831 --- /dev/null +++ b/tests/protectproxy.lua | |||
@@ -0,0 +1,27 @@ | |||
1 | require "lanes" | ||
2 | |||
3 | local body = function( param) | ||
4 | print ( "lane body: " .. param) | ||
5 | return 1 | ||
6 | end | ||
7 | |||
8 | local gen = lanes.gen( "*", body) | ||
9 | |||
10 | local mylane = gen( "hello") | ||
11 | |||
12 | local result = mylane[1] | ||
13 | |||
14 | -- make sure we have properly protected the lane | ||
15 | |||
16 | -- can't access the metatable | ||
17 | print( "metatable:" .. tostring( getmetatable( mylane))) | ||
18 | |||
19 | -- can't write to the userdata | ||
20 | print( "lane result: " .. mylane[1]) | ||
21 | |||
22 | -- read nonexistent values -> nil | ||
23 | print "reading nonexistent return value" | ||
24 | a = mylane[2] | ||
25 | |||
26 | print "writing to the lane -> error" | ||
27 | mylane[4] = true | ||