1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/BytesLoader.java Sun Dec 16 20:17:06 2012 +0100
1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/BytesLoader.java Sun Dec 16 20:48:21 2012 +0100
1.3 @@ -33,6 +33,21 @@
1.4 if (!requested.add(name)) {
1.5 throw new IllegalStateException("Requested for second time: " + name);
1.6 }
1.7 + byte[] arr = readClass(name);
1.8 + /*
1.9 + System.err.print("loader['" + name + "'] = [");
1.10 + for (int i = 0; i < arr.length; i++) {
1.11 + if (i > 0) {
1.12 + System.err.print(", ");
1.13 + }
1.14 + System.err.print(arr[i]);
1.15 + }
1.16 + System.err.println("]");
1.17 + */
1.18 + return arr;
1.19 + }
1.20 +
1.21 + static byte[] readClass(String name) throws IOException {
1.22 InputStream is = BytesLoader.class.getClassLoader().getResourceAsStream(name);
1.23 if (is == null) {
1.24 throw new IOException("Can't find " + name);
1.25 @@ -46,16 +61,6 @@
1.26 }
1.27 offset += len;
1.28 }
1.29 - /*
1.30 - System.err.print("loader['" + name + "'] = [");
1.31 - for (int i = 0; i < arr.length; i++) {
1.32 - if (i > 0) {
1.33 - System.err.print(", ");
1.34 - }
1.35 - System.err.print(arr[i]);
1.36 - }
1.37 - System.err.println("]");
1.38 - */
1.39 return arr;
1.40 }
1.41
2.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/VMinVMTest.java Sun Dec 16 20:17:06 2012 +0100
2.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/VMinVMTest.java Sun Dec 16 20:48:21 2012 +0100
2.3 @@ -20,7 +20,6 @@
2.4 import java.io.File;
2.5 import java.io.FileWriter;
2.6 import java.io.IOException;
2.7 -import java.io.InputStream;
2.8 import static org.testng.Assert.*;
2.9 import javax.script.Invocable;
2.10 import org.testng.annotations.BeforeClass;
2.11 @@ -36,13 +35,13 @@
2.12 private static Invocable code;
2.13
2.14 @Test public void compareGeneratedCodeForArrayClass() throws Exception {
2.15 - compareCode("/org/apidesign/vm4brwsr/Array.class");
2.16 + compareCode("org/apidesign/vm4brwsr/Array.class");
2.17 }
2.18
2.19 @Test public void compareGeneratedCodeForClassesClass() throws Exception {
2.20 - compareCode("/org/apidesign/vm4brwsr/Classes.class");
2.21 + compareCode("org/apidesign/vm4brwsr/Classes.class");
2.22 }
2.23 -
2.24 +
2.25 @BeforeClass
2.26 public void compileTheCode() throws Exception {
2.27 StringBuilder sb = new StringBuilder();
2.28 @@ -52,20 +51,8 @@
2.29 codeSeq = sb;
2.30 }
2.31
2.32 - private static byte[] readClass(String res) throws IOException {
2.33 - InputStream is1 = VMinVMTest.class.getResourceAsStream(res);
2.34 - assertNotNull(is1, "Stream found");
2.35 - byte[] arr = new byte[is1.available()];
2.36 - int len = is1.read(arr);
2.37 - is1.close();
2.38 - if (len != arr.length) {
2.39 - throw new IOException("Wrong len " + len + " for arr: " + arr.length);
2.40 - }
2.41 - return arr;
2.42 - }
2.43 -
2.44 private void compareCode(final String nm) throws Exception, IOException {
2.45 - byte[] arr = readClass(nm);
2.46 + byte[] arr = BytesLoader.readClass(nm);
2.47 String ret1 = VMinVM.toJavaScript(arr);
2.48
2.49 Object ret;