From 251e055594091054e4a2b6ff1f2be3810e2853ec Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Sat, 6 Oct 2007 18:48:37 +0000 Subject: [PATCH] Fix StrLib test case by fixing pcall to restore currenct call after exceptions --- src/main/java/lua/debug/DebugStackState.java | 5 +++++ src/test/java/lua/LuaJTest.java | 18 +++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/lua/debug/DebugStackState.java b/src/main/java/lua/debug/DebugStackState.java index fc4c57a8..29926db5 100644 --- a/src/main/java/lua/debug/DebugStackState.java +++ b/src/main/java/lua/debug/DebugStackState.java @@ -52,6 +52,11 @@ public class DebugStackState extends StackState implements DebugRequestListener public DebugStackState() { } + protected void debugAssert(boolean b) { + if ( ! b ) + error( "assert failure" ); + } + public void addDebugEventListener(DebugEventListener listener) { if (!debugEventListeners.contains(listener)) { debugEventListeners.add(listener); diff --git a/src/test/java/lua/LuaJTest.java b/src/test/java/lua/LuaJTest.java index 62cdb301..74e1a9d2 100644 --- a/src/test/java/lua/LuaJTest.java +++ b/src/test/java/lua/LuaJTest.java @@ -5,9 +5,9 @@ import java.io.InputStream; import java.io.OutputStream; import junit.framework.TestCase; -import lua.StackState; import lua.addon.luacompat.LuaCompat; import lua.addon.luajava.LuaJava; +import lua.debug.DebugStackState; import lua.io.Closure; import lua.io.LoadState; import lua.io.Proto; @@ -16,11 +16,6 @@ import lua.value.LValue; public class LuaJTest extends TestCase { - /* - public void testTest6() throws IOException, InterruptedException { - runTest( "test6" ); - } -/*/ public void testTest1() throws IOException, InterruptedException { runTest( "test1" ); } @@ -100,7 +95,7 @@ public class LuaJTest extends TestCase { public void testUpvalues2() throws IOException, InterruptedException { runTest( "upvalues2" ); } - //*/ + private void runTest( String testName ) throws IOException, InterruptedException { // Reset the _G table just in case some test mucks with it @@ -113,7 +108,7 @@ public class LuaJTest extends TestCase { LuaCompat.install(); // new lua state - StackState state = new StackState(); + StackState state = new DebugStackState(); // load the file Proto p = loadScriptResource( state, testName ); @@ -162,13 +157,14 @@ public class LuaJTest extends TestCase { is.close(); } } else { - InputStream script = getClass().getResourceAsStream( "/" + testName + ".luac" ); - if ( script == null ) { + InputStream script; +// 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 { return collectProcessOutput( new String[] { "lua", "-" }, script ); } finally {