Add basic jit tests.
This commit is contained in:
@@ -27,13 +27,92 @@ public class LuaJitBasicTest extends TestCase {
|
|||||||
stringTest( "print( 'hello, world' )" );
|
stringTest( "print( 'hello, world' )" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testForLoop() throws IOException {
|
public void testForInDoEnd() throws IOException {
|
||||||
stringTest( "print 'starting'\n" +
|
}
|
||||||
"for i=1,3 do\n" +
|
|
||||||
|
public void testForIEqualsDoEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"print 'starting'\n" +
|
||||||
|
"for i=1,5,2 do\n" +
|
||||||
" print( 'i', i )\n" +
|
" print( 'i', i )\n" +
|
||||||
"end");
|
"end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRepeatUntil() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"local i=7" +
|
||||||
|
"repeat\n"+
|
||||||
|
" print(i)\n"+
|
||||||
|
"until i\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWhileDoEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"local i=4" +
|
||||||
|
"while i>0 do\n"+
|
||||||
|
" print( i )\n"+
|
||||||
|
" i = i-1\n"+
|
||||||
|
"end\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testForIEqualsDoBreakEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"print 'starting'\n" +
|
||||||
|
"for i=1,5,2 do\n" +
|
||||||
|
" print( 'i', i )\n" +
|
||||||
|
" break\n" +
|
||||||
|
"end");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRepeatUntilBreak() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"local i=7" +
|
||||||
|
"repeat\n"+
|
||||||
|
" print(i)\n"+
|
||||||
|
" break\n"+
|
||||||
|
"until i\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWhileDoBreak() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"local i=4" +
|
||||||
|
"while i>0 do\n"+
|
||||||
|
" print( i )\n"+
|
||||||
|
" break\n"+
|
||||||
|
" i = i-1\n"+
|
||||||
|
"end\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIfThenEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"if a then\n" +
|
||||||
|
" print(1)\n" +
|
||||||
|
"end\n" +
|
||||||
|
"print(2)\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIfThenElseEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"if a then\n" +
|
||||||
|
" print(1)\n" +
|
||||||
|
"else\n" +
|
||||||
|
" print(2)\n" +
|
||||||
|
"end\n" +
|
||||||
|
"print(3)\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIfThenElseifElseEnd() throws IOException {
|
||||||
|
stringTest(
|
||||||
|
"if a then\n" +
|
||||||
|
" print(1)\n" +
|
||||||
|
"elseif b then \n" +
|
||||||
|
" print(2)\n" +
|
||||||
|
"else\n" +
|
||||||
|
" print(3)\n" +
|
||||||
|
"end\n" +
|
||||||
|
"print(4)\n" );
|
||||||
|
}
|
||||||
|
|
||||||
private void stringTest(String program) throws IOException {
|
private void stringTest(String program) throws IOException {
|
||||||
InputStream is = new ByteArrayInputStream(program.getBytes());
|
InputStream is = new ByteArrayInputStream(program.getBytes());
|
||||||
LPrototype p = LuaC.compile(is, "program");
|
LPrototype p = LuaC.compile(is, "program");
|
||||||
|
|||||||
Reference in New Issue
Block a user