diff --git a/luaj-test/src/test/java/org/luaj/PlatformTestCase.java b/luaj-test/src/test/java/org/luaj/PlatformTestCase.java index 5d4af4a2..265e99d3 100644 --- a/luaj-test/src/test/java/org/luaj/PlatformTestCase.java +++ b/luaj-test/src/test/java/org/luaj/PlatformTestCase.java @@ -25,10 +25,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.OpenOption; import org.junit.jupiter.api.BeforeEach; import org.luaj.vm2.Globals; @@ -94,6 +97,8 @@ abstract class PlatformTestCase extends ResourcesTestCase { actualOutput = actualOutput.replaceAll("\r\n", "\n"); expectedOutput = expectedOutput.replaceAll("\r\n", "\n"); + if (!expectedOutput.equals(actualOutput)) + Files.write(new File(testName + ".out").toPath(), actualOutput.getBytes(), new OpenOption[0]); assertEquals(expectedOutput, actualOutput); } finally { globals.STDOUT = oldps; @@ -132,7 +137,7 @@ abstract class PlatformTestCase extends ResourcesTestCase { } private String getExpectedOutput(final String name) throws IOException, InterruptedException { - InputStream output = inputStreamOfResult(name); + InputStream output = inputStreamOfResult(platform.name().toLowerCase() + "/" + name); if (output != null) try { return readString(output); diff --git a/luaj-test/src/test/resources/compatibility/baselib.out b/luaj-test/src/test/resources/compatibility/jme/baselib.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/baselib.out rename to luaj-test/src/test/resources/compatibility/jme/baselib.out diff --git a/luaj-test/src/test/resources/compatibility/coroutinelib.out b/luaj-test/src/test/resources/compatibility/jme/coroutinelib.out similarity index 58% rename from luaj-test/src/test/resources/compatibility/coroutinelib.out rename to luaj-test/src/test/resources/compatibility/jme/coroutinelib.out index 7fff9194..a759fbb1 100644 --- a/luaj-test/src/test/resources/compatibility/coroutinelib.out +++ b/luaj-test/src/test/resources/compatibility/jme/coroutinelib.out @@ -61,14 +61,39 @@ main-c suspended c-c running c-resume-b false cannot resume non-suspended coroutine c-resume-c false cannot resume non-suspended coroutine - b-resume-c false attempt to yield across metamethod/C-call boundary -main-resume-b false attempt to yield across metamethod/C-call boundary -main-resume-c false cannot resume dead coroutine -main-b dead + b-resume-c true c-rslt +main-resume-b true b-rslt + c-resumed main-arg-for-c true + c-b suspended + c-c running + b-resumed b-arg-for-b true + b-b running + b-c normal + b-resume-b false cannot resume non-suspended coroutine + b-resume-c false cannot resume non-suspended coroutine + c-resume-b true b-rslt + c-resume-c false cannot resume non-suspended coroutine +main-resume-c true c-rslt +main-b suspended +main-c suspended + b-resumed main-arg-for-b true + b-b running + b-c suspended + b-resume-b false cannot resume non-suspended coroutine + c-resumed b-arg-for-c true + c-b normal + c-c running + c-resume-b false cannot resume non-suspended coroutine + c-resume-c false cannot resume non-suspended coroutine + b-resume-c true c-rslt +main-resume-b true b-rslt +main-resume-c true +main-b suspended main-c dead -main-resume-b false cannot resume dead coroutine -main-resume-c false cannot resume dead coroutine -main-b dead -main-c dead -main-resume-b false cannot resume dead coroutine + b-resumed main-arg-for-b true + b-b running + b-c dead + b-resume-b false cannot resume non-suspended coroutine + b-resume-c false cannot resume dead coroutine +main-resume-b true b-rslt main-resume-c false cannot resume dead coroutine diff --git a/luaj-test/src/test/resources/compatibility/debuglib.out b/luaj-test/src/test/resources/compatibility/jme/debuglib.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/debuglib.out rename to luaj-test/src/test/resources/compatibility/jme/debuglib.out diff --git a/luaj-test/src/test/resources/compatibility/errors.out b/luaj-test/src/test/resources/compatibility/jme/errors.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/errors.out rename to luaj-test/src/test/resources/compatibility/jme/errors.out diff --git a/luaj-test/src/test/resources/compatibility/functions.out b/luaj-test/src/test/resources/compatibility/jme/functions.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/functions.out rename to luaj-test/src/test/resources/compatibility/jme/functions.out diff --git a/luaj-test/src/test/resources/compatibility/jme/iolib.out b/luaj-test/src/test/resources/compatibility/jme/iolib.out new file mode 100644 index 00000000..f7cf6c18 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jme/iolib.out @@ -0,0 +1,82 @@ +true +true +true +true +true +write file.0 +Thiswrite file.0 + is a pen.write file.0 +flush true +f userdata +file.1 +write file.2 +type(f) file.1 +close true +type(f) closed file +type("f") nil +"abc" string +----- 1 +"def" string +----- 2 +"12345" number +----- 3 +"678910" number +----- 4 +" more\7aaaaaa\8bbbthe rest" string +----- 5 +h file.1 file.4 nil +write file.3 +close true +f.type file.5 +f file.6 +write file.6 +type(f) file.5 +close true +"line one" +"line two" +"" +"after blank line" +"unterminated line" +"line one" +"line two" +"" +"after blank line" +"unterminated line" +"line one" +"line two" +"" +"after blank line" +"unterminated line" +"line one" +"line two" +"" +"after blank line" +"unterminated line" +file.7 +file.7 +a:write file.8 +b:write file.9 +a:setvbuf true +a:setvbuf true +a:setvbuf true +a:write file.8 +b:write file.9 +a:flush true +b:flush true +a:close true +a:write false closed +a:flush false closed +a:read false closed +a:lines false closed +a:seek false closed +a:setvbuf false closed +a:close false closed +io.type(a) true +io.close() true +io.close(io.output()) true +io.close() true +io.write false closed +io.flush false closed +io.close false closed +io.read false closed +io.lines false closed diff --git a/luaj-test/src/test/resources/compatibility/manyupvals.out b/luaj-test/src/test/resources/compatibility/jme/manyupvals.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/manyupvals.out rename to luaj-test/src/test/resources/compatibility/jme/manyupvals.out diff --git a/luaj-test/src/test/resources/compatibility/jme/mathlib.out b/luaj-test/src/test/resources/compatibility/jme/mathlib.out new file mode 100644 index 00000000..2fec97b8 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jme/mathlib.out @@ -0,0 +1,729 @@ +---------- miscellaneous tests ---------- +math.sin( 0.0 ) true +math.cos( math.pi ) true -1 +math.sqrt( 9.0 ) true 3 +math.modf( 5.25 ) true 5 0.25 +math.frexp(0.00625) true 0.8 -7 +-5 ^ 2 true -25 +-5 / 2 true -2.5 +-5 % 2 true 1 +---------- constants ---------- +math.huge true +math.pi true 3.1415 +---------- unary operator - ---------- +--2.5 true +--2 true +-0 true +-2 true -2 +-2.5 true -2.5 +-'-2.5' true 2.5 +-'-2' true 2 +-'0' true +-'2' true -2 +-'2.5' true -2.5 +---------- unary operator not ---------- +not -2.5 true false +not -2 true false +not 0 true false +not 2 true false +not 2.5 true false +not '-2.5' true false +not '-2' true false +not '0' true false +not '2' true false +not '2.5' true false +---------- binary operator + ---------- +2+0 true 2 +-2.5+0 true -2.5 +2+1 true 3 +5+2 true 7 +-5+2 true -3 +16+2 true 18 +-16+-2 true -18 +0.5+0 true 0.5 +0.5+1 true 1.5 +0.5+2 true 2.5 +0.5+-1 true -0.5 +0.5+2 true 2.5 +2.25+0 true 2.25 +2.25+2 true 4.25 +-2+0 true -2 +3+3 true 6 +'2'+'0' true 2 +'2.5'+'3' true 5.5 +'-2'+'1.5' true -0.5 +'-2.5'+'-1.5' true -4 +'3.0'+'3.0' true 6 +2.75+2.75 true 5.5 +'2.75'+'2.75' true 5.5 +3+'3' true 6 +'3'+3 true 6 +2.75+'2.75' true 5.5 +'2.75'+2.75 true 5.5 +-3+'-4' true -7 +'-3'+4 true 1 +-3+'4' true 1 +'-3'+-4 true -7 +-4.75+'2.75' true -2 +'-2.75'+1.75 true -1 +4.75+'-2.75' true 2 +'2.75'+-1.75 true 1 +---------- binary operator - ---------- +2-0 true 2 +-2.5-0 true -2.5 +2-1 true 1 +5-2 true 3 +-5-2 true -7 +16-2 true 14 +-16--2 true -14 +0.5-0 true 0.5 +0.5-1 true -0.5 +0.5-2 true -1.5 +0.5--1 true 1.5 +0.5-2 true -1.5 +2.25-0 true 2.25 +2.25-2 true 0.25 +-2-0 true -2 +3-3 true +'2'-'0' true 2 +'2.5'-'3' true -0.5 +'-2'-'1.5' true -3.5 +'-2.5'-'-1.5' true -1 +'3.0'-'3.0' true +2.75-2.75 true +'2.75'-'2.75' true +3-'3' true +'3'-3 true +2.75-'2.75' true +'2.75'-2.75 true +-3-'-4' true 1 +'-3'-4 true -7 +-3-'4' true -7 +'-3'--4 true 1 +-4.75-'2.75' true -7.5 +'-2.75'-1.75 true -4.5 +4.75-'-2.75' true 7.5 +'2.75'--1.75 true 4.5 +---------- binary operator * ---------- +2*0 true +-2.5*0 true +2*1 true 2 +5*2 true 10 +-5*2 true -10 +16*2 true 32 +-16*-2 true 32 +0.5*0 true +0.5*1 true 0.5 +0.5*2 true 1 +0.5*-1 true -0.5 +0.5*2 true 1 +2.25*0 true +2.25*2 true 4.5 +-2*0 true +3*3 true 9 +'2'*'0' true +'2.5'*'3' true 7.5 +'-2'*'1.5' true -3 +'-2.5'*'-1.5' true 3.75 +'3.0'*'3.0' true 9 +2.75*2.75 true 7.5625 +'2.75'*'2.75' true 7.5625 +3*'3' true 9 +'3'*3 true 9 +2.75*'2.75' true 7.5625 +'2.75'*2.75 true 7.5625 +-3*'-4' true 12 +'-3'*4 true -12 +-3*'4' true -12 +'-3'*-4 true 12 +-4.75*'2.75' true -13.06 +'-2.75'*1.75 true -4.812 +4.75*'-2.75' true -13.06 +'2.75'*-1.75 true -4.812 +---------- binary operator ^ ---------- +2^0 true 1 +-2.5^0 true 1 +2^1 true 2 +5^2 true 25 +-5^2 true 25 +16^2 true 256 +-16^-2 true 0.0039 +0.5^0 true 1 +0.5^1 true 0.5 +0.5^2 true 0.25 +0.5^-1 true 2 +0.5^2 true 0.25 +2.25^0 true 1 +2.25^2 true 5.0625 +-2^0 true 1 +3^3 true 27 +'2'^'0' true 1 +'2.5'^'3' true 15.625 +'-2'^'1.5' true -nan +'-2.5'^'-1.5' true -nan +'3.0'^'3.0' true 27 +2.75^2.75 true 16.149 +'2.75'^'2.75' true 16.149 +3^'3' true 27 +'3'^3 true 27 +2.75^'2.75' true 16.149 +'2.75'^2.75 true 16.149 +-3^'-4' true 0.0123 +'-3'^4 true 81 +-3^'4' true 81 +'-3'^-4 true 0.0123 +-4.75^'2.75' true -nan +'-2.75'^1.75 true -nan +4.75^'-2.75' true 0.0137 +'2.75'^-1.75 true 0.1702 +---------- binary operator / ---------- +2/0 true +-2.5/0 true +2/1 true 2 +5/2 true 2.5 +-5/2 true -2.5 +16/2 true 8 +-16/-2 true 8 +0.5/0 true +0.5/1 true 0.5 +0.5/2 true 0.25 +0.5/-1 true -0.5 +0.5/2 true 0.25 +2.25/0 true +2.25/2 true 1.125 +-2/0 true +3/3 true 1 +'2'/'0' true +'2.5'/'3' true 0.8333 +'-2'/'1.5' true -1.333 +'-2.5'/'-1.5' true 1.6666 +'3.0'/'3.0' true 1 +2.75/2.75 true 1 +'2.75'/'2.75' true 1 +3/'3' true 1 +'3'/3 true 1 +2.75/'2.75' true 1 +'2.75'/2.75 true 1 +-3/'-4' true 0.75 +'-3'/4 true -0.75 +-3/'4' true -0.75 +'-3'/-4 true 0.75 +-4.75/'2.75' true -1.727 +'-2.75'/1.75 true -1.571 +4.75/'-2.75' true -1.727 +'2.75'/-1.75 true -1.571 +---------- binary operator % ---------- +2%0 true -nan +-2.5%0 true -nan +2%1 true +5%2 true 1 +-5%2 true 1 +16%2 true +-16%-2 true +0.5%0 true -nan +0.5%1 true 0.5 +0.5%2 true 0.5 +0.5%-1 true -0.5 +0.5%2 true 0.5 +2.25%0 true -nan +2.25%2 true 0.25 +-2%0 true -nan +3%3 true +'2'%'0' true -nan +'2.5'%'3' true 2.5 +'-2'%'1.5' true 1 +'-2.5'%'-1.5' true -1 +'3.0'%'3.0' true +2.75%2.75 true +'2.75'%'2.75' true +3%'3' true +'3'%3 true +2.75%'2.75' true +'2.75'%2.75 true +-3%'-4' true -3 +'-3'%4 true 1 +-3%'4' true 1 +'-3'%-4 true -3 +-4.75%'2.75' true 0.75 +'-2.75'%1.75 true 0.75 +4.75%'-2.75' true -0.75 +'2.75'%-1.75 true -0.75 +---------- binary operator == ---------- +2==0 true false +-2.5==0 true false +2==1 true false +5==2 true false +-5==2 true false +16==2 true false +-16==-2 true false +0.5==0 true false +0.5==1 true false +0.5==2 true false +0.5==-1 true false +0.5==2 true false +2.25==0 true false +2.25==2 true false +-2==0 true false +3==3 true true +'2'=='0' true false +'2.5'=='3' true false +'-2'=='1.5' true false +'-2.5'=='-1.5' true false +'3.0'=='3.0' true true +2.75==2.75 true true +'2.75'=='2.75' true true +---------- binary operator ~= ---------- +2~=0 true true +-2.5~=0 true true +2~=1 true true +5~=2 true true +-5~=2 true true +16~=2 true true +-16~=-2 true true +0.5~=0 true true +0.5~=1 true true +0.5~=2 true true +0.5~=-1 true true +0.5~=2 true true +2.25~=0 true true +2.25~=2 true true +-2~=0 true true +3~=3 true false +'2'~='0' true true +'2.5'~='3' true true +'-2'~='1.5' true true +'-2.5'~='-1.5' true true +'3.0'~='3.0' true false +2.75~=2.75 true false +'2.75'~='2.75' true false +---------- binary operator > ---------- +2>0 true true +-2.5>0 true false +2>1 true true +5>2 true true +-5>2 true false +16>2 true true +-16>-2 true false +0.5>0 true true +0.5>1 true false +0.5>2 true false +0.5>-1 true true +0.5>2 true false +2.25>0 true true +2.25>2 true true +-2>0 true false +3>3 true false +'2'>'0' true true +'2.5'>'3' true false +'-2'>'1.5' true false +'-2.5'>'-1.5' true true +'3.0'>'3.0' true false +2.75>2.75 true false +'2.75'>'2.75' true false +---------- binary operator < ---------- +2<0 true false +-2.5<0 true true +2<1 true false +5<2 true false +-5<2 true true +16<2 true false +-16<-2 true true +0.5<0 true false +0.5<1 true true +0.5<2 true true +0.5<-1 true false +0.5<2 true true +2.25<0 true false +2.25<2 true false +-2<0 true true +3<3 true false +'2'<'0' true false +'2.5'<'3' true true +'-2'<'1.5' true true +'-2.5'<'-1.5' true false +'3.0'<'3.0' true false +2.75<2.75 true false +'2.75'<'2.75' true false +---------- binary operator >= ---------- +2>=0 true true +-2.5>=0 true false +2>=1 true true +5>=2 true true +-5>=2 true false +16>=2 true true +-16>=-2 true false +0.5>=0 true true +0.5>=1 true false +0.5>=2 true false +0.5>=-1 true true +0.5>=2 true false +2.25>=0 true true +2.25>=2 true true +-2>=0 true false +3>=3 true true +'2'>='0' true true +'2.5'>='3' true false +'-2'>='1.5' true false +'-2.5'>='-1.5' true true +'3.0'>='3.0' true true +2.75>=2.75 true true +'2.75'>='2.75' true true +---------- binary operator <= ---------- +2<=0 true false +-2.5<=0 true true +2<=1 true false +5<=2 true false +-5<=2 true true +16<=2 true false +-16<=-2 true true +0.5<=0 true false +0.5<=1 true true +0.5<=2 true true +0.5<=-1 true false +0.5<=2 true true +2.25<=0 true false +2.25<=2 true false +-2<=0 true true +3<=3 true true +'2'<='0' true false +'2.5'<='3' true true +'-2'<='1.5' true true +'-2.5'<='-1.5' true false +'3.0'<='3.0' true true +2.75<=2.75 true true +'2.75'<='2.75' true true +---------- math.abs ---------- +math.abs(-2.5) true 2.5 +math.abs(-2) true 2 +math.abs(0) true +math.abs(2) true 2 +math.abs(2.5) true 2.5 +math.abs('-2.5') true 2.5 +math.abs('-2') true 2 +math.abs('0') true +math.abs('2') true 2 +math.abs('2.5') true 2.5 +---------- math.ceil ---------- +math.ceil(-2.5) true -2 +math.ceil(-2) true -2 +math.ceil(0) true +math.ceil(2) true 2 +math.ceil(2.5) true 3 +math.ceil('-2.5') true -2 +math.ceil('-2') true -2 +math.ceil('0') true +math.ceil('2') true 2 +math.ceil('2.5') true 3 +---------- math.cos ---------- +math.cos(-2.5) true -0.801 +math.cos(-2) true -0.416 +math.cos(0) true 1 +math.cos(2) true -0.416 +math.cos(2.5) true -0.801 +math.cos('-2.5') true -0.801 +math.cos('-2') true -0.416 +math.cos('0') true 1 +math.cos('2') true -0.416 +math.cos('2.5') true -0.801 +---------- math.deg ---------- +math.deg(-2.5) true -143.2 +math.deg(-2) true -114.5 +math.deg(0) true +math.deg(2) true 114.59 +math.deg(2.5) true 143.23 +math.deg('-2.5') true -143.2 +math.deg('-2') true -114.5 +math.deg('0') true +math.deg('2') true 114.59 +math.deg('2.5') true 143.23 +---------- math.exp ---------- +math.exp(-2.5) true 0.0820 +math.exp(-2) true 0.1353 +math.exp(0) true 1 +math.exp(2) true 7.3890 +math.exp(2.5) true 12.182 +math.exp('-2.5') true 0.0820 +math.exp('-2') true 0.1353 +math.exp('0') true 1 +math.exp('2') true 7.3890 +math.exp('2.5') true 12.182 +---------- math.floor ---------- +math.floor(-2.5) true -3 +math.floor(-2) true -2 +math.floor(0) true +math.floor(2) true 2 +math.floor(2.5) true 2 +math.floor('-2.5') true -3 +math.floor('-2') true -2 +math.floor('0') true +math.floor('2') true 2 +math.floor('2.5') true 2 +---------- math.frexp ---------- +math.frexp(-2.5) true -0.625 2 +math.frexp(-2) true -0.5 2 +math.frexp(0) true +math.frexp(2) true 0.5 2 +math.frexp(2.5) true 0.625 2 +math.frexp('-2.5') true -0.625 2 +math.frexp('-2') true -0.5 2 +math.frexp('0') true +math.frexp('2') true 0.5 2 +math.frexp('2.5') true 0.625 2 +---------- math.modf ---------- +math.modf(-2.5) true -2 -0.5 +math.modf(-2) true -2 +math.modf(0) true +math.modf(2) true 2 +math.modf(2.5) true 2 0.5 +math.modf('-2.5') true -2 -0.5 +math.modf('-2') true -2 +math.modf('0') true +math.modf('2') true 2 +math.modf('2.5') true 2 0.5 +---------- math.rad ---------- +math.rad(-2.5) true -0.043 +math.rad(-2) true -0.034 +math.rad(0) true +math.rad(2) true 0.0349 +math.rad(2.5) true 0.0436 +math.rad('-2.5') true -0.043 +math.rad('-2') true -0.034 +math.rad('0') true +math.rad('2') true 0.0349 +math.rad('2.5') true 0.0436 +---------- math.sin ---------- +math.sin(-2.5) true -0.598 +math.sin(-2) true -0.909 +math.sin(0) true +math.sin(2) true 0.9092 +math.sin(2.5) true 0.5984 +math.sin('-2.5') true -0.598 +math.sin('-2') true -0.909 +math.sin('0') true +math.sin('2') true 0.9092 +math.sin('2.5') true 0.5984 +---------- math.sqrt ---------- +math.sqrt(-2.5) true -nan +math.sqrt(-2) true -nan +math.sqrt(0) true +math.sqrt(2) true 1.4142 +math.sqrt(2.5) true 1.5811 +math.sqrt('-2.5') true -nan +math.sqrt('-2') true -nan +math.sqrt('0') true +math.sqrt('2') true 1.4142 +math.sqrt('2.5') true 1.5811 +---------- math.tan ---------- +math.tan(-2.5) true 0.7470 +math.tan(-2) true 2.1850 +math.tan(0) true +math.tan(2) true -2.185 +math.tan(2.5) true -0.747 +math.tan('-2.5') true 0.7470 +math.tan('-2') true 2.1850 +math.tan('0') true +math.tan('2') true -2.185 +math.tan('2.5') true -0.747 +---------- math.fmod ---------- +math.fmod(2,0) true -nan +math.fmod(-2.5,0) true -nan +math.fmod(2,1) true +math.fmod(5,2) true 1 +math.fmod(-5,2) true -1 +math.fmod(16,2) true +math.fmod(-16,-2) true +math.fmod(0.5,0) true -nan +math.fmod(0.5,1) true 0.5 +math.fmod(0.5,2) true 0.5 +math.fmod(0.5,-1) true 0.5 +math.fmod(0.5,2) true 0.5 +math.fmod(2.25,0) true -nan +math.fmod(2.25,2) true 0.25 +math.fmod(-2,0) true -nan +math.fmod(3,3) true +math.fmod('2','0') true -nan +math.fmod('2.5','3') true 2.5 +math.fmod('-2','1.5') true -0.5 +math.fmod('-2.5','-1.5') true -1 +math.fmod('3.0','3.0') true +math.fmod(2.75,2.75) true +math.fmod('2.75','2.75') true +math.fmod(3,'3') true +math.fmod('3',3) true +math.fmod(2.75,'2.75') true +math.fmod('2.75',2.75) true +math.fmod(-3,'-4') true -3 +math.fmod('-3',4) true -3 +math.fmod(-3,'4') true -3 +math.fmod('-3',-4) true -3 +math.fmod(-4.75,'2.75') true -2 +math.fmod('-2.75',1.75) true -1 +math.fmod(4.75,'-2.75') true 2 +math.fmod('2.75',-1.75) true 1 +---------- math.ldexp ---------- +math.ldexp(2,0) true 2 +math.ldexp(-2.5,0) true -2.5 +math.ldexp(2,1) true 4 +math.ldexp(5,2) true 20 +math.ldexp(-5,2) true -20 +math.ldexp(16,2) true 64 +math.ldexp(-16,-2) true -4 +math.ldexp(0.5,0) true 0.5 +math.ldexp(0.5,1) true 1 +math.ldexp(0.5,2) true 2 +math.ldexp(0.5,-1) true 0.25 +math.ldexp(0.5,2) true 2 +math.ldexp(2.25,0) true 2.25 +math.ldexp(2.25,2) true 9 +math.ldexp(-2,0) true -2 +math.ldexp(3,3) true 24 +math.ldexp('2','0') true 2 +math.ldexp('2.5','3') true 20 +math.ldexp('-2','1.5') true -4 +math.ldexp('-2.5','-1.5') true -1.25 +math.ldexp('3.0','3.0') true 24 +math.ldexp(2.75,2.75) true 11 +math.ldexp('2.75','2.75') true 11 +math.ldexp(3,'3') true 24 +math.ldexp('3',3) true 24 +math.ldexp(2.75,'2.75') true 11 +math.ldexp('2.75',2.75) true 11 +math.ldexp(-3,'-4') true -0.187 +math.ldexp('-3',4) true -48 +math.ldexp(-3,'4') true -48 +math.ldexp('-3',-4) true -0.187 +math.ldexp(-4.75,'2.75') true -19 +math.ldexp('-2.75',1.75) true -5.5 +math.ldexp(4.75,'-2.75') true 1.1875 +math.ldexp('2.75',-1.75) true 1.375 +---------- math.pow ---------- +math.pow(2,0) true 1 +math.pow(-2.5,0) true 1 +math.pow(2,1) true 2 +math.pow(5,2) true 25 +math.pow(-5,2) true 25 +math.pow(16,2) true 256 +math.pow(-16,-2) true 0.0039 +math.pow(0.5,0) true 1 +math.pow(0.5,1) true 0.5 +math.pow(0.5,2) true 0.25 +math.pow(0.5,-1) true 2 +math.pow(0.5,2) true 0.25 +math.pow(2.25,0) true 1 +math.pow(2.25,2) true 5.0625 +math.pow(-2,0) true 1 +math.pow(3,3) true 27 +math.pow('2','0') true 1 +math.pow('2.5','3') true 15.625 +math.pow('-2','1.5') true -nan +math.pow('-2.5','-1.5') true -nan +math.pow('3.0','3.0') true 27 +math.pow(2.75,2.75) true 16.149 +math.pow('2.75','2.75') true 16.149 +math.pow(3,'3') true 27 +math.pow('3',3) true 27 +math.pow(2.75,'2.75') true 16.149 +math.pow('2.75',2.75) true 16.149 +math.pow(-3,'-4') true 0.0123 +math.pow('-3',4) true 81 +math.pow(-3,'4') true 81 +math.pow('-3',-4) true 0.0123 +math.pow(-4.75,'2.75') true -nan +math.pow('-2.75',1.75) true -nan +math.pow(4.75,'-2.75') true 0.0137 +math.pow('2.75',-1.75) true 0.1702 +---------- math.max ---------- +math.max(4) true 4 +math.max(-4.5) true -4.5 +math.max('5.5') true 5.5 +math.max('-5') true -5 +math.max(4,'8') true 8 +math.max(-4.5,'-8') true -4.5 +math.max('5.5',2.2) true 5.5 +math.max('-5',-2.2) true -2.2 +math.max(111,222,333) true 333 +math.max(-222,-333,-111) true -111 +math.max(444,-111,-222) true 444 +---------- math.min ---------- +math.min(4) true 4 +math.min(-4.5) true -4.5 +math.min('5.5') true 5.5 +math.min('-5') true -5 +math.min(4,'8') true 4 +math.min(-4.5,'-8') true -8 +math.min('5.5',2.2) true 2.2 +math.min('-5',-2.2) true -5 +math.min(111,222,333) true 111 +math.min(-222,-333,-111) true -333 +math.min(444,-111,-222) true -222 +----------- Random number tests +math.random() number true +math.random() number true +math.random() number true +math.random() number true +math.random() number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true + +-- comparing new numbers +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +-- resetting seed + +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +----------- Tests involving -0 and NaN +0 == -0 true +t[-0] == t[0] true +mz, z +mz == z true +a[z] == 1 and a[mz] == 1 true diff --git a/luaj-test/src/test/resources/compatibility/metatags.out b/luaj-test/src/test/resources/compatibility/jme/metatags.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/metatags.out rename to luaj-test/src/test/resources/compatibility/jme/metatags.out diff --git a/luaj-test/src/test/resources/compatibility/oslib.out b/luaj-test/src/test/resources/compatibility/jme/oslib.out similarity index 69% rename from luaj-test/src/test/resources/compatibility/oslib.out rename to luaj-test/src/test/resources/compatibility/jme/oslib.out index 5148663e..38f1af9c 100644 --- a/luaj-test/src/test/resources/compatibility/oslib.out +++ b/luaj-test/src/test/resources/compatibility/jme/oslib.out @@ -19,15 +19,29 @@ os.date('%A', 1281364496) true string nil os.date('%b', 1281364496) true string nil os.date('%B', 1281364496) true string nil os.date('%c', 1281364496) true string nil +os.date('%C', 1281364496) true string nil os.date('%d', 1281364496) true string nil +os.date('%D', 1281364496) true string nil +os.date('%e', 1281364496) true string nil +os.date('%F', 1281364496) true string nil +os.date('%g', 1281364496) true string nil +os.date('%G', 1281364496) true string nil +os.date('%h', 1281364496) true string nil os.date('%H', 1281364496) true string nil os.date('%I', 1281364496) true string nil os.date('%j', 1281364496) true string nil os.date('%m', 1281364496) true string nil os.date('%M', 1281364496) true string nil +os.date('%n', 1281364496) true string nil os.date('%p', 1281364496) true string nil +os.date('%r', 1281364496) true string nil +os.date('%R', 1281364496) true string nil os.date('%S', 1281364496) true string nil +os.date('%t', 1281364496) true string nil +os.date('%T', 1281364496) true string nil +os.date('%u', 1281364496) true string nil os.date('%U', 1281364496) true string nil +os.date('%V', 1281364496) true string nil os.date('%w', 1281364496) true string nil os.date('%W', 1281364496) true string nil os.date('%x', 1281364496) true string nil @@ -35,15 +49,16 @@ os.date('%X', 1281364496) true string nil os.date('%y', 1281364496) true string nil os.date('%Y', 1281364496) true string nil os.date('%z', 1281364496) true string nil +os.date('%Z', 1281364496) true string nil k string year v number 2010 k string month v number 8 k string day v number 9 -k string hour v number 7 +k string hour v number 16 k string min v number 34 k string sec v number 56 k string wday v number 2 k string yday v number 221 k string isdst v boolean true type(os.time()) number -os.time({year=1971, month=2, day=25}) 36360000 -os.time({year=1971, month=2, day=25, hour=11, min=22, sec=33}) 36357753 +os.time({year=1971, month=2, day=25}) 36327600 +os.time({year=1971, month=2, day=25, hour=11, min=22, sec=33}) 36325353 diff --git a/luaj-test/src/test/resources/compatibility/stringlib.out b/luaj-test/src/test/resources/compatibility/jme/stringlib.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/stringlib.out rename to luaj-test/src/test/resources/compatibility/jme/stringlib.out diff --git a/luaj-test/src/test/resources/compatibility/tablelib.out b/luaj-test/src/test/resources/compatibility/jme/tablelib.out similarity index 93% rename from luaj-test/src/test/resources/compatibility/tablelib.out rename to luaj-test/src/test/resources/compatibility/jme/tablelib.out index 4f49801c..83c8b8a9 100644 --- a/luaj-test/src/test/resources/compatibility/tablelib.out +++ b/luaj-test/src/test/resources/compatibility/jme/tablelib.out @@ -1,5 +1,4 @@ 2 -7 -- concat tests onetwothree one--two--three @@ -26,7 +25,6 @@ two {[1]=seven,[2]=one,[3]=two,[4]=three,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 {[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[a]=aaa,[b]=bbb,[c]=ccc} 6 {[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[7]=nine,[a]=aaa,[b]=bbb,[c]=ccc} 7 -{[10]=ten,[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[7]=nine,[a]=aaa,[b]=bbb,[c]=ccc} 7 #{} 0 #{"a"} 1 #{"a","b"} 2 @@ -49,13 +47,7 @@ table.remove(t,1) one {[10]=ten,[1]=two,[2]=three,[3]=four,[4]=five,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 table.remove(t,3) four {[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 -table.remove(t,5) -{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 -table.remove(t,10) -{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 -table.remove(t,-1) -{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 -table.remove(t,-1) +table.remove(t,5) nil {[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 -- sort tests one-two-three diff --git a/luaj-test/src/test/resources/compatibility/tailcalls.out b/luaj-test/src/test/resources/compatibility/jme/tailcalls.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/tailcalls.out rename to luaj-test/src/test/resources/compatibility/jme/tailcalls.out diff --git a/luaj-test/src/test/resources/compatibility/upvalues.out b/luaj-test/src/test/resources/compatibility/jme/upvalues.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/upvalues.out rename to luaj-test/src/test/resources/compatibility/jme/upvalues.out diff --git a/luaj-test/src/test/resources/compatibility/vm.out b/luaj-test/src/test/resources/compatibility/jme/vm.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/vm.out rename to luaj-test/src/test/resources/compatibility/jme/vm.out diff --git a/luaj-test/src/test/resources/compatibility/jse/baselib.out b/luaj-test/src/test/resources/compatibility/jse/baselib.out new file mode 100644 index 00000000..c3b5c1da --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/baselib.out @@ -0,0 +1,240 @@ + +11 +abc 123 nil pqr +F +F +T +assert(true) true +pcall(assert,true) true +pcall(assert,false) false string +pcall(assert,nil) false string +pcall(assert,true,"msg") true +pcall(assert,false,"msg") false string +pcall(assert,nil,"msg") false string +pcall(assert,false,"msg","msg2") false string +collectgarbage("count") number +collectgarbage("collect") number +collectgarbage("count") number +pcall(ipairs) false string +pcall(ipairs,nil) false string +pcall(ipairs,"a") false string +pcall(ipairs,1) false string +ipairs2 1 one +ipairs2 2 two +ipairs4 1 one +ipairs4 2 two +table loaded +load: nil +load("print(3+4); return 8") func.1 nil +7 +load("print(3+4); return 8")() 8 +pcall(pairs) false string +pcall(pairs,nil) false string +pcall(pairs,"a") false string +pcall(pairs,1) false string +pairs2 1 one +pairs2 2 two +pairs3 aa aaa +pairs4 1 one +pairs4 2 two +pairs4 aa aaa +pairs5 20 30 +pairs5 30 20 +_G["abc"] (before) nil +_G["abc"] (after) def +type(nil) nil +type("a") string +type(1) number +type(1.5) number +type(function() end) function +type({}) table +type(true) boolean +type(false) boolean +pcall(type,type) function +pcall(type) false string +(function() return pcall(type) end)() false string +la() false string +ga() false string +getmetatable(ta) nil +getmetatable(tb) nil +setmetatable(ta),{cc1="ccc1"} table +setmetatable(tb),{dd1="ddd1"} table +getmetatable(ta)["cc1"] ccc1 +getmetatable(tb)["dd1"] ddd1 +getmetatable(1) nil +pcall(setmetatable,1) false string +pcall(setmetatable,nil) false string +pcall(setmetatable,"ABC") false string +pcall(setmetatable,function() end) false string +pcall(rawget) false string +pcall(rawget,"a") false string +pcall(rawget,s) false string +pcall(rawget,t) false string + s nil nil ccc ddd nil nil nil + s nil nil ccc ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,s,"aa","www") tbl.2 + s www nil ccc ddd nil nil nil + s www nil ccc ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,s,"cc","xxx") tbl.2 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,t,"aa","yyy") tbl.3 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc ddd nil nil nil + t yyy nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,t,"dd","zzz") tbl.3 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawlen, {}) 0 +pcall(rawlen, {"a"}) 1 +pcall(rawlen, {"a","b"}) 2 +pcall(rawlen, "") 0 +pcall(rawlen, "a") 1 +pcall(rawlen, "ab") 2 +pcall(rawlen, 1) false string +pcall(rawlen, nil) false string +pcall(rawlen) false string + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +s["ee"]="ppp" + s www nil xxx ddd ppp nil nil + s www nil xxx ddd ppp nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +s["cc"]="qqq" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +t["ff"]="rrr" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc zzz nil rrr nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil rrr nil + mt aaa bbb nil nil nil rrr nil +t["dd"]="sss" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc sss nil rrr nil + t yyy nil ccc sss nil nil nil + mt aaa bbb nil nil nil rrr nil + mt aaa bbb nil nil nil rrr nil +mt["gg"]="ttt" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc sss nil rrr ttt + t yyy nil ccc sss nil nil nil + mt aaa bbb nil nil nil rrr ttt + mt aaa bbb nil nil nil rrr ttt +pcall(select) false string +select(1,11,22,33,44,55) 11 22 33 44 55 +select(2,11,22,33,44,55) 22 33 44 55 +select(3,11,22,33,44,55) 33 44 55 +select(4,11,22,33,44,55) 44 55 +pcall(select,5,11,22,33,44,55) 55 +pcall(select,6,11,22,33,44,55) nil +pcall(select,7,11,22,33,44,55) nil +pcall(select,0,11,22,33,44,55) false string +pcall(select,-1,11,22,33,44,55) 55 +pcall(select,-2,11,22,33,44,55) 44 +pcall(select,-4,11,22,33,44,55) 22 +pcall(select,-5,11,22,33,44,55) 11 +pcall(select,-6,11,22,33,44,55) false string +pcall(select,1) nil +pcall(select,select) false string +pcall(select,{}) false string +pcall(select,"2",11,22,33) 22 +pcall(select,"abc",11,22,33) false string +pcall(tonumber) nil +pcall(tonumber,nil) nil +pcall(tonumber,"abc") nil +pcall(tonumber,"123") 123 +pcall(tonumber,"123",10) 123 +pcall(tonumber,"123",8) 83 +pcall(tonumber,"123",6) 51 +pcall(tonumber,"10101",4) 273 +pcall(tonumber,"10101",3) 91 +pcall(tonumber,"10101",2) 21 +pcall(tonumber,"1a1",16) 417 +pcall(tonumber,"1a1",32) 1345 +pcall(tonumber,"1a1",54) false string +pcall(tonumber,"1a1",1) false string +pcall(tonumber,"1a1",0) false string +pcall(tonumber,"1a1",-1) false string +pcall(tonumber,"1a1","32") 1345 +pcall(tonumber,"123","456") false string +pcall(tonumber,"1a1",10) nil +pcall(tonumber,"151",4) nil +pcall(tonumber,"151",3) nil +pcall(tonumber,"151",2) nil +pcall(tonumber,"123",8,8) 83 +pcall(tonumber,123) 123 +pcall(tonumber,true) nil +pcall(tonumber,false) nil +pcall(tonumber,tonumber) nil +pcall(tonumber,function() end) nil +pcall(tonumber,{"one","two",a="aa",b="bb"}) nil +pcall(tonumber,"123.456") 123.456 +pcall(tonumber," 123.456") 123.456 +pcall(tonumber," 234qwer") nil +pcall(tonumber,"0x20") 32 +pcall(tonumber," 0x20") 32 +pcall(tonumber,"0x20 ") 32 +pcall(tonumber," 0x20 ") 32 +pcall(tonumber,"0X20") 32 +pcall(tonumber," 0X20") 32 +pcall(tonumber,"0X20 ") 32 +pcall(tonumber," 0X20 ") 32 +pcall(tonumber,"0x20",10) nil +pcall(tonumber,"0x20",16) nil +pcall(tonumber,"0x20",8) nil +pcall(tostring) nil +pcall(tostring,nil) nil +pcall(tostring,"abc") abc +pcall(tostring,"abc","def") abc +pcall(tostring,123) 123 +pcall(tostring,true) true +pcall(tostring,false) false +tostring(tostring) string +tostring(function() end) string +tostring({"one","two",a="aa",b="bb"}) string +_VERSION string +pcall(badfunc) false string +pcall(badfunc,errfunc) false string +pcall(badfunc,badfunc) false string +pcall(wrappedbad) nil +pcall(wrappedbad,errfunc) nil +pcall(xpcall(badfunc)) false string + in errfunc string +pcall(xpcall(badfunc,errfunc)) false +pcall(xpcall(badfunc,badfunc)) false +pcall(xpcall(wrappedbad)) false string +xpcall(wrappedbad,errfunc) true diff --git a/luaj-test/src/test/resources/compatibility/jse/coroutinelib.out b/luaj-test/src/test/resources/compatibility/jse/coroutinelib.out new file mode 100644 index 00000000..a759fbb1 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/coroutinelib.out @@ -0,0 +1,99 @@ +running is not nil +co.status suspended +co-body 1 10 +foo 2 +main true 4 +co.status suspended +co-body r +main true 11 -9 +co.status suspended +co-body x y +running is not nil +co.status.inside running +co.status.inside running +co.status.inside2 normal +main true 10 end +co.status dead +main false cannot resume dead coroutine +co.status dead +running is not nil +co.status suspended +co-body 1 10 +foo 2 +main true 4 +co.status suspended +co-body nil nil +main true 11 -9 +co.status suspended +co-body x y +main true 10 end +co.status dead +main false cannot resume dead coroutine +co.status dead +co-body 1 10 +foo 2 +g 4 +co-body r +g 11 -9 +co-body x y +g 10 end +g cannot resume dead coroutine +(main) sending args 111 222 333 +(echocr) first args 111 222 333 +(main) resume returns true 111 222 333 +(main) sending args +(echoch) yield returns +(main) resume returns true +(main) sending args 111 +(echoch) yield returns 111 +(main) resume returns true 111 +(main) sending args 111 222 333 +(echoch) yield returns 111 222 333 +(main) resume returns true 111 222 333 +main-b suspended +main-c suspended + b-resumed main-arg-for-b true + b-b running + b-c suspended + b-resume-b false cannot resume non-suspended coroutine + c-resumed b-arg-for-c true + c-b normal + c-c running + c-resume-b false cannot resume non-suspended coroutine + c-resume-c false cannot resume non-suspended coroutine + b-resume-c true c-rslt +main-resume-b true b-rslt + c-resumed main-arg-for-c true + c-b suspended + c-c running + b-resumed b-arg-for-b true + b-b running + b-c normal + b-resume-b false cannot resume non-suspended coroutine + b-resume-c false cannot resume non-suspended coroutine + c-resume-b true b-rslt + c-resume-c false cannot resume non-suspended coroutine +main-resume-c true c-rslt +main-b suspended +main-c suspended + b-resumed main-arg-for-b true + b-b running + b-c suspended + b-resume-b false cannot resume non-suspended coroutine + c-resumed b-arg-for-c true + c-b normal + c-c running + c-resume-b false cannot resume non-suspended coroutine + c-resume-c false cannot resume non-suspended coroutine + b-resume-c true c-rslt +main-resume-b true b-rslt +main-resume-c true +main-b suspended +main-c dead + b-resumed main-arg-for-b true + b-b running + b-c dead + b-resume-b false cannot resume non-suspended coroutine + b-resume-c false cannot resume dead coroutine +main-resume-b true b-rslt +main-resume-c false cannot resume dead coroutine diff --git a/luaj-test/src/test/resources/compatibility/luajit/debuglib.out b/luaj-test/src/test/resources/compatibility/jse/debuglib.out similarity index 97% rename from luaj-test/src/test/resources/compatibility/luajit/debuglib.out rename to luaj-test/src/test/resources/compatibility/jse/debuglib.out index e03e8d18..663fe0be 100644 --- a/luaj-test/src/test/resources/compatibility/luajit/debuglib.out +++ b/luaj-test/src/test/resources/compatibility/jse/debuglib.out @@ -61,18 +61,18 @@ a.a=bbb a.b=nil b.a=nil b.b=nil a.a=bbb a.b=ccc b.a=nil b.b=nil boolean table nil table boolean nil nil nil -boolean boolean nil nil +boolean table nil nil a.a=bbb a.b=nil b.a=nil b.b=nil boolean nil nil nil get=true,true,nil -set=true,false,nil +set=true,true,nil get=true,true,nil get=true,true,nil -set=true,false,nil +set=true,true,nil get=true,true,nil true nil -true true -true true +true 1 +true 1 ----- debug.getinfo 6 --- @@ -83,7 +83,7 @@ debug.getinfo(1) currentline: 144 linedefined: 141 lastlinedefined: 155 - nups: 4 + nups: 5 func: function debug.getinfo(1,"") debug.getinfo(1,"l") @@ -98,7 +98,7 @@ debug.getinfo(2) currentline: 157 linedefined: 135 lastlinedefined: 159 - nups: 5 + nups: 6 func: function debug.getinfo(2,"l") currentline: 157 @@ -162,7 +162,7 @@ true currentline: -1 linedefined: 141 lastlinedefined: 155 - nups: 4 + nups: 5 func: function debug.getinfo(test) true @@ -172,18 +172,22 @@ true currentline: -1 linedefined: 135 lastlinedefined: 159 - nups: 5 + nups: 6 func: function ----- debug.sethook, debug.gethook ... in hook call nil - info[2]=debuglib.lua,174 + info[2]=debuglib.lua,177 ... in hook call nil - info[2]=debuglib.lua,175 + info[2]=debuglib.lua,176 ... in hook call nil info[2]=[C],-1 ... in hook call nil info[2]=[C],-1 hook = c -> result=true,nil,nil,nil,false,false,nil + ... in hook return nil + info[2]=[C],-1 + ... in hook return nil + info[2]=[C],-1 hook = r -> result=true,nil,nil,nil,false,false,nil ... in hook line 192 info[2]=debuglib.lua,192 @@ -196,19 +200,23 @@ hook = r -> result=true,nil,nil,nil,false,false,nil ... in hook line 195 info[2]=debuglib.lua,195 hook = l -> result=true,nil,nil,nil,false,false,nil + ... in hook return nil + info[2]=[C],-1 ... in hook line 192 info[2]=debuglib.lua,192 ... in hook call nil - info[2]=debuglib.lua,174 + info[2]=debuglib.lua,177 ... in hook line 177 info[2]=debuglib.lua,177 ... in hook line 178 info[2]=debuglib.lua,178 ... in hook call nil - info[2]=debuglib.lua,175 + info[2]=debuglib.lua,176 ... in hook line 176 info[2]=debuglib.lua,176 ... in hook call nil + info[2]=[C],-1 + ... in hook return nil info[2]=[C],-1 ... in hook line 195 info[2]=debuglib.lua,195 @@ -229,7 +237,7 @@ stack traceback: debuglib.lua:238: in function [C]: in function 'pcall' debuglib.lua:240: in main chunk - [C]: at 0x55eaaf4e2f20 + [C]: in ? ----- debug.upvalueid debug.getupvalue(a1,1) x 100 debug.getupvalue(a1,2) y 200 diff --git a/luaj-test/src/test/resources/compatibility/jse/errors.out b/luaj-test/src/test/resources/compatibility/jse/errors.out new file mode 100644 index 00000000..cc674319 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/errors.out @@ -0,0 +1,97 @@ +a(error) false nil +a(error,"msg") false string +a(error,"msg",0) false string +a(error,"msg",1) false string +a(error,"msg",2) false string +a(error,"msg",3) false string +a(error,"msg",4) false string +a(error,"msg",5) false string +a(error,"msg",6) false string +a(nil()) false string +a(t()) false string +a(s()) false string +a(true()) false string +a(nil+1) false string +a(a+1) false string +a(s+1) false string +a(true+1) false string +a(nil.x) false string +a(a.x) false string +a(s.x) true nil +a(true.x) false string +a(nil.x=5) false string +a(a.x=5) false string +a(s.x=5) false string +a(true.x=5) false string +a(#nil) false string +a(#t) true 0 +a(#s) true 11 +a(#a) false string +a(#true) false string +a(nil>1) false string +a(a>1) false string +a(s>1) false string +a(true>1) false string +a(-nil) false string +a(-a) false string +a(-s) false string +a(-true) false string +-------- string concatenation +"a".."b" true +"a"..nil false +nil.."b" false +"a"..{} false +{}.."b" false +"a"..2 true +2.."b" true +"a"..print false +print.."b" false +"a"..true false +true.."b" false +nil..true false +"a"..3.5 true +3.5.."b" true +-------- table concatenation +"a".."b" true +"a"..nil false +nil.."b" false +"a"..{} false +{}.."b" false +"a"..2 true +2.."b" true +"a"..print false +print.."b" false +"a"..true false +true.."b" false +nil..true false +"a"..3.5 true +3.5.."b" true +-------- pairs tests +a(pairs(nil)) false string +a(pairs(a)) false string +a(pairs(s)) false string +a(pairs(t)) true func.1 +a(pairs(true)) false string +-------- setmetatable tests +a(setmetatable(nil)) false string +a(setmetatable(a)) false string +a(setmetatable(s)) false string +a(setmetatable(true)) false string +a(setmetatable(t)) true tbl.2 +a(getmetatable(t)) true tbl.3 +a(setmetatable(t*)) true tbl.2 +a(getmetatable(t)) true tbl.4 +a(setmetatable(t)) false string +a(getmetatable(t)) true tbl.4 +a(setmetatable(t)) true tbl.5 +a(getmetatable(t)) true tbl.6 +a(setmetatable(t*)) true tbl.5 +a(getmetatable(t)) true some string +a(setmetatable(t)) false string +a(getmetatable(t)) true some string +a(setmetatable(t,nil)) false string +a(setmetatable(t)) false string +a(setmetatable({},"abc")) false string +error("msg","arg") false string +loadfile("bogus.txt") true nil +dofile("bogus.txt") false string diff --git a/luaj-test/src/test/resources/compatibility/jse/functions.out b/luaj-test/src/test/resources/compatibility/jse/functions.out new file mode 100644 index 00000000..cdffa68a --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/functions.out @@ -0,0 +1,68 @@ +f0: +f0: +f0: +f0: +f0: +f1: nil +f1: a1/1 +f1: a1/2 +f1: a1/3 +f1: a1/4 +f2: nil nil +f2: a1/1 nil +f2: a1/2 a2/2 +f2: a1/3 a2/3 +f2: a1/4 a2/4 +f3: nil nil nil +f3: a1/1 nil nil +f3: a1/2 a2/2 nil +f3: a1/3 a2/3 a3/3 +f3: a1/4 a2/4 a3/4 +f4: nil nil nil nil +f4: a1/1 nil nil nil +f4: a1/2 a2/2 nil nil +f4: a1/3 a2/3 a3/3 nil +f4: a1/4 a2/4 a3/4 a4/4 +z0: nil +z2: c2.3/4 +z4: c4.1/4 +g0: nil nil nil nil (eol) +g2: b2.3/4 b2.4/4 nil nil (eol) +g4: b4.1/4 b4.2/4 b4.3/4 b4.4/4 (eol) +11 12 13 +23 22 21 +32 45 58 +a nil +... +...,a nil nil +a,... nil +a q +... +...,a nil q +a,... q +a q +... r +...,a r q +a,... q r +a q +... r s +...,a r q +a,... q r s +third abc nil | nil nil nil +third def nil | nil nil nil +third def nil | nil nil nil +third abc p | p nil nil +third def nil | p nil nil +third def nil | p nil nil +third abc p | p q nil +third def q | p q nil +third def q | p q nil +third abc p | p q r +third def q | p q r +third def q | p q r +third abc p | p q r +third def q | p q r +third def q | p q r +third abc nil | nil nil nil +third def nil | nil nil nil +third def nil | nil nil nil diff --git a/luaj-test/src/test/resources/compatibility/iolib.out b/luaj-test/src/test/resources/compatibility/jse/iolib.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/iolib.out rename to luaj-test/src/test/resources/compatibility/jse/iolib.out diff --git a/luaj-test/src/test/resources/compatibility/jse/manyupvals.out b/luaj-test/src/test/resources/compatibility/jse/manyupvals.out new file mode 100644 index 00000000..391387a3 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/manyupvals.out @@ -0,0 +1,1981 @@ + local f1 + f1 = function() return 1 end + local f2 + f2 = function() return 1 end + local f3 + do + local result + function f3() + if not result then + result = f1() + f2() + end + return result + end + end + local f4 + do + local result + function f4() + if not result then + result = f2() + f3() + end + return result + end + end + local f5 + do + local result + function f5() + if not result then + result = f3() + f4() + end + return result + end + end + local f6 + do + local result + function f6() + if not result then + result = f4() + f5() + end + return result + end + end + local f7 + do + local result + function f7() + if not result then + result = f5() + f6() + end + return result + end + end + local f8 + do + local result + function f8() + if not result then + result = f6() + f7() + end + return result + end + end + local f9 + do + local result + function f9() + if not result then + result = f7() + f8() + end + return result + end + end + local f10 + do + local result + function f10() + if not result then + result = f8() + f9() + end + return result + end + end + local f11 + do + local result + function f11() + if not result then + result = f9() + f10() + end + return result + end + end + local f12 + do + local result + function f12() + if not result then + result = f10() + f11() + end + return result + end + end + local f13 + do + local result + function f13() + if not result then + result = f11() + f12() + end + return result + end + end + local f14 + do + local result + function f14() + if not result then + result = f12() + f13() + end + return result + end + end + local f15 + do + local result + function f15() + if not result then + result = f13() + f14() + end + return result + end + end + local f16 + do + local result + function f16() + if not result then + result = f14() + f15() + end + return result + end + end + local f17 + do + local result + function f17() + if not result then + result = f15() + f16() + end + return result + end + end + local f18 + do + local result + function f18() + if not result then + result = f16() + f17() + end + return result + end + end + local f19 + do + local result + function f19() + if not result then + result = f17() + f18() + end + return result + end + end + local f20 + do + local result + function f20() + if not result then + result = f18() + f19() + end + return result + end + end + local f21 + do + local result + function f21() + if not result then + result = f19() + f20() + end + return result + end + end + local f22 + do + local result + function f22() + if not result then + result = f20() + f21() + end + return result + end + end + local f23 + do + local result + function f23() + if not result then + result = f21() + f22() + end + return result + end + end + local f24 + do + local result + function f24() + if not result then + result = f22() + f23() + end + return result + end + end + local f25 + do + local result + function f25() + if not result then + result = f23() + f24() + end + return result + end + end + local f26 + do + local result + function f26() + if not result then + result = f24() + f25() + end + return result + end + end + local f27 + do + local result + function f27() + if not result then + result = f25() + f26() + end + return result + end + end + local f28 + do + local result + function f28() + if not result then + result = f26() + f27() + end + return result + end + end + local f29 + do + local result + function f29() + if not result then + result = f27() + f28() + end + return result + end + end + local f30 + do + local result + function f30() + if not result then + result = f28() + f29() + end + return result + end + end + local f31 + do + local result + function f31() + if not result then + result = f29() + f30() + end + return result + end + end + local f32 + do + local result + function f32() + if not result then + result = f30() + f31() + end + return result + end + end + local f33 + do + local result + function f33() + if not result then + result = f31() + f32() + end + return result + end + end + local f34 + do + local result + function f34() + if not result then + result = f32() + f33() + end + return result + end + end + local f35 + do + local result + function f35() + if not result then + result = f33() + f34() + end + return result + end + end + local f36 + do + local result + function f36() + if not result then + result = f34() + f35() + end + return result + end + end + local f37 + do + local result + function f37() + if not result then + result = f35() + f36() + end + return result + end + end + local f38 + do + local result + function f38() + if not result then + result = f36() + f37() + end + return result + end + end + local f39 + do + local result + function f39() + if not result then + result = f37() + f38() + end + return result + end + end + local f40 + do + local result + function f40() + if not result then + result = f38() + f39() + end + return result + end + end + local f41 + do + local result + function f41() + if not result then + result = f39() + f40() + end + return result + end + end + local f42 + do + local result + function f42() + if not result then + result = f40() + f41() + end + return result + end + end + local f43 + do + local result + function f43() + if not result then + result = f41() + f42() + end + return result + end + end + local f44 + do + local result + function f44() + if not result then + result = f42() + f43() + end + return result + end + end + local f45 + do + local result + function f45() + if not result then + result = f43() + f44() + end + return result + end + end + local f46 + do + local result + function f46() + if not result then + result = f44() + f45() + end + return result + end + end + local f47 + do + local result + function f47() + if not result then + result = f45() + f46() + end + return result + end + end + local f48 + do + local result + function f48() + if not result then + result = f46() + f47() + end + return result + end + end + local f49 + do + local result + function f49() + if not result then + result = f47() + f48() + end + return result + end + end + local f50 + do + local result + function f50() + if not result then + result = f48() + f49() + end + return result + end + end + local f51 + do + local result + function f51() + if not result then + result = f49() + f50() + end + return result + end + end + local f52 + do + local result + function f52() + if not result then + result = f50() + f51() + end + return result + end + end + local f53 + do + local result + function f53() + if not result then + result = f51() + f52() + end + return result + end + end + local f54 + do + local result + function f54() + if not result then + result = f52() + f53() + end + return result + end + end + local f55 + do + local result + function f55() + if not result then + result = f53() + f54() + end + return result + end + end + local f56 + do + local result + function f56() + if not result then + result = f54() + f55() + end + return result + end + end + local f57 + do + local result + function f57() + if not result then + result = f55() + f56() + end + return result + end + end + local f58 + do + local result + function f58() + if not result then + result = f56() + f57() + end + return result + end + end + local f59 + do + local result + function f59() + if not result then + result = f57() + f58() + end + return result + end + end + local f60 + do + local result + function f60() + if not result then + result = f58() + f59() + end + return result + end + end + local f61 + do + local result + function f61() + if not result then + result = f59() + f60() + end + return result + end + end + local f62 + do + local result + function f62() + if not result then + result = f60() + f61() + end + return result + end + end + local f63 + do + local result + function f63() + if not result then + result = f61() + f62() + end + return result + end + end + local f64 + do + local result + function f64() + if not result then + result = f62() + f63() + end + return result + end + end + local f65 + do + local result + function f65() + if not result then + result = f63() + f64() + end + return result + end + end + local f66 + do + local result + function f66() + if not result then + result = f64() + f65() + end + return result + end + end + local f67 + do + local result + function f67() + if not result then + result = f65() + f66() + end + return result + end + end + local f68 + do + local result + function f68() + if not result then + result = f66() + f67() + end + return result + end + end + local f69 + do + local result + function f69() + if not result then + result = f67() + f68() + end + return result + end + end + local f70 + do + local result + function f70() + if not result then + result = f68() + f69() + end + return result + end + end + local f71 + do + local result + function f71() + if not result then + result = f69() + f70() + end + return result + end + end + local f72 + do + local result + function f72() + if not result then + result = f70() + f71() + end + return result + end + end + local f73 + do + local result + function f73() + if not result then + result = f71() + f72() + end + return result + end + end + local f74 + do + local result + function f74() + if not result then + result = f72() + f73() + end + return result + end + end + local f75 + do + local result + function f75() + if not result then + result = f73() + f74() + end + return result + end + end + local f76 + do + local result + function f76() + if not result then + result = f74() + f75() + end + return result + end + end + local f77 + do + local result + function f77() + if not result then + result = f75() + f76() + end + return result + end + end + local f78 + do + local result + function f78() + if not result then + result = f76() + f77() + end + return result + end + end + local f79 + do + local result + function f79() + if not result then + result = f77() + f78() + end + return result + end + end + local f80 + do + local result + function f80() + if not result then + result = f78() + f79() + end + return result + end + end + local f81 + do + local result + function f81() + if not result then + result = f79() + f80() + end + return result + end + end + local f82 + do + local result + function f82() + if not result then + result = f80() + f81() + end + return result + end + end + local f83 + do + local result + function f83() + if not result then + result = f81() + f82() + end + return result + end + end + local f84 + do + local result + function f84() + if not result then + result = f82() + f83() + end + return result + end + end + local f85 + do + local result + function f85() + if not result then + result = f83() + f84() + end + return result + end + end + local f86 + do + local result + function f86() + if not result then + result = f84() + f85() + end + return result + end + end + local f87 + do + local result + function f87() + if not result then + result = f85() + f86() + end + return result + end + end + local f88 + do + local result + function f88() + if not result then + result = f86() + f87() + end + return result + end + end + local f89 + do + local result + function f89() + if not result then + result = f87() + f88() + end + return result + end + end + local f90 + do + local result + function f90() + if not result then + result = f88() + f89() + end + return result + end + end + local f91 + do + local result + function f91() + if not result then + result = f89() + f90() + end + return result + end + end + local f92 + do + local result + function f92() + if not result then + result = f90() + f91() + end + return result + end + end + local f93 + do + local result + function f93() + if not result then + result = f91() + f92() + end + return result + end + end + local f94 + do + local result + function f94() + if not result then + result = f92() + f93() + end + return result + end + end + local f95 + do + local result + function f95() + if not result then + result = f93() + f94() + end + return result + end + end + local f96 + do + local result + function f96() + if not result then + result = f94() + f95() + end + return result + end + end + local f97 + do + local result + function f97() + if not result then + result = f95() + f96() + end + return result + end + end + local f98 + do + local result + function f98() + if not result then + result = f96() + f97() + end + return result + end + end + local f99 + do + local result + function f99() + if not result then + result = f97() + f98() + end + return result + end + end + local f100 + do + local result + function f100() + if not result then + result = f98() + f99() + end + return result + end + end + local f101 + do + local result + function f101() + if not result then + result = f99() + f100() + end + return result + end + end + local f102 + do + local result + function f102() + if not result then + result = f100() + f101() + end + return result + end + end + local f103 + do + local result + function f103() + if not result then + result = f101() + f102() + end + return result + end + end + local f104 + do + local result + function f104() + if not result then + result = f102() + f103() + end + return result + end + end + local f105 + do + local result + function f105() + if not result then + result = f103() + f104() + end + return result + end + end + local f106 + do + local result + function f106() + if not result then + result = f104() + f105() + end + return result + end + end + local f107 + do + local result + function f107() + if not result then + result = f105() + f106() + end + return result + end + end + local f108 + do + local result + function f108() + if not result then + result = f106() + f107() + end + return result + end + end + local f109 + do + local result + function f109() + if not result then + result = f107() + f108() + end + return result + end + end + local f110 + do + local result + function f110() + if not result then + result = f108() + f109() + end + return result + end + end + local f111 + do + local result + function f111() + if not result then + result = f109() + f110() + end + return result + end + end + local f112 + do + local result + function f112() + if not result then + result = f110() + f111() + end + return result + end + end + local f113 + do + local result + function f113() + if not result then + result = f111() + f112() + end + return result + end + end + local f114 + do + local result + function f114() + if not result then + result = f112() + f113() + end + return result + end + end + local f115 + do + local result + function f115() + if not result then + result = f113() + f114() + end + return result + end + end + local f116 + do + local result + function f116() + if not result then + result = f114() + f115() + end + return result + end + end + local f117 + do + local result + function f117() + if not result then + result = f115() + f116() + end + return result + end + end + local f118 + do + local result + function f118() + if not result then + result = f116() + f117() + end + return result + end + end + local f119 + do + local result + function f119() + if not result then + result = f117() + f118() + end + return result + end + end + local f120 + do + local result + function f120() + if not result then + result = f118() + f119() + end + return result + end + end + local f121 + do + local result + function f121() + if not result then + result = f119() + f120() + end + return result + end + end + local f122 + do + local result + function f122() + if not result then + result = f120() + f121() + end + return result + end + end + local f123 + do + local result + function f123() + if not result then + result = f121() + f122() + end + return result + end + end + local f124 + do + local result + function f124() + if not result then + result = f122() + f123() + end + return result + end + end + local f125 + do + local result + function f125() + if not result then + result = f123() + f124() + end + return result + end + end + local f126 + do + local result + function f126() + if not result then + result = f124() + f125() + end + return result + end + end + local f127 + do + local result + function f127() + if not result then + result = f125() + f126() + end + return result + end + end + local f128 + do + local result + function f128() + if not result then + result = f126() + f127() + end + return result + end + end + local f129 + do + local result + function f129() + if not result then + result = f127() + f128() + end + return result + end + end + local f130 + do + local result + function f130() + if not result then + result = f128() + f129() + end + return result + end + end + local f131 + do + local result + function f131() + if not result then + result = f129() + f130() + end + return result + end + end + local f132 + do + local result + function f132() + if not result then + result = f130() + f131() + end + return result + end + end + local f133 + do + local result + function f133() + if not result then + result = f131() + f132() + end + return result + end + end + local f134 + do + local result + function f134() + if not result then + result = f132() + f133() + end + return result + end + end + local f135 + do + local result + function f135() + if not result then + result = f133() + f134() + end + return result + end + end + local f136 + do + local result + function f136() + if not result then + result = f134() + f135() + end + return result + end + end + local f137 + do + local result + function f137() + if not result then + result = f135() + f136() + end + return result + end + end + local f138 + do + local result + function f138() + if not result then + result = f136() + f137() + end + return result + end + end + local f139 + do + local result + function f139() + if not result then + result = f137() + f138() + end + return result + end + end + local f140 + do + local result + function f140() + if not result then + result = f138() + f139() + end + return result + end + end + local f141 + do + local result + function f141() + if not result then + result = f139() + f140() + end + return result + end + end + local f142 + do + local result + function f142() + if not result then + result = f140() + f141() + end + return result + end + end + local f143 + do + local result + function f143() + if not result then + result = f141() + f142() + end + return result + end + end + local f144 + do + local result + function f144() + if not result then + result = f142() + f143() + end + return result + end + end + local f145 + do + local result + function f145() + if not result then + result = f143() + f144() + end + return result + end + end + local f146 + do + local result + function f146() + if not result then + result = f144() + f145() + end + return result + end + end + local f147 + do + local result + function f147() + if not result then + result = f145() + f146() + end + return result + end + end + local f148 + do + local result + function f148() + if not result then + result = f146() + f147() + end + return result + end + end + local f149 + do + local result + function f149() + if not result then + result = f147() + f148() + end + return result + end + end + local f150 + do + local result + function f150() + if not result then + result = f148() + f149() + end + return result + end + end + local f151 + do + local result + function f151() + if not result then + result = f149() + f150() + end + return result + end + end + local f152 + do + local result + function f152() + if not result then + result = f150() + f151() + end + return result + end + end + local f153 + do + local result + function f153() + if not result then + result = f151() + f152() + end + return result + end + end + local f154 + do + local result + function f154() + if not result then + result = f152() + f153() + end + return result + end + end + local f155 + do + local result + function f155() + if not result then + result = f153() + f154() + end + return result + end + end + local f156 + do + local result + function f156() + if not result then + result = f154() + f155() + end + return result + end + end + local f157 + do + local result + function f157() + if not result then + result = f155() + f156() + end + return result + end + end + local f158 + do + local result + function f158() + if not result then + result = f156() + f157() + end + return result + end + end + local f159 + do + local result + function f159() + if not result then + result = f157() + f158() + end + return result + end + end + local f160 + do + local result + function f160() + if not result then + result = f158() + f159() + end + return result + end + end + local f161 + do + local result + function f161() + if not result then + result = f159() + f160() + end + return result + end + end + local f162 + do + local result + function f162() + if not result then + result = f160() + f161() + end + return result + end + end + local f163 + do + local result + function f163() + if not result then + result = f161() + f162() + end + return result + end + end + local f164 + do + local result + function f164() + if not result then + result = f162() + f163() + end + return result + end + end + local f165 + do + local result + function f165() + if not result then + result = f163() + f164() + end + return result + end + end + local f166 + do + local result + function f166() + if not result then + result = f164() + f165() + end + return result + end + end + local f167 + do + local result + function f167() + if not result then + result = f165() + f166() + end + return result + end + end + local f168 + do + local result + function f168() + if not result then + result = f166() + f167() + end + return result + end + end + local f169 + do + local result + function f169() + if not result then + result = f167() + f168() + end + return result + end + end + local f170 + do + local result + function f170() + if not result then + result = f168() + f169() + end + return result + end + end + local f171 + do + local result + function f171() + if not result then + result = f169() + f170() + end + return result + end + end + local f172 + do + local result + function f172() + if not result then + result = f170() + f171() + end + return result + end + end + local f173 + do + local result + function f173() + if not result then + result = f171() + f172() + end + return result + end + end + local f174 + do + local result + function f174() + if not result then + result = f172() + f173() + end + return result + end + end + local f175 + do + local result + function f175() + if not result then + result = f173() + f174() + end + return result + end + end + local f176 + do + local result + function f176() + if not result then + result = f174() + f175() + end + return result + end + end + local f177 + do + local result + function f177() + if not result then + result = f175() + f176() + end + return result + end + end + local f178 + do + local result + function f178() + if not result then + result = f176() + f177() + end + return result + end + end + local f179 + do + local result + function f179() + if not result then + result = f177() + f178() + end + return result + end + end + local f180 + do + local result + function f180() + if not result then + result = f178() + f179() + end + return result + end + end + local f181 + do + local result + function f181() + if not result then + result = f179() + f180() + end + return result + end + end + local f182 + do + local result + function f182() + if not result then + result = f180() + f181() + end + return result + end + end + local f183 + do + local result + function f183() + if not result then + result = f181() + f182() + end + return result + end + end + local f184 + do + local result + function f184() + if not result then + result = f182() + f183() + end + return result + end + end + local f185 + do + local result + function f185() + if not result then + result = f183() + f184() + end + return result + end + end + local f186 + do + local result + function f186() + if not result then + result = f184() + f185() + end + return result + end + end + local f187 + do + local result + function f187() + if not result then + result = f185() + f186() + end + return result + end + end + local f188 + do + local result + function f188() + if not result then + result = f186() + f187() + end + return result + end + end + local f189 + do + local result + function f189() + if not result then + result = f187() + f188() + end + return result + end + end + local f190 + do + local result + function f190() + if not result then + result = f188() + f189() + end + return result + end + end + local f191 + do + local result + function f191() + if not result then + result = f189() + f190() + end + return result + end + end + local f192 + do + local result + function f192() + if not result then + result = f190() + f191() + end + return result + end + end + local f193 + do + local result + function f193() + if not result then + result = f191() + f192() + end + return result + end + end + local f194 + do + local result + function f194() + if not result then + result = f192() + f193() + end + return result + end + end + local f195 + do + local result + function f195() + if not result then + result = f193() + f194() + end + return result + end + end + local f196 + do + local result + function f196() + if not result then + result = f194() + f195() + end + return result + end + end + local f197 + do + local result + function f197() + if not result then + result = f195() + f196() + end + return result + end + end + local f198 + do + local result + function f198() + if not result then + result = f196() + f197() + end + return result + end + end + local f199 + do + local result + function f199() + if not result then + result = f197() + f198() + end + return result + end + end + print("5th fibonacci number is", f5()) + print("10th fibonacci number is", f10()) + print("199th fibonacci number is", f199()) + +5th fibonacci number is 5 +10th fibonacci number is 55 +199th fibonacci number is 1.734025211728e+41 diff --git a/luaj-test/src/test/resources/compatibility/jse/mathlib.out b/luaj-test/src/test/resources/compatibility/jse/mathlib.out new file mode 100644 index 00000000..65b8f799 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/mathlib.out @@ -0,0 +1,842 @@ +---------- miscellaneous tests ---------- +math.sin( 0.0 ) true +math.cos( math.pi ) true -1 +math.sqrt( 9.0 ) true 3 +math.modf( 5.25 ) true 5 0.25 +math.frexp(0.00625) true 0.8 -7 +-5 ^ 2 true -25 +-5 / 2 true -2.5 +-5 % 2 true 1 +---------- constants ---------- +math.huge true +math.pi true 3.1415 +---------- unary operator - ---------- +--2.5 true +--2 true +-0 true +-2 true -2 +-2.5 true -2.5 +-'-2.5' true 2.5 +-'-2' true 2 +-'0' true +-'2' true -2 +-'2.5' true -2.5 +---------- unary operator not ---------- +not -2.5 true false +not -2 true false +not 0 true false +not 2 true false +not 2.5 true false +not '-2.5' true false +not '-2' true false +not '0' true false +not '2' true false +not '2.5' true false +---------- binary operator + ---------- +2+0 true 2 +-2.5+0 true -2.5 +2+1 true 3 +5+2 true 7 +-5+2 true -3 +16+2 true 18 +-16+-2 true -18 +0.5+0 true 0.5 +0.5+1 true 1.5 +0.5+2 true 2.5 +0.5+-1 true -0.5 +0.5+2 true 2.5 +2.25+0 true 2.25 +2.25+2 true 4.25 +-2+0 true -2 +3+3 true 6 +'2'+'0' true 2 +'2.5'+'3' true 5.5 +'-2'+'1.5' true -0.5 +'-2.5'+'-1.5' true -4 +'3.0'+'3.0' true 6 +2.75+2.75 true 5.5 +'2.75'+'2.75' true 5.5 +3+'3' true 6 +'3'+3 true 6 +2.75+'2.75' true 5.5 +'2.75'+2.75 true 5.5 +-3+'-4' true -7 +'-3'+4 true 1 +-3+'4' true 1 +'-3'+-4 true -7 +-4.75+'2.75' true -2 +'-2.75'+1.75 true -1 +4.75+'-2.75' true 2 +'2.75'+-1.75 true 1 +---------- binary operator - ---------- +2-0 true 2 +-2.5-0 true -2.5 +2-1 true 1 +5-2 true 3 +-5-2 true -7 +16-2 true 14 +-16--2 true -14 +0.5-0 true 0.5 +0.5-1 true -0.5 +0.5-2 true -1.5 +0.5--1 true 1.5 +0.5-2 true -1.5 +2.25-0 true 2.25 +2.25-2 true 0.25 +-2-0 true -2 +3-3 true +'2'-'0' true 2 +'2.5'-'3' true -0.5 +'-2'-'1.5' true -3.5 +'-2.5'-'-1.5' true -1 +'3.0'-'3.0' true +2.75-2.75 true +'2.75'-'2.75' true +3-'3' true +'3'-3 true +2.75-'2.75' true +'2.75'-2.75 true +-3-'-4' true 1 +'-3'-4 true -7 +-3-'4' true -7 +'-3'--4 true 1 +-4.75-'2.75' true -7.5 +'-2.75'-1.75 true -4.5 +4.75-'-2.75' true 7.5 +'2.75'--1.75 true 4.5 +---------- binary operator * ---------- +2*0 true +-2.5*0 true +2*1 true 2 +5*2 true 10 +-5*2 true -10 +16*2 true 32 +-16*-2 true 32 +0.5*0 true +0.5*1 true 0.5 +0.5*2 true 1 +0.5*-1 true -0.5 +0.5*2 true 1 +2.25*0 true +2.25*2 true 4.5 +-2*0 true +3*3 true 9 +'2'*'0' true +'2.5'*'3' true 7.5 +'-2'*'1.5' true -3 +'-2.5'*'-1.5' true 3.75 +'3.0'*'3.0' true 9 +2.75*2.75 true 7.5625 +'2.75'*'2.75' true 7.5625 +3*'3' true 9 +'3'*3 true 9 +2.75*'2.75' true 7.5625 +'2.75'*2.75 true 7.5625 +-3*'-4' true 12 +'-3'*4 true -12 +-3*'4' true -12 +'-3'*-4 true 12 +-4.75*'2.75' true -13.06 +'-2.75'*1.75 true -4.812 +4.75*'-2.75' true -13.06 +'2.75'*-1.75 true -4.812 +---------- binary operator ^ ---------- +2^0 true 1 +-2.5^0 true 1 +2^1 true 2 +5^2 true 25 +-5^2 true 25 +16^2 true 256 +-16^-2 true 0.0039 +0.5^0 true 1 +0.5^1 true 0.5 +0.5^2 true 0.25 +0.5^-1 true 2 +0.5^2 true 0.25 +2.25^0 true 1 +2.25^2 true 5.0625 +-2^0 true 1 +3^3 true 27 +'2'^'0' true 1 +'2.5'^'3' true 15.625 +'-2'^'1.5' true -nan +'-2.5'^'-1.5' true -nan +'3.0'^'3.0' true 27 +2.75^2.75 true 16.149 +'2.75'^'2.75' true 16.149 +3^'3' true 27 +'3'^3 true 27 +2.75^'2.75' true 16.149 +'2.75'^2.75 true 16.149 +-3^'-4' true 0.0123 +'-3'^4 true 81 +-3^'4' true 81 +'-3'^-4 true 0.0123 +-4.75^'2.75' true -nan +'-2.75'^1.75 true -nan +4.75^'-2.75' true 0.0137 +'2.75'^-1.75 true 0.1702 +---------- binary operator / ---------- +2/0 true +-2.5/0 true +2/1 true 2 +5/2 true 2.5 +-5/2 true -2.5 +16/2 true 8 +-16/-2 true 8 +0.5/0 true +0.5/1 true 0.5 +0.5/2 true 0.25 +0.5/-1 true -0.5 +0.5/2 true 0.25 +2.25/0 true +2.25/2 true 1.125 +-2/0 true +3/3 true 1 +'2'/'0' true +'2.5'/'3' true 0.8333 +'-2'/'1.5' true -1.333 +'-2.5'/'-1.5' true 1.6666 +'3.0'/'3.0' true 1 +2.75/2.75 true 1 +'2.75'/'2.75' true 1 +3/'3' true 1 +'3'/3 true 1 +2.75/'2.75' true 1 +'2.75'/2.75 true 1 +-3/'-4' true 0.75 +'-3'/4 true -0.75 +-3/'4' true -0.75 +'-3'/-4 true 0.75 +-4.75/'2.75' true -1.727 +'-2.75'/1.75 true -1.571 +4.75/'-2.75' true -1.727 +'2.75'/-1.75 true -1.571 +---------- binary operator % ---------- +2%0 true -nan +-2.5%0 true -nan +2%1 true +5%2 true 1 +-5%2 true 1 +16%2 true +-16%-2 true +0.5%0 true -nan +0.5%1 true 0.5 +0.5%2 true 0.5 +0.5%-1 true -0.5 +0.5%2 true 0.5 +2.25%0 true -nan +2.25%2 true 0.25 +-2%0 true -nan +3%3 true +'2'%'0' true -nan +'2.5'%'3' true 2.5 +'-2'%'1.5' true 1 +'-2.5'%'-1.5' true -1 +'3.0'%'3.0' true +2.75%2.75 true +'2.75'%'2.75' true +3%'3' true +'3'%3 true +2.75%'2.75' true +'2.75'%2.75 true +-3%'-4' true -3 +'-3'%4 true 1 +-3%'4' true 1 +'-3'%-4 true -3 +-4.75%'2.75' true 0.75 +'-2.75'%1.75 true 0.75 +4.75%'-2.75' true -0.75 +'2.75'%-1.75 true -0.75 +---------- binary operator == ---------- +2==0 true false +-2.5==0 true false +2==1 true false +5==2 true false +-5==2 true false +16==2 true false +-16==-2 true false +0.5==0 true false +0.5==1 true false +0.5==2 true false +0.5==-1 true false +0.5==2 true false +2.25==0 true false +2.25==2 true false +-2==0 true false +3==3 true true +'2'=='0' true false +'2.5'=='3' true false +'-2'=='1.5' true false +'-2.5'=='-1.5' true false +'3.0'=='3.0' true true +2.75==2.75 true true +'2.75'=='2.75' true true +---------- binary operator ~= ---------- +2~=0 true true +-2.5~=0 true true +2~=1 true true +5~=2 true true +-5~=2 true true +16~=2 true true +-16~=-2 true true +0.5~=0 true true +0.5~=1 true true +0.5~=2 true true +0.5~=-1 true true +0.5~=2 true true +2.25~=0 true true +2.25~=2 true true +-2~=0 true true +3~=3 true false +'2'~='0' true true +'2.5'~='3' true true +'-2'~='1.5' true true +'-2.5'~='-1.5' true true +'3.0'~='3.0' true false +2.75~=2.75 true false +'2.75'~='2.75' true false +---------- binary operator > ---------- +2>0 true true +-2.5>0 true false +2>1 true true +5>2 true true +-5>2 true false +16>2 true true +-16>-2 true false +0.5>0 true true +0.5>1 true false +0.5>2 true false +0.5>-1 true true +0.5>2 true false +2.25>0 true true +2.25>2 true true +-2>0 true false +3>3 true false +'2'>'0' true true +'2.5'>'3' true false +'-2'>'1.5' true false +'-2.5'>'-1.5' true true +'3.0'>'3.0' true false +2.75>2.75 true false +'2.75'>'2.75' true false +---------- binary operator < ---------- +2<0 true false +-2.5<0 true true +2<1 true false +5<2 true false +-5<2 true true +16<2 true false +-16<-2 true true +0.5<0 true false +0.5<1 true true +0.5<2 true true +0.5<-1 true false +0.5<2 true true +2.25<0 true false +2.25<2 true false +-2<0 true true +3<3 true false +'2'<'0' true false +'2.5'<'3' true true +'-2'<'1.5' true true +'-2.5'<'-1.5' true false +'3.0'<'3.0' true false +2.75<2.75 true false +'2.75'<'2.75' true false +---------- binary operator >= ---------- +2>=0 true true +-2.5>=0 true false +2>=1 true true +5>=2 true true +-5>=2 true false +16>=2 true true +-16>=-2 true false +0.5>=0 true true +0.5>=1 true false +0.5>=2 true false +0.5>=-1 true true +0.5>=2 true false +2.25>=0 true true +2.25>=2 true true +-2>=0 true false +3>=3 true true +'2'>='0' true true +'2.5'>='3' true false +'-2'>='1.5' true false +'-2.5'>='-1.5' true true +'3.0'>='3.0' true true +2.75>=2.75 true true +'2.75'>='2.75' true true +---------- binary operator <= ---------- +2<=0 true false +-2.5<=0 true true +2<=1 true false +5<=2 true false +-5<=2 true true +16<=2 true false +-16<=-2 true true +0.5<=0 true false +0.5<=1 true true +0.5<=2 true true +0.5<=-1 true false +0.5<=2 true true +2.25<=0 true false +2.25<=2 true false +-2<=0 true true +3<=3 true true +'2'<='0' true false +'2.5'<='3' true true +'-2'<='1.5' true true +'-2.5'<='-1.5' true false +'3.0'<='3.0' true true +2.75<=2.75 true true +'2.75'<='2.75' true true +---------- math.abs ---------- +math.abs(-2.5) true 2.5 +math.abs(-2) true 2 +math.abs(0) true +math.abs(2) true 2 +math.abs(2.5) true 2.5 +math.abs('-2.5') true 2.5 +math.abs('-2') true 2 +math.abs('0') true +math.abs('2') true 2 +math.abs('2.5') true 2.5 +---------- math.ceil ---------- +math.ceil(-2.5) true -2 +math.ceil(-2) true -2 +math.ceil(0) true +math.ceil(2) true 2 +math.ceil(2.5) true 3 +math.ceil('-2.5') true -2 +math.ceil('-2') true -2 +math.ceil('0') true +math.ceil('2') true 2 +math.ceil('2.5') true 3 +---------- math.cos ---------- +math.cos(-2.5) true -0.801 +math.cos(-2) true -0.416 +math.cos(0) true 1 +math.cos(2) true -0.416 +math.cos(2.5) true -0.801 +math.cos('-2.5') true -0.801 +math.cos('-2') true -0.416 +math.cos('0') true 1 +math.cos('2') true -0.416 +math.cos('2.5') true -0.801 +---------- math.deg ---------- +math.deg(-2.5) true -143.2 +math.deg(-2) true -114.5 +math.deg(0) true +math.deg(2) true 114.59 +math.deg(2.5) true 143.23 +math.deg('-2.5') true -143.2 +math.deg('-2') true -114.5 +math.deg('0') true +math.deg('2') true 114.59 +math.deg('2.5') true 143.23 +---------- math.exp ---------- +math.exp(-2.5) true 0.0820 +math.exp(-2) true 0.1353 +math.exp(0) true 1 +math.exp(2) true 7.3890 +math.exp(2.5) true 12.182 +math.exp('-2.5') true 0.0820 +math.exp('-2') true 0.1353 +math.exp('0') true 1 +math.exp('2') true 7.3890 +math.exp('2.5') true 12.182 +---------- math.floor ---------- +math.floor(-2.5) true -3 +math.floor(-2) true -2 +math.floor(0) true +math.floor(2) true 2 +math.floor(2.5) true 2 +math.floor('-2.5') true -3 +math.floor('-2') true -2 +math.floor('0') true +math.floor('2') true 2 +math.floor('2.5') true 2 +---------- math.frexp ---------- +math.frexp(-2.5) true -0.625 2 +math.frexp(-2) true -0.5 2 +math.frexp(0) true +math.frexp(2) true 0.5 2 +math.frexp(2.5) true 0.625 2 +math.frexp('-2.5') true -0.625 2 +math.frexp('-2') true -0.5 2 +math.frexp('0') true +math.frexp('2') true 0.5 2 +math.frexp('2.5') true 0.625 2 +---------- math.modf ---------- +math.modf(-2.5) true -2 -0.5 +math.modf(-2) true -2 +math.modf(0) true +math.modf(2) true 2 +math.modf(2.5) true 2 0.5 +math.modf('-2.5') true -2 -0.5 +math.modf('-2') true -2 +math.modf('0') true +math.modf('2') true 2 +math.modf('2.5') true 2 0.5 +---------- math.rad ---------- +math.rad(-2.5) true -0.043 +math.rad(-2) true -0.034 +math.rad(0) true +math.rad(2) true 0.0349 +math.rad(2.5) true 0.0436 +math.rad('-2.5') true -0.043 +math.rad('-2') true -0.034 +math.rad('0') true +math.rad('2') true 0.0349 +math.rad('2.5') true 0.0436 +---------- math.sin ---------- +math.sin(-2.5) true -0.598 +math.sin(-2) true -0.909 +math.sin(0) true +math.sin(2) true 0.9092 +math.sin(2.5) true 0.5984 +math.sin('-2.5') true -0.598 +math.sin('-2') true -0.909 +math.sin('0') true +math.sin('2') true 0.9092 +math.sin('2.5') true 0.5984 +---------- math.sqrt ---------- +math.sqrt(-2.5) true -nan +math.sqrt(-2) true -nan +math.sqrt(0) true +math.sqrt(2) true 1.4142 +math.sqrt(2.5) true 1.5811 +math.sqrt('-2.5') true -nan +math.sqrt('-2') true -nan +math.sqrt('0') true +math.sqrt('2') true 1.4142 +math.sqrt('2.5') true 1.5811 +---------- math.tan ---------- +math.tan(-2.5) true 0.7470 +math.tan(-2) true 2.1850 +math.tan(0) true +math.tan(2) true -2.185 +math.tan(2.5) true -0.747 +math.tan('-2.5') true 0.7470 +math.tan('-2') true 2.1850 +math.tan('0') true +math.tan('2') true -2.185 +math.tan('2.5') true -0.747 +---------- math.acos (jse only) ---------- +math.acos(-2.5) true +math.acos(-2) true +math.acos(0) true 1.5707 +math.acos(2) true +math.acos(2.5) true +math.acos('-2.5') true +math.acos('-2') true +math.acos('0') true 1.5707 +math.acos('2') true +math.acos('2.5') true +---------- math.asin (jse only) ---------- +math.asin(-2.5) true +math.asin(-2) true +math.asin(0) true +math.asin(2) true +math.asin(2.5) true +math.asin('-2.5') true +math.asin('-2') true +math.asin('0') true +math.asin('2') true +math.asin('2.5') true +---------- math.atan (jse only) ---------- +math.atan(-2.5) true -1.190 +math.atan(-2) true -1.107 +math.atan(0) true +math.atan(2) true 1.1071 +math.atan(2.5) true 1.1902 +math.atan('-2.5') true -1.190 +math.atan('-2') true -1.107 +math.atan('0') true +math.atan('2') true 1.1071 +math.atan('2.5') true 1.1902 +---------- math.cosh (jse only) ---------- +math.cosh(-2.5) true 6.1322 +math.cosh(-2) true 3.7621 +math.cosh(0) true 1 +math.cosh(2) true 3.7621 +math.cosh(2.5) true 6.1322 +math.cosh('-2.5') true 6.1322 +math.cosh('-2') true 3.7621 +math.cosh('0') true 1 +math.cosh('2') true 3.7621 +math.cosh('2.5') true 6.1322 +---------- math.log (jse only) ---------- +math.log(-2.5) true -nan +math.log(-2) true -nan +math.log(0) true +math.log(2) true 0.6931 +math.log(2.5) true 0.9162 +math.log('-2.5') true -nan +math.log('-2') true -nan +math.log('0') true +math.log('2') true 0.6931 +math.log('2.5') true 0.9162 +---------- math.sinh (jse only) ---------- +math.sinh(-2.5) true -6.050 +math.sinh(-2) true -3.626 +math.sinh(0) true +math.sinh(2) true 3.6268 +math.sinh(2.5) true 6.0502 +math.sinh('-2.5') true -6.050 +math.sinh('-2') true -3.626 +math.sinh('0') true +math.sinh('2') true 3.6268 +math.sinh('2.5') true 6.0502 +---------- math.tanh (jse only) ---------- +math.tanh(-2.5) true -0.986 +math.tanh(-2) true -0.964 +math.tanh(0) true +math.tanh(2) true 0.9640 +math.tanh(2.5) true 0.9866 +math.tanh('-2.5') true -0.986 +math.tanh('-2') true -0.964 +math.tanh('0') true +math.tanh('2') true 0.9640 +math.tanh('2.5') true 0.9866 +---------- math.fmod ---------- +math.fmod(2,0) true -nan +math.fmod(-2.5,0) true -nan +math.fmod(2,1) true +math.fmod(5,2) true 1 +math.fmod(-5,2) true -1 +math.fmod(16,2) true +math.fmod(-16,-2) true +math.fmod(0.5,0) true -nan +math.fmod(0.5,1) true 0.5 +math.fmod(0.5,2) true 0.5 +math.fmod(0.5,-1) true 0.5 +math.fmod(0.5,2) true 0.5 +math.fmod(2.25,0) true -nan +math.fmod(2.25,2) true 0.25 +math.fmod(-2,0) true -nan +math.fmod(3,3) true +math.fmod('2','0') true -nan +math.fmod('2.5','3') true 2.5 +math.fmod('-2','1.5') true -0.5 +math.fmod('-2.5','-1.5') true -1 +math.fmod('3.0','3.0') true +math.fmod(2.75,2.75) true +math.fmod('2.75','2.75') true +math.fmod(3,'3') true +math.fmod('3',3) true +math.fmod(2.75,'2.75') true +math.fmod('2.75',2.75) true +math.fmod(-3,'-4') true -3 +math.fmod('-3',4) true -3 +math.fmod(-3,'4') true -3 +math.fmod('-3',-4) true -3 +math.fmod(-4.75,'2.75') true -2 +math.fmod('-2.75',1.75) true -1 +math.fmod(4.75,'-2.75') true 2 +math.fmod('2.75',-1.75) true 1 +---------- math.ldexp ---------- +math.ldexp(2,0) true 2 +math.ldexp(-2.5,0) true -2.5 +math.ldexp(2,1) true 4 +math.ldexp(5,2) true 20 +math.ldexp(-5,2) true -20 +math.ldexp(16,2) true 64 +math.ldexp(-16,-2) true -4 +math.ldexp(0.5,0) true 0.5 +math.ldexp(0.5,1) true 1 +math.ldexp(0.5,2) true 2 +math.ldexp(0.5,-1) true 0.25 +math.ldexp(0.5,2) true 2 +math.ldexp(2.25,0) true 2.25 +math.ldexp(2.25,2) true 9 +math.ldexp(-2,0) true -2 +math.ldexp(3,3) true 24 +math.ldexp('2','0') true 2 +math.ldexp('2.5','3') true 20 +math.ldexp('-2','1.5') true -4 +math.ldexp('-2.5','-1.5') true -1.25 +math.ldexp('3.0','3.0') true 24 +math.ldexp(2.75,2.75) true 11 +math.ldexp('2.75','2.75') true 11 +math.ldexp(3,'3') true 24 +math.ldexp('3',3) true 24 +math.ldexp(2.75,'2.75') true 11 +math.ldexp('2.75',2.75) true 11 +math.ldexp(-3,'-4') true -0.187 +math.ldexp('-3',4) true -48 +math.ldexp(-3,'4') true -48 +math.ldexp('-3',-4) true -0.187 +math.ldexp(-4.75,'2.75') true -19 +math.ldexp('-2.75',1.75) true -5.5 +math.ldexp(4.75,'-2.75') true 1.1875 +math.ldexp('2.75',-1.75) true 1.375 +---------- math.pow ---------- +math.pow(2,0) true 1 +math.pow(-2.5,0) true 1 +math.pow(2,1) true 2 +math.pow(5,2) true 25 +math.pow(-5,2) true 25 +math.pow(16,2) true 256 +math.pow(-16,-2) true 0.0039 +math.pow(0.5,0) true 1 +math.pow(0.5,1) true 0.5 +math.pow(0.5,2) true 0.25 +math.pow(0.5,-1) true 2 +math.pow(0.5,2) true 0.25 +math.pow(2.25,0) true 1 +math.pow(2.25,2) true 5.0625 +math.pow(-2,0) true 1 +math.pow(3,3) true 27 +math.pow('2','0') true 1 +math.pow('2.5','3') true 15.625 +math.pow('-2','1.5') true -nan +math.pow('-2.5','-1.5') true -nan +math.pow('3.0','3.0') true 27 +math.pow(2.75,2.75) true 16.149 +math.pow('2.75','2.75') true 16.149 +math.pow(3,'3') true 27 +math.pow('3',3) true 27 +math.pow(2.75,'2.75') true 16.149 +math.pow('2.75',2.75) true 16.149 +math.pow(-3,'-4') true 0.0123 +math.pow('-3',4) true 81 +math.pow(-3,'4') true 81 +math.pow('-3',-4) true 0.0123 +math.pow(-4.75,'2.75') true -nan +math.pow('-2.75',1.75) true -nan +math.pow(4.75,'-2.75') true 0.0137 +math.pow('2.75',-1.75) true 0.1702 +---------- math.atan2 (jse only) ---------- +math.atan2(2,0) true 1.5707 +math.atan2(-2.5,0) true -1.570 +math.atan2(2,1) true 1.1071 +math.atan2(5,2) true 1.1902 +math.atan2(-5,2) true -1.190 +math.atan2(16,2) true 1.4464 +math.atan2(-16,-2) true -1.695 +math.atan2(0.5,0) true 1.5707 +math.atan2(0.5,1) true 0.4636 +math.atan2(0.5,2) true 0.2449 +math.atan2(0.5,-1) true 2.6779 +math.atan2(0.5,2) true 0.2449 +math.atan2(2.25,0) true 1.5707 +math.atan2(2.25,2) true 0.8441 +math.atan2(-2,0) true -1.570 +math.atan2(3,3) true 0.7853 +math.atan2('2','0') true 1.5707 +math.atan2('2.5','3') true 0.6947 +math.atan2('-2','1.5') true -0.927 +math.atan2('-2.5','-1.5') true -2.111 +math.atan2('3.0','3.0') true 0.7853 +math.atan2(2.75,2.75) true 0.7853 +math.atan2('2.75','2.75') true 0.7853 +math.atan2(3,'3') true 0.7853 +math.atan2('3',3) true 0.7853 +math.atan2(2.75,'2.75') true 0.7853 +math.atan2('2.75',2.75) true 0.7853 +math.atan2(-3,'-4') true -2.498 +math.atan2('-3',4) true -0.643 +math.atan2(-3,'4') true -0.643 +math.atan2('-3',-4) true -2.498 +math.atan2(-4.75,'2.75') true -1.046 +math.atan2('-2.75',1.75) true -1.004 +math.atan2(4.75,'-2.75') true 2.0955 +math.atan2('2.75',-1.75) true 2.1375 +---------- math.max ---------- +math.max(4) true 4 +math.max(-4.5) true -4.5 +math.max('5.5') true 5.5 +math.max('-5') true -5 +math.max(4,'8') true 8 +math.max(-4.5,'-8') true -4.5 +math.max('5.5',2.2) true 5.5 +math.max('-5',-2.2) true -2.2 +math.max(111,222,333) true 333 +math.max(-222,-333,-111) true -111 +math.max(444,-111,-222) true 444 +---------- math.min ---------- +math.min(4) true 4 +math.min(-4.5) true -4.5 +math.min('5.5') true 5.5 +math.min('-5') true -5 +math.min(4,'8') true 4 +math.min(-4.5,'-8') true -8 +math.min('5.5',2.2) true 2.2 +math.min('-5',-2.2) true -5 +math.min(111,222,333) true 111 +math.min(-222,-333,-111) true -333 +math.min(444,-111,-222) true -222 +----------- Random number tests +math.random() number true +math.random() number true +math.random() number true +math.random() number true +math.random() number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(5,10) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(30) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true +math.random(-4,-2) number true + +-- comparing new numbers +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +false false +-- resetting seed + +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +----------- Tests involving -0 and NaN +0 == -0 true +t[-0] == t[0] true +mz, z +mz == z true +a[z] == 1 and a[mz] == 1 true diff --git a/luaj-test/src/test/resources/compatibility/jse/metatags.out b/luaj-test/src/test/resources/compatibility/jse/metatags.out new file mode 100644 index 00000000..694cb7eb --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/metatags.out @@ -0,0 +1,649 @@ +---- __eq same types +nil nil before true true +nil nil before true false +nil +nil +nil nil after true true +nil nil after true false +nil +nil +boolean boolean before true false +boolean boolean before true true +true +false +boolean boolean after true false +boolean boolean after true true +true +false +number number before true false +number number before true true +123 +456 +number number after true false +number number after true true +123 +456 +number number before true false +number number before true true +11 +5.5 +number number after true false +number number after true true +11 +5.5 +function function before true false +function function before true true +function.1 +function.2 +function function after true false +function function after true true +function.1 +function.2 +thread nil before true false +thread nil before true true +thread.3 +nil +thread nil after true false +thread nil after true true +thread.3 +nil +string string before true false +string string before true true +abc +def +string string after true false +string string after true true +abc +def +number string before true false +number string before true true +111 +111 +number string after true false +number string after true true +111 +111 +---- __eq, tables - should invoke metatag comparison +table table before true false +table table before true true +table.4 +table.5 +mt.__eq() table.4 table.5 +table table after-a true true +mt.__eq() table.4 table.5 +table table after-a true false +table.4 +table.5 +nilmt nil +boolmt nil +number nil +function nil +thread nil +---- __call +number before false attempt to call +111 +mt.__call() 111 nil +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +111 +boolean before false attempt to call +false +mt.__call() false nil +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +false +function before true nil +function.1 +function after true +function after true +function after true +function after true +function after true +function.1 +thread before false attempt to call +thread.3 +mt.__call() thread.3 nil +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +thread.3 +table before false attempt to call +table.4 +mt.__call() table.4 nil +table after true __call-result +mt.__call() table.4 a +table after true __call-result +mt.__call() table.4 a +table after true __call-result +mt.__call() table.4 a +table after true __call-result +mt.__call() table.4 a +table after true __call-result +table.4 +---- __add, __sub, __mul, __div, __pow, __mod +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +false +mt.__add() false false +boolean boolean after true __add-result +mt.__add() false false +boolean boolean after true __add-result +mt.__sub() false false +boolean boolean after true __sub-result +mt.__sub() false false +boolean boolean after true __sub-result +mt.__mul() false false +boolean boolean after true __mul-result +mt.__mul() false false +boolean boolean after true __mul-result +mt.__pow() false false +boolean boolean after true __pow-result +mt.__pow() false false +boolean boolean after true __pow-result +mt.__mod() false false +boolean boolean after true __mod-result +mt.__mod() false false +boolean boolean after true __mod-result +false +false +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +false +mt.__add() false thread.3 +boolean thread after true __add-result +mt.__add() thread.3 false +boolean thread after true __add-result +mt.__sub() false thread.3 +boolean thread after true __sub-result +mt.__sub() thread.3 false +boolean thread after true __sub-result +mt.__mul() false thread.3 +boolean thread after true __mul-result +mt.__mul() thread.3 false +boolean thread after true __mul-result +mt.__pow() false thread.3 +boolean thread after true __pow-result +mt.__pow() thread.3 false +boolean thread after true __pow-result +mt.__mod() false thread.3 +boolean thread after true __mod-result +mt.__mod() thread.3 false +boolean thread after true __mod-result +false +thread.3 +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +false +mt.__add() false function.1 +boolean function after true __add-result +mt.__add() function.1 false +boolean function after true __add-result +mt.__sub() false function.1 +boolean function after true __sub-result +mt.__sub() function.1 false +boolean function after true __sub-result +mt.__mul() false function.1 +boolean function after true __mul-result +mt.__mul() function.1 false +boolean function after true __mul-result +mt.__pow() false function.1 +boolean function after true __pow-result +mt.__pow() function.1 false +boolean function after true __pow-result +mt.__mod() false function.1 +boolean function after true __mod-result +mt.__mod() function.1 false +boolean function after true __mod-result +false +function.1 +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +false +mt.__add() false abc +boolean string after true __add-result +mt.__add() abc false +boolean string after true __add-result +mt.__sub() false abc +boolean string after true __sub-result +mt.__sub() abc false +boolean string after true __sub-result +mt.__mul() false abc +boolean string after true __mul-result +mt.__mul() abc false +boolean string after true __mul-result +mt.__pow() false abc +boolean string after true __pow-result +mt.__pow() abc false +boolean string after true __pow-result +mt.__mod() false abc +boolean string after true __mod-result +mt.__mod() abc false +boolean string after true __mod-result +false +abc +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +false +mt.__add() false table.4 +boolean table after true __add-result +mt.__add() table.4 false +boolean table after true __add-result +mt.__sub() false table.4 +boolean table after true __sub-result +mt.__sub() table.4 false +boolean table after true __sub-result +mt.__mul() false table.4 +boolean table after true __mul-result +mt.__mul() table.4 false +boolean table after true __mul-result +mt.__pow() false table.4 +boolean table after true __pow-result +mt.__pow() table.4 false +boolean table after true __pow-result +mt.__mod() false table.4 +boolean table after true __mod-result +mt.__mod() table.4 false +boolean table after true __mod-result +false +table.4 +---- __len +boolean before false attempt to get length of +false +mt.__len() false +boolean after true __len-result +false +function before false attempt to get length of +function.1 +mt.__len() function.1 +function after true __len-result +function.1 +thread before false attempt to get length of +thread.3 +mt.__len() thread.3 +thread after true __len-result +thread.3 +number before false attempt to get length of +111 +mt.__len() 111 +number after true __len-result +111 +---- __neg +nil before false attempt to perform arithmetic +false +mt.__unm() false +nil after true __unm-result +false +nil before false attempt to perform arithmetic +function.1 +mt.__unm() function.1 +nil after true __unm-result +function.1 +nil before false attempt to perform arithmetic +thread.3 +mt.__unm() thread.3 +nil after true __unm-result +thread.3 +nil before false attempt to perform arithmetic +abcd +mt.__unm() abcd +nil after true __unm-result +abcd +nil before false attempt to perform arithmetic +table.4 +mt.__unm() table.4 +nil after true __unm-result +table.4 +nil before true -111 +111 +nil after true -111 +111 +---- __lt, __le, same types +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +true +true +mt.__lt() true true +boolean boolean after true true +mt.__le() true true +boolean boolean after true true +mt.__lt() true true +boolean boolean after true true +mt.__le() true true +boolean boolean after true true +true +true +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +true +false +mt.__lt() true false +boolean boolean after true true +mt.__le() true false +boolean boolean after true true +mt.__lt() false true +boolean boolean after true true +mt.__le() false true +boolean boolean after true true +true +false +function function before false attempt to compare +function function before false attempt to compare +function function before false attempt to compare +function function before false attempt to compare +function.1 +function.6 +mt.__lt() function.1 function.6 +function function after true true +mt.__le() function.1 function.6 +function function after true true +mt.__lt() function.6 function.1 +function function after true true +mt.__le() function.6 function.1 +function function after true true +function.1 +function.6 +thread thread before false attempt to compare +thread thread before false attempt to compare +thread thread before false attempt to compare +thread thread before false attempt to compare +thread.3 +thread.7 +mt.__lt() thread.3 thread.7 +thread thread after true true +mt.__le() thread.3 thread.7 +thread thread after true true +mt.__lt() thread.7 thread.3 +thread thread after true true +mt.__le() thread.7 thread.3 +thread thread after true true +thread.3 +thread.7 +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table.4 +table.4 +mt.__lt() table.4 table.4 +table table after true true +mt.__le() table.4 table.4 +table table after true true +mt.__lt() table.4 table.4 +table table after true true +mt.__le() table.4 table.4 +table table after true true +table.4 +table.4 +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table.4 +table.8 +mt.__lt() table.4 table.8 +table table after true true +mt.__le() table.4 table.8 +table table after true true +mt.__lt() table.8 table.4 +table table after true true +mt.__le() table.8 table.4 +table table after true true +table.4 +table.8 +---- __lt, __le, different types +boolean thread before false attempt to compare +boolean thread before false attempt to compare +boolean thread before false attempt to compare +boolean thread before false attempt to compare +false +thread.3 +mt.__lt() false thread.3 +boolean thread after-a true true +mt.__le() false thread.3 +boolean thread after-a true true +mt.__lt() thread.3 false +boolean thread after-a true true +mt.__le() thread.3 false +boolean thread after-a true true +false +thread.3 +---- __tostring +mt.__tostring(boolean) +boolean after mt.__tostring(boolean) mt.__tostring(boolean) +false +function.1 +function after true mt.__tostring(function) +function.1 +thread.3 +thread after true mt.__tostring(thread) +thread.3 +table.4 +table after true mt.__tostring(table) +table.4 +mt.__tostring(string) +mt.__tostring(string) mt.__tostring(string) true mt.__tostring(string) +abc +---- __index, __newindex +boolean before false attempt to index +boolean before false attempt to index +boolean before false index +boolean before false index +boolean before false attempt to index +false +mt.__index() false foo +boolean after true __index-result +mt.__index() false 123 +boolean after true __index-result +mt.__newindex() false foo bar +boolean after true +mt.__newindex() false 123 bar +boolean after true +mt.__index() false foo +boolean after false attempt to call +false +number before false attempt to index +number before false attempt to index +number before false index +number before false index +number before false attempt to index +111 +mt.__index() 111 foo +number after true __index-result +mt.__index() 111 123 +number after true __index-result +mt.__newindex() 111 foo bar +number after true +mt.__newindex() 111 123 bar +number after true +mt.__index() 111 foo +number after false attempt to call +111 +function before false attempt to index +function before false attempt to index +function before false index +function before false index +function before false attempt to index +function.1 +mt.__index() function.1 foo +function after true __index-result +mt.__index() function.1 123 +function after true __index-result +mt.__newindex() function.1 foo bar +function after true +mt.__newindex() function.1 123 bar +function after true +mt.__index() function.1 foo +function after false attempt to call +function.1 +thread before false attempt to index +thread before false attempt to index +thread before false index +thread before false index +thread before false attempt to index +thread.3 +mt.__index() thread.3 foo +thread after true __index-result +mt.__index() thread.3 123 +thread after true __index-result +mt.__newindex() thread.3 foo bar +thread after true +mt.__newindex() thread.3 123 bar +thread after true +mt.__index() thread.3 foo +thread after false attempt to call +thread.3 +---- __concat +table function before false attempt to concatenate +table function before false attempt to concatenate +table string number before false attempt to concatenate +string table number before false attempt to concatenate +string number table before false attempt to concatenate +table.4 +mt.__concat(table,function) table.4 function.1 +table function after true table.9 +mt.__concat(function,table) function.1 table.4 +table function after true table.9 +mt.__concat(table,string) table.4 sss777 +table string number before true table.9 +mt.__concat(table,number) table.4 777 +string table number before false attempt to concatenate +mt.__concat(number,table) 777 table.4 +string number table before false attempt to concatenate +table.4 +function.1 +function table before false attempt to concatenate +function table before false attempt to concatenate +function string number before false attempt to concatenate +string function number before false attempt to concatenate +string number function before false attempt to concatenate +function.1 +mt.__concat(function,table) function.1 table.4 +function table after true table.9 +mt.__concat(table,function) table.4 function.1 +function table after true table.9 +mt.__concat(function,string) function.1 sss777 +function string number before true table.9 +mt.__concat(function,number) function.1 777 +string function number before false attempt to concatenate +mt.__concat(number,function) 777 function.1 +string number function before false attempt to concatenate +function.1 +table.4 +number nil before false attempt to concatenate +number nil before false attempt to concatenate +number string number before true 123sss777 +string number number before true sss123777 +string number number before true sss777123 +123 +mt.__concat(number,nil) 123 nil +number nil after true table.9 +mt.__concat(nil,number) nil 123 +number nil after true table.9 +number string number before true 123sss777 +string number number before true sss123777 +string number number before true sss777123 +123 +nil +nil number before false attempt to concatenate +nil number before false attempt to concatenate +nil string number before false attempt to concatenate +string nil number before false attempt to concatenate +string number nil before false attempt to concatenate +nil +mt.__concat(nil,number) nil 123 +nil number after true table.9 +mt.__concat(number,nil) 123 nil +nil number after true table.9 +mt.__concat(nil,string) nil sss777 +nil string number before true table.9 +mt.__concat(nil,number) nil 777 +string nil number before false attempt to concatenate +mt.__concat(number,nil) 777 nil +string number nil before false attempt to concatenate +nil +123 +---- __metatable +boolean before true nil nil +false +boolean after true table.10 table.11 +false +function before true nil nil +function.1 +function after true table.10 table.11 +function.1 +thread before true nil nil +thread.3 +thread after true table.10 table.11 +thread.3 +table before true nil nil +table.4 +table after true table.10 table.11 +table.4 +string before true table.12 table.12 +abc +string after true table.10 table.11 +abc diff --git a/luaj-test/src/test/resources/compatibility/jse/oslib.out b/luaj-test/src/test/resources/compatibility/jse/oslib.out new file mode 100644 index 00000000..38f1af9c --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/oslib.out @@ -0,0 +1,64 @@ +os table +os.clock() true number nil +os.date() true string nil +os.difftime(123000, 21500) true number nil +os.getenv() false string nil +os.getenv("bogus.key") true nil nil +os.tmpname() true string +os.tmpname() true string +io.open true userdata +write false string nil +close false string nil +os.rename(p,q) true boolean nil +os.remove(q) true boolean nil +os.remove(q) true nil string +os.setlocale("C") true string nil +os.exit function +os.date('%a', 1281364496) true string nil +os.date('%A', 1281364496) true string nil +os.date('%b', 1281364496) true string nil +os.date('%B', 1281364496) true string nil +os.date('%c', 1281364496) true string nil +os.date('%C', 1281364496) true string nil +os.date('%d', 1281364496) true string nil +os.date('%D', 1281364496) true string nil +os.date('%e', 1281364496) true string nil +os.date('%F', 1281364496) true string nil +os.date('%g', 1281364496) true string nil +os.date('%G', 1281364496) true string nil +os.date('%h', 1281364496) true string nil +os.date('%H', 1281364496) true string nil +os.date('%I', 1281364496) true string nil +os.date('%j', 1281364496) true string nil +os.date('%m', 1281364496) true string nil +os.date('%M', 1281364496) true string nil +os.date('%n', 1281364496) true string nil +os.date('%p', 1281364496) true string nil +os.date('%r', 1281364496) true string nil +os.date('%R', 1281364496) true string nil +os.date('%S', 1281364496) true string nil +os.date('%t', 1281364496) true string nil +os.date('%T', 1281364496) true string nil +os.date('%u', 1281364496) true string nil +os.date('%U', 1281364496) true string nil +os.date('%V', 1281364496) true string nil +os.date('%w', 1281364496) true string nil +os.date('%W', 1281364496) true string nil +os.date('%x', 1281364496) true string nil +os.date('%X', 1281364496) true string nil +os.date('%y', 1281364496) true string nil +os.date('%Y', 1281364496) true string nil +os.date('%z', 1281364496) true string nil +os.date('%Z', 1281364496) true string nil +k string year v number 2010 +k string month v number 8 +k string day v number 9 +k string hour v number 16 +k string min v number 34 +k string sec v number 56 +k string wday v number 2 +k string yday v number 221 +k string isdst v boolean true +type(os.time()) number +os.time({year=1971, month=2, day=25}) 36327600 +os.time({year=1971, month=2, day=25, hour=11, min=22, sec=33}) 36325353 diff --git a/luaj-test/src/test/resources/compatibility/jse/stringlib.out b/luaj-test/src/test/resources/compatibility/jse/stringlib.out new file mode 100644 index 00000000..7ebe326d Binary files /dev/null and b/luaj-test/src/test/resources/compatibility/jse/stringlib.out differ diff --git a/luaj-test/src/test/resources/compatibility/jse/tablelib.out b/luaj-test/src/test/resources/compatibility/jse/tablelib.out new file mode 100644 index 00000000..83c8b8a9 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/tablelib.out @@ -0,0 +1,237 @@ +2 +-- concat tests +onetwothree +one--two--three +two,three +two + +onetwothreefourfive +one--two--three--four--five +two,three,four,five +two + + + + + + + + + + +-- insert, len tests +{[1]=one,[2]=two,[3]=three,[a]=aaa,[b]=bbb,[c]=ccc} 3 +{[1]=one,[2]=two,[3]=three,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +{[1]=seven,[2]=one,[3]=two,[4]=three,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 +{[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[a]=aaa,[b]=bbb,[c]=ccc} 6 +{[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[7]=nine,[a]=aaa,[b]=bbb,[c]=ccc} 7 +#{} 0 +#{"a"} 1 +#{"a","b"} 2 +#{"a",nil} 1 +#{nil,nil} 0 +#{nil,"b"} true +#{"a","b","c"} 3 +#{"a","b",nil} 2 +#{"a",nil,nil} 1 +#{nil,nil,nil} 0 +#{nil,nil,"c"} true +#{nil,"b","c"} true +#{nil,"b",nil} true +#{"a",nil,"c"} true +-- remove tests +{[10]=ten,[1]=one,[2]=two,[3]=three,[4]=four,[5]=five,[6]=six,[7]=seven,[a]=aaa,[b]=bbb,[c]=ccc} 7 +table.remove(t) seven +{[10]=ten,[1]=one,[2]=two,[3]=three,[4]=four,[5]=five,[6]=six,[a]=aaa,[b]=bbb,[c]=ccc} 6 +table.remove(t,1) one +{[10]=ten,[1]=two,[2]=three,[3]=four,[4]=five,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 +table.remove(t,3) four +{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +table.remove(t,5) nil +{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +-- sort tests +one-two-three +one-three-two +www-vvv-uuu-ttt-sss-zzz-yyy-xxx +sss-ttt-uuu-vvv-www-xxx-yyy-zzz +www-vvv-uuu-ttt-sss-zzz-yyy-xxx +zzz-yyy-xxx-www-vvv-uuu-ttt-sss +----- unpack tests ------- +pcall(unpack) false +pcall(unpack,nil) false +pcall(unpack,"abc") false +pcall(unpack,1) false +unpack({"aa"}) aa +unpack({"aa","bb"}) aa bb +unpack({"aa","bb","cc"}) aa bb cc +unpack - +unpack a a +unpack . nil +unpack ab a b +unpack .b nil b +unpack a. a nil +unpack abc a b c +unpack .ab nil a b +unpack a.b a nil b +unpack ab. a b nil +unpack ..b nil nil b +unpack a.. a nil nil +unpack .b. nil b nil +unpack ... nil nil nil +unpack (-) +unpack (a) a +unpack (.) nil +unpack (ab) a b +unpack (.b) nil b +unpack (a.) a nil +unpack (abc) a b c +unpack (.ab) nil a b +unpack (a.b) a nil b +unpack (ab.) a b nil +unpack (..b) nil nil b +unpack (a..) a nil nil +unpack (.b.) nil b nil +unpack (...) nil nil nil +pcall(unpack,t) true aa bb cc dd ee ff +pcall(unpack,t,2) true bb cc dd ee ff +pcall(unpack,t,2,5) true bb cc dd ee +pcall(unpack,t,2,6) true bb cc dd ee ff +pcall(unpack,t,2,7) true bb cc dd ee ff nil +pcall(unpack,t,1) true aa bb cc dd ee ff +pcall(unpack,t,1,5) true aa bb cc dd ee +pcall(unpack,t,1,6) true aa bb cc dd ee ff +pcall(unpack,t,1,7) true aa bb cc dd ee ff nil +pcall(unpack,t,0) true nil aa bb cc dd ee ff +pcall(unpack,t,0,5) true nil aa bb cc dd ee +pcall(unpack,t,0,6) true nil aa bb cc dd ee ff +pcall(unpack,t,0,7) true nil aa bb cc dd ee ff nil +pcall(unpack,t,-1) true nil nil aa bb cc dd ee ff +pcall(unpack,t,-1,5) true nil nil aa bb cc dd ee +pcall(unpack,t,-1,6) true nil nil aa bb cc dd ee ff +pcall(unpack,t,-1,7) true nil nil aa bb cc dd ee ff nil +pcall(unpack,t,2,4) true bb cc dd +pcall(unpack,t,2,5) true bb cc dd ee +pcall(unpack,t,2,6) true bb cc dd ee ff +pcall(unpack,t,2,7) true bb cc dd ee ff nil +pcall(unpack,t,2,8) true bb cc dd ee ff nil nil +pcall(unpack,t,2,2) true +pcall(unpack,t,2,1) true +pcall(unpack,t,2,0) true +pcall(unpack,t,2,-1) true +pcall(unpack,t,0) true zz aa bb cc dd ee ff +pcall(unpack,t,2,0) true +pcall(unpack,t,2,-1) true +pcall(unpack,t,"3") true cc dd ee ff +pcall(unpack,t,"a") false +pcall(unpack,t,function() end) false +----- misc table initializer tests ------- +3 +4 +4 +----- basic table operations ------- +------ basic table tests on basic table table +t[1]=2 true +t[1] true 2 +t[1]=nil true +t[1] true nil +t["a"]="b" true +t["a"],t.a true b b +t.a="c" true +t["a"],t.a true c c +t.a=nil true +t["a"],t.a true nil nil +t[nil]="d" false string +t[nil] true nil +t[nil]=nil false string +t[nil] true nil +------ basic table tests on function metatable on __index table +t[1]=2 true +t[1] true 2 +t[1]=nil true +metatable call args table 1 +t[1] true dummy +t["a"]="b" true +t["a"],t.a true b b +t.a="c" true +t["a"],t.a true c c +t.a=nil true +metatable call args table a +metatable call args table a +t["a"],t.a true dummy dummy +t[nil]="d" false string +metatable call args table nil +t[nil] true dummy +t[nil]=nil false string +metatable call args table nil +t[nil] true dummy +------ basic table tests on function metatable on __newindex table +metatable call args table 1 2 +t[1]=2 true +t[1] true nil +metatable call args table 1 nil +t[1]=nil true +t[1] true nil +metatable call args table a b +t["a"]="b" true +t["a"],t.a true nil nil +metatable call args table a c +t.a="c" true +t["a"],t.a true nil nil +metatable call args table a nil +t.a=nil true +t["a"],t.a true nil nil +metatable call args table nil d +t[nil]="d" true nil +t[nil] true nil +metatable call args table nil nil +t[nil]=nil true nil +t[nil] true nil +------ basic table tests on plain metatable on __index table +t[1]=2 true +t[1] true 2 +t[1]=nil true +t[1] true nil +t["a"]="b" true +t["a"],t.a true b b +t.a="c" true +t["a"],t.a true c c +t.a=nil true +t["a"],t.a true nil nil +t[nil]="d" false string +t[nil] true nil +t[nil]=nil false string +t[nil] true nil +------ basic table tests on plain metatable on __newindex table +t[1]=2 true +t[1] true 2 +t[1]=nil true +t[1] true nil +t["a"]="b" true +t["a"],t.a true b b +t.a="c" true +t["a"],t.a true c c +t.a=nil true +t["a"],t.a true nil nil +t[nil]="d" false string +t[nil] true nil +t[nil]=nil false string +t[nil] true nil +-- sort tests +default (lexical) comparator +2-4-6-8-1-3-5-7 +1-2-3-4-5-6-7-8 +333-222-111 +111-222-333 +www-xxx-yyy-aaa-bbb-ccc +aaa-bbb-ccc-www-xxx-yyy +21-23-25-27-22-24-26-28 +sort failed +custom (numerical) comparator +2-4-6-8-1-3-5-7 +1-2-3-4-5-6-7-8 +333-222-111 +111-222-333 +www-xxx-yyy-aaa-bbb-ccc +sort failed +21-23-25-27-22-24-26-28 +21-22-23-24-25-26-27-28 diff --git a/luaj-test/src/test/resources/compatibility/jse/tailcalls.out b/luaj-test/src/test/resources/compatibility/jse/tailcalls.out new file mode 100644 index 00000000..3f30692c --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/tailcalls.out @@ -0,0 +1,211 @@ +true true +b +true true +true true c +--f, n, table.unpack(t) func.1 0 +true 0 0 0 +--f, n, table.unpack(t) func.1 0 1 +true 1 1 1 +--f, n, table.unpack(t) func.1 0 1 2 +true 1 3 3 +--f, n, table.unpack(t) func.1 0 1 2 3 +true 1 3 6 +--f, n, table.unpack(t) func.1 0 1 2 3 4 +true 1 3 6 +--f, n, table.unpack(t) func.1 1 +true 0 0 0 +--f, n, table.unpack(t) func.1 1 1 +true 1 2 3 +--f, n, table.unpack(t) func.1 1 1 2 +true 1 4 7 +--f, n, table.unpack(t) func.1 1 1 2 3 +true 1 4 10 +--f, n, table.unpack(t) func.1 1 1 2 3 4 +true 1 4 10 +--f, n, table.unpack(t) func.1 2 +true 0 0 0 +--f, n, table.unpack(t) func.1 2 1 +true 1 3 6 +--f, n, table.unpack(t) func.1 2 1 2 +true 1 5 12 +--f, n, table.unpack(t) func.1 2 1 2 3 +true 1 5 15 +--f, n, table.unpack(t) func.1 2 1 2 3 4 +true 1 5 15 +--f, n, table.unpack(t) func.1 3 +true 0 0 0 +--f, n, table.unpack(t) func.1 3 1 +true 1 4 10 +--f, n, table.unpack(t) func.1 3 1 2 +true 1 6 18 +--f, n, table.unpack(t) func.1 3 1 2 3 +true 1 6 21 +--f, n, table.unpack(t) func.1 3 1 2 3 4 +true 1 6 21 +--f, n, table.unpack(t) func.2 0 + --f2, n<=0, returning sum(...) +true 0 +--f, n, table.unpack(t) func.2 0 1 + --f2, n<=0, returning sum(...) 1 +true 1 +--f, n, table.unpack(t) func.2 0 1 2 + --f2, n<=0, returning sum(...) 1 2 +true 3 +--f, n, table.unpack(t) func.2 0 1 2 3 + --f2, n<=0, returning sum(...) 1 2 3 +true 6 +--f, n, table.unpack(t) func.2 0 1 2 3 4 + --f2, n<=0, returning sum(...) 1 2 3 4 +true 10 +--f, n, table.unpack(t) func.2 1 + --f2, n>0, returning f2(n-1,n,...) 0 1 + --f2, n<=0, returning sum(...) 1 +true 1 +--f, n, table.unpack(t) func.2 1 1 + --f2, n>0, returning f2(n-1,n,...) 0 1 1 + --f2, n<=0, returning sum(...) 1 1 +true 2 +--f, n, table.unpack(t) func.2 1 1 2 + --f2, n>0, returning f2(n-1,n,...) 0 1 1 2 + --f2, n<=0, returning sum(...) 1 1 2 +true 4 +--f, n, table.unpack(t) func.2 1 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 0 1 1 2 3 + --f2, n<=0, returning sum(...) 1 1 2 3 +true 7 +--f, n, table.unpack(t) func.2 1 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 0 1 1 2 3 4 + --f2, n<=0, returning sum(...) 1 1 2 3 4 +true 11 +--f, n, table.unpack(t) func.2 2 + --f2, n>0, returning f2(n-1,n,...) 1 2 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 + --f2, n<=0, returning sum(...) 1 2 +true 3 +--f, n, table.unpack(t) func.2 2 1 + --f2, n>0, returning f2(n-1,n,...) 1 2 1 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 1 + --f2, n<=0, returning sum(...) 1 2 1 +true 4 +--f, n, table.unpack(t) func.2 2 1 2 + --f2, n>0, returning f2(n-1,n,...) 1 2 1 2 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2 + --f2, n<=0, returning sum(...) 1 2 1 2 +true 6 +--f, n, table.unpack(t) func.2 2 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 1 2 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2 3 + --f2, n<=0, returning sum(...) 1 2 1 2 3 +true 9 +--f, n, table.unpack(t) func.2 2 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 1 2 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2 3 4 + --f2, n<=0, returning sum(...) 1 2 1 2 3 4 +true 13 +--f, n, table.unpack(t) func.2 3 + --f2, n>0, returning f2(n-1,n,...) 2 3 + --f2, n>0, returning f2(n-1,n,...) 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 3 + --f2, n<=0, returning sum(...) 1 2 3 +true 6 +--f, n, table.unpack(t) func.2 3 1 + --f2, n>0, returning f2(n-1,n,...) 2 3 1 + --f2, n>0, returning f2(n-1,n,...) 1 2 3 1 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 + --f2, n<=0, returning sum(...) 1 2 3 1 +true 7 +--f, n, table.unpack(t) func.2 3 1 2 + --f2, n>0, returning f2(n-1,n,...) 2 3 1 2 + --f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2 + --f2, n<=0, returning sum(...) 1 2 3 1 2 +true 9 +--f, n, table.unpack(t) func.2 3 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 2 3 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2 3 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2 3 + --f2, n<=0, returning sum(...) 1 2 3 1 2 3 +true 12 +--f, n, table.unpack(t) func.2 3 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 2 3 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2 3 4 + --f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2 3 4 + --f2, n<=0, returning sum(...) 1 2 3 1 2 3 4 +true 16 +--f, n, table.unpack(t) func.3 0 +true 0 +--f, n, table.unpack(t) func.3 0 1 +true 1 +--f, n, table.unpack(t) func.3 0 1 2 +true 3 +--f, n, table.unpack(t) func.3 0 1 2 3 +true 6 +--f, n, table.unpack(t) func.3 0 1 2 3 4 +true 10 +--f, n, table.unpack(t) func.3 1 + f3,n-1,n,... func.3 0 1 +true true 1 +--f, n, table.unpack(t) func.3 1 1 + f3,n-1,n,... func.3 0 1 1 +true true 2 +--f, n, table.unpack(t) func.3 1 1 2 + f3,n-1,n,... func.3 0 1 1 2 +true true 4 +--f, n, table.unpack(t) func.3 1 1 2 3 + f3,n-1,n,... func.3 0 1 1 2 3 +true true 7 +--f, n, table.unpack(t) func.3 1 1 2 3 4 + f3,n-1,n,... func.3 0 1 1 2 3 4 +true true 11 +--f, n, table.unpack(t) func.3 2 + f3,n-1,n,... func.3 1 2 + f3,n-1,n,... func.3 0 1 2 +true true true 3 +--f, n, table.unpack(t) func.3 2 1 + f3,n-1,n,... func.3 1 2 1 + f3,n-1,n,... func.3 0 1 2 1 +true true true 4 +--f, n, table.unpack(t) func.3 2 1 2 + f3,n-1,n,... func.3 1 2 1 2 + f3,n-1,n,... func.3 0 1 2 1 2 +true true true 6 +--f, n, table.unpack(t) func.3 2 1 2 3 + f3,n-1,n,... func.3 1 2 1 2 3 + f3,n-1,n,... func.3 0 1 2 1 2 3 +true true true 9 +--f, n, table.unpack(t) func.3 2 1 2 3 4 + f3,n-1,n,... func.3 1 2 1 2 3 4 + f3,n-1,n,... func.3 0 1 2 1 2 3 4 +true true true 13 +--f, n, table.unpack(t) func.3 3 + f3,n-1,n,... func.3 2 3 + f3,n-1,n,... func.3 1 2 3 + f3,n-1,n,... func.3 0 1 2 3 +true true true true 6 +--f, n, table.unpack(t) func.3 3 1 + f3,n-1,n,... func.3 2 3 1 + f3,n-1,n,... func.3 1 2 3 1 + f3,n-1,n,... func.3 0 1 2 3 1 +true true true true 7 +--f, n, table.unpack(t) func.3 3 1 2 + f3,n-1,n,... func.3 2 3 1 2 + f3,n-1,n,... func.3 1 2 3 1 2 + f3,n-1,n,... func.3 0 1 2 3 1 2 +true true true true 9 +--f, n, table.unpack(t) func.3 3 1 2 3 + f3,n-1,n,... func.3 2 3 1 2 3 + f3,n-1,n,... func.3 1 2 3 1 2 3 + f3,n-1,n,... func.3 0 1 2 3 1 2 3 +true true true true 12 +--f, n, table.unpack(t) func.3 3 1 2 3 4 + f3,n-1,n,... func.3 2 3 1 2 3 4 + f3,n-1,n,... func.3 1 2 3 1 2 3 4 + f3,n-1,n,... func.3 0 1 2 3 1 2 3 4 +true true true true 16 +120 +120 +1234 +true 832040 +true 832040 +true inf +1 1 2 3 5 8 13 21 34 diff --git a/luaj-test/src/test/resources/compatibility/jse/upvalues.out b/luaj-test/src/test/resources/compatibility/jse/upvalues.out new file mode 100644 index 00000000..c9260f54 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/upvalues.out @@ -0,0 +1,23 @@ +-------- simple upvalues tests -------- +6 +5 +f1()= 6 +g1()= 5 +6 +5 +f2()= 6 +g2()= 5 +g1()= 4 +f1()= 5 +simplevalues result: true +----------- upvalued in middle ------------ +x= 3 +y= 5 +z= 7 +x= x +y= y +z= z +true +--------- nested upvalues ---------- +10 20 +nestedupvaluestest result: true diff --git a/luaj-test/src/test/resources/compatibility/jse/vm.out b/luaj-test/src/test/resources/compatibility/jse/vm.out new file mode 100644 index 00000000..79f74754 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/jse/vm.out @@ -0,0 +1,418 @@ +-------- basic vm tests -------- +-- boolean tests +true +false +false +true +true +false +false +true +true +false +false +true +false +true +1 +0 +nil +1 +0 +nil +booleantests result: true +------------- varargs +---- function p() +--p(): +a nil +... +...,a nil nil +a,... nil + -> true +--p("q"): +a q +... +...,a nil q +a,... q + -> true +--p("q","r"): +a q +... r +...,a r q +a,... q r + -> true +--p("q","r","s"): +a q +... r s +...,a r q +a,... q r s + -> true +---- function q() +--q(): +a,arg[1],arg[2],arg[3] nil nil global-1 global-2 global-3 + -> true +--q("q"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +--q("q","r"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +--q("q","r","s"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +---- function r() +--r(): +a,arg[1],arg[2],arg[3] nil nil global-1 global-2 global-3 +a nil +... +...,a nil nil +a,... nil + -> true +--r("q"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... +...,a nil q +a,... q + -> true +--r("q","r"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... r +...,a r q +a,... q r + -> true +--r("q","r","s"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... r s +...,a r q +a,... q r s + -> true +---- function s() +--s(): +a,arg[1],arg[2],arg[3] nil 1 2 3 +a nil + -> true +--s("q"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +--s("q","r"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +--s("q","r","s"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +---- function t() +--t(): +a,arg[1],arg[2],arg[3] nil 1 2 3 +a nil +... +...,a nil nil +a,... nil + -> true +--t("q"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... +...,a nil q +a,... q + -> true +--t("q","r"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... r +...,a r q +a,... q r + -> true +--t("q","r","s"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... r s +...,a r q +a,... q r s + -> true +---- function u() +--u(): +arg nil + -> true +--u("q"): +arg q + -> true +--u("q","r"): +arg q + -> true +--u("q","r","s"): +arg q + -> true +---- function v() +--v(): +arg nil +... +arg,... nil + -> true +--v("q"): +arg q +... +arg,... q + -> true +--v("q","r"): +arg q +... r +arg,... q r + -> true +--v("q","r","s"): +arg q +... r s +arg,... q r s + -> true +varargstest result: true +---------- metatable tests +ell +set{} tbl.1 tbl.2 tbl.1 nil +set-nil tbl.1 nil tbl.1 nil +set{} tbl.1 tbl.3 tbl.1 nil +set tbl.1 tbl.3 false string +set{} tbl.1 tbl.4 tbl.1 nil +set{} tbl.1 tbl.5 tbl.1 nil +set{}{} tbl.1 tbl.6 tbl.1 nil +set-nil tbl.1 nil tbl.1 nil +set{__} tbl.1 tbl.7 tbl.1 nil +set{} tbl.1 tbl.7 false string +set-nil tbl.1 tbl.7 false string +set{} tbl.8 tbl.9 tbl.8 nil +set-nil tbl.8 nil tbl.8 nil +set{__} tbl.8 abc tbl.8 nil +set{} tbl.8 abc false string +set-nil tbl.8 abc false string +t.a 1234 +t.b 1235 +t.a 1234 +t.b 1235 +t.c 1236 +t.a 1234 +t.b 1235 +t.c 1236 +t.d 1237 +metatabletests result: true +------------ huge tables +#t= 100 t[1,50,51,59] 1 1 1 1 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +#t2= 70 t[1,50,51,59] 1 1 1 1 +0,3,4,7,9,8,12,15,23,5,10,13,14,17,19,18,112,115,123,15,20,33,24,27,29,28,212,215,223,25,40,43,44,47,49,48,412,415,423,45,50,53,54,57,59,58,512,515,523,55,60,63,64,67,69,68,612,615,623,65,70,73,74,77,79,78,72,715,723,75 +t[2000] a +t[2001] b +t[2002] c +t[2003] d +t[2004] e +t[2005] f +t[2006] g +t[2007] h +t[2008] i +t[2009] j +t[3000] a +t[3001] b +t[3002] c +t[3003] d +t[3004] e +t[3005] f +t[3006] g +t[3007] h +t[3008] i +t[3009] j +t[4000] a +t[4001] b +t[4002] c +t[4003] d +t[4004] e +t[4005] f +t[4006] g +t[4007] h +t[4008] i +t[4009] j +t[5000] a +t[5001] b +t[5002] c +t[5003] d +t[5004] e +t[5005] f +t[5006] g +t[5007] h +t[5008] i +t[5009] j +t[6000] a +t[6001] b +t[6002] c +t[6003] d +t[6004] e +t[6005] f +t[6006] g +t[6007] h +t[6008] i +t[6009] j +t[7000] a +t[7001] b +t[7002] c +t[7003] d +t[7004] e +t[7005] f +t[7006] g +t[7007] h +t[7008] i +t[7009] j +t[8000] a +t[8001] b +t[8002] c +t[8003] d +t[8004] e +t[8005] f +t[8006] g +t[8007] h +t[8008] i +t[8009] j +hugetables result: true +--------- many locals +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +manylocals result: true diff --git a/luaj-test/src/test/resources/compatibility/luajit/baselib.out b/luaj-test/src/test/resources/compatibility/luajit/baselib.out new file mode 100644 index 00000000..4d94d645 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/baselib.out @@ -0,0 +1,240 @@ + +11 +abc 123 nil pqr +F +F +T +assert(true) true +pcall(assert,true) true +pcall(assert,false) false string +pcall(assert,nil) false string +pcall(assert,true,"msg") true +pcall(assert,false,"msg") false string +pcall(assert,nil,"msg") false string +pcall(assert,false,"msg","msg2") false string +collectgarbage("count") number +collectgarbage("collect") number +collectgarbage("count") number +pcall(ipairs) false string +pcall(ipairs,nil) false string +pcall(ipairs,"a") false string +pcall(ipairs,1) false string +ipairs2 1 one +ipairs2 2 two +ipairs4 1 one +ipairs4 2 two +table loaded +load: nil +load("print(3+4); return 8") func.1 nil +7 +load("print(3+4); return 8")() 8 +pcall(pairs) false string +pcall(pairs,nil) false string +pcall(pairs,"a") false string +pcall(pairs,1) false string +pairs2 1 one +pairs2 2 two +pairs3 aa aaa +pairs4 1 one +pairs4 2 two +pairs4 aa aaa +pairs5 20 30 +pairs5 30 20 +_G["abc"] (before) nil +_G["abc"] (after) def +type(nil) nil +type("a") string +type(1) number +type(1.5) number +type(function() end) function +type({}) table +type(true) boolean +type(false) boolean +pcall(type,type) function +pcall(type) false string +(function() return pcall(type) end)() false string +la() false string +ga() false string +getmetatable(ta) nil +getmetatable(tb) nil +setmetatable(ta),{cc1="ccc1"} table +setmetatable(tb),{dd1="ddd1"} table +getmetatable(ta)["cc1"] ccc1 +getmetatable(tb)["dd1"] ddd1 +getmetatable(1) nil +pcall(setmetatable,1) false string +pcall(setmetatable,nil) false string +pcall(setmetatable,"ABC") false string +pcall(setmetatable,function() end) false string +pcall(rawget) false string +pcall(rawget,"a") false string +pcall(rawget,s) false string +pcall(rawget,t) false string + s nil nil ccc ddd nil nil nil + s nil nil ccc ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,s,"aa","www") tbl.2 + s www nil ccc ddd nil nil nil + s www nil ccc ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,s,"cc","xxx") tbl.2 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t aaa bbb ccc ddd nil nil nil + t nil nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,t,"aa","yyy") tbl.3 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc ddd nil nil nil + t yyy nil ccc ddd nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawset,t,"dd","zzz") tbl.3 + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +pcall(rawlen, {}) false string +pcall(rawlen, {"a"}) false string +pcall(rawlen, {"a","b"}) false string +pcall(rawlen, "") false string +pcall(rawlen, "a") false string +pcall(rawlen, "ab") false string +pcall(rawlen, 1) false string +pcall(rawlen, nil) false string +pcall(rawlen) false string + s www nil xxx ddd nil nil nil + s www nil xxx ddd nil nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +s["ee"]="ppp" + s www nil xxx ddd ppp nil nil + s www nil xxx ddd ppp nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +s["cc"]="qqq" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc zzz nil nil nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil nil nil + mt aaa bbb nil nil nil nil nil +t["ff"]="rrr" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc zzz nil rrr nil + t yyy nil ccc zzz nil nil nil + mt aaa bbb nil nil nil rrr nil + mt aaa bbb nil nil nil rrr nil +t["dd"]="sss" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc sss nil rrr nil + t yyy nil ccc sss nil nil nil + mt aaa bbb nil nil nil rrr nil + mt aaa bbb nil nil nil rrr nil +mt["gg"]="ttt" + s www nil qqq ddd ppp nil nil + s www nil qqq ddd ppp nil nil + t yyy bbb ccc sss nil rrr ttt + t yyy nil ccc sss nil nil nil + mt aaa bbb nil nil nil rrr ttt + mt aaa bbb nil nil nil rrr ttt +pcall(select) false string +select(1,11,22,33,44,55) 11 22 33 44 55 +select(2,11,22,33,44,55) 22 33 44 55 +select(3,11,22,33,44,55) 33 44 55 +select(4,11,22,33,44,55) 44 55 +pcall(select,5,11,22,33,44,55) 55 +pcall(select,6,11,22,33,44,55) nil +pcall(select,7,11,22,33,44,55) nil +pcall(select,0,11,22,33,44,55) false string +pcall(select,-1,11,22,33,44,55) 55 +pcall(select,-2,11,22,33,44,55) 44 +pcall(select,-4,11,22,33,44,55) 22 +pcall(select,-5,11,22,33,44,55) 11 +pcall(select,-6,11,22,33,44,55) false string +pcall(select,1) nil +pcall(select,select) false string +pcall(select,{}) false string +pcall(select,"2",11,22,33) 22 +pcall(select,"abc",11,22,33) false string +pcall(tonumber) nil +pcall(tonumber,nil) nil +pcall(tonumber,"abc") nil +pcall(tonumber,"123") 123 +pcall(tonumber,"123",10) 123 +pcall(tonumber,"123",8) 83 +pcall(tonumber,"123",6) 51 +pcall(tonumber,"10101",4) 273 +pcall(tonumber,"10101",3) 91 +pcall(tonumber,"10101",2) 21 +pcall(tonumber,"1a1",16) 417 +pcall(tonumber,"1a1",32) 1345 +pcall(tonumber,"1a1",54) false string +pcall(tonumber,"1a1",1) false string +pcall(tonumber,"1a1",0) false string +pcall(tonumber,"1a1",-1) false string +pcall(tonumber,"1a1","32") 1345 +pcall(tonumber,"123","456") false string +pcall(tonumber,"1a1",10) nil +pcall(tonumber,"151",4) nil +pcall(tonumber,"151",3) nil +pcall(tonumber,"151",2) nil +pcall(tonumber,"123",8,8) 83 +pcall(tonumber,123) 123 +pcall(tonumber,true) nil +pcall(tonumber,false) nil +pcall(tonumber,tonumber) nil +pcall(tonumber,function() end) nil +pcall(tonumber,{"one","two",a="aa",b="bb"}) nil +pcall(tonumber,"123.456") 123.456 +pcall(tonumber," 123.456") 123.456 +pcall(tonumber," 234qwer") nil +pcall(tonumber,"0x20") 32 +pcall(tonumber," 0x20") 32 +pcall(tonumber,"0x20 ") 32 +pcall(tonumber," 0x20 ") 32 +pcall(tonumber,"0X20") 32 +pcall(tonumber," 0X20") 32 +pcall(tonumber,"0X20 ") 32 +pcall(tonumber," 0X20 ") 32 +pcall(tonumber,"0x20",10) 32 +pcall(tonumber,"0x20",16) 32 +pcall(tonumber,"0x20",8) nil +pcall(tostring) nil +pcall(tostring,nil) nil +pcall(tostring,"abc") abc +pcall(tostring,"abc","def") abc +pcall(tostring,123) 123 +pcall(tostring,true) true +pcall(tostring,false) false +tostring(tostring) string +tostring(function() end) string +tostring({"one","two",a="aa",b="bb"}) string +_VERSION string +pcall(badfunc) false string +pcall(badfunc,errfunc) false string +pcall(badfunc,badfunc) false string +pcall(wrappedbad) nil +pcall(wrappedbad,errfunc) nil +pcall(xpcall(badfunc)) false string + in errfunc string +pcall(xpcall(badfunc,errfunc)) false +pcall(xpcall(badfunc,badfunc)) false +pcall(xpcall(wrappedbad)) false string +xpcall(wrappedbad,errfunc) true diff --git a/luaj-test/src/test/resources/compatibility/luajit/coroutinelib.out b/luaj-test/src/test/resources/compatibility/luajit/coroutinelib.out new file mode 100644 index 00000000..c9e5bb4d --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/coroutinelib.out @@ -0,0 +1,95 @@ +running is nil +co.status suspended +co-body 1 10 +foo 2 +main true 4 +co.status suspended +co-body r +main true 11 -9 +co.status suspended +co-body x y +running is not nil +co.status.inside running +co.status.inside running +co.status.inside2 normal +main true 10 end +co.status dead +main false cannot resume dead coroutine +co.status dead +running is nil +co.status suspended +co-body 1 10 +foo 2 +main true 4 +co.status suspended +co-body nil nil +main true 11 -9 +co.status suspended +co-body x y +main true 10 end +co.status dead +main false cannot resume dead coroutine +co.status dead +co-body 1 10 +foo 2 +g 4 +co-body r +g 11 -9 +co-body x y +g 10 end +g cannot resume dead coroutine +(main) sending args 111 222 333 +(main) resume returns false coroutinelib.lua:83: attempt to call field 'pack' (a nil value) +(main) sending args +(main) resume returns false cannot resume dead coroutine +(main) sending args 111 +(main) resume returns false cannot resume dead coroutine +(main) sending args 111 222 333 +(main) resume returns false cannot resume dead coroutine +main-b suspended +main-c suspended + b-resumed main-arg-for-b true + b-b running + b-c suspended + b-resume-b false cannot resume running coroutine + c-resumed b-arg-for-c true + c-b normal + c-c running + c-resume-b false cannot resume running coroutine + c-resume-c false cannot resume running coroutine + b-resume-c true c-rslt +main-resume-b true b-rslt + c-resumed main-arg-for-c true + c-b suspended + c-c running + b-resumed b-arg-for-b true + b-b running + b-c normal + b-resume-b false cannot resume running coroutine + b-resume-c false cannot resume running coroutine + c-resume-b true b-rslt + c-resume-c false cannot resume running coroutine +main-resume-c true c-rslt +main-b suspended +main-c suspended + b-resumed main-arg-for-b true + b-b running + b-c suspended + b-resume-b false cannot resume running coroutine + c-resumed b-arg-for-c true + c-b normal + c-c running + c-resume-b false cannot resume running coroutine + c-resume-c false cannot resume running coroutine + b-resume-c true c-rslt +main-resume-b true b-rslt +main-resume-c true +main-b suspended +main-c dead + b-resumed main-arg-for-b true + b-b running + b-c dead + b-resume-b false cannot resume running coroutine + b-resume-c false cannot resume dead coroutine +main-resume-b true b-rslt +main-resume-c false cannot resume dead coroutine diff --git a/luaj-test/src/test/resources/compatibility/luajit/errors.out b/luaj-test/src/test/resources/compatibility/luajit/errors.out new file mode 100644 index 00000000..cc674319 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/errors.out @@ -0,0 +1,97 @@ +a(error) false nil +a(error,"msg") false string +a(error,"msg",0) false string +a(error,"msg",1) false string +a(error,"msg",2) false string +a(error,"msg",3) false string +a(error,"msg",4) false string +a(error,"msg",5) false string +a(error,"msg",6) false string +a(nil()) false string +a(t()) false string +a(s()) false string +a(true()) false string +a(nil+1) false string +a(a+1) false string +a(s+1) false string +a(true+1) false string +a(nil.x) false string +a(a.x) false string +a(s.x) true nil +a(true.x) false string +a(nil.x=5) false string +a(a.x=5) false string +a(s.x=5) false string +a(true.x=5) false string +a(#nil) false string +a(#t) true 0 +a(#s) true 11 +a(#a) false string +a(#true) false string +a(nil>1) false string +a(a>1) false string +a(s>1) false string +a(true>1) false string +a(-nil) false string +a(-a) false string +a(-s) false string +a(-true) false string +-------- string concatenation +"a".."b" true +"a"..nil false +nil.."b" false +"a"..{} false +{}.."b" false +"a"..2 true +2.."b" true +"a"..print false +print.."b" false +"a"..true false +true.."b" false +nil..true false +"a"..3.5 true +3.5.."b" true +-------- table concatenation +"a".."b" true +"a"..nil false +nil.."b" false +"a"..{} false +{}.."b" false +"a"..2 true +2.."b" true +"a"..print false +print.."b" false +"a"..true false +true.."b" false +nil..true false +"a"..3.5 true +3.5.."b" true +-------- pairs tests +a(pairs(nil)) false string +a(pairs(a)) false string +a(pairs(s)) false string +a(pairs(t)) true func.1 +a(pairs(true)) false string +-------- setmetatable tests +a(setmetatable(nil)) false string +a(setmetatable(a)) false string +a(setmetatable(s)) false string +a(setmetatable(true)) false string +a(setmetatable(t)) true tbl.2 +a(getmetatable(t)) true tbl.3 +a(setmetatable(t*)) true tbl.2 +a(getmetatable(t)) true tbl.4 +a(setmetatable(t)) false string +a(getmetatable(t)) true tbl.4 +a(setmetatable(t)) true tbl.5 +a(getmetatable(t)) true tbl.6 +a(setmetatable(t*)) true tbl.5 +a(getmetatable(t)) true some string +a(setmetatable(t)) false string +a(getmetatable(t)) true some string +a(setmetatable(t,nil)) false string +a(setmetatable(t)) false string +a(setmetatable({},"abc")) false string +error("msg","arg") false string +loadfile("bogus.txt") true nil +dofile("bogus.txt") false string diff --git a/luaj-test/src/test/resources/compatibility/luajit/functions.out b/luaj-test/src/test/resources/compatibility/luajit/functions.out new file mode 100644 index 00000000..cdffa68a --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/functions.out @@ -0,0 +1,68 @@ +f0: +f0: +f0: +f0: +f0: +f1: nil +f1: a1/1 +f1: a1/2 +f1: a1/3 +f1: a1/4 +f2: nil nil +f2: a1/1 nil +f2: a1/2 a2/2 +f2: a1/3 a2/3 +f2: a1/4 a2/4 +f3: nil nil nil +f3: a1/1 nil nil +f3: a1/2 a2/2 nil +f3: a1/3 a2/3 a3/3 +f3: a1/4 a2/4 a3/4 +f4: nil nil nil nil +f4: a1/1 nil nil nil +f4: a1/2 a2/2 nil nil +f4: a1/3 a2/3 a3/3 nil +f4: a1/4 a2/4 a3/4 a4/4 +z0: nil +z2: c2.3/4 +z4: c4.1/4 +g0: nil nil nil nil (eol) +g2: b2.3/4 b2.4/4 nil nil (eol) +g4: b4.1/4 b4.2/4 b4.3/4 b4.4/4 (eol) +11 12 13 +23 22 21 +32 45 58 +a nil +... +...,a nil nil +a,... nil +a q +... +...,a nil q +a,... q +a q +... r +...,a r q +a,... q r +a q +... r s +...,a r q +a,... q r s +third abc nil | nil nil nil +third def nil | nil nil nil +third def nil | nil nil nil +third abc p | p nil nil +third def nil | p nil nil +third def nil | p nil nil +third abc p | p q nil +third def q | p q nil +third def q | p q nil +third abc p | p q r +third def q | p q r +third def q | p q r +third abc p | p q r +third def q | p q r +third def q | p q r +third abc nil | nil nil nil +third def nil | nil nil nil +third def nil | nil nil nil diff --git a/luaj-test/src/test/resources/compatibility/luajit/iolib.out b/luaj-test/src/test/resources/compatibility/luajit/iolib.out new file mode 100644 index 00000000..80f6dfd0 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/iolib.out @@ -0,0 +1,8 @@ +true +true +true +true +true +write true +Thiswrite true + is a pen.write true diff --git a/luaj-test/src/test/resources/compatibility/luajit/manyupvals.out b/luaj-test/src/test/resources/compatibility/luajit/manyupvals.out new file mode 100644 index 00000000..391387a3 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/manyupvals.out @@ -0,0 +1,1981 @@ + local f1 + f1 = function() return 1 end + local f2 + f2 = function() return 1 end + local f3 + do + local result + function f3() + if not result then + result = f1() + f2() + end + return result + end + end + local f4 + do + local result + function f4() + if not result then + result = f2() + f3() + end + return result + end + end + local f5 + do + local result + function f5() + if not result then + result = f3() + f4() + end + return result + end + end + local f6 + do + local result + function f6() + if not result then + result = f4() + f5() + end + return result + end + end + local f7 + do + local result + function f7() + if not result then + result = f5() + f6() + end + return result + end + end + local f8 + do + local result + function f8() + if not result then + result = f6() + f7() + end + return result + end + end + local f9 + do + local result + function f9() + if not result then + result = f7() + f8() + end + return result + end + end + local f10 + do + local result + function f10() + if not result then + result = f8() + f9() + end + return result + end + end + local f11 + do + local result + function f11() + if not result then + result = f9() + f10() + end + return result + end + end + local f12 + do + local result + function f12() + if not result then + result = f10() + f11() + end + return result + end + end + local f13 + do + local result + function f13() + if not result then + result = f11() + f12() + end + return result + end + end + local f14 + do + local result + function f14() + if not result then + result = f12() + f13() + end + return result + end + end + local f15 + do + local result + function f15() + if not result then + result = f13() + f14() + end + return result + end + end + local f16 + do + local result + function f16() + if not result then + result = f14() + f15() + end + return result + end + end + local f17 + do + local result + function f17() + if not result then + result = f15() + f16() + end + return result + end + end + local f18 + do + local result + function f18() + if not result then + result = f16() + f17() + end + return result + end + end + local f19 + do + local result + function f19() + if not result then + result = f17() + f18() + end + return result + end + end + local f20 + do + local result + function f20() + if not result then + result = f18() + f19() + end + return result + end + end + local f21 + do + local result + function f21() + if not result then + result = f19() + f20() + end + return result + end + end + local f22 + do + local result + function f22() + if not result then + result = f20() + f21() + end + return result + end + end + local f23 + do + local result + function f23() + if not result then + result = f21() + f22() + end + return result + end + end + local f24 + do + local result + function f24() + if not result then + result = f22() + f23() + end + return result + end + end + local f25 + do + local result + function f25() + if not result then + result = f23() + f24() + end + return result + end + end + local f26 + do + local result + function f26() + if not result then + result = f24() + f25() + end + return result + end + end + local f27 + do + local result + function f27() + if not result then + result = f25() + f26() + end + return result + end + end + local f28 + do + local result + function f28() + if not result then + result = f26() + f27() + end + return result + end + end + local f29 + do + local result + function f29() + if not result then + result = f27() + f28() + end + return result + end + end + local f30 + do + local result + function f30() + if not result then + result = f28() + f29() + end + return result + end + end + local f31 + do + local result + function f31() + if not result then + result = f29() + f30() + end + return result + end + end + local f32 + do + local result + function f32() + if not result then + result = f30() + f31() + end + return result + end + end + local f33 + do + local result + function f33() + if not result then + result = f31() + f32() + end + return result + end + end + local f34 + do + local result + function f34() + if not result then + result = f32() + f33() + end + return result + end + end + local f35 + do + local result + function f35() + if not result then + result = f33() + f34() + end + return result + end + end + local f36 + do + local result + function f36() + if not result then + result = f34() + f35() + end + return result + end + end + local f37 + do + local result + function f37() + if not result then + result = f35() + f36() + end + return result + end + end + local f38 + do + local result + function f38() + if not result then + result = f36() + f37() + end + return result + end + end + local f39 + do + local result + function f39() + if not result then + result = f37() + f38() + end + return result + end + end + local f40 + do + local result + function f40() + if not result then + result = f38() + f39() + end + return result + end + end + local f41 + do + local result + function f41() + if not result then + result = f39() + f40() + end + return result + end + end + local f42 + do + local result + function f42() + if not result then + result = f40() + f41() + end + return result + end + end + local f43 + do + local result + function f43() + if not result then + result = f41() + f42() + end + return result + end + end + local f44 + do + local result + function f44() + if not result then + result = f42() + f43() + end + return result + end + end + local f45 + do + local result + function f45() + if not result then + result = f43() + f44() + end + return result + end + end + local f46 + do + local result + function f46() + if not result then + result = f44() + f45() + end + return result + end + end + local f47 + do + local result + function f47() + if not result then + result = f45() + f46() + end + return result + end + end + local f48 + do + local result + function f48() + if not result then + result = f46() + f47() + end + return result + end + end + local f49 + do + local result + function f49() + if not result then + result = f47() + f48() + end + return result + end + end + local f50 + do + local result + function f50() + if not result then + result = f48() + f49() + end + return result + end + end + local f51 + do + local result + function f51() + if not result then + result = f49() + f50() + end + return result + end + end + local f52 + do + local result + function f52() + if not result then + result = f50() + f51() + end + return result + end + end + local f53 + do + local result + function f53() + if not result then + result = f51() + f52() + end + return result + end + end + local f54 + do + local result + function f54() + if not result then + result = f52() + f53() + end + return result + end + end + local f55 + do + local result + function f55() + if not result then + result = f53() + f54() + end + return result + end + end + local f56 + do + local result + function f56() + if not result then + result = f54() + f55() + end + return result + end + end + local f57 + do + local result + function f57() + if not result then + result = f55() + f56() + end + return result + end + end + local f58 + do + local result + function f58() + if not result then + result = f56() + f57() + end + return result + end + end + local f59 + do + local result + function f59() + if not result then + result = f57() + f58() + end + return result + end + end + local f60 + do + local result + function f60() + if not result then + result = f58() + f59() + end + return result + end + end + local f61 + do + local result + function f61() + if not result then + result = f59() + f60() + end + return result + end + end + local f62 + do + local result + function f62() + if not result then + result = f60() + f61() + end + return result + end + end + local f63 + do + local result + function f63() + if not result then + result = f61() + f62() + end + return result + end + end + local f64 + do + local result + function f64() + if not result then + result = f62() + f63() + end + return result + end + end + local f65 + do + local result + function f65() + if not result then + result = f63() + f64() + end + return result + end + end + local f66 + do + local result + function f66() + if not result then + result = f64() + f65() + end + return result + end + end + local f67 + do + local result + function f67() + if not result then + result = f65() + f66() + end + return result + end + end + local f68 + do + local result + function f68() + if not result then + result = f66() + f67() + end + return result + end + end + local f69 + do + local result + function f69() + if not result then + result = f67() + f68() + end + return result + end + end + local f70 + do + local result + function f70() + if not result then + result = f68() + f69() + end + return result + end + end + local f71 + do + local result + function f71() + if not result then + result = f69() + f70() + end + return result + end + end + local f72 + do + local result + function f72() + if not result then + result = f70() + f71() + end + return result + end + end + local f73 + do + local result + function f73() + if not result then + result = f71() + f72() + end + return result + end + end + local f74 + do + local result + function f74() + if not result then + result = f72() + f73() + end + return result + end + end + local f75 + do + local result + function f75() + if not result then + result = f73() + f74() + end + return result + end + end + local f76 + do + local result + function f76() + if not result then + result = f74() + f75() + end + return result + end + end + local f77 + do + local result + function f77() + if not result then + result = f75() + f76() + end + return result + end + end + local f78 + do + local result + function f78() + if not result then + result = f76() + f77() + end + return result + end + end + local f79 + do + local result + function f79() + if not result then + result = f77() + f78() + end + return result + end + end + local f80 + do + local result + function f80() + if not result then + result = f78() + f79() + end + return result + end + end + local f81 + do + local result + function f81() + if not result then + result = f79() + f80() + end + return result + end + end + local f82 + do + local result + function f82() + if not result then + result = f80() + f81() + end + return result + end + end + local f83 + do + local result + function f83() + if not result then + result = f81() + f82() + end + return result + end + end + local f84 + do + local result + function f84() + if not result then + result = f82() + f83() + end + return result + end + end + local f85 + do + local result + function f85() + if not result then + result = f83() + f84() + end + return result + end + end + local f86 + do + local result + function f86() + if not result then + result = f84() + f85() + end + return result + end + end + local f87 + do + local result + function f87() + if not result then + result = f85() + f86() + end + return result + end + end + local f88 + do + local result + function f88() + if not result then + result = f86() + f87() + end + return result + end + end + local f89 + do + local result + function f89() + if not result then + result = f87() + f88() + end + return result + end + end + local f90 + do + local result + function f90() + if not result then + result = f88() + f89() + end + return result + end + end + local f91 + do + local result + function f91() + if not result then + result = f89() + f90() + end + return result + end + end + local f92 + do + local result + function f92() + if not result then + result = f90() + f91() + end + return result + end + end + local f93 + do + local result + function f93() + if not result then + result = f91() + f92() + end + return result + end + end + local f94 + do + local result + function f94() + if not result then + result = f92() + f93() + end + return result + end + end + local f95 + do + local result + function f95() + if not result then + result = f93() + f94() + end + return result + end + end + local f96 + do + local result + function f96() + if not result then + result = f94() + f95() + end + return result + end + end + local f97 + do + local result + function f97() + if not result then + result = f95() + f96() + end + return result + end + end + local f98 + do + local result + function f98() + if not result then + result = f96() + f97() + end + return result + end + end + local f99 + do + local result + function f99() + if not result then + result = f97() + f98() + end + return result + end + end + local f100 + do + local result + function f100() + if not result then + result = f98() + f99() + end + return result + end + end + local f101 + do + local result + function f101() + if not result then + result = f99() + f100() + end + return result + end + end + local f102 + do + local result + function f102() + if not result then + result = f100() + f101() + end + return result + end + end + local f103 + do + local result + function f103() + if not result then + result = f101() + f102() + end + return result + end + end + local f104 + do + local result + function f104() + if not result then + result = f102() + f103() + end + return result + end + end + local f105 + do + local result + function f105() + if not result then + result = f103() + f104() + end + return result + end + end + local f106 + do + local result + function f106() + if not result then + result = f104() + f105() + end + return result + end + end + local f107 + do + local result + function f107() + if not result then + result = f105() + f106() + end + return result + end + end + local f108 + do + local result + function f108() + if not result then + result = f106() + f107() + end + return result + end + end + local f109 + do + local result + function f109() + if not result then + result = f107() + f108() + end + return result + end + end + local f110 + do + local result + function f110() + if not result then + result = f108() + f109() + end + return result + end + end + local f111 + do + local result + function f111() + if not result then + result = f109() + f110() + end + return result + end + end + local f112 + do + local result + function f112() + if not result then + result = f110() + f111() + end + return result + end + end + local f113 + do + local result + function f113() + if not result then + result = f111() + f112() + end + return result + end + end + local f114 + do + local result + function f114() + if not result then + result = f112() + f113() + end + return result + end + end + local f115 + do + local result + function f115() + if not result then + result = f113() + f114() + end + return result + end + end + local f116 + do + local result + function f116() + if not result then + result = f114() + f115() + end + return result + end + end + local f117 + do + local result + function f117() + if not result then + result = f115() + f116() + end + return result + end + end + local f118 + do + local result + function f118() + if not result then + result = f116() + f117() + end + return result + end + end + local f119 + do + local result + function f119() + if not result then + result = f117() + f118() + end + return result + end + end + local f120 + do + local result + function f120() + if not result then + result = f118() + f119() + end + return result + end + end + local f121 + do + local result + function f121() + if not result then + result = f119() + f120() + end + return result + end + end + local f122 + do + local result + function f122() + if not result then + result = f120() + f121() + end + return result + end + end + local f123 + do + local result + function f123() + if not result then + result = f121() + f122() + end + return result + end + end + local f124 + do + local result + function f124() + if not result then + result = f122() + f123() + end + return result + end + end + local f125 + do + local result + function f125() + if not result then + result = f123() + f124() + end + return result + end + end + local f126 + do + local result + function f126() + if not result then + result = f124() + f125() + end + return result + end + end + local f127 + do + local result + function f127() + if not result then + result = f125() + f126() + end + return result + end + end + local f128 + do + local result + function f128() + if not result then + result = f126() + f127() + end + return result + end + end + local f129 + do + local result + function f129() + if not result then + result = f127() + f128() + end + return result + end + end + local f130 + do + local result + function f130() + if not result then + result = f128() + f129() + end + return result + end + end + local f131 + do + local result + function f131() + if not result then + result = f129() + f130() + end + return result + end + end + local f132 + do + local result + function f132() + if not result then + result = f130() + f131() + end + return result + end + end + local f133 + do + local result + function f133() + if not result then + result = f131() + f132() + end + return result + end + end + local f134 + do + local result + function f134() + if not result then + result = f132() + f133() + end + return result + end + end + local f135 + do + local result + function f135() + if not result then + result = f133() + f134() + end + return result + end + end + local f136 + do + local result + function f136() + if not result then + result = f134() + f135() + end + return result + end + end + local f137 + do + local result + function f137() + if not result then + result = f135() + f136() + end + return result + end + end + local f138 + do + local result + function f138() + if not result then + result = f136() + f137() + end + return result + end + end + local f139 + do + local result + function f139() + if not result then + result = f137() + f138() + end + return result + end + end + local f140 + do + local result + function f140() + if not result then + result = f138() + f139() + end + return result + end + end + local f141 + do + local result + function f141() + if not result then + result = f139() + f140() + end + return result + end + end + local f142 + do + local result + function f142() + if not result then + result = f140() + f141() + end + return result + end + end + local f143 + do + local result + function f143() + if not result then + result = f141() + f142() + end + return result + end + end + local f144 + do + local result + function f144() + if not result then + result = f142() + f143() + end + return result + end + end + local f145 + do + local result + function f145() + if not result then + result = f143() + f144() + end + return result + end + end + local f146 + do + local result + function f146() + if not result then + result = f144() + f145() + end + return result + end + end + local f147 + do + local result + function f147() + if not result then + result = f145() + f146() + end + return result + end + end + local f148 + do + local result + function f148() + if not result then + result = f146() + f147() + end + return result + end + end + local f149 + do + local result + function f149() + if not result then + result = f147() + f148() + end + return result + end + end + local f150 + do + local result + function f150() + if not result then + result = f148() + f149() + end + return result + end + end + local f151 + do + local result + function f151() + if not result then + result = f149() + f150() + end + return result + end + end + local f152 + do + local result + function f152() + if not result then + result = f150() + f151() + end + return result + end + end + local f153 + do + local result + function f153() + if not result then + result = f151() + f152() + end + return result + end + end + local f154 + do + local result + function f154() + if not result then + result = f152() + f153() + end + return result + end + end + local f155 + do + local result + function f155() + if not result then + result = f153() + f154() + end + return result + end + end + local f156 + do + local result + function f156() + if not result then + result = f154() + f155() + end + return result + end + end + local f157 + do + local result + function f157() + if not result then + result = f155() + f156() + end + return result + end + end + local f158 + do + local result + function f158() + if not result then + result = f156() + f157() + end + return result + end + end + local f159 + do + local result + function f159() + if not result then + result = f157() + f158() + end + return result + end + end + local f160 + do + local result + function f160() + if not result then + result = f158() + f159() + end + return result + end + end + local f161 + do + local result + function f161() + if not result then + result = f159() + f160() + end + return result + end + end + local f162 + do + local result + function f162() + if not result then + result = f160() + f161() + end + return result + end + end + local f163 + do + local result + function f163() + if not result then + result = f161() + f162() + end + return result + end + end + local f164 + do + local result + function f164() + if not result then + result = f162() + f163() + end + return result + end + end + local f165 + do + local result + function f165() + if not result then + result = f163() + f164() + end + return result + end + end + local f166 + do + local result + function f166() + if not result then + result = f164() + f165() + end + return result + end + end + local f167 + do + local result + function f167() + if not result then + result = f165() + f166() + end + return result + end + end + local f168 + do + local result + function f168() + if not result then + result = f166() + f167() + end + return result + end + end + local f169 + do + local result + function f169() + if not result then + result = f167() + f168() + end + return result + end + end + local f170 + do + local result + function f170() + if not result then + result = f168() + f169() + end + return result + end + end + local f171 + do + local result + function f171() + if not result then + result = f169() + f170() + end + return result + end + end + local f172 + do + local result + function f172() + if not result then + result = f170() + f171() + end + return result + end + end + local f173 + do + local result + function f173() + if not result then + result = f171() + f172() + end + return result + end + end + local f174 + do + local result + function f174() + if not result then + result = f172() + f173() + end + return result + end + end + local f175 + do + local result + function f175() + if not result then + result = f173() + f174() + end + return result + end + end + local f176 + do + local result + function f176() + if not result then + result = f174() + f175() + end + return result + end + end + local f177 + do + local result + function f177() + if not result then + result = f175() + f176() + end + return result + end + end + local f178 + do + local result + function f178() + if not result then + result = f176() + f177() + end + return result + end + end + local f179 + do + local result + function f179() + if not result then + result = f177() + f178() + end + return result + end + end + local f180 + do + local result + function f180() + if not result then + result = f178() + f179() + end + return result + end + end + local f181 + do + local result + function f181() + if not result then + result = f179() + f180() + end + return result + end + end + local f182 + do + local result + function f182() + if not result then + result = f180() + f181() + end + return result + end + end + local f183 + do + local result + function f183() + if not result then + result = f181() + f182() + end + return result + end + end + local f184 + do + local result + function f184() + if not result then + result = f182() + f183() + end + return result + end + end + local f185 + do + local result + function f185() + if not result then + result = f183() + f184() + end + return result + end + end + local f186 + do + local result + function f186() + if not result then + result = f184() + f185() + end + return result + end + end + local f187 + do + local result + function f187() + if not result then + result = f185() + f186() + end + return result + end + end + local f188 + do + local result + function f188() + if not result then + result = f186() + f187() + end + return result + end + end + local f189 + do + local result + function f189() + if not result then + result = f187() + f188() + end + return result + end + end + local f190 + do + local result + function f190() + if not result then + result = f188() + f189() + end + return result + end + end + local f191 + do + local result + function f191() + if not result then + result = f189() + f190() + end + return result + end + end + local f192 + do + local result + function f192() + if not result then + result = f190() + f191() + end + return result + end + end + local f193 + do + local result + function f193() + if not result then + result = f191() + f192() + end + return result + end + end + local f194 + do + local result + function f194() + if not result then + result = f192() + f193() + end + return result + end + end + local f195 + do + local result + function f195() + if not result then + result = f193() + f194() + end + return result + end + end + local f196 + do + local result + function f196() + if not result then + result = f194() + f195() + end + return result + end + end + local f197 + do + local result + function f197() + if not result then + result = f195() + f196() + end + return result + end + end + local f198 + do + local result + function f198() + if not result then + result = f196() + f197() + end + return result + end + end + local f199 + do + local result + function f199() + if not result then + result = f197() + f198() + end + return result + end + end + print("5th fibonacci number is", f5()) + print("10th fibonacci number is", f10()) + print("199th fibonacci number is", f199()) + +5th fibonacci number is 5 +10th fibonacci number is 55 +199th fibonacci number is 1.734025211728e+41 diff --git a/luaj-test/src/test/resources/compatibility/mathlib.out b/luaj-test/src/test/resources/compatibility/luajit/mathlib.out similarity index 100% rename from luaj-test/src/test/resources/compatibility/mathlib.out rename to luaj-test/src/test/resources/compatibility/luajit/mathlib.out diff --git a/luaj-test/src/test/resources/compatibility/luajit/metatags.out b/luaj-test/src/test/resources/compatibility/luajit/metatags.out new file mode 100644 index 00000000..5178703b --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/metatags.out @@ -0,0 +1,645 @@ +---- __eq same types +nil nil before true true +nil nil before true false +true +true +nil nil after true true +nil nil after true false +true +true +boolean boolean before true false +boolean boolean before true true +true +true +boolean boolean after true false +boolean boolean after true true +true +true +number number before true false +number number before true true +true +true +number number after true false +number number after true true +true +true +number number before true false +number number before true true +true +true +number number after true false +number number after true true +true +true +function function before true false +function function before true true +true +true +function function after true false +function function after true true +true +true +thread nil before true false +thread nil before true true +true +true +thread nil after true false +thread nil after true true +true +true +string string before true false +string string before true true +true +true +string string after true false +string string after true true +true +true +number string before true false +number string before true true +true +true +number string after true false +number string after true true +true +true +---- __eq, tables - should invoke metatag comparison +table table before true false +table table before true true +true +true +mt.__eq() table.1 table.2 +table table after-a true true +mt.__eq() table.1 table.2 +table table after-a true false +true +true +nilmt nil +boolmt nil +number nil +function nil +thread nil +---- __call +number before false attempt to call +true +mt.__call() 111 nil +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +mt.__call() 111 a +number after true __call-result +true +boolean before false attempt to call +true +mt.__call() false nil +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +mt.__call() false a +boolean after true __call-result +true +function before true nil +true +function after true +function after true +function after true +function after true +function after true +true +thread before false attempt to call +true +mt.__call() thread.3 nil +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +mt.__call() thread.3 a +thread after true __call-result +true +table before false attempt to call +true +mt.__call() table.1 nil +table after true __call-result +mt.__call() table.1 a +table after true __call-result +mt.__call() table.1 a +table after true __call-result +mt.__call() table.1 a +table after true __call-result +mt.__call() table.1 a +table after true __call-result +true +---- __add, __sub, __mul, __div, __pow, __mod +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +boolean boolean before false attempt to perform arithmetic +true +mt.__add() false false +boolean boolean after true __add-result +mt.__add() false false +boolean boolean after true __add-result +mt.__sub() false false +boolean boolean after true __sub-result +mt.__sub() false false +boolean boolean after true __sub-result +mt.__mul() false false +boolean boolean after true __mul-result +mt.__mul() false false +boolean boolean after true __mul-result +mt.__pow() false false +boolean boolean after true __pow-result +mt.__pow() false false +boolean boolean after true __pow-result +mt.__mod() false false +boolean boolean after true __mod-result +mt.__mod() false false +boolean boolean after true __mod-result +true +true +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +boolean thread before false attempt to perform arithmetic +true +mt.__add() false thread.3 +boolean thread after true __add-result +mt.__add() thread.3 false +boolean thread after true __add-result +mt.__sub() false thread.3 +boolean thread after true __sub-result +mt.__sub() thread.3 false +boolean thread after true __sub-result +mt.__mul() false thread.3 +boolean thread after true __mul-result +mt.__mul() thread.3 false +boolean thread after true __mul-result +mt.__pow() false thread.3 +boolean thread after true __pow-result +mt.__pow() thread.3 false +boolean thread after true __pow-result +mt.__mod() false thread.3 +boolean thread after true __mod-result +mt.__mod() thread.3 false +boolean thread after true __mod-result +true +true +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +boolean function before false attempt to perform arithmetic +true +mt.__add() false function.4 +boolean function after true __add-result +mt.__add() function.4 false +boolean function after true __add-result +mt.__sub() false function.4 +boolean function after true __sub-result +mt.__sub() function.4 false +boolean function after true __sub-result +mt.__mul() false function.4 +boolean function after true __mul-result +mt.__mul() function.4 false +boolean function after true __mul-result +mt.__pow() false function.4 +boolean function after true __pow-result +mt.__pow() function.4 false +boolean function after true __pow-result +mt.__mod() false function.4 +boolean function after true __mod-result +mt.__mod() function.4 false +boolean function after true __mod-result +true +true +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +boolean string before false attempt to perform arithmetic +true +mt.__add() false abc +boolean string after true __add-result +mt.__add() abc false +boolean string after true __add-result +mt.__sub() false abc +boolean string after true __sub-result +mt.__sub() abc false +boolean string after true __sub-result +mt.__mul() false abc +boolean string after true __mul-result +mt.__mul() abc false +boolean string after true __mul-result +mt.__pow() false abc +boolean string after true __pow-result +mt.__pow() abc false +boolean string after true __pow-result +mt.__mod() false abc +boolean string after true __mod-result +mt.__mod() abc false +boolean string after true __mod-result +true +true +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +boolean table before false attempt to perform arithmetic +true +mt.__add() false table.1 +boolean table after true __add-result +mt.__add() table.1 false +boolean table after true __add-result +mt.__sub() false table.1 +boolean table after true __sub-result +mt.__sub() table.1 false +boolean table after true __sub-result +mt.__mul() false table.1 +boolean table after true __mul-result +mt.__mul() table.1 false +boolean table after true __mul-result +mt.__pow() false table.1 +boolean table after true __pow-result +mt.__pow() table.1 false +boolean table after true __pow-result +mt.__mod() false table.1 +boolean table after true __mod-result +mt.__mod() table.1 false +boolean table after true __mod-result +true +true +---- __len +boolean before false attempt to get length of +true +mt.__len() false +boolean after true __len-result +true +function before false attempt to get length of +true +mt.__len() function.4 +function after true __len-result +true +thread before false attempt to get length of +true +mt.__len() thread.3 +thread after true __len-result +true +number before false attempt to get length of +true +mt.__len() 111 +number after true __len-result +true +---- __neg +nil before false attempt to perform arithmetic +true +mt.__unm() false +nil after true __unm-result +true +nil before false attempt to perform arithmetic +true +mt.__unm() function.4 +nil after true __unm-result +true +nil before false attempt to perform arithmetic +true +mt.__unm() thread.3 +nil after true __unm-result +true +nil before false attempt to perform arithmetic +true +mt.__unm() abcd +nil after true __unm-result +true +nil before false attempt to perform arithmetic +true +mt.__unm() table.1 +nil after true __unm-result +true +nil before true -111 +true +nil after true -111 +true +---- __lt, __le, same types +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +true +true +mt.__lt() true true +boolean boolean after true true +mt.__le() true true +boolean boolean after true true +mt.__lt() true true +boolean boolean after true true +mt.__le() true true +boolean boolean after true true +true +true +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +boolean boolean before false attempt to compare +true +true +mt.__lt() true false +boolean boolean after true true +mt.__le() true false +boolean boolean after true true +mt.__lt() false true +boolean boolean after true true +mt.__le() false true +boolean boolean after true true +true +true +function function before false attempt to compare +function function before false attempt to compare +function function before false attempt to compare +function function before false attempt to compare +true +true +mt.__lt() function.4 function.5 +function function after true true +mt.__le() function.4 function.5 +function function after true true +mt.__lt() function.5 function.4 +function function after true true +mt.__le() function.5 function.4 +function function after true true +true +true +thread thread before false attempt to compare +thread thread before false attempt to compare +thread thread before false attempt to compare +thread thread before false attempt to compare +true +true +mt.__lt() thread.3 thread.6 +thread thread after true true +mt.__le() thread.3 thread.6 +thread thread after true true +mt.__lt() thread.6 thread.3 +thread thread after true true +mt.__le() thread.6 thread.3 +thread thread after true true +true +true +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +true +true +mt.__lt() table.1 table.1 +table table after true true +mt.__le() table.1 table.1 +table table after true true +mt.__lt() table.1 table.1 +table table after true true +mt.__le() table.1 table.1 +table table after true true +true +true +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +table table before false attempt to compare +true +true +mt.__lt() table.1 table.7 +table table after true true +mt.__le() table.1 table.7 +table table after true true +mt.__lt() table.7 table.1 +table table after true true +mt.__le() table.7 table.1 +table table after true true +true +true +---- __lt, __le, different types +boolean thread before false attempt to compare +boolean thread before false attempt to compare +boolean thread before false attempt to compare +boolean thread before false attempt to compare +true +true +boolean thread after-a false attempt to compare +boolean thread after-a false attempt to compare +boolean thread after-a false attempt to compare +boolean thread after-a false attempt to compare +true +true +---- __tostring +mt.__tostring(boolean) +boolean after mt.__tostring(boolean) mt.__tostring(boolean) +true +true +function after true mt.__tostring(function) +true +true +thread after true mt.__tostring(thread) +true +true +table after true mt.__tostring(table) +true +true +string after true abc +true +---- __index, __newindex +boolean before false attempt to index +boolean before false attempt to index +boolean before false index +boolean before false index +boolean before false attempt to index +true +mt.__index() false foo +boolean after true __index-result +mt.__index() false 123 +boolean after true __index-result +mt.__newindex() false foo bar +boolean after true +mt.__newindex() false 123 bar +boolean after true +mt.__index() false foo +boolean after false attempt to call +true +number before false attempt to index +number before false attempt to index +number before false index +number before false index +number before false attempt to index +true +mt.__index() 111 foo +number after true __index-result +mt.__index() 111 123 +number after true __index-result +mt.__newindex() 111 foo bar +number after true +mt.__newindex() 111 123 bar +number after true +mt.__index() 111 foo +number after false attempt to call +true +function before false attempt to index +function before false attempt to index +function before false index +function before false index +function before false attempt to index +true +mt.__index() function.4 foo +function after true __index-result +mt.__index() function.4 123 +function after true __index-result +mt.__newindex() function.4 foo bar +function after true +mt.__newindex() function.4 123 bar +function after true +mt.__index() function.4 foo +function after false attempt to call +true +thread before false attempt to index +thread before false attempt to index +thread before false index +thread before false index +thread before false attempt to index +true +mt.__index() thread.3 foo +thread after true __index-result +mt.__index() thread.3 123 +thread after true __index-result +mt.__newindex() thread.3 foo bar +thread after true +mt.__newindex() thread.3 123 bar +thread after true +mt.__index() thread.3 foo +thread after false attempt to call +true +---- __concat +table function before false attempt to concatenate +table function before false attempt to concatenate +table string number before false attempt to concatenate +string table number before false attempt to concatenate +string number table before false attempt to concatenate +true +mt.__concat(table,function) table.1 function.4 +table function after true table.8 +mt.__concat(function,table) function.4 table.1 +table function after true table.8 +mt.__concat(table,string) table.1 sss777 +table string number before true table.8 +mt.__concat(table,number) table.1 777 +string table number before false attempt to concatenate +mt.__concat(number,table) 777 table.1 +string number table before false attempt to concatenate +true +true +function table before false attempt to concatenate +function table before false attempt to concatenate +function string number before false attempt to concatenate +string function number before false attempt to concatenate +string number function before false attempt to concatenate +true +mt.__concat(function,table) function.4 table.1 +function table after true table.8 +mt.__concat(table,function) table.1 function.4 +function table after true table.8 +mt.__concat(function,string) function.4 sss777 +function string number before true table.8 +mt.__concat(function,number) function.4 777 +string function number before false attempt to concatenate +mt.__concat(number,function) 777 function.4 +string number function before false attempt to concatenate +true +true +number nil before false attempt to concatenate +number nil before false attempt to concatenate +number string number before true 123sss777 +string number number before true sss123777 +string number number before true sss777123 +true +mt.__concat(number,nil) 123 nil +number nil after true table.8 +mt.__concat(nil,number) nil 123 +number nil after true table.8 +number string number before true 123sss777 +string number number before true sss123777 +string number number before true sss777123 +true +true +nil number before false attempt to concatenate +nil number before false attempt to concatenate +nil string number before false attempt to concatenate +string nil number before false attempt to concatenate +string number nil before false attempt to concatenate +true +mt.__concat(nil,number) nil 123 +nil number after true table.8 +mt.__concat(number,nil) 123 nil +nil number after true table.8 +mt.__concat(nil,string) nil sss777 +nil string number before true table.8 +mt.__concat(nil,number) nil 777 +string nil number before false attempt to concatenate +mt.__concat(number,nil) 777 nil +string number nil before false attempt to concatenate +true +true +---- __metatable +boolean before true nil nil +true +boolean after true table.9 table.10 +true +function before true nil nil +true +function after true table.9 table.10 +true +thread before true nil nil +true +thread after true table.9 table.10 +true +table before true nil nil +true +table after true table.9 table.10 +true +string before true table.11 table.11 +true +string after true table.9 table.10 +true diff --git a/luaj-test/src/test/resources/compatibility/luajit/oslib.out b/luaj-test/src/test/resources/compatibility/luajit/oslib.out new file mode 100644 index 00000000..b8a01c2f --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/oslib.out @@ -0,0 +1,80 @@ +os table +os.clock() true number nil +os.date() true string nil +os.difftime(123000, 21500) true number nil +os.getenv() false string nil +os.getenv("bogus.key") true nil nil +os.tmpname() true string +os.tmpname() true string +io.open true userdata +write false string nil +close false string nil +os.rename(p,q) true boolean nil +os.remove(q) true boolean nil +os.remove(q) true nil string +os.setlocale("C") true string nil +os.exit function +os.date('%a', 1281364496) true string nil +os.date('%A', 1281364496) true string nil +os.date('%b', 1281364496) true string nil +os.date('%B', 1281364496) true string nil +os.date('%c', 1281364496) true string nil +os.date('%C', 1281364496) true string nil +os.date('%d', 1281364496) true string nil +os.date('%D', 1281364496) true string nil +os.date('%e', 1281364496) true string nil +os.date('%E', 1281364496) true string nil +os.date('%f', 1281364496) true string nil +os.date('%F', 1281364496) true string nil +os.date('%g', 1281364496) true string nil +os.date('%G', 1281364496) true string nil +os.date('%h', 1281364496) true string nil +os.date('%H', 1281364496) true string nil +os.date('%i', 1281364496) true string nil +os.date('%I', 1281364496) true string nil +os.date('%j', 1281364496) true string nil +os.date('%J', 1281364496) true string nil +os.date('%k', 1281364496) true string nil +os.date('%K', 1281364496) true string nil +os.date('%l', 1281364496) true string nil +os.date('%L', 1281364496) true string nil +os.date('%m', 1281364496) true string nil +os.date('%M', 1281364496) true string nil +os.date('%n', 1281364496) true string nil +os.date('%N', 1281364496) true string nil +os.date('%o', 1281364496) true string nil +os.date('%O', 1281364496) true string nil +os.date('%p', 1281364496) true string nil +os.date('%P', 1281364496) true string nil +os.date('%q', 1281364496) true string nil +os.date('%Q', 1281364496) true string nil +os.date('%r', 1281364496) true string nil +os.date('%R', 1281364496) true string nil +os.date('%s', 1281364496) true string nil +os.date('%S', 1281364496) true string nil +os.date('%t', 1281364496) true string nil +os.date('%T', 1281364496) true string nil +os.date('%u', 1281364496) true string nil +os.date('%U', 1281364496) true string nil +os.date('%v', 1281364496) true string nil +os.date('%V', 1281364496) true string nil +os.date('%w', 1281364496) true string nil +os.date('%W', 1281364496) true string nil +os.date('%x', 1281364496) true string nil +os.date('%X', 1281364496) true string nil +os.date('%y', 1281364496) true string nil +os.date('%Y', 1281364496) true string nil +os.date('%z', 1281364496) true string nil +os.date('%Z', 1281364496) true string nil +k string year v number 2010 +k string month v number 8 +k string day v number 9 +k string hour v number 16 +k string min v number 34 +k string sec v number 56 +k string wday v number 2 +k string yday v number 221 +k string isdst v boolean true +type(os.time()) number +os.time({year=1971, month=2, day=25}) 36327600 +os.time({year=1971, month=2, day=25, hour=11, min=22, sec=33}) 36325353 diff --git a/luaj-test/src/test/resources/compatibility/luajit/stringlib.out b/luaj-test/src/test/resources/compatibility/luajit/stringlib.out new file mode 100644 index 00000000..7ebe326d Binary files /dev/null and b/luaj-test/src/test/resources/compatibility/luajit/stringlib.out differ diff --git a/luaj-test/src/test/resources/compatibility/luajit/tablelib.out b/luaj-test/src/test/resources/compatibility/luajit/tablelib.out new file mode 100644 index 00000000..c86243be --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/tablelib.out @@ -0,0 +1,63 @@ +2 +-- concat tests +onetwothree +one--two--three +two,three +two + +onetwothreefourfive +one--two--three--four--five +two,three,four,five +two + + + + + + + + + + +-- insert, len tests +{[1]=one,[2]=two,[3]=three,[a]=aaa,[b]=bbb,[c]=ccc} 3 +{[1]=one,[2]=two,[3]=three,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +{[1]=seven,[2]=one,[3]=two,[4]=three,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 +{[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[a]=aaa,[b]=bbb,[c]=ccc} 6 +{[1]=seven,[2]=one,[3]=two,[4]=eight,[5]=three,[6]=six,[7]=nine,[a]=aaa,[b]=bbb,[c]=ccc} 7 +#{} 0 +#{"a"} 1 +#{"a","b"} 2 +#{"a",nil} 1 +#{nil,nil} 0 +#{nil,"b"} true +#{"a","b","c"} 3 +#{"a","b",nil} 2 +#{"a",nil,nil} 1 +#{nil,nil,nil} 0 +#{nil,nil,"c"} true +#{nil,"b","c"} true +#{nil,"b",nil} true +#{"a",nil,"c"} true +-- remove tests +{[10]=ten,[1]=one,[2]=two,[3]=three,[4]=four,[5]=five,[6]=six,[7]=seven,[a]=aaa,[b]=bbb,[c]=ccc} 7 +table.remove(t) seven +{[10]=ten,[1]=one,[2]=two,[3]=three,[4]=four,[5]=five,[6]=six,[a]=aaa,[b]=bbb,[c]=ccc} 6 +table.remove(t,1) one +{[10]=ten,[1]=two,[2]=three,[3]=four,[4]=five,[5]=six,[a]=aaa,[b]=bbb,[c]=ccc} 5 +table.remove(t,3) four +{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +table.remove(t,5) +{[10]=ten,[1]=two,[2]=three,[3]=five,[4]=six,[a]=aaa,[b]=bbb,[c]=ccc} 4 +-- sort tests +one-two-three +one-three-two +www-vvv-uuu-ttt-sss-zzz-yyy-xxx +sss-ttt-uuu-vvv-www-xxx-yyy-zzz +www-vvv-uuu-ttt-sss-zzz-yyy-xxx +zzz-yyy-xxx-www-vvv-uuu-ttt-sss +----- unpack tests ------- +pcall(unpack) false +pcall(unpack,nil) false +pcall(unpack,"abc") false +pcall(unpack,1) false diff --git a/luaj-test/src/test/resources/compatibility/luajit/tailcalls.out b/luaj-test/src/test/resources/compatibility/luajit/tailcalls.out new file mode 100644 index 00000000..2efcd47f --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/tailcalls.out @@ -0,0 +1,4 @@ +true true +b +true true +true true c diff --git a/luaj-test/src/test/resources/compatibility/luajit/upvalues.out b/luaj-test/src/test/resources/compatibility/luajit/upvalues.out new file mode 100644 index 00000000..c9260f54 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/upvalues.out @@ -0,0 +1,23 @@ +-------- simple upvalues tests -------- +6 +5 +f1()= 6 +g1()= 5 +6 +5 +f2()= 6 +g2()= 5 +g1()= 4 +f1()= 5 +simplevalues result: true +----------- upvalued in middle ------------ +x= 3 +y= 5 +z= 7 +x= x +y= y +z= z +true +--------- nested upvalues ---------- +10 20 +nestedupvaluestest result: true diff --git a/luaj-test/src/test/resources/compatibility/luajit/vm.out b/luaj-test/src/test/resources/compatibility/luajit/vm.out new file mode 100644 index 00000000..79f74754 --- /dev/null +++ b/luaj-test/src/test/resources/compatibility/luajit/vm.out @@ -0,0 +1,418 @@ +-------- basic vm tests -------- +-- boolean tests +true +false +false +true +true +false +false +true +true +false +false +true +false +true +1 +0 +nil +1 +0 +nil +booleantests result: true +------------- varargs +---- function p() +--p(): +a nil +... +...,a nil nil +a,... nil + -> true +--p("q"): +a q +... +...,a nil q +a,... q + -> true +--p("q","r"): +a q +... r +...,a r q +a,... q r + -> true +--p("q","r","s"): +a q +... r s +...,a r q +a,... q r s + -> true +---- function q() +--q(): +a,arg[1],arg[2],arg[3] nil nil global-1 global-2 global-3 + -> true +--q("q"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +--q("q","r"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +--q("q","r","s"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 + -> true +---- function r() +--r(): +a,arg[1],arg[2],arg[3] nil nil global-1 global-2 global-3 +a nil +... +...,a nil nil +a,... nil + -> true +--r("q"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... +...,a nil q +a,... q + -> true +--r("q","r"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... r +...,a r q +a,... q r + -> true +--r("q","r","s"): +a,arg[1],arg[2],arg[3] q nil global-1 global-2 global-3 +a q +... r s +...,a r q +a,... q r s + -> true +---- function s() +--s(): +a,arg[1],arg[2],arg[3] nil 1 2 3 +a nil + -> true +--s("q"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +--s("q","r"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +--s("q","r","s"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q + -> true +---- function t() +--t(): +a,arg[1],arg[2],arg[3] nil 1 2 3 +a nil +... +...,a nil nil +a,... nil + -> true +--t("q"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... +...,a nil q +a,... q + -> true +--t("q","r"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... r +...,a r q +a,... q r + -> true +--t("q","r","s"): +a,arg[1],arg[2],arg[3] q 1 2 3 +a q +... r s +...,a r q +a,... q r s + -> true +---- function u() +--u(): +arg nil + -> true +--u("q"): +arg q + -> true +--u("q","r"): +arg q + -> true +--u("q","r","s"): +arg q + -> true +---- function v() +--v(): +arg nil +... +arg,... nil + -> true +--v("q"): +arg q +... +arg,... q + -> true +--v("q","r"): +arg q +... r +arg,... q r + -> true +--v("q","r","s"): +arg q +... r s +arg,... q r s + -> true +varargstest result: true +---------- metatable tests +ell +set{} tbl.1 tbl.2 tbl.1 nil +set-nil tbl.1 nil tbl.1 nil +set{} tbl.1 tbl.3 tbl.1 nil +set tbl.1 tbl.3 false string +set{} tbl.1 tbl.4 tbl.1 nil +set{} tbl.1 tbl.5 tbl.1 nil +set{}{} tbl.1 tbl.6 tbl.1 nil +set-nil tbl.1 nil tbl.1 nil +set{__} tbl.1 tbl.7 tbl.1 nil +set{} tbl.1 tbl.7 false string +set-nil tbl.1 tbl.7 false string +set{} tbl.8 tbl.9 tbl.8 nil +set-nil tbl.8 nil tbl.8 nil +set{__} tbl.8 abc tbl.8 nil +set{} tbl.8 abc false string +set-nil tbl.8 abc false string +t.a 1234 +t.b 1235 +t.a 1234 +t.b 1235 +t.c 1236 +t.a 1234 +t.b 1235 +t.c 1236 +t.d 1237 +metatabletests result: true +------------ huge tables +#t= 100 t[1,50,51,59] 1 1 1 1 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +#t2= 70 t[1,50,51,59] 1 1 1 1 +0,3,4,7,9,8,12,15,23,5,10,13,14,17,19,18,112,115,123,15,20,33,24,27,29,28,212,215,223,25,40,43,44,47,49,48,412,415,423,45,50,53,54,57,59,58,512,515,523,55,60,63,64,67,69,68,612,615,623,65,70,73,74,77,79,78,72,715,723,75 +t[2000] a +t[2001] b +t[2002] c +t[2003] d +t[2004] e +t[2005] f +t[2006] g +t[2007] h +t[2008] i +t[2009] j +t[3000] a +t[3001] b +t[3002] c +t[3003] d +t[3004] e +t[3005] f +t[3006] g +t[3007] h +t[3008] i +t[3009] j +t[4000] a +t[4001] b +t[4002] c +t[4003] d +t[4004] e +t[4005] f +t[4006] g +t[4007] h +t[4008] i +t[4009] j +t[5000] a +t[5001] b +t[5002] c +t[5003] d +t[5004] e +t[5005] f +t[5006] g +t[5007] h +t[5008] i +t[5009] j +t[6000] a +t[6001] b +t[6002] c +t[6003] d +t[6004] e +t[6005] f +t[6006] g +t[6007] h +t[6008] i +t[6009] j +t[7000] a +t[7001] b +t[7002] c +t[7003] d +t[7004] e +t[7005] f +t[7006] g +t[7007] h +t[7008] i +t[7009] j +t[8000] a +t[8001] b +t[8002] c +t[8003] d +t[8004] e +t[8005] f +t[8006] g +t[8007] h +t[8008] i +t[8009] j +hugetables result: true +--------- many locals +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +a a +b b +c c +d d +e e +f f +g g +h h +i i +j j +manylocals result: true diff --git a/luaj-test/src/test/resources/errors/args.out b/luaj-test/src/test/resources/errors/args.out deleted file mode 100644 index e69de29b..00000000 diff --git a/luaj-test/src/test/resources/errors/baselibargs.out b/luaj-test/src/test/resources/errors/jse/baselibargs.out similarity index 91% rename from luaj-test/src/test/resources/errors/baselibargs.out rename to luaj-test/src/test/resources/errors/jse/baselibargs.out index 102fe749..c33d242c 100644 --- a/luaj-test/src/test/resources/errors/baselibargs.out +++ b/luaj-test/src/test/resources/errors/jse/baselibargs.out @@ -58,30 +58,6 @@ --- checkallpass - load(,nil) - load(,'abc') ---- checkallerrors -- load(nil,nil) ...bad argument... -needcheck load('abc',nil) nil -needcheck load(1.25,nil) nil -- load(true,nil) ...bad argument... -- load(,nil) ...bad argument... -- load(,nil) ...bad argument... -- load(nil,'abc') ...bad argument... -needcheck load('abc','abc') nil -needcheck load(1.25,'abc') nil -- load(true,'abc') ...bad argument... -- load(
,'abc') ...bad argument... -- load(,'abc') ...bad argument... -- load(nil,1.25) ...bad argument... -needcheck load('abc',1.25) nil -needcheck load(1.25,1.25) nil -- load(true,1.25) ...bad argument... -- load(
,1.25) ...bad argument... -- load(,1.25) ...bad argument... ---- checkallerrors -- load(,) ...bad argument... -- load(,
) ...bad argument... -====== loadfile ====== -====== load ====== --- checkallpass - load('return') --- checkallpass @@ -89,24 +65,44 @@ needcheck load(1.25,1.25) nil --- checkallpass - load('return a ... b','mychunk') nil,string --- checkallerrors +- load(,true) ...bad argument... +- load(,
) ...bad argument... +- load(,) ...bad argument... +- load(,) ...bad argument... +--- checkallerrors - load(nil,nil) ...bad argument... - load(true,nil) ...bad argument... - load(
,nil) ...bad argument... -needcheck load(,nil) function: 0x10011ba00 - load(,nil) ...bad argument... -- load(nil,'abc') ...bad argument... -- load(true,'abc') ...bad argument... -- load(
,'abc') ...bad argument... -needcheck load(,'abc') function: 0x10011c780 -- load(,'abc') ...bad argument... -- load(nil,1.25) ...bad argument... -- load(true,1.25) ...bad argument... -- load(
,1.25) ...bad argument... -needcheck load(,1.25) function: 0x10011d560 -- load(,1.25) ...bad argument... +- load(nil,true) ...bad argument... +- load(true,true) ...bad argument... +- load(
,true) ...bad argument... +- load(,true) ...bad argument... +- load(nil,
) ...bad argument... +- load(true,
) ...bad argument... +- load(
,
) ...bad argument... +- load(,
) ...bad argument... +- load(nil,) ...bad argument... +- load(true,) ...bad argument... +- load(
,) ...bad argument... +- load(,) ...bad argument... +- load(nil,) ...bad argument... +- load(true,) ...bad argument... +- load(
,) ...bad argument... +- load(,) ...bad argument... --- checkallerrors -- load('return',) ...bad argument... +- load('return',true) ...bad argument... - load('return',
) ...bad argument... +- load('return',) ...bad argument... +- load('return',) ...bad argument... +====== loadfile ====== +--- checkallpass +- loadfile('args.lua') +--- checkallerrors +- loadfile(true) ...bad argument... +- loadfile(
) ...bad argument... +- loadfile() ...bad argument... +- loadfile() ...bad argument... ====== next ====== --- checkallpass - next(
,'aa') @@ -382,8 +378,8 @@ true - select() ...bad argument... ====== setmetatable ====== --- checkallpass +- setmetatable(
,nil)
- setmetatable(
,
)
---- checkallpass --- checkallerrors - setmetatable(nil,
) ...bad argument... - setmetatable('abc',
) ...bad argument... @@ -414,12 +410,15 @@ true - tonumber(
,nil) - tonumber(,nil) - tonumber(,nil) +--- checkallpass - tonumber('abc',10) - tonumber(1.25,10) -fail tonumber(true,10) 'bad argument #1 to '_G.tonumber' (string expected, got boolean)' -fail tonumber(
,10) 'bad argument #1 to '_G.tonumber' (string expected, got table)' -fail tonumber(,10) 'bad argument #1 to '_G.tonumber' (string expected, got function)' -fail tonumber(,10) 'bad argument #1 to '_G.tonumber' (string expected, got thread)' +--- checkallerrors +- tonumber(nil,10) ...bad argument... +- tonumber(true,10) ...bad argument... +- tonumber(
,10) ...bad argument... +- tonumber(,10) ...bad argument... +- tonumber(,10) ...bad argument... --- checkallerrors - tonumber(nil,2) ...bad argument... - tonumber(,2) ...bad argument... diff --git a/luaj-test/src/test/resources/errors/coroutinelibargs.out b/luaj-test/src/test/resources/errors/jse/coroutinelibargs.out similarity index 100% rename from luaj-test/src/test/resources/errors/coroutinelibargs.out rename to luaj-test/src/test/resources/errors/jse/coroutinelibargs.out diff --git a/luaj-test/src/test/resources/errors/debuglibargs.out b/luaj-test/src/test/resources/errors/jse/debuglibargs.out similarity index 94% rename from luaj-test/src/test/resources/errors/debuglibargs.out rename to luaj-test/src/test/resources/errors/jse/debuglibargs.out index 66698f0b..d1284532 100644 --- a/luaj-test/src/test/resources/errors/debuglibargs.out +++ b/luaj-test/src/test/resources/errors/jse/debuglibargs.out @@ -8,9 +8,9 @@ - debug.getinfo(25) - debug.getinfo('25') --- checkallpass -- debug.getinfo()
-- debug.getinfo(25) -- debug.getinfo('25') +- debug.getinfo(,)
+- debug.getinfo(,25) +- debug.getinfo(,'25') --- checkallpass - debug.getinfo(,'')
- debug.getinfo(25,'') @@ -22,9 +22,15 @@ - debug.getinfo(25,'flnStu') - debug.getinfo('25','flnStu') --- checkallpass -fail debug.getinfo('') 'bad argument #1 to 'debug.getinfo' (function or level expected)' -fail debug.getinfo('n') 'bad argument #1 to 'debug.getinfo' (function or level expected)' -fail debug.getinfo('flnStu') 'bad argument #1 to 'debug.getinfo' (function or level expected)' +- debug.getinfo(,,'')
+- debug.getinfo(,25,'') +- debug.getinfo(,'25','') +- debug.getinfo(,,'n')
+- debug.getinfo(,25,'n') +- debug.getinfo(,'25','n') +- debug.getinfo(,,'flnStu')
+- debug.getinfo(,25,'flnStu') +- debug.getinfo(,'25','flnStu') --- checkallerrors - debug.getinfo() ...function or level... --- checkallerrors @@ -48,7 +54,7 @@ fail debug.getinfo('flnStu') 'bad argument #1 to 'debug.getinfo' (function or l - debug.getinfo(
,,'abc') ...string expected... - debug.getinfo(,,'abc') ...string expected... --- checkallerrors -badmsg debug.getinfo('qzQZ') template='invalid option' actual='bad argument #1 to 'debug.getinfo' (function or level expected)' +- debug.getinfo(,,'qzQZ') ...invalid option... ====== debug.getlocal ====== f: x,y,a,b,p,q 1 2 nil nil p q --- checkallpass @@ -310,47 +316,47 @@ p,q abc abc --- checkallpass - debug.traceback() 'stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:127: in main chunk [C]: in ?' --- checkallpass - debug.traceback('abc') 'abc stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:128: in main chunk [C]: in ?' --- checkallpass - debug.traceback('abc',1.25) 'abc stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:129: in main chunk [C]: in ?' --- checkallpass - debug.traceback() 'stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:130: in main chunk [C]: in ?' --- checkallpass - debug.traceback(,'abc') 'abc stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:131: in main chunk [C]: in ?' --- checkallpass - debug.traceback(,'abc',1.25) 'abc stack traceback: [C]: in function 'pcall' - args.lua:143: in function 'invoke' - args.lua:167: in function 'checkallpass' + args.lua:144: in function 'invoke' + args.lua:168: in function 'checkallpass' debuglibargs.lua:132: in main chunk [C]: in ?' --- checkallpass diff --git a/luaj-test/src/test/resources/errors/iolibargs.out b/luaj-test/src/test/resources/errors/jse/iolibargs.out similarity index 99% rename from luaj-test/src/test/resources/errors/iolibargs.out rename to luaj-test/src/test/resources/errors/jse/iolibargs.out index e0603df4..9f146f27 100644 --- a/luaj-test/src/test/resources/errors/iolibargs.out +++ b/luaj-test/src/test/resources/errors/jse/iolibargs.out @@ -24,7 +24,6 @@ --- checkallerrors - io.lines() ...bad argument... --- checkallerrors -needcheck io.lines(nil) function: 0x100112cf0 - io.lines(true) ...bad argument... - io.lines(
) ...bad argument... - io.lines() ...bad argument... diff --git a/luaj-test/src/test/resources/errors/mathlibargs.out b/luaj-test/src/test/resources/errors/jse/mathlibargs.out similarity index 100% rename from luaj-test/src/test/resources/errors/mathlibargs.out rename to luaj-test/src/test/resources/errors/jse/mathlibargs.out diff --git a/luaj-test/src/test/resources/errors/modulelibargs.out b/luaj-test/src/test/resources/errors/jse/modulelibargs.out similarity index 57% rename from luaj-test/src/test/resources/errors/modulelibargs.out rename to luaj-test/src/test/resources/errors/jse/modulelibargs.out index 65071399..c6e55f37 100644 --- a/luaj-test/src/test/resources/errors/modulelibargs.out +++ b/luaj-test/src/test/resources/errors/jse/modulelibargs.out @@ -23,11 +23,11 @@ - package.loadlib() ...bad argument... ====== package.seeall ====== --- checkallpass -fail package.seeall(
) 'attempt to call a nil value' +- package.seeall(
) --- checkallerrors -badmsg package.seeall(nil) template='bad argument' actual='attempt to call a nil value' -badmsg package.seeall('abc') template='bad argument' actual='attempt to call a nil value' -badmsg package.seeall(1.25) template='bad argument' actual='attempt to call a nil value' -badmsg package.seeall(true) template='bad argument' actual='attempt to call a nil value' -badmsg package.seeall() template='bad argument' actual='attempt to call a nil value' -badmsg package.seeall() template='bad argument' actual='attempt to call a nil value' +- package.seeall(nil) ...bad argument... +- package.seeall('abc') ...bad argument... +- package.seeall(1.25) ...bad argument... +- package.seeall(true) ...bad argument... +- package.seeall() ...bad argument... +- package.seeall() ...bad argument... diff --git a/luaj-test/src/test/resources/errors/operators.out b/luaj-test/src/test/resources/errors/jse/operators.out similarity index 98% rename from luaj-test/src/test/resources/errors/operators.out rename to luaj-test/src/test/resources/errors/jse/operators.out index 126f0c69..2e244967 100644 --- a/luaj-test/src/test/resources/errors/operators.out +++ b/luaj-test/src/test/resources/errors/jse/operators.out @@ -14,7 +14,6 @@ - lengthop(
) 0 --- checkallerrors - lengthop(nil) ...attempt to get length of... -needcheck lengthop('abc') 3 - lengthop(1.25) ...attempt to get length of... - lengthop(true) ...attempt to get length of... - lengthop() ...attempt to get length of... @@ -564,43 +563,35 @@ needcheck lengthop('abc') 3 - bracketop(
,) --- checkallerrors - bracketop(nil,'abc') ...attempt to index... -needcheck bracketop('abc','abc') nil - bracketop(1.25,'abc') ...attempt to index... - bracketop(true,'abc') ...attempt to index... - bracketop(,'abc') ...attempt to index... - bracketop(,'abc') ...attempt to index... - bracketop(nil,1.25) ...attempt to index... -needcheck bracketop('abc',1.25) nil - bracketop(1.25,1.25) ...attempt to index... - bracketop(true,1.25) ...attempt to index... - bracketop(,1.25) ...attempt to index... - bracketop(,1.25) ...attempt to index... - bracketop(nil,true) ...attempt to index... -needcheck bracketop('abc',true) nil - bracketop(1.25,true) ...attempt to index... - bracketop(true,true) ...attempt to index... - bracketop(,true) ...attempt to index... - bracketop(,true) ...attempt to index... - bracketop(nil,
) ...attempt to index... -needcheck bracketop('abc',
) nil - bracketop(1.25,
) ...attempt to index... - bracketop(true,
) ...attempt to index... - bracketop(,
) ...attempt to index... - bracketop(,
) ...attempt to index... - bracketop(nil,) ...attempt to index... -needcheck bracketop('abc',) nil - bracketop(1.25,) ...attempt to index... - bracketop(true,) ...attempt to index... - bracketop(,) ...attempt to index... - bracketop(,) ...attempt to index... - bracketop(nil,) ...attempt to index... -needcheck bracketop('abc',) nil - bracketop(1.25,) ...attempt to index... - bracketop(true,) ...attempt to index... - bracketop(,) ...attempt to index... - bracketop(,) ...attempt to index... ---- checkallerrors -needcheck bracketop(
) nil ====== . ====== --- checkallpass - dotop(
,'abc') @@ -611,43 +602,35 @@ needcheck bracketop(
) nil - dotop(
,) --- checkallerrors - dotop(nil,'abc') ...attempt to index... -needcheck dotop('abc','abc') nil - dotop(1.25,'abc') ...attempt to index... - dotop(true,'abc') ...attempt to index... - dotop(,'abc') ...attempt to index... - dotop(,'abc') ...attempt to index... - dotop(nil,1.25) ...attempt to index... -needcheck dotop('abc',1.25) nil - dotop(1.25,1.25) ...attempt to index... - dotop(true,1.25) ...attempt to index... - dotop(,1.25) ...attempt to index... - dotop(,1.25) ...attempt to index... - dotop(nil,true) ...attempt to index... -needcheck dotop('abc',true) nil - dotop(1.25,true) ...attempt to index... - dotop(true,true) ...attempt to index... - dotop(,true) ...attempt to index... - dotop(,true) ...attempt to index... - dotop(nil,
) ...attempt to index... -needcheck dotop('abc',
) nil - dotop(1.25,
) ...attempt to index... - dotop(true,
) ...attempt to index... - dotop(,
) ...attempt to index... - dotop(,
) ...attempt to index... - dotop(nil,) ...attempt to index... -needcheck dotop('abc',) nil - dotop(1.25,) ...attempt to index... - dotop(true,) ...attempt to index... - dotop(,) ...attempt to index... - dotop(,) ...attempt to index... - dotop(nil,) ...attempt to index... -needcheck dotop('abc',) nil - dotop(1.25,) ...attempt to index... - dotop(true,) ...attempt to index... - dotop(,) ...attempt to index... - dotop(,) ...attempt to index... ---- checkallerrors -needcheck dotop(
) nil ====== and ====== --- checkallpass - andop(nil,nil) diff --git a/luaj-test/src/test/resources/errors/stringlibargs.out b/luaj-test/src/test/resources/errors/jse/stringlibargs.out similarity index 98% rename from luaj-test/src/test/resources/errors/stringlibargs.out rename to luaj-test/src/test/resources/errors/jse/stringlibargs.out index d02c7bd1..46108ea1 100644 Binary files a/luaj-test/src/test/resources/errors/stringlibargs.out and b/luaj-test/src/test/resources/errors/jse/stringlibargs.out differ diff --git a/luaj-test/src/test/resources/errors/tablelibargs.out b/luaj-test/src/test/resources/errors/jse/tablelibargs.out similarity index 100% rename from luaj-test/src/test/resources/errors/tablelibargs.out rename to luaj-test/src/test/resources/errors/jse/tablelibargs.out