Fix StrLib test case by fixing pcall to restore currenct call after exceptions

This commit is contained in:
James Roseborough
2007-10-06 18:48:37 +00:00
parent 0353660299
commit 251e055594
2 changed files with 12 additions and 11 deletions

View File

@@ -52,6 +52,11 @@ public class DebugStackState extends StackState implements DebugRequestListener
public DebugStackState() { public DebugStackState() {
} }
protected void debugAssert(boolean b) {
if ( ! b )
error( "assert failure" );
}
public void addDebugEventListener(DebugEventListener listener) { public void addDebugEventListener(DebugEventListener listener) {
if (!debugEventListeners.contains(listener)) { if (!debugEventListeners.contains(listener)) {
debugEventListeners.add(listener); debugEventListeners.add(listener);

View File

@@ -5,9 +5,9 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import junit.framework.TestCase; import junit.framework.TestCase;
import lua.StackState;
import lua.addon.luacompat.LuaCompat; import lua.addon.luacompat.LuaCompat;
import lua.addon.luajava.LuaJava; import lua.addon.luajava.LuaJava;
import lua.debug.DebugStackState;
import lua.io.Closure; import lua.io.Closure;
import lua.io.LoadState; import lua.io.LoadState;
import lua.io.Proto; import lua.io.Proto;
@@ -16,11 +16,6 @@ import lua.value.LValue;
public class LuaJTest extends TestCase { public class LuaJTest extends TestCase {
/*
public void testTest6() throws IOException, InterruptedException {
runTest( "test6" );
}
/*/
public void testTest1() throws IOException, InterruptedException { public void testTest1() throws IOException, InterruptedException {
runTest( "test1" ); runTest( "test1" );
} }
@@ -100,7 +95,7 @@ public class LuaJTest extends TestCase {
public void testUpvalues2() throws IOException, InterruptedException { public void testUpvalues2() throws IOException, InterruptedException {
runTest( "upvalues2" ); runTest( "upvalues2" );
} }
//*/
private void runTest( String testName ) throws IOException, InterruptedException { private void runTest( String testName ) throws IOException, InterruptedException {
// Reset the _G table just in case some test mucks with it // Reset the _G table just in case some test mucks with it
@@ -113,7 +108,7 @@ public class LuaJTest extends TestCase {
LuaCompat.install(); LuaCompat.install();
// new lua state // new lua state
StackState state = new StackState(); StackState state = new DebugStackState();
// load the file // load the file
Proto p = loadScriptResource( state, testName ); Proto p = loadScriptResource( state, testName );
@@ -162,13 +157,14 @@ public class LuaJTest extends TestCase {
is.close(); is.close();
} }
} else { } else {
InputStream script = getClass().getResourceAsStream( "/" + testName + ".luac" ); InputStream script;
if ( script == null ) { // script = getClass().getResourceAsStream( "/" + testName + ".luac" );
// if ( script == null ) {
script = getClass().getResourceAsStream( "/" + testName + ".lua" ); script = getClass().getResourceAsStream( "/" + testName + ".lua" );
if ( script == null ) { if ( script == null ) {
fail( "Could not find script for test case: "+testName ); 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 {