Add a new test case for upvalues, and enhance upvalue handling so that

they pass.
This commit is contained in:
Ian Farmer
2007-07-09 04:10:25 +00:00
parent 45964d7e22
commit f7d6a49acb
6 changed files with 104 additions and 15 deletions

View File

@@ -0,0 +1,42 @@
-- The point of this test is that when an upvalue is created, it may
-- need to be inserted in the middle of the list, rather than always
-- appended at the end. Otherwise, it may not be found when it is
-- needed by another closure.
local function test()
local x = 3
local y = 5
local z = 7
local function f()
print("y=", y)
end
local function g()
print("z=", z)
end
local function h()
print("x=", x)
end
local function setter(x1, y1, z1)
x = x1
y = y1
z = z1
end
return f, g, h, setter
end
local f, g, h, setter = test()
h()
f()
g()
setter("x", "y", "z")
h()
f()
g()

BIN
src/test/res/upvalues2.luac Normal file

Binary file not shown.