From 83eedc10a5d15f2e3ae0c3b9a737d52e68f45fc1 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Thu, 21 Aug 2008 14:52:14 +0000 Subject: [PATCH] Optionally write test chunks to files. --- .../luaj/compiler/DumpLoadEndianIntTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/luaj/compiler/DumpLoadEndianIntTest.java b/src/test/java/org/luaj/compiler/DumpLoadEndianIntTest.java index b4400a82..8ef6b3cf 100644 --- a/src/test/java/org/luaj/compiler/DumpLoadEndianIntTest.java +++ b/src/test/java/org/luaj/compiler/DumpLoadEndianIntTest.java @@ -2,6 +2,7 @@ package org.luaj.compiler; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -62,9 +63,9 @@ public class DumpLoadEndianIntTest extends TestCase { // dump into bytes ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DumpState.dump(p, baos, false, intNumbers, littleEndian); + DumpState.dump(p, baos, stripDebug, intNumbers, littleEndian); byte[] dumped = baos.toByteArray(); - + // load again using compiler is = new ByteArrayInputStream(dumped); vm.load(is, "dumped"); @@ -72,6 +73,18 @@ public class DumpLoadEndianIntTest extends TestCase { actual = vm.poplvalue().toJavaString(); assertEquals( expected, actual ); + // write test chunk + if ( System.getProperty("SAVECHUNKS") != null ) { + String filename = "test-" + +(littleEndian? "little-": "big-") + +(intNumbers? "int-": "double-") + +(stripDebug? "nodebug-": "debug-") + +"bin.lua"; + FileOutputStream fos = new FileOutputStream(filename); + fos.write( dumped ); + fos.close(); + } + } catch (IOException e) { fail(e.toString()); }