Simplify layout of lua test script locations.
This commit is contained in:
@@ -23,11 +23,11 @@ abstract public class AbstractUnitTests extends TestCase {
|
||||
private final String jar;
|
||||
private LuaTable _G;
|
||||
|
||||
public AbstractUnitTests(String zipfile, String dir) {
|
||||
public AbstractUnitTests(String zipdir, String zipfile, String dir) {
|
||||
URL zip = null;
|
||||
zip = getClass().getResource(zipfile);
|
||||
if ( zip == null ) {
|
||||
File file = new File("test/junit/org/luaj/vm2/compiler/"+zipfile);
|
||||
File file = new File(zipdir+"/"+zipfile);
|
||||
try {
|
||||
if ( file.exists() )
|
||||
zip = file.toURI().toURL();
|
||||
@@ -71,7 +71,7 @@ abstract public class AbstractUnitTests extends TestCase {
|
||||
String actual = protoToString(p);
|
||||
|
||||
// load expected value from jar
|
||||
byte[] luac = bytesFromJar(path + "c");
|
||||
byte[] luac = bytesFromJar(path.substring(0, path.length()-4)+".lc");
|
||||
Prototype e = loadFromBytes(luac, file);
|
||||
String expected = protoToString(e);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ package org.luaj.vm2.compiler;
|
||||
public class CompilerUnitTests extends AbstractUnitTests {
|
||||
|
||||
public CompilerUnitTests() {
|
||||
super("lua5.2.1-tests.zip", "lua5.2.1-tests");
|
||||
super("test/lua", "luaj3.0-tests.zip", "lua5.2.1-tests");
|
||||
}
|
||||
|
||||
public void testAll() { doTest("all.lua"); }
|
||||
|
||||
@@ -17,8 +17,7 @@ package org.luaj.vm2.compiler;
|
||||
public class RegressionTests extends AbstractUnitTests {
|
||||
|
||||
public RegressionTests() {
|
||||
super( "regressions.zip",
|
||||
"regressions" );
|
||||
super( "test/lua", "luaj3.0-tests.zip", "regressions" );
|
||||
}
|
||||
|
||||
public void testModulo() { doTest("modulo.lua"); }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -196,7 +196,7 @@ public class LuaJavaCoercionTest extends TestCase {
|
||||
public void testExceptionMessage() {
|
||||
String script = "local c = luajava.bindClass( \""+SomeClass.class.getName()+"\" )\n" +
|
||||
"return pcall( c.someMethod, c )";
|
||||
Varargs vresult = _G.get("loadstring").call(LuaValue.valueOf(script)).invoke(LuaValue.NONE);
|
||||
Varargs vresult = _G.get("load").call(LuaValue.valueOf(script)).invoke(LuaValue.NONE);
|
||||
LuaValue status = vresult.arg1();
|
||||
LuaValue message = vresult.arg(2);
|
||||
assertEquals( LuaValue.FALSE, status );
|
||||
@@ -206,7 +206,7 @@ public class LuaJavaCoercionTest extends TestCase {
|
||||
|
||||
public void testLuaErrorCause() {
|
||||
String script = "luajava.bindClass( \""+SomeClass.class.getName()+"\"):someMethod()";
|
||||
LuaValue chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
|
||||
LuaValue chunk = _G.get("load").call(LuaValue.valueOf(script));
|
||||
try {
|
||||
chunk.invoke(LuaValue.NONE);
|
||||
fail( "call should not have succeeded" );
|
||||
@@ -235,7 +235,7 @@ public class LuaJavaCoercionTest extends TestCase {
|
||||
" ) or '-nil')\n" +
|
||||
" end,\n" +
|
||||
"} )\n";
|
||||
Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
|
||||
Varargs chunk = _G.get("load").call(LuaValue.valueOf(script));
|
||||
if ( ! chunk.arg1().toboolean() )
|
||||
fail( chunk.arg(2).toString() );
|
||||
LuaValue result = chunk.arg1().call();
|
||||
@@ -260,7 +260,7 @@ public class LuaJavaCoercionTest extends TestCase {
|
||||
//"print(bigNumB:toString())\n" +
|
||||
//"print(bigNumC:toString())\n" +
|
||||
"return bigNumA:toString(), bigNumB:toString(), bigNumC:toString()";
|
||||
Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
|
||||
Varargs chunk = _G.get("load").call(LuaValue.valueOf(script));
|
||||
if ( ! chunk.arg1().toboolean() )
|
||||
fail( chunk.arg(2).toString() );
|
||||
Varargs results = chunk.arg1().invoke();
|
||||
@@ -345,7 +345,7 @@ public class LuaJavaCoercionTest extends TestCase {
|
||||
"local b = a:set(a:get"+typename+"())\n" +
|
||||
"local c = a:setr(a:get"+typename+"())\n" +
|
||||
"return b,c";
|
||||
Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
|
||||
Varargs chunk = _G.get("load").call(LuaValue.valueOf(script));
|
||||
if ( ! chunk.arg1().toboolean() )
|
||||
fail( chunk.arg(2).toString() );
|
||||
Varargs results = chunk.arg1().invoke();
|
||||
|
||||
Reference in New Issue
Block a user