|
|
|
@ -1394,6 +1394,55 @@ compile(test_longkey);
|
|
|
|
|
assert(pcall(test_yields_in_metamethods));
|
|
|
|
|
print 'Test 54 Ok'
|
|
|
|
|
|
|
|
|
|
function test_upvaluejoin()
|
|
|
|
|
local debug = require'debug'
|
|
|
|
|
local foo1, foo2, foo3, foo4
|
|
|
|
|
do
|
|
|
|
|
local a:integer, b:integer = 3, 5
|
|
|
|
|
local c:number = 7.1
|
|
|
|
|
foo1 = function() return a+b end
|
|
|
|
|
foo2 = function() return b+a end
|
|
|
|
|
foo4 = function() return c end
|
|
|
|
|
do
|
|
|
|
|
local a: integer = 10
|
|
|
|
|
foo3 = function() return a+b end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert(debug.upvalueid(foo1, 1))
|
|
|
|
|
assert(debug.upvalueid(foo1, 2))
|
|
|
|
|
assert(not pcall(debug.upvalueid, foo1, 3))
|
|
|
|
|
assert(debug.upvalueid(foo1, 1) == debug.upvalueid(foo2, 2))
|
|
|
|
|
assert(debug.upvalueid(foo1, 2) == debug.upvalueid(foo2, 1))
|
|
|
|
|
assert(debug.upvalueid(foo3, 1))
|
|
|
|
|
assert(debug.upvalueid(foo1, 1) ~= debug.upvalueid(foo3, 1))
|
|
|
|
|
assert(debug.upvalueid(foo1, 2) == debug.upvalueid(foo3, 2))
|
|
|
|
|
|
|
|
|
|
assert(debug.upvalueid(string.gmatch("x", "x"), 1) ~= nil)
|
|
|
|
|
|
|
|
|
|
assert(foo1() == 3 + 5 and foo2() == 5 + 3)
|
|
|
|
|
debug.upvaluejoin(foo1, 2, foo2, 2)
|
|
|
|
|
assert(foo1() == 3 + 3 and foo2() == 5 + 3)
|
|
|
|
|
assert(foo3() == 10 + 5)
|
|
|
|
|
debug.upvaluejoin(foo3, 2, foo2, 1)
|
|
|
|
|
assert(foo3() == 10 + 5)
|
|
|
|
|
debug.upvaluejoin(foo3, 2, foo2, 2)
|
|
|
|
|
assert(foo3() == 10 + 3)
|
|
|
|
|
-- Following will fail as typeof(foo4,1) is not same as typeof(foo1,1)
|
|
|
|
|
debug.upvaluejoin(foo4, 1, foo1, 1)
|
|
|
|
|
assert(foo4() == 7.1)
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, foo1, 3, foo2, 1))
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, foo1, 1, foo2, 3))
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, foo1, 0, foo2, 1))
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, print, 1, foo2, 1))
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, {}, 1, foo2, 1))
|
|
|
|
|
assert(not pcall(debug.upvaluejoin, foo1, 1, print, 1))
|
|
|
|
|
end
|
|
|
|
|
assert(pcall(test_upvaluejoin));
|
|
|
|
|
compile(test_upvaluejoin);
|
|
|
|
|
assert(pcall(test_upvaluejoin));
|
|
|
|
|
print 'Test 55 Ok'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for k,v in pairs(opcodes_coverage)
|
|
|
|
|
do
|
|
|
|
|