aboutsummaryrefslogtreecommitdiff
path: root/tests/rupval.lua
blob: ad5ad9da462ec3ff9eff1c4221097a09378733ef (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
lanes = require "lanes".configure{with_timers=false}

-- make sure we can copy functions with interdependant upvalues

local x = 33
local y = 44
local z = 55

local b
local a = function( n)
	print( "a", n)
	return n <= 0 and x or b( n-1)
end

local c
b = function( n)
	print( "b", n)
	return n <= 0 and y or c( n-1)
end

c = function( n)
	print( "c", n)
	return n <= 0 and z or a( n-1)
end

local g = lanes.gen( "base", { name = 'auto' }, a)

local l = g(7)
local r = l:join()
assert(r == y)
print(r)

local l = g(8)
local r = l:join()
assert(r == z)
print(r)

local l = g(9)
local r = l:join()
assert(r == x)
print(r)

print "TEST OK"