|
|
|
@ -117,7 +117,9 @@ opcodes_coverage.TOTAB = 0
|
|
|
|
|
opcodes_coverage.MOVETAB = 0
|
|
|
|
|
opcodes_coverage.SETUPVALT = 0
|
|
|
|
|
opcodes_coverage.SELF_S = 0
|
|
|
|
|
|
|
|
|
|
opcodes_coverage.TOTYPE = 0
|
|
|
|
|
opcodes_coverage.TOSTRING = 0
|
|
|
|
|
opcodes_coverage.TOCLOSURE = 0
|
|
|
|
|
|
|
|
|
|
local compile = function(f)
|
|
|
|
|
if ravi.jit() then
|
|
|
|
@ -425,7 +427,7 @@ assert(x(5.1) == 2.0)
|
|
|
|
|
assert(x(4.0) == 3.0)
|
|
|
|
|
print("test 8 OK")
|
|
|
|
|
|
|
|
|
|
-- test 10
|
|
|
|
|
-- test 9
|
|
|
|
|
x = function (y: integer, z)
|
|
|
|
|
if y == 1 then
|
|
|
|
|
if z == 1 then
|
|
|
|
@ -451,7 +453,7 @@ assert(x(5) == 2.0)
|
|
|
|
|
assert(x(4) == 3.0)
|
|
|
|
|
print("test 9 OK")
|
|
|
|
|
|
|
|
|
|
-- test 11
|
|
|
|
|
-- test 10
|
|
|
|
|
x = function()
|
|
|
|
|
local function tryme()
|
|
|
|
|
local i,j = 5,6
|
|
|
|
@ -469,7 +471,7 @@ check(x, 'CLOSURE', 'GETTABUP_SK', 'GETUPVAL',
|
|
|
|
|
x()
|
|
|
|
|
print("test 10 OK")
|
|
|
|
|
|
|
|
|
|
-- test 12
|
|
|
|
|
-- test 11
|
|
|
|
|
function x()
|
|
|
|
|
local a : number[], j:number = {}
|
|
|
|
|
for i=1,10 do
|
|
|
|
@ -487,7 +489,7 @@ compile(x)
|
|
|
|
|
assert(x() == 55.0)
|
|
|
|
|
print("test 11 OK")
|
|
|
|
|
|
|
|
|
|
-- test 13
|
|
|
|
|
-- test 12
|
|
|
|
|
function pisum()
|
|
|
|
|
local sum : number
|
|
|
|
|
for j = 1,500 do
|
|
|
|
@ -508,7 +510,7 @@ assert(compile(pisum))
|
|
|
|
|
assert(math.abs(pisum()-1.644834071848065) < 1e-12)
|
|
|
|
|
print("test 12 OK")
|
|
|
|
|
|
|
|
|
|
-- test 15
|
|
|
|
|
-- test 13
|
|
|
|
|
function y()
|
|
|
|
|
local i,j = 5.1,"6.2"
|
|
|
|
|
return i,j
|
|
|
|
@ -525,7 +527,7 @@ assert(compile(x))
|
|
|
|
|
assert(math.abs(x(y) - 11.3) < 0.0001)
|
|
|
|
|
print("test 13 OK")
|
|
|
|
|
|
|
|
|
|
-- test 16
|
|
|
|
|
-- test 14
|
|
|
|
|
function tryme(x,y)
|
|
|
|
|
if x < y then
|
|
|
|
|
return 1
|
|
|
|
@ -543,7 +545,7 @@ assert(tryme(1,2) == 1)
|
|
|
|
|
assert(tryme(2,1) == 0)
|
|
|
|
|
print("test 14 OK")
|
|
|
|
|
|
|
|
|
|
-- test 17
|
|
|
|
|
-- test 15
|
|
|
|
|
function tryme(x,y)
|
|
|
|
|
return x < y
|
|
|
|
|
end
|
|
|
|
@ -555,7 +557,7 @@ assert(tryme(1,2))
|
|
|
|
|
assert(not tryme(2,1))
|
|
|
|
|
print("test 15 OK")
|
|
|
|
|
|
|
|
|
|
-- test 18
|
|
|
|
|
-- test 16
|
|
|
|
|
function tabtest(x)
|
|
|
|
|
x[1] = 5
|
|
|
|
|
return x[1]
|
|
|
|
@ -566,7 +568,7 @@ compile(tabtest)
|
|
|
|
|
assert(tabtest({}) == 5)
|
|
|
|
|
print("test 16 OK")
|
|
|
|
|
|
|
|
|
|
-- test 19
|
|
|
|
|
-- test 17
|
|
|
|
|
function optest()
|
|
|
|
|
local a,b,c = 1, 5
|
|
|
|
|
c = a and b
|
|
|
|
@ -579,7 +581,7 @@ compile(optest)
|
|
|
|
|
assert(optest() == 5)
|
|
|
|
|
print("test 17 OK")
|
|
|
|
|
|
|
|
|
|
-- test 20
|
|
|
|
|
-- test 18
|
|
|
|
|
function optest()
|
|
|
|
|
local a,b,c = 1, 5
|
|
|
|
|
c = a or b
|
|
|
|
@ -592,7 +594,7 @@ compile(optest)
|
|
|
|
|
assert(optest() == 1)
|
|
|
|
|
print("test 18 OK")
|
|
|
|
|
|
|
|
|
|
-- test 21
|
|
|
|
|
-- test 19
|
|
|
|
|
function optest()
|
|
|
|
|
local a,b = 1, 5
|
|
|
|
|
if a and b then
|
|
|
|
@ -607,7 +609,7 @@ compile(optest)
|
|
|
|
|
assert(optest() == 5)
|
|
|
|
|
print("test 19 OK")
|
|
|
|
|
|
|
|
|
|
-- test 22
|
|
|
|
|
-- test 20
|
|
|
|
|
function optest()
|
|
|
|
|
local a,b = nil, 5
|
|
|
|
|
if a or b then
|
|
|
|
@ -622,7 +624,7 @@ compile(optest)
|
|
|
|
|
assert(optest() == 5)
|
|
|
|
|
print("test 20 OK")
|
|
|
|
|
|
|
|
|
|
-- test 29
|
|
|
|
|
-- test 21
|
|
|
|
|
z = function()
|
|
|
|
|
local x=function()
|
|
|
|
|
local j:number[] = {}
|
|
|
|
@ -643,7 +645,7 @@ compile(z)
|
|
|
|
|
z()
|
|
|
|
|
print("test 21 OK")
|
|
|
|
|
|
|
|
|
|
-- test 30
|
|
|
|
|
-- test 22
|
|
|
|
|
z = function()
|
|
|
|
|
local days: table = {"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
|
|
|
"Thursday", "Friday", "Saturda"}
|
|
|
|
@ -674,7 +676,7 @@ compile(z)
|
|
|
|
|
z()
|
|
|
|
|
print("test 22 OK")
|
|
|
|
|
|
|
|
|
|
-- test 31
|
|
|
|
|
-- test 23
|
|
|
|
|
x = function(a)
|
|
|
|
|
return not a
|
|
|
|
|
end
|
|
|
|
@ -688,7 +690,7 @@ assert(y(x(false)))
|
|
|
|
|
assert(not y(x(true)))
|
|
|
|
|
print("test 23 OK")
|
|
|
|
|
|
|
|
|
|
-- test 36
|
|
|
|
|
-- test 24
|
|
|
|
|
t = { name_ = "ravi" }
|
|
|
|
|
function t:name()
|
|
|
|
|
return self.name_
|
|
|
|
@ -699,9 +701,9 @@ end
|
|
|
|
|
assert(compile(t.name))
|
|
|
|
|
assert(compile(z))
|
|
|
|
|
assert(z(t) == "ravi")
|
|
|
|
|
print("test 25 OK")
|
|
|
|
|
print("test 24 OK")
|
|
|
|
|
|
|
|
|
|
-- test 38
|
|
|
|
|
-- test 25
|
|
|
|
|
-- test ravi integer array
|
|
|
|
|
function f()
|
|
|
|
|
local x: integer[] = { 1, 5 }
|
|
|
|
@ -714,9 +716,9 @@ function f()
|
|
|
|
|
end
|
|
|
|
|
assert(compile(f))
|
|
|
|
|
assert(f() == 6)
|
|
|
|
|
print("test 26 OK")
|
|
|
|
|
print("test 25 OK")
|
|
|
|
|
|
|
|
|
|
-- test 39
|
|
|
|
|
-- test 26
|
|
|
|
|
function f()
|
|
|
|
|
local x: number[] = { 5.0, 6.1 }
|
|
|
|
|
x[3] = x[1] + x[2]
|
|
|
|
@ -725,9 +727,9 @@ end
|
|
|
|
|
--ravi.dumplua(f)
|
|
|
|
|
assert(compile(f))
|
|
|
|
|
assert(math.abs(f()-11.1) < 1e-12)
|
|
|
|
|
print("test 27 OK")
|
|
|
|
|
print("test 26 OK")
|
|
|
|
|
|
|
|
|
|
-- test 41
|
|
|
|
|
-- test 27
|
|
|
|
|
-- Ravi arrays support for ipairs()
|
|
|
|
|
-- Plus special slot at [0]
|
|
|
|
|
x = function()
|
|
|
|
@ -743,9 +745,9 @@ x = function()
|
|
|
|
|
end
|
|
|
|
|
assert(compile(x))
|
|
|
|
|
assert(x() == 28)
|
|
|
|
|
print("test 28 OK")
|
|
|
|
|
print("test 27 OK")
|
|
|
|
|
|
|
|
|
|
-- test 42
|
|
|
|
|
-- test 28
|
|
|
|
|
-- Ravi arrays support for pairs()
|
|
|
|
|
-- Plus special slot at [0]
|
|
|
|
|
x = function()
|
|
|
|
@ -761,9 +763,9 @@ x = function()
|
|
|
|
|
end
|
|
|
|
|
assert(compile(x))
|
|
|
|
|
assert(x() == 28)
|
|
|
|
|
print("test 29 OK")
|
|
|
|
|
print("test 28 OK")
|
|
|
|
|
|
|
|
|
|
-- test 43
|
|
|
|
|
-- test 29
|
|
|
|
|
-- test creation of arrays and slice
|
|
|
|
|
x = function()
|
|
|
|
|
local zeros: integer[] = table.intarray(10, 0)
|
|
|
|
@ -785,9 +787,9 @@ x = function()
|
|
|
|
|
end
|
|
|
|
|
assert(compile(x))
|
|
|
|
|
assert(x() == true)
|
|
|
|
|
print("test 30 OK")
|
|
|
|
|
print("test 29 OK")
|
|
|
|
|
|
|
|
|
|
-- test 44
|
|
|
|
|
-- test 30
|
|
|
|
|
matrix = {}
|
|
|
|
|
matrix.new = function (m, n)
|
|
|
|
|
local t = {m, n, table.numarray(m*n, 0)}
|
|
|
|
@ -833,9 +835,9 @@ assert(compile(matrix.getcol))
|
|
|
|
|
assert(compile(matrix.getdata))
|
|
|
|
|
assert(compile(x))
|
|
|
|
|
assert(x() == 65)
|
|
|
|
|
print("test 31 OK")
|
|
|
|
|
print("test 30 OK")
|
|
|
|
|
|
|
|
|
|
-- test 23
|
|
|
|
|
-- test 31
|
|
|
|
|
function testadd(a,b)
|
|
|
|
|
return a+b
|
|
|
|
|
end
|
|
|
|
@ -844,9 +846,9 @@ assert(testadd(1,1) == 2)
|
|
|
|
|
assert(testadd(1.5,1.6) == 3.1)
|
|
|
|
|
assert(testadd("1.5",1.6) == 3.1)
|
|
|
|
|
assert(testadd("1.5","1.6") == 3.1)
|
|
|
|
|
print("test 32 OK")
|
|
|
|
|
print("test 31 OK")
|
|
|
|
|
|
|
|
|
|
-- test 24
|
|
|
|
|
-- test 32
|
|
|
|
|
function testsub(a,b)
|
|
|
|
|
return a-b
|
|
|
|
|
end
|
|
|
|
@ -855,9 +857,9 @@ assert(testsub(1,1) == 0)
|
|
|
|
|
assert(math.abs(testsub(1.5,1.6)-(-0.1)) < 1e-6)
|
|
|
|
|
assert(math.abs(testsub("1.5",1.6)-(-0.1)) < 1e-6)
|
|
|
|
|
assert(math.abs(testsub("1.5","1.6")-(-0.1)) < 1e-6)
|
|
|
|
|
print("test 33 OK")
|
|
|
|
|
print("test 32 OK")
|
|
|
|
|
|
|
|
|
|
-- test 25
|
|
|
|
|
-- test 33
|
|
|
|
|
function testmul(a,b)
|
|
|
|
|
return a*b
|
|
|
|
|
end
|
|
|
|
@ -866,10 +868,10 @@ assert(testmul(2,2) == 4)
|
|
|
|
|
assert(math.abs(testmul(1.5,1.6)-2.4) < 1e-12)
|
|
|
|
|
assert(math.abs(testmul("1.5",1.6)-2.4) < 1e-12)
|
|
|
|
|
assert(math.abs(testmul("1.5","1.6")-2.4) < 1e-12)
|
|
|
|
|
print("test 34 OK")
|
|
|
|
|
print("test 33 OK")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- test 26
|
|
|
|
|
-- test 34
|
|
|
|
|
function testdiv(a,b)
|
|
|
|
|
return a/b
|
|
|
|
|
end
|
|
|
|
@ -878,10 +880,10 @@ assert(testdiv(2,2) == 1.0)
|
|
|
|
|
assert(math.abs(testdiv(1.5,1.6)-0.9375) < 1e-12)
|
|
|
|
|
assert(math.abs(testdiv("1.5",1.6)-0.9375) < 1e-12)
|
|
|
|
|
assert(math.abs(testdiv("1.5","1.6")-0.9375) < 1e-12)
|
|
|
|
|
print("test 35 OK")
|
|
|
|
|
print("test 34 OK")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- test 37
|
|
|
|
|
-- test 35
|
|
|
|
|
-- this tests that within the for loop
|
|
|
|
|
-- the locals get mapped correctly to upvalues
|
|
|
|
|
function f()
|
|
|
|
@ -904,11 +906,9 @@ assert(t[1]() == 10)
|
|
|
|
|
assert(t[2]() == 10)
|
|
|
|
|
assert(t[1]() == 20)
|
|
|
|
|
assert(t[2]() == 20)
|
|
|
|
|
print("test 36 OK")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("test 35 OK")
|
|
|
|
|
|
|
|
|
|
-- test 27
|
|
|
|
|
-- test 36
|
|
|
|
|
-- upvalues
|
|
|
|
|
local x = 1
|
|
|
|
|
local y=function()
|
|
|
|
@ -923,9 +923,9 @@ local f = y()
|
|
|
|
|
assert(f() == 1)
|
|
|
|
|
x=5
|
|
|
|
|
assert(f() == 5)
|
|
|
|
|
print("test 37 OK")
|
|
|
|
|
print("test 36 OK")
|
|
|
|
|
|
|
|
|
|
-- test 28
|
|
|
|
|
-- test 37
|
|
|
|
|
-- upvalues
|
|
|
|
|
x1 = 3
|
|
|
|
|
local y=function()
|
|
|
|
@ -944,9 +944,9 @@ local f = y()
|
|
|
|
|
assert(f() == 3)
|
|
|
|
|
x1=5
|
|
|
|
|
assert(f() == 5)
|
|
|
|
|
print("test 38 OK")
|
|
|
|
|
print("test 37 OK")
|
|
|
|
|
|
|
|
|
|
-- test 35
|
|
|
|
|
-- test 38
|
|
|
|
|
function x()
|
|
|
|
|
local x = 1
|
|
|
|
|
local f = function()
|
|
|
|
@ -959,7 +959,7 @@ f=x()
|
|
|
|
|
assert(compile(f))
|
|
|
|
|
assert(f() == 2)
|
|
|
|
|
assert(f() == 3)
|
|
|
|
|
print("test 39 OK")
|
|
|
|
|
print("test 38 OK")
|
|
|
|
|
|
|
|
|
|
-- test setupval, getupval
|
|
|
|
|
function x()
|
|
|
|
@ -973,9 +973,9 @@ compile(y)
|
|
|
|
|
assert(y(2) == 2)
|
|
|
|
|
assert(y(2) == 4)
|
|
|
|
|
assert(y(3) == 7)
|
|
|
|
|
print('test 40 Ok')
|
|
|
|
|
print('test 39 OK')
|
|
|
|
|
|
|
|
|
|
-- test 32
|
|
|
|
|
-- test 40
|
|
|
|
|
x=function(a,b)
|
|
|
|
|
return a%b
|
|
|
|
|
end
|
|
|
|
@ -984,9 +984,9 @@ assert(compile(x))
|
|
|
|
|
-- if ravi.jit() then ravi.compile(x) end
|
|
|
|
|
assert(x(5,2) == 1)
|
|
|
|
|
assert(math.abs(x(5.1,2.1)-0.9) < 1e-6)
|
|
|
|
|
print("test 41 OK")
|
|
|
|
|
print("test 40 OK")
|
|
|
|
|
|
|
|
|
|
-- test 33
|
|
|
|
|
-- test 41
|
|
|
|
|
x=function(a,b)
|
|
|
|
|
return a//b
|
|
|
|
|
end
|
|
|
|
@ -995,9 +995,9 @@ assert(compile(x))
|
|
|
|
|
-- if ravi.jit() then ravi.compile(x) end
|
|
|
|
|
assert(x(5,2) == 2)
|
|
|
|
|
assert(math.abs(x(5.5,2.1)-2.0) < 1e-6)
|
|
|
|
|
print("test 42 OK")
|
|
|
|
|
print("test 41 OK")
|
|
|
|
|
|
|
|
|
|
-- test 6
|
|
|
|
|
-- test 42
|
|
|
|
|
x = function ()
|
|
|
|
|
local j = 0
|
|
|
|
|
for i=2.0,6.0,3.1 do
|
|
|
|
@ -1007,10 +1007,10 @@ x = function ()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if (not compile(x)) then
|
|
|
|
|
print("test 6 FAILED to compile")
|
|
|
|
|
print("test FAILED to compile")
|
|
|
|
|
end
|
|
|
|
|
assert(x() == 5.1)
|
|
|
|
|
print("test 43 OK")
|
|
|
|
|
print("test 42 OK")
|
|
|
|
|
|
|
|
|
|
-- test parameter types
|
|
|
|
|
x = function (a: integer, b: number)
|
|
|
|
@ -1022,7 +1022,7 @@ end
|
|
|
|
|
assert(x(1,5.5) == 6.5)
|
|
|
|
|
compile(x)
|
|
|
|
|
assert(x(1,5.5) == 6.5)
|
|
|
|
|
print'test 44 OK'
|
|
|
|
|
print'test 43 OK'
|
|
|
|
|
|
|
|
|
|
x=function (a:number[], b:integer)
|
|
|
|
|
local j: number = a[b]
|
|
|
|
@ -1037,9 +1037,9 @@ assert(y() == 4.2)
|
|
|
|
|
compile(x)
|
|
|
|
|
compile(y)
|
|
|
|
|
assert(y() == 4.2)
|
|
|
|
|
print'test 45 OK'
|
|
|
|
|
print'test 44 OK'
|
|
|
|
|
|
|
|
|
|
-- test 40
|
|
|
|
|
-- test 45
|
|
|
|
|
function x(t) return t; end
|
|
|
|
|
function f()
|
|
|
|
|
local tt: integer[] = {1}
|
|
|
|
@ -1055,23 +1055,19 @@ function f()
|
|
|
|
|
tt = x({})
|
|
|
|
|
end
|
|
|
|
|
--ravi.dumplua(f)
|
|
|
|
|
print'+'
|
|
|
|
|
assert(compile(f))
|
|
|
|
|
assert(not pcall(f))
|
|
|
|
|
print'+'
|
|
|
|
|
function f()
|
|
|
|
|
local tt: integer[] = {1}
|
|
|
|
|
local ss: number[] = { 55.5 }
|
|
|
|
|
ss = x(tt)
|
|
|
|
|
end
|
|
|
|
|
print'+'
|
|
|
|
|
assert(compile(f))
|
|
|
|
|
assert(not pcall(f))
|
|
|
|
|
|
|
|
|
|
print("test 46 OK")
|
|
|
|
|
|
|
|
|
|
print("test 45 OK")
|
|
|
|
|
|
|
|
|
|
-- test 41
|
|
|
|
|
-- test 47
|
|
|
|
|
function test_idiv()
|
|
|
|
|
local t = {}
|
|
|
|
|
t.__idiv = function(...) return 'idiv' end
|
|
|
|
@ -1149,7 +1145,7 @@ function test_self_s()
|
|
|
|
|
local t : table = {}
|
|
|
|
|
t.name_ = 'dibyendu majumdar'
|
|
|
|
|
t.name = function (t:table) return t.name_ end
|
|
|
|
|
print(t:name())
|
|
|
|
|
assert(t:name())
|
|
|
|
|
return t:name()
|
|
|
|
|
end
|
|
|
|
|
check(test_self_s, 'NEWTABLE', 'SETTABLE_S', 'CLOSURE',
|
|
|
|
@ -1160,7 +1156,7 @@ compile(test_self_s)
|
|
|
|
|
assert(test_self_s() == 'dibyendu majumdar')
|
|
|
|
|
print 'Test 49 OK'
|
|
|
|
|
|
|
|
|
|
-- issue #73
|
|
|
|
|
-- issue #73
|
|
|
|
|
function bug_index_event()
|
|
|
|
|
local t1 = { name='dibyendu' }
|
|
|
|
|
local t2 = { surname='majumdar' }
|
|
|
|
@ -1264,11 +1260,11 @@ check(test_longkey, 'NEWTABLE', 'SETTABLE', 'GETTABUP_SK', 'GETTABLE',
|
|
|
|
|
assert(pcall(test_longkey));
|
|
|
|
|
compile(test_longkey);
|
|
|
|
|
assert(pcall(test_longkey));
|
|
|
|
|
print 'Test 53 OK'
|
|
|
|
|
print 'Test 54 OK'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function test_yields_in_metamethods()
|
|
|
|
|
print"testing yields inside metamethods"
|
|
|
|
|
--print"testing yields inside metamethods"
|
|
|
|
|
local mt = {
|
|
|
|
|
__eq = function(a:table,b:table) coroutine.yield(nil, "eq"); return a.x == b.x end,
|
|
|
|
|
__lt = function(a:table,b:table) coroutine.yield(nil, "lt"); return a.x < b.x end,
|
|
|
|
@ -1396,7 +1392,7 @@ end
|
|
|
|
|
assert(pcall(test_yields_in_metamethods));
|
|
|
|
|
compile(test_longkey);
|
|
|
|
|
assert(pcall(test_yields_in_metamethods));
|
|
|
|
|
print 'Test 54 Ok'
|
|
|
|
|
print 'Test 55 OK'
|
|
|
|
|
|
|
|
|
|
function test_upvaluejoin()
|
|
|
|
|
local debug = require'debug'
|
|
|
|
@ -1445,7 +1441,7 @@ end
|
|
|
|
|
assert(pcall(test_upvaluejoin));
|
|
|
|
|
compile(test_upvaluejoin);
|
|
|
|
|
assert(pcall(test_upvaluejoin));
|
|
|
|
|
print 'Test 55 Ok'
|
|
|
|
|
print 'Test 56 OK'
|
|
|
|
|
|
|
|
|
|
function test_idiv(y: integer)
|
|
|
|
|
local era: integer
|
|
|
|
@ -1456,7 +1452,7 @@ check(test_idiv, 'TOINT', 'LOADNIL', 'LOADIZ', 'IDIV', 'RETURN', 'RETURN')
|
|
|
|
|
assert(test_idiv(1900) == 4)
|
|
|
|
|
compile(test_idiv)
|
|
|
|
|
assert(test_idiv(1900) == 4)
|
|
|
|
|
print 'Test 56 Ok'
|
|
|
|
|
print 'Test 57 OK'
|
|
|
|
|
|
|
|
|
|
function from_dmy1(y: integer, m: integer, d: integer)
|
|
|
|
|
if m <= 2 then
|
|
|
|
@ -1512,7 +1508,48 @@ check(from_dmy1, 'TOINT', 'TOINT', 'TOINT', 'LE_II', 'JMP',
|
|
|
|
|
'JMP','LOADK','ADDII','MULII','ADDII','IDIV','ADDII','SUBII',
|
|
|
|
|
'MULII','IDIV','ADDII','IDIV','SUBII','ADDII','MULII','ADDII',
|
|
|
|
|
'SUBII','RETURN','RETURN')
|
|
|
|
|
print 'Test 57 Ok'
|
|
|
|
|
print 'Test 58 OK'
|
|
|
|
|
|
|
|
|
|
function x(s1: string, s2: string)
|
|
|
|
|
return @string( s1 .. s2 )
|
|
|
|
|
end
|
|
|
|
|
check(x, 'TOSTRING', 'TOSTRING', 'MOVE', 'MOVE', 'CONCAT', 'TOSTRING', 'RETURN', 'RETURN')
|
|
|
|
|
assert(x('a', 'b') == 'ab')
|
|
|
|
|
compile(x)
|
|
|
|
|
assert(x('a', 'b') == 'ab')
|
|
|
|
|
print 'Test 59 OK'
|
|
|
|
|
|
|
|
|
|
function x(f: closure)
|
|
|
|
|
local g = @closure f
|
|
|
|
|
return g()
|
|
|
|
|
end
|
|
|
|
|
check(x, 'TOCLOSURE', 'MOVE', 'MOVE', 'TAILCALL', 'RETURN', 'RETURN')
|
|
|
|
|
local called = 0
|
|
|
|
|
function y()
|
|
|
|
|
called = called + 1
|
|
|
|
|
end
|
|
|
|
|
x(y)
|
|
|
|
|
assert(called == 1)
|
|
|
|
|
compile(x)
|
|
|
|
|
compile(y)
|
|
|
|
|
x(y)
|
|
|
|
|
assert(called == 2)
|
|
|
|
|
print 'Test 60 OK'
|
|
|
|
|
|
|
|
|
|
local mt = { __name='MyType'}
|
|
|
|
|
debug.getregistry().MyType = mt
|
|
|
|
|
local t = {}
|
|
|
|
|
setmetatable(t, mt)
|
|
|
|
|
|
|
|
|
|
function x(s: MyType)
|
|
|
|
|
local assert = assert
|
|
|
|
|
assert(@MyType s == @MyType t)
|
|
|
|
|
assert(@MyType t == t)
|
|
|
|
|
end
|
|
|
|
|
x(t)
|
|
|
|
|
compile(x)
|
|
|
|
|
x(t)
|
|
|
|
|
print 'Test 61 OK'
|
|
|
|
|
|
|
|
|
|
for k,v in pairs(opcodes_coverage)
|
|
|
|
|
do
|
|
|
|
@ -1521,3 +1558,4 @@ end
|
|
|
|
|
|
|
|
|
|
-- ravi.dumplua(test_yields_in_metamethods)
|
|
|
|
|
|
|
|
|
|
print 'OK'
|