aboutsummaryrefslogtreecommitdiff
path: root/tests/protectproxy.lua
blob: 84887ec0e8b5e3f562478422b9b2d6d01fa23b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local lanes = require "lanes".configure{ with_timers = false}

local body = function( param)
	print ( "lane body: " .. param)
	return 1
end

local gen = lanes.gen( "*", { name = 'auto' }, body)

local mylane = gen( "hello")

local result = mylane[1]

-- make sure we have properly protected the lane

-- can't access the metatable
print( "metatable:" .. tostring( getmetatable( mylane)))

-- can't write to the userdata
print( "lane result: " .. mylane[1])

-- read nonexistent values -> nil
print "reading nonexistent return value"
a = mylane[2]

print "writing to the lane -> error"
mylane[4] = true