Now that compiler is integrated, change LuaJTest to load source files when
pre-compiled script is missing.
This commit is contained in:
@@ -64,6 +64,10 @@ public class LuaJTest extends TestCase {
|
|||||||
runTest( "compare" );
|
runTest( "compare" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMathLib() throws IOException, InterruptedException {
|
||||||
|
runTest( "mathlib" );
|
||||||
|
}
|
||||||
|
|
||||||
public void testMetatables() throws IOException, InterruptedException {
|
public void testMetatables() throws IOException, InterruptedException {
|
||||||
runTest( "metatables" );
|
runTest( "metatables" );
|
||||||
}
|
}
|
||||||
@@ -107,7 +111,7 @@ public class LuaJTest extends TestCase {
|
|||||||
StackState state = new StackState();
|
StackState state = new StackState();
|
||||||
|
|
||||||
// load the file
|
// load the file
|
||||||
Proto p = loadScriptResource( state, testName, "/" + testName + ".luac" );
|
Proto p = loadScriptResource( state, testName );
|
||||||
|
|
||||||
// Replace System.out with a ByteArrayOutputStream
|
// Replace System.out with a ByteArrayOutputStream
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
@@ -127,12 +131,19 @@ public class LuaJTest extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Proto loadScriptResource( StackState state, String name, String path ) throws IOException {
|
private Proto loadScriptResource( StackState state, String name ) throws IOException {
|
||||||
InputStream compiledScript = getClass().getResourceAsStream( path );
|
InputStream script = getClass().getResourceAsStream( "/"+name+".luac" );
|
||||||
|
if ( script == null ) {
|
||||||
|
script = getClass().getResourceAsStream( "/"+name+".lua" );
|
||||||
|
if ( script == null ) {
|
||||||
|
fail( "Could not load script for test case: "+name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return LoadState.undump(state, compiledScript, name);
|
return LoadState.undump(state, script, name);
|
||||||
} finally {
|
} finally {
|
||||||
compiledScript.close();
|
script.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +158,12 @@ public class LuaJTest extends TestCase {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
InputStream script = getClass().getResourceAsStream( "/" + testName + ".luac" );
|
InputStream script = getClass().getResourceAsStream( "/" + testName + ".luac" );
|
||||||
|
if ( script == null ) {
|
||||||
|
script = getClass().getResourceAsStream( "/" + testName + ".lua" );
|
||||||
|
if ( script == null ) {
|
||||||
|
fail( "Could not find script for test case: "+testName );
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return collectProcessOutput( new String[] { "lua", "-" }, script );
|
return collectProcessOutput( new String[] { "lua", "-" }, script );
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user