Improve error reporting.

This commit is contained in:
James Roseborough
2010-05-15 21:56:29 +00:00
parent a6a06776fb
commit 3a21941e57
7 changed files with 121 additions and 106 deletions

View File

@@ -21,7 +21,11 @@
******************************************************************************/
package org.luaj.vm2;
import java.io.IOException;
import java.io.InputStream;
import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.BaseLib;
/**
@@ -42,7 +46,14 @@ public class ErrorsTest extends ScriptDrivenTest {
super.setUp();
}
public void testBaseLibArgs() { runTest("baselibargs"); }
public void testBaseLibArgs() {
BaseLib.instance.STDIN = new InputStream() {
public int read() throws IOException {
return -1;
}
};
runTest("baselibargs");
}
public void testCoroutineLibArgs() { runTest("coroutinelibargs"); }
public void testIoLibArgs() { runTest("iolibargs"); }
public void testMathLibArgs() { runTest("mathlibargs"); }

View File

@@ -68,13 +68,13 @@ public class ScriptDrivenTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
initGlobals();
}
// */
protected void runTest(String testName) {
try {
// override print()
initGlobals();
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final PrintStream oldps = BaseLib.instance.STDOUT;
final PrintStream ps = new PrintStream( output );