Fix compiler varargs support, add tests for varargs compatibility.
This commit is contained in:
Binary file not shown.
@@ -8,7 +8,7 @@ public class CompilerUnitTests extends AbstractUnitTests {
|
||||
super("src/test/compile/lua5.1-tests.zip", "lua5.1-tests");
|
||||
}
|
||||
|
||||
public void testAll() { doTest("all.lua"); }
|
||||
public void testAll() { doTest("all.lua"); }
|
||||
public void testApi() { doTest("api.lua"); }
|
||||
public void testAttrib() { doTest("attrib.lua"); }
|
||||
public void testBig() { doTest("big.lua"); }
|
||||
|
||||
@@ -21,11 +21,11 @@ public class RegressionTests extends AbstractUnitTests {
|
||||
"regressions" );
|
||||
}
|
||||
|
||||
public void testModulo() { doTest("modulo.lua"); }
|
||||
public void testConstruct() { doTest("construct.lua"); }
|
||||
public void testBigAttrs() { doTest("bigattr.lua"); }
|
||||
public void testControlChars() { doTest("controlchars.lua"); }
|
||||
public void testComparators() { doTest("comparators.lua"); }
|
||||
public void testMathRandomseed() { doTest("mathrandomseed.lua"); }
|
||||
|
||||
public void testModulo() { doTest("modulo.lua"); }
|
||||
public void testConstruct() { doTest("construct.lua"); }
|
||||
public void testBigAttrs() { doTest("bigattr.lua"); }
|
||||
public void testControlChars() { doTest("controlchars.lua"); }
|
||||
public void testComparators() { doTest("comparators.lua"); }
|
||||
public void testMathRandomseed() { doTest("mathrandomseed.lua"); }
|
||||
public void testVarargs() { doTest("varargs.lua"); }
|
||||
}
|
||||
|
||||
@@ -176,6 +176,10 @@ public class CompatibiltyTest extends ScriptDrivenTest {
|
||||
runTest("upvalues3");
|
||||
}
|
||||
|
||||
public void testVarargs() throws IOException, InterruptedException {
|
||||
runTest("varargs");
|
||||
}
|
||||
|
||||
public void testWeakTable() throws IOException, InterruptedException {
|
||||
runTest("weaktable");
|
||||
}
|
||||
|
||||
49
src/test/res/varargs.lua
Normal file
49
src/test/res/varargs.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
function p(a,...)
|
||||
print("a",a)
|
||||
print("...",...)
|
||||
print("...,a",...,a)
|
||||
print("a,...",a,...)
|
||||
end
|
||||
--[[ -- these have semantics that depend on compatibity flags
|
||||
function q(a,...)
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg[1],arg[2],arg[3])
|
||||
end
|
||||
function r(a,...)
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg[1],arg[2],arg[3])
|
||||
print("a",a)
|
||||
print("...",...)
|
||||
print("...,a",...,a)
|
||||
print("a,...",a,...)
|
||||
end
|
||||
--]]
|
||||
function s(a)
|
||||
local arg = { '1', '2', '3' }
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg[1],arg[2],arg[3])
|
||||
print("a",a)
|
||||
end
|
||||
function t(a,...)
|
||||
local arg = { '1', '2', '3' }
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg[1],arg[2],arg[3])
|
||||
print("a",a)
|
||||
print("...",...)
|
||||
print("...,a",...,a)
|
||||
print("a,...",a,...)
|
||||
end
|
||||
arg = { "global-1", "global-2", "global-3" }
|
||||
function tryall(f,name)
|
||||
print( '---- function '..name..'()' )
|
||||
print( '--'..name..'():' )
|
||||
print( ' ->', pcall( f ) )
|
||||
print( '--'..name..'("q"):' )
|
||||
print( ' ->', pcall( f, "q" ) )
|
||||
print( '--'..name..'("q","r"):' )
|
||||
print( ' ->', pcall( f, "q", "r" ) )
|
||||
print( '--'..name..'("q","r","s"):' )
|
||||
print( ' ->', pcall( f, "q", "r", "s" ) )
|
||||
end
|
||||
tryall(p,'p')
|
||||
-- tryall(q,'q')
|
||||
-- tryall(r,'r')
|
||||
tryall(s,'s')
|
||||
tryall(t,'t')
|
||||
Reference in New Issue
Block a user