aboutsummaryrefslogtreecommitdiff
path: root/tests/protectproxy.lua
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2011-02-17 07:52:53 +0100
committerBenoit Germain <bnt.germain@gmail.com>2011-02-17 07:52:53 +0100
commitab233d0c9a1edc34836e2249c1eb6d714f1066b5 (patch)
treea91078b0ca240f870f5f15c2930bc0719a86c9d1 /tests/protectproxy.lua
parentafb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7 (diff)
downloadlanes-ab233d0c9a1edc34836e2249c1eb6d714f1066b5.tar.gz
lanes-ab233d0c9a1edc34836e2249c1eb6d714f1066b5.tar.bz2
lanes-ab233d0c9a1edc34836e2249c1eb6d714f1066b5.zip
Lane userdata implementation refactoring:
- Refactor lane proxy implementation: it is now a full userdata instead of a table, and its methods are implemented in C instead of Lua. * its metatable is no longer accessible. * writing to the proxy raises an error. * it is no longer possible to overwrite its join() and cancel() methods - when a deep userdata idfunc requests a module to be required, manually check that it is not loaded before requiring it instead of relying on the require function's loop detection feature. - when a module must be required, raise an error if the 'require' function is not found in the target state. - we know Lanes is loaded in the master state, so we don't force it to be required in every lane too when a linda deep userdata is copied.
Diffstat (limited to 'tests/protectproxy.lua')
-rw-r--r--tests/protectproxy.lua27
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 @@
1require "lanes"
2
3local body = function( param)
4 print ( "lane body: " .. param)
5 return 1
6end
7
8local gen = lanes.gen( "*", body)
9
10local mylane = gen( "hello")
11
12local result = mylane[1]
13
14-- make sure we have properly protected the lane
15
16-- can't access the metatable
17print( "metatable:" .. tostring( getmetatable( mylane)))
18
19-- can't write to the userdata
20print( "lane result: " .. mylane[1])
21
22-- read nonexistent values -> nil
23print "reading nonexistent return value"
24a = mylane[2]
25
26print "writing to the lane -> error"
27mylane[4] = true