Moving the VM compatibility tests to emul.compact model
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 28 Apr 2013 10:26:08 +0200
branchmodel
changeset 103428dc692f3b11
parent 1033 b8773b7b9ecd
child 1035 23cc80f969d7
Moving the VM compatibility tests to emul.compact
rt/emul/compact/pom.xml
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt
rt/vmtest/pom.xml
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java
rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java
rt/vmtest/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe
rt/vmtest/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt
     1.1 --- a/rt/emul/compact/pom.xml	Sun Apr 28 10:14:31 2013 +0200
     1.2 +++ b/rt/emul/compact/pom.xml	Sun Apr 28 10:26:08 2013 +0200
     1.3 @@ -28,6 +28,12 @@
     1.4        <scope>test</scope>
     1.5      </dependency>
     1.6      <dependency>
     1.7 +      <groupId>${project.groupId}</groupId>
     1.8 +      <artifactId>launcher.http</artifactId>
     1.9 +      <version>${project.version}</version>
    1.10 +      <scope>test</scope>
    1.11 +    </dependency>
    1.12 +    <dependency>
    1.13        <groupId>org.netbeans.api</groupId>
    1.14        <artifactId>org-openide-util-lookup</artifactId>
    1.15        <scope>test</scope>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java	Sun Apr 28 10:26:08 2013 +0200
     2.3 @@ -0,0 +1,43 @@
     2.4 +/**
     2.5 + * Back 2 Browser Bytecode Translator
     2.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.7 + *
     2.8 + * This program is free software: you can redistribute it and/or modify
     2.9 + * it under the terms of the GNU General Public License as published by
    2.10 + * the Free Software Foundation, version 2 of the License.
    2.11 + *
    2.12 + * This program is distributed in the hope that it will be useful,
    2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 + * GNU General Public License for more details.
    2.16 + *
    2.17 + * You should have received a copy of the GNU General Public License
    2.18 + * along with this program. Look for COPYING file in the top folder.
    2.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    2.20 + */
    2.21 +package org.apidesign.bck2brwsr.tck;
    2.22 +
    2.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    2.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    2.25 +import org.testng.annotations.Factory;
    2.26 +
    2.27 +/**
    2.28 + *
    2.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    2.30 + */
    2.31 +public class AssertionTest {
    2.32 +
    2.33 +    @Compare public Object checkAssert() throws ClassNotFoundException {
    2.34 +        try {
    2.35 +            assert false : "Is assertion status on?";
    2.36 +            return null;
    2.37 +        } catch (AssertionError ex) {
    2.38 +            return ex.getClass().getName();
    2.39 +        }
    2.40 +    }
    2.41 +    
    2.42 +    @Factory
    2.43 +    public static Object[] create() {
    2.44 +        return VMTest.create(AssertionTest.class);
    2.45 +    }
    2.46 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java	Sun Apr 28 10:26:08 2013 +0200
     3.3 @@ -0,0 +1,57 @@
     3.4 +/**
     3.5 + * Back 2 Browser Bytecode Translator
     3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     3.7 + *
     3.8 + * This program is free software: you can redistribute it and/or modify
     3.9 + * it under the terms of the GNU General Public License as published by
    3.10 + * the Free Software Foundation, version 2 of the License.
    3.11 + *
    3.12 + * This program is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + * GNU General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU General Public License
    3.18 + * along with this program. Look for COPYING file in the top folder.
    3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    3.20 + */
    3.21 +package org.apidesign.bck2brwsr.tck;
    3.22 +
    3.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
    3.24 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    3.25 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
    3.26 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    3.27 +import org.testng.annotations.Factory;
    3.28 +
    3.29 +/**
    3.30 + *
    3.31 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    3.32 + */
    3.33 +public class BrwsrCheckTest {
    3.34 +
    3.35 +    @BrwsrTest public void assertWindowObjectIsDefined() {
    3.36 +        assert window() != null : "No window object found!";
    3.37 +    }
    3.38 +
    3.39 +    
    3.40 +    
    3.41 +    
    3.42 +    @HtmlFragment("<h1 id='hello'>\n"
    3.43 +        + "Hello!\n"
    3.44 +        + "</h1>\n")
    3.45 +    @BrwsrTest public void accessProvidedFragment() {
    3.46 +        assert getElementById("hello") != null : "Element with 'hello' ID found";
    3.47 +    }
    3.48 +    
    3.49 +    @Factory
    3.50 +    public static Object[] create() {
    3.51 +        return VMTest.create(BrwsrCheckTest.class);
    3.52 +    }
    3.53 +    
    3.54 +
    3.55 +    @JavaScriptBody(args = {}, body = "return window;")
    3.56 +    private static native Object window();
    3.57 +
    3.58 +    @JavaScriptBody(args = { "id" }, body = "return window.document.getElementById(id);")
    3.59 +    private static native Object getElementById(String id);
    3.60 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java	Sun Apr 28 10:26:08 2013 +0200
     4.3 @@ -0,0 +1,147 @@
     4.4 +/**
     4.5 + * Back 2 Browser Bytecode Translator
     4.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     4.7 + *
     4.8 + * This program is free software: you can redistribute it and/or modify
     4.9 + * it under the terms of the GNU General Public License as published by
    4.10 + * the Free Software Foundation, version 2 of the License.
    4.11 + *
    4.12 + * This program is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 + * GNU General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU General Public License
    4.18 + * along with this program. Look for COPYING file in the top folder.
    4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    4.20 + */
    4.21 +package org.apidesign.bck2brwsr.tck;
    4.22 +
    4.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
    4.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
    4.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    4.26 +import org.testng.annotations.Factory;
    4.27 +
    4.28 +/**
    4.29 + *
    4.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    4.31 + */
    4.32 +public class ByteArithmeticTest {
    4.33 +    
    4.34 +    private static byte add(byte x, byte y) {
    4.35 +        return (byte)(x + y);
    4.36 +    }
    4.37 +    
    4.38 +    private static byte sub(byte x, byte y) {
    4.39 +        return (byte)(x - y);
    4.40 +    }
    4.41 +    
    4.42 +    private static byte mul(byte x, byte y) {
    4.43 +        return (byte)(x * y);
    4.44 +    }
    4.45 +    
    4.46 +    private static byte div(byte x, byte y) {
    4.47 +        return (byte)(x / y);
    4.48 +    }
    4.49 +    
    4.50 +    private static byte mod(byte x, byte y) {
    4.51 +        return (byte)(x % y);
    4.52 +    }
    4.53 +    
    4.54 +    @Compare public byte conversion() {
    4.55 +        return (byte)123456;
    4.56 +    }
    4.57 +    
    4.58 +    @Compare public byte addOverflow() {
    4.59 +        return add(Byte.MAX_VALUE, (byte)1);
    4.60 +    }
    4.61 +    
    4.62 +    @Compare public byte subUnderflow() {
    4.63 +        return sub(Byte.MIN_VALUE, (byte)1);
    4.64 +    }
    4.65 +    
    4.66 +    @Compare public byte addMaxByteAndMaxByte() {
    4.67 +        return add(Byte.MAX_VALUE, Byte.MAX_VALUE);
    4.68 +    }
    4.69 +    
    4.70 +    @Compare public byte subMinByteAndMinByte() {
    4.71 +        return sub(Byte.MIN_VALUE, Byte.MIN_VALUE);
    4.72 +    }
    4.73 +    
    4.74 +    @Compare public byte multiplyMaxByte() {
    4.75 +        return mul(Byte.MAX_VALUE, (byte)2);
    4.76 +    }
    4.77 +    
    4.78 +    @Compare public byte multiplyMaxByteAndMaxByte() {
    4.79 +        return mul(Byte.MAX_VALUE, Byte.MAX_VALUE);
    4.80 +    }
    4.81 +    
    4.82 +    @Compare public byte multiplyMinByte() {
    4.83 +        return mul(Byte.MIN_VALUE, (byte)2);
    4.84 +    }
    4.85 +    
    4.86 +    @Compare public byte multiplyMinByteAndMinByte() {
    4.87 +        return mul(Byte.MIN_VALUE, Byte.MIN_VALUE);
    4.88 +    }
    4.89 +    
    4.90 +    @Compare public byte multiplyPrecision() {
    4.91 +        return mul((byte)17638, (byte)1103);
    4.92 +    }
    4.93 +    
    4.94 +    @Compare public byte division() {
    4.95 +        return div((byte)1, (byte)2);
    4.96 +    }
    4.97 +    
    4.98 +    @Compare public byte divisionReminder() {
    4.99 +        return mod((byte)1, (byte)2);
   4.100 +    }
   4.101 +
   4.102 +    private static int readShort(byte[] byteCodes, int offset) {
   4.103 +        int signed = byteCodes[offset];
   4.104 +        byte b0 = (byte)signed;
   4.105 +        return (b0 << 8) | (byteCodes[offset + 1] & 0xff);
   4.106 +    }
   4.107 +    
   4.108 +    private static int readShortArg(byte[] byteCodes, int offsetInstruction) {
   4.109 +        return readShort(byteCodes, offsetInstruction + 1);
   4.110 +    }
   4.111 +    
   4.112 +    @Compare public int readIntArgs255and156() {
   4.113 +        final byte[] arr = new byte[] { (byte)0, (byte)255, (byte)156 };
   4.114 +        
   4.115 +        assert arr[1] == -1 : "First byte: " + arr[1];
   4.116 +        assert arr[2] == -100 : "Second byte: " + arr[2];
   4.117 +        final int ret = readShortArg(arr, 0);
   4.118 +        assert ret < 65000: "Value: " + ret;
   4.119 +        return ret;
   4.120 +    }
   4.121 +    
   4.122 +    @JavaScriptBody(args = { "arr" }, body = "arr[1] = 255; arr[2] = 156; return arr;")
   4.123 +    private static byte[] fill255and156(byte[] arr) {
   4.124 +        arr[1] = (byte)255;
   4.125 +        arr[2] = (byte)156;
   4.126 +        return arr;
   4.127 +    }
   4.128 +
   4.129 +    @Compare public int readIntArgs255and156JSArray() {
   4.130 +        final byte[] arr = fill255and156(new byte[] { 0, 0, 0 });
   4.131 +        
   4.132 +        final int ret = readShortArg(arr, 0);
   4.133 +        assert ret < 65000: "Value: " + ret;
   4.134 +        return ret;
   4.135 +    }
   4.136 +    
   4.137 +    @Compare public int readIntArgsMinus1andMinus100() {
   4.138 +        final byte[] arr = new byte[] { (byte)0, (byte)-1, (byte)-100 };
   4.139 +        
   4.140 +        assert arr[1] == -1 : "First byte: " + arr[1];
   4.141 +        assert arr[2] == -100 : "Second byte: " + arr[2];
   4.142 +        
   4.143 +        return readShortArg(arr, 0);
   4.144 +    }
   4.145 +    
   4.146 +    @Factory
   4.147 +    public static Object[] create() {
   4.148 +        return VMTest.create(ByteArithmeticTest.class);
   4.149 +    }
   4.150 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Sun Apr 28 10:26:08 2013 +0200
     5.3 @@ -0,0 +1,73 @@
     5.4 +/**
     5.5 + * Back 2 Browser Bytecode Translator
     5.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     5.7 + *
     5.8 + * This program is free software: you can redistribute it and/or modify
     5.9 + * it under the terms of the GNU General Public License as published by
    5.10 + * the Free Software Foundation, version 2 of the License.
    5.11 + *
    5.12 + * This program is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 + * GNU General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU General Public License
    5.18 + * along with this program. Look for COPYING file in the top folder.
    5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    5.20 + */
    5.21 +package org.apidesign.bck2brwsr.tck;
    5.22 +
    5.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    5.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    5.25 +import org.testng.annotations.Factory;
    5.26 +
    5.27 +/**
    5.28 + *
    5.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    5.30 + */
    5.31 +public class CloneTest {
    5.32 +    private int value;
    5.33 +    
    5.34 +    @Compare
    5.35 +    public Object notSupported() throws CloneNotSupportedException {
    5.36 +        return this.clone();
    5.37 +    }
    5.38 +
    5.39 +    @Compare public String sameClass() throws CloneNotSupportedException {
    5.40 +        return new Clnbl().clone().getClass().getName();
    5.41 +    }
    5.42 +
    5.43 +    @Compare public boolean differentInstance() throws CloneNotSupportedException {
    5.44 +        Clnbl orig = new Clnbl();
    5.45 +        return orig == orig.clone();
    5.46 +    }
    5.47 +
    5.48 +    @Compare public int sameReference() throws CloneNotSupportedException {
    5.49 +        CloneTest self = this;
    5.50 +        Clnbl orig = new Clnbl();
    5.51 +        self.value = 33;
    5.52 +        orig.ref = self;
    5.53 +        return ((Clnbl)orig.clone()).ref.value;
    5.54 +    }
    5.55 +
    5.56 +    @Compare public int sameValue() throws CloneNotSupportedException {
    5.57 +        Clnbl orig = new Clnbl();
    5.58 +        orig.value = 10;
    5.59 +        return ((Clnbl)orig.clone()).value;
    5.60 +    }
    5.61 +    
    5.62 +    @Factory
    5.63 +    public static Object[] create() {
    5.64 +        return VMTest.create(CloneTest.class);
    5.65 +    }
    5.66 +    
    5.67 +    public static final class Clnbl implements Cloneable {
    5.68 +        public CloneTest ref;
    5.69 +        private int value;
    5.70 +
    5.71 +        @Override
    5.72 +        public Object clone() throws CloneNotSupportedException {
    5.73 +            return super.clone();
    5.74 +        }
    5.75 +    }
    5.76 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java	Sun Apr 28 10:26:08 2013 +0200
     6.3 @@ -0,0 +1,103 @@
     6.4 +/**
     6.5 + * Back 2 Browser Bytecode Translator
     6.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     6.7 + *
     6.8 + * This program is free software: you can redistribute it and/or modify
     6.9 + * it under the terms of the GNU General Public License as published by
    6.10 + * the Free Software Foundation, version 2 of the License.
    6.11 + *
    6.12 + * This program is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 + * GNU General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU General Public License
    6.18 + * along with this program. Look for COPYING file in the top folder.
    6.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    6.20 + */
    6.21 +package org.apidesign.bck2brwsr.tck;
    6.22 +
    6.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    6.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    6.25 +import org.testng.annotations.Factory;
    6.26 +
    6.27 +/**
    6.28 + *
    6.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    6.30 + */
    6.31 +public class CompareByteArrayTest {
    6.32 +    @Compare public int byteArraySum() {
    6.33 +        byte[] arr = createArray();
    6.34 +        return sumByteArr(arr);
    6.35 +    }
    6.36 +    
    6.37 +    @Compare public int countZeros() {
    6.38 +        int zeros = 0;
    6.39 +        for (Byte b : createArray()) {
    6.40 +            if (b == 0) {
    6.41 +                zeros++;
    6.42 +            }
    6.43 +        }
    6.44 +        return zeros;
    6.45 +    }
    6.46 +    
    6.47 +    private static int sumByteArr(byte[] arr) {
    6.48 +        int sum = 0;
    6.49 +        for (int i = 0; i < arr.length; i++) {
    6.50 +            sum += arr[i];
    6.51 +        }
    6.52 +        return sum;
    6.53 +    }
    6.54 +    
    6.55 +    @Compare public String noOutOfBounds() {
    6.56 +        return atIndex(1);
    6.57 +    }
    6.58 +
    6.59 +    @Compare public String outOfBounds() {
    6.60 +        return atIndex(5);
    6.61 +    }
    6.62 +
    6.63 +    @Compare public String outOfBoundsMinus() {
    6.64 +        return atIndex(-1);
    6.65 +    }
    6.66 +
    6.67 +    @Compare public String toOfBounds() {
    6.68 +        return toIndex(5);
    6.69 +    }
    6.70 +
    6.71 +    @Compare public String toOfBoundsMinus() {
    6.72 +        return toIndex(-1);
    6.73 +    }
    6.74 +    
    6.75 +    @Compare public int multiArrayLength() {
    6.76 +         int[][] arr = new int[1][0];
    6.77 +         return arr[0].length;
    6.78 +    }
    6.79 +
    6.80 +    @Compare public int multiObjectArrayLength() {
    6.81 +         Object[][] arr = new Object[1][0];
    6.82 +         return arr[0].length;
    6.83 +    }
    6.84 +
    6.85 +    private static final int[] arr = { 0, 1, 2 };
    6.86 +    public static String atIndex(int at) {
    6.87 +        return "at@" + arr[at];
    6.88 +    }
    6.89 +    public static String toIndex(int at) {
    6.90 +        arr[at] = 10;
    6.91 +        return "ok";
    6.92 +    }
    6.93 +    
    6.94 +    
    6.95 +    @Factory
    6.96 +    public static Object[] create() {
    6.97 +        return VMTest.create(CompareByteArrayTest.class);
    6.98 +    }
    6.99 +
   6.100 +    private byte[] createArray() {
   6.101 +        byte[] arr = new byte[10];
   6.102 +        arr[5] = 3;
   6.103 +        arr[7] = 8;
   6.104 +        return arr;
   6.105 +    }
   6.106 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java	Sun Apr 28 10:26:08 2013 +0200
     7.3 @@ -0,0 +1,50 @@
     7.4 +/**
     7.5 + * Back 2 Browser Bytecode Translator
     7.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     7.7 + *
     7.8 + * This program is free software: you can redistribute it and/or modify
     7.9 + * it under the terms of the GNU General Public License as published by
    7.10 + * the Free Software Foundation, version 2 of the License.
    7.11 + *
    7.12 + * This program is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 + * GNU General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU General Public License
    7.18 + * along with this program. Look for COPYING file in the top folder.
    7.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    7.20 + */
    7.21 +package org.apidesign.bck2brwsr.tck;
    7.22 +
    7.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    7.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    7.25 +import org.testng.annotations.Factory;
    7.26 +
    7.27 +/**
    7.28 + *
    7.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    7.30 + */
    7.31 +public class CompareHashTest {
    7.32 +    @Compare public int hashOfString() {
    7.33 +        return "Ahoj".hashCode();
    7.34 +    }
    7.35 +    
    7.36 +    @Compare public int hashRemainsYieldsZero() {
    7.37 +        Object o = new Object();
    7.38 +        return o.hashCode() - o.hashCode();
    7.39 +    }
    7.40 +    
    7.41 +    @Compare public int initializeInStatic() {
    7.42 +        return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode();
    7.43 +    }
    7.44 +    
    7.45 +    @Compare public int hashOfInt() {
    7.46 +        return Integer.valueOf(Integer.MAX_VALUE).hashCode();
    7.47 +    }
    7.48 +    
    7.49 +    @Factory
    7.50 +    public static Object[] create() {
    7.51 +        return VMTest.create(CompareHashTest.class);
    7.52 +    }
    7.53 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java	Sun Apr 28 10:26:08 2013 +0200
     8.3 @@ -0,0 +1,63 @@
     8.4 +/**
     8.5 + * Back 2 Browser Bytecode Translator
     8.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     8.7 + *
     8.8 + * This program is free software: you can redistribute it and/or modify
     8.9 + * it under the terms of the GNU General Public License as published by
    8.10 + * the Free Software Foundation, version 2 of the License.
    8.11 + *
    8.12 + * This program is distributed in the hope that it will be useful,
    8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.15 + * GNU General Public License for more details.
    8.16 + *
    8.17 + * You should have received a copy of the GNU General Public License
    8.18 + * along with this program. Look for COPYING file in the top folder.
    8.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    8.20 + */
    8.21 +package org.apidesign.bck2brwsr.tck;
    8.22 +
    8.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    8.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    8.25 +import org.testng.annotations.Factory;
    8.26 +
    8.27 +/**
    8.28 + *
    8.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    8.30 + */
    8.31 +public class CompareIntArrayTest {
    8.32 +    @Compare public int integerArraySum() {
    8.33 +        int[] arr = createArray();
    8.34 +        return sumIntArr(arr);
    8.35 +    }
    8.36 +    
    8.37 +    @Compare public int countZeros() {
    8.38 +        int zeros = 0;
    8.39 +        for (Integer i : createArray()) {
    8.40 +            if (i == 0) {
    8.41 +                zeros++;
    8.42 +            }
    8.43 +        }
    8.44 +        return zeros;
    8.45 +    }
    8.46 +    
    8.47 +    private static int sumIntArr(int[] arr) {
    8.48 +        int sum = 0;
    8.49 +        for (int i = 0; i < arr.length; i++) {
    8.50 +            sum += arr[i];
    8.51 +        }
    8.52 +        return sum;
    8.53 +    }
    8.54 +    
    8.55 +    @Factory
    8.56 +    public static Object[] create() {
    8.57 +        return VMTest.create(CompareIntArrayTest.class);
    8.58 +    }
    8.59 +
    8.60 +    private int[] createArray() {
    8.61 +        int[] arr = new int[10];
    8.62 +        arr[5] = 3;
    8.63 +        arr[7] = 8;
    8.64 +        return arr;
    8.65 +    }
    8.66 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java	Sun Apr 28 10:26:08 2013 +0200
     9.3 @@ -0,0 +1,174 @@
     9.4 +/**
     9.5 + * Back 2 Browser Bytecode Translator
     9.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     9.7 + *
     9.8 + * This program is free software: you can redistribute it and/or modify
     9.9 + * it under the terms of the GNU General Public License as published by
    9.10 + * the Free Software Foundation, version 2 of the License.
    9.11 + *
    9.12 + * This program is distributed in the hope that it will be useful,
    9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.15 + * GNU General Public License for more details.
    9.16 + *
    9.17 + * You should have received a copy of the GNU General Public License
    9.18 + * along with this program. Look for COPYING file in the top folder.
    9.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    9.20 + */
    9.21 +package org.apidesign.bck2brwsr.tck;
    9.22 +
    9.23 +import java.io.UnsupportedEncodingException;
    9.24 +import java.net.MalformedURLException;
    9.25 +import java.net.URL;
    9.26 +import org.apidesign.bck2brwsr.vmtest.Compare;
    9.27 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    9.28 +import org.testng.annotations.Factory;
    9.29 +
    9.30 +/**
    9.31 + *
    9.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    9.33 + */
    9.34 +public class CompareStringsTest {
    9.35 +    @Compare public String firstChar() {
    9.36 +        return "" + ("Hello".toCharArray()[0]);
    9.37 +    }
    9.38 +    
    9.39 +    @Compare public String classCast() {
    9.40 +        Object o = firstChar();
    9.41 +        return String.class.cast(o);
    9.42 +    }
    9.43 +
    9.44 +    @Compare public String classCastThrown() {
    9.45 +        Object o = null;
    9.46 +        return String.class.cast(o);
    9.47 +    }
    9.48 +    
    9.49 +    @Compare public boolean equalToNull() {
    9.50 +        return "Ahoj".equals(null);
    9.51 +    }
    9.52 +    
    9.53 +    @Compare public int highByteLenght() {
    9.54 +        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
    9.55 +        return new String(arr, 0).length();
    9.56 +    }
    9.57 +    
    9.58 +    @Compare public String highByte() {
    9.59 +        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
    9.60 +        StringBuilder sb = new StringBuilder();
    9.61 +        sb.append("pref:");
    9.62 +        sb.append(new String(arr, 0));
    9.63 +        return sb.toString();
    9.64 +    }
    9.65 +    
    9.66 +    @Compare public static Object compareURLs() throws MalformedURLException {
    9.67 +        return new URL("http://apidesign.org:8080/wiki/").toExternalForm().toString();
    9.68 +    }
    9.69 +    
    9.70 +    @Compare public String deleteLastTwoCharacters() {
    9.71 +        StringBuilder sb = new StringBuilder();
    9.72 +        sb.append("453.0");
    9.73 +        if (sb.toString().endsWith(".0")) {
    9.74 +            final int l = sb.length();
    9.75 +            sb.delete(l - 2, l);
    9.76 +        }
    9.77 +        return sb.toString().toString();
    9.78 +    }
    9.79 +    
    9.80 +    @Compare public String nameOfStringClass() throws Exception {
    9.81 +        return Class.forName("java.lang.String").getName();
    9.82 +    }
    9.83 +    @Compare public String nameOfArrayClass() throws Exception {
    9.84 +        return Class.forName("org.apidesign.bck2brwsr.tck.CompareHashTest").getName();
    9.85 +    }
    9.86 +    
    9.87 +    @Compare public String lowerHello() {
    9.88 +        return "HeLlO".toLowerCase();
    9.89 +    }
    9.90 +    
    9.91 +    @Compare public String lowerA() {
    9.92 +        return String.valueOf(Character.toLowerCase('A')).toString();
    9.93 +    }
    9.94 +    @Compare public String upperHello() {
    9.95 +        return "hello".toUpperCase();
    9.96 +    }
    9.97 +    
    9.98 +    @Compare public String upperA() {
    9.99 +        return String.valueOf(Character.toUpperCase('a')).toString();
   9.100 +    }
   9.101 +    
   9.102 +    @Compare public boolean matchRegExp() throws Exception {
   9.103 +        return "58038503".matches("\\d*");
   9.104 +    }
   9.105 +
   9.106 +    @Compare public boolean doesNotMatchRegExp() throws Exception {
   9.107 +        return "58038503GH".matches("\\d*");
   9.108 +    }
   9.109 +
   9.110 +    @Compare public boolean doesNotMatchRegExpFully() throws Exception {
   9.111 +        return "Hello".matches("Hell");
   9.112 +    }
   9.113 +    
   9.114 +    @Compare public String emptyCharArray() {
   9.115 +        char[] arr = new char[10];
   9.116 +        return new String(arr);
   9.117 +    }
   9.118 +    
   9.119 +    @Compare public String variousCharacterTests() throws Exception {
   9.120 +        StringBuilder sb = new StringBuilder();
   9.121 +        
   9.122 +        sb.append(Character.isUpperCase('a'));
   9.123 +        sb.append(Character.isUpperCase('A'));
   9.124 +        sb.append(Character.isLowerCase('a'));
   9.125 +        sb.append(Character.isLowerCase('A'));
   9.126 +        
   9.127 +        sb.append(Character.isLetter('A'));
   9.128 +        sb.append(Character.isLetterOrDigit('9'));
   9.129 +        sb.append(Character.isLetterOrDigit('A'));
   9.130 +        sb.append(Character.isLetter('0'));
   9.131 +        
   9.132 +        return sb.toString().toString();
   9.133 +    }
   9.134 +        
   9.135 +    @Compare
   9.136 +    public String nullFieldInitialized() {
   9.137 +        NullField nf = new NullField();
   9.138 +        return ("" + nf.name).toString();
   9.139 +    }
   9.140 +    @Compare
   9.141 +    public String toUTFString() throws UnsupportedEncodingException {
   9.142 +        byte[] arr = {
   9.143 +            (byte) -59, (byte) -67, (byte) 108, (byte) 117, (byte) -59, (byte) -91,
   9.144 +            (byte) 111, (byte) 117, (byte) -60, (byte) -115, (byte) 107, (byte) -61,
   9.145 +            (byte) -67, (byte) 32, (byte) 107, (byte) -59, (byte) -81, (byte) -59,
   9.146 +            (byte) -120
   9.147 +        };
   9.148 +        return new String(arr, "utf-8");
   9.149 +    }
   9.150 +
   9.151 +    @Compare
   9.152 +    public int stringToBytesLenght() throws UnsupportedEncodingException {
   9.153 +        return "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148".getBytes("utf8").length;
   9.154 +    }
   9.155 +    
   9.156 +    @Compare public String replaceSeq() {
   9.157 +        return "Hello World.".replace(".", "!");
   9.158 +    }
   9.159 +    @Compare public String replaceSeqAll() {
   9.160 +        return "Hello World! Hello World.".replace("World", "Jarda");
   9.161 +    }
   9.162 +    @Compare public String replaceSeqAA() {
   9.163 +        String res = "aaa".replace("aa", "b");
   9.164 +        assert res.equals("ba") : "Expecting ba: " + res;
   9.165 +        return res;
   9.166 +    }
   9.167 +
   9.168 +    @Factory
   9.169 +    public static Object[] create() {
   9.170 +        return VMTest.create(CompareStringsTest.class);
   9.171 +    }
   9.172 +
   9.173 +    private static final class NullField {
   9.174 +
   9.175 +        String name;
   9.176 +    }
   9.177 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java	Sun Apr 28 10:26:08 2013 +0200
    10.3 @@ -0,0 +1,65 @@
    10.4 +/**
    10.5 + * Back 2 Browser Bytecode Translator
    10.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    10.7 + *
    10.8 + * This program is free software: you can redistribute it and/or modify
    10.9 + * it under the terms of the GNU General Public License as published by
   10.10 + * the Free Software Foundation, version 2 of the License.
   10.11 + *
   10.12 + * This program is distributed in the hope that it will be useful,
   10.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.15 + * GNU General Public License for more details.
   10.16 + *
   10.17 + * You should have received a copy of the GNU General Public License
   10.18 + * along with this program. Look for COPYING file in the top folder.
   10.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   10.20 + */
   10.21 +package org.apidesign.bck2brwsr.tck;
   10.22 +
   10.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   10.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   10.25 +import org.testng.annotations.Factory;
   10.26 +
   10.27 +/**
   10.28 + *
   10.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   10.30 + */
   10.31 +public class DoubleTest {
   10.32 +    @Compare public String integerToString() {
   10.33 +        return toStr(1);
   10.34 +    }
   10.35 +
   10.36 +    @Compare public String integerAndHalfToString() {
   10.37 +        return toStr(1.5);
   10.38 +    }
   10.39 +
   10.40 +    @Compare public double longToAndBack() {
   10.41 +        return Double.parseDouble(toStr(Long.MAX_VALUE / 10));
   10.42 +    }
   10.43 +
   10.44 +    @Compare public String negativeIntToString() {
   10.45 +        return toStr(-10);
   10.46 +    }
   10.47 +
   10.48 +    @Compare public String negativeIntAndHalfToString() {
   10.49 +        return toStr(-10.5);
   10.50 +    }
   10.51 +
   10.52 +    @Compare public double negativeLongAndBack() {
   10.53 +        return Double.parseDouble(toStr(Long.MIN_VALUE / 10));
   10.54 +    }
   10.55 +    
   10.56 +    @Compare public double canParseExp() {
   10.57 +        return Double.parseDouble(toStr(1.7976931348623157e+308));
   10.58 +    }
   10.59 +    
   10.60 +    private static String toStr(double d) {
   10.61 +        return Double.toString(d);
   10.62 +    }
   10.63 +    
   10.64 +    @Factory 
   10.65 +    public static Object[] create() {
   10.66 +        return VMTest.create(DoubleTest.class);
   10.67 +    }
   10.68 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Sun Apr 28 10:26:08 2013 +0200
    11.3 @@ -0,0 +1,106 @@
    11.4 +/**
    11.5 + * Back 2 Browser Bytecode Translator
    11.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    11.7 + *
    11.8 + * This program is free software: you can redistribute it and/or modify
    11.9 + * it under the terms of the GNU General Public License as published by
   11.10 + * the Free Software Foundation, version 2 of the License.
   11.11 + *
   11.12 + * This program is distributed in the hope that it will be useful,
   11.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.15 + * GNU General Public License for more details.
   11.16 + *
   11.17 + * You should have received a copy of the GNU General Public License
   11.18 + * along with this program. Look for COPYING file in the top folder.
   11.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   11.20 + */
   11.21 +package org.apidesign.bck2brwsr.tck;
   11.22 +
   11.23 +import java.io.InputStream;
   11.24 +import java.net.URL;
   11.25 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   11.26 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   11.27 +import org.apidesign.bck2brwsr.vmtest.Http;
   11.28 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   11.29 +import org.testng.annotations.Factory;
   11.30 +
   11.31 +/**
   11.32 + *
   11.33 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   11.34 + */
   11.35 +public class HttpResourceTest {
   11.36 +    
   11.37 +    @Http({
   11.38 +        @Http.Resource(path = "/xhr", content = "Hello Brwsr!", mimeType = "text/plain")
   11.39 +    })
   11.40 +    @BrwsrTest
   11.41 +    
   11.42 +    
   11.43 +    public String testReadContentViaXHR() throws Exception {
   11.44 +        String msg = read("/xhr");
   11.45 +        assert "Hello Brwsr!".equals(msg) : "The message was " + msg;
   11.46 +        return msg;
   11.47 +    }
   11.48 +
   11.49 +    @Http({
   11.50 +        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   11.51 +    })
   11.52 +    @BrwsrTest
   11.53 +    public String testReadContentViaURL() throws Exception {
   11.54 +        URL url = new URL("http:/url");
   11.55 +        String msg = (String) url.getContent();
   11.56 +        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   11.57 +        return msg;
   11.58 +    }
   11.59 +    @Http({
   11.60 +        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   11.61 +    })
   11.62 +    @BrwsrTest
   11.63 +    public String testReadContentViaURLWithStringParam() throws Exception {
   11.64 +        URL url = new URL("http:/url");
   11.65 +        String msg = (String) url.getContent(new Class[] { String.class });
   11.66 +        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   11.67 +        return msg;
   11.68 +    }
   11.69 +
   11.70 +    @Http({
   11.71 +        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   11.72 +    })
   11.73 +    @BrwsrTest
   11.74 +    public void testReadByte() throws Exception {
   11.75 +        URL url = new URL("http:/bytes");
   11.76 +        final Object res = url.getContent(new Class[] { byte[].class });
   11.77 +        assert res instanceof byte[] : "Expecting byte[]: " + res;
   11.78 +        byte[] arr = (byte[]) res;
   11.79 +        assert arr.length == 1 : "One byte " + arr.length;
   11.80 +        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   11.81 +    }
   11.82 +
   11.83 +    @Http({
   11.84 +        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   11.85 +    })
   11.86 +    @BrwsrTest
   11.87 +    public void testReadByteViaInputStream() throws Exception {
   11.88 +        URL url = new URL("http:/bytes");
   11.89 +        InputStream is = url.openStream();
   11.90 +        byte[] arr = new byte[10];
   11.91 +        int len = is.read(arr);
   11.92 +        assert len == 1 : "One byte " + len;
   11.93 +        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   11.94 +    }
   11.95 +    
   11.96 +    @JavaScriptBody(args = { "url" }, body = 
   11.97 +          "var req = new XMLHttpRequest();\n"
   11.98 +        + "req.open('GET', url, false);\n"
   11.99 +        + "req.send();\n"
  11.100 +        + "return req.responseText;"
  11.101 +    )
  11.102 +    private static native String read(String url);
  11.103 +    
  11.104 +    
  11.105 +    @Factory
  11.106 +    public static Object[] create() {
  11.107 +        return VMTest.create(HttpResourceTest.class);
  11.108 +    }
  11.109 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java	Sun Apr 28 10:26:08 2013 +0200
    12.3 @@ -0,0 +1,34 @@
    12.4 +/**
    12.5 + * Back 2 Browser Bytecode Translator
    12.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    12.7 + *
    12.8 + * This program is free software: you can redistribute it and/or modify
    12.9 + * it under the terms of the GNU General Public License as published by
   12.10 + * the Free Software Foundation, version 2 of the License.
   12.11 + *
   12.12 + * This program is distributed in the hope that it will be useful,
   12.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.15 + * GNU General Public License for more details.
   12.16 + *
   12.17 + * You should have received a copy of the GNU General Public License
   12.18 + * along with this program. Look for COPYING file in the top folder.
   12.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   12.20 + */
   12.21 +package org.apidesign.bck2brwsr.tck;
   12.22 +
   12.23 +/**
   12.24 + *
   12.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   12.26 + */
   12.27 +public class InheritanceA {
   12.28 +    private String name;
   12.29 +    
   12.30 +    public void setA(String n) {
   12.31 +        this.name = n;
   12.32 +    }
   12.33 +    
   12.34 +    public String getA() {
   12.35 +        return name;
   12.36 +    }
   12.37 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java	Sun Apr 28 10:26:08 2013 +0200
    13.3 @@ -0,0 +1,34 @@
    13.4 +/**
    13.5 + * Back 2 Browser Bytecode Translator
    13.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    13.7 + *
    13.8 + * This program is free software: you can redistribute it and/or modify
    13.9 + * it under the terms of the GNU General Public License as published by
   13.10 + * the Free Software Foundation, version 2 of the License.
   13.11 + *
   13.12 + * This program is distributed in the hope that it will be useful,
   13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.15 + * GNU General Public License for more details.
   13.16 + *
   13.17 + * You should have received a copy of the GNU General Public License
   13.18 + * along with this program. Look for COPYING file in the top folder.
   13.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   13.20 + */
   13.21 +package org.apidesign.bck2brwsr.tck;
   13.22 +
   13.23 +/**
   13.24 + *
   13.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   13.26 + */
   13.27 +public class InheritanceB extends InheritanceA {
   13.28 +    private String name;
   13.29 +    
   13.30 +    public void setB(String n) {
   13.31 +        this.name = n;
   13.32 +    }
   13.33 +    
   13.34 +    public String getB() {
   13.35 +        return name;
   13.36 +    }
   13.37 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java	Sun Apr 28 10:26:08 2013 +0200
    14.3 @@ -0,0 +1,41 @@
    14.4 +/**
    14.5 + * Back 2 Browser Bytecode Translator
    14.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    14.7 + *
    14.8 + * This program is free software: you can redistribute it and/or modify
    14.9 + * it under the terms of the GNU General Public License as published by
   14.10 + * the Free Software Foundation, version 2 of the License.
   14.11 + *
   14.12 + * This program is distributed in the hope that it will be useful,
   14.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.15 + * GNU General Public License for more details.
   14.16 + *
   14.17 + * You should have received a copy of the GNU General Public License
   14.18 + * along with this program. Look for COPYING file in the top folder.
   14.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   14.20 + */
   14.21 +package org.apidesign.bck2brwsr.tck;
   14.22 +
   14.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   14.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   14.25 +import org.testng.annotations.Factory;
   14.26 +
   14.27 +/**
   14.28 + *
   14.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   14.30 + */
   14.31 +public class InheritanceTest {
   14.32 +
   14.33 +    @Compare public String checkFieldsIndependent() throws ClassNotFoundException {
   14.34 +        InheritanceB ib = new InheritanceB();
   14.35 +        ib.setA("A");
   14.36 +        ib.setB("B");
   14.37 +        return "A: " + ib.getA() + " B: " + ib.getB();
   14.38 +    }
   14.39 +    
   14.40 +    @Factory
   14.41 +    public static Object[] create() {
   14.42 +        return VMTest.create(InheritanceTest.class);
   14.43 +    }
   14.44 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Sun Apr 28 10:26:08 2013 +0200
    15.3 @@ -0,0 +1,166 @@
    15.4 +/**
    15.5 + * Back 2 Browser Bytecode Translator
    15.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    15.7 + *
    15.8 + * This program is free software: you can redistribute it and/or modify
    15.9 + * it under the terms of the GNU General Public License as published by
   15.10 + * the Free Software Foundation, version 2 of the License.
   15.11 + *
   15.12 + * This program is distributed in the hope that it will be useful,
   15.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.15 + * GNU General Public License for more details.
   15.16 + *
   15.17 + * You should have received a copy of the GNU General Public License
   15.18 + * along with this program. Look for COPYING file in the top folder.
   15.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   15.20 + */
   15.21 +package org.apidesign.bck2brwsr.tck;
   15.22 +
   15.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   15.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   15.25 +import org.testng.annotations.Factory;
   15.26 +
   15.27 +/**
   15.28 + *
   15.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   15.30 + */
   15.31 +public class IntegerArithmeticTest {
   15.32 +    
   15.33 +    private static int add(int x, int y) {
   15.34 +        return x + y;
   15.35 +    }
   15.36 +    
   15.37 +    private static int sub(int x, int y) {
   15.38 +        return x - y;
   15.39 +    }
   15.40 +    
   15.41 +    private static int mul(int x, int y) {
   15.42 +        return x * y;
   15.43 +    }
   15.44 +    
   15.45 +    private static int div(int x, int y) {
   15.46 +        return x / y;
   15.47 +    }
   15.48 +    
   15.49 +    private static int mod(int x, int y) {
   15.50 +        return x % y;
   15.51 +    }
   15.52 +    
   15.53 +    private static int neg(int x) {
   15.54 +        return (-x);
   15.55 +    }
   15.56 +
   15.57 +    private static float fadd(float x, float y) {
   15.58 +        return x + y;
   15.59 +    }
   15.60 +
   15.61 +    private static double dadd(double x, double y) {
   15.62 +        return x + y;
   15.63 +    }
   15.64 +    
   15.65 +    @Compare public int addOverflow() {
   15.66 +        return add(Integer.MAX_VALUE, 1);
   15.67 +    }
   15.68 +    
   15.69 +    @Compare public int subUnderflow() {
   15.70 +        return sub(Integer.MIN_VALUE, 1);
   15.71 +    }
   15.72 +    
   15.73 +    @Compare public int addMaxIntAndMaxInt() {
   15.74 +        return add(Integer.MAX_VALUE, Integer.MAX_VALUE);
   15.75 +    }
   15.76 +    
   15.77 +    @Compare public int subMinIntAndMinInt() {
   15.78 +        return sub(Integer.MIN_VALUE, Integer.MIN_VALUE);
   15.79 +    }
   15.80 +    
   15.81 +    @Compare public int multiplyMaxInt() {
   15.82 +        return mul(Integer.MAX_VALUE, 2);
   15.83 +    }
   15.84 +    
   15.85 +    @Compare public int multiplyMaxIntAndMaxInt() {
   15.86 +        return mul(Integer.MAX_VALUE, Integer.MAX_VALUE);
   15.87 +    }
   15.88 +    
   15.89 +    @Compare public int multiplyMinInt() {
   15.90 +        return mul(Integer.MIN_VALUE, 2);
   15.91 +    }
   15.92 +    
   15.93 +    @Compare public int multiplyMinIntAndMinInt() {
   15.94 +        return mul(Integer.MIN_VALUE, Integer.MIN_VALUE);
   15.95 +    }
   15.96 +    
   15.97 +    @Compare public int multiplyPrecision() {
   15.98 +        return mul(119106029, 1103515245);
   15.99 +    }
  15.100 +    
  15.101 +    @Compare public int division() {
  15.102 +        return div(1, 2);
  15.103 +    }
  15.104 +
  15.105 +    @Compare public int divisionReminder() {
  15.106 +        return mod(1, 2);
  15.107 +    }
  15.108 +
  15.109 +    @Compare public int negativeDivision() {
  15.110 +        return div(-7, 3);
  15.111 +    }
  15.112 +
  15.113 +    @Compare public int negativeDivisionReminder() {
  15.114 +        return mod(-7, 3);
  15.115 +    }
  15.116 +
  15.117 +    @Compare public int conversionFromFloat() {
  15.118 +        return (int) fadd(-2, -0.6f);
  15.119 +    }
  15.120 +
  15.121 +    @Compare public int conversionFromDouble() {
  15.122 +        return (int) dadd(-2, -0.6);
  15.123 +    }
  15.124 +
  15.125 +    @Compare public boolean divByZeroThrowsArithmeticException() {
  15.126 +        try {
  15.127 +            div(1, 0);
  15.128 +            return false;
  15.129 +        } catch (final ArithmeticException e) {
  15.130 +            return true;
  15.131 +        }
  15.132 +    }
  15.133 +
  15.134 +    @Compare public boolean modByZeroThrowsArithmeticException() {
  15.135 +        try {
  15.136 +            mod(1, 0);
  15.137 +            return false;
  15.138 +        } catch (final ArithmeticException e) {
  15.139 +            return true;
  15.140 +        }
  15.141 +    }
  15.142 +
  15.143 +    @Compare public int negate() {
  15.144 +        return neg(123456);
  15.145 +    }
  15.146 +    
  15.147 +    @Compare public int negateMaxInt() {
  15.148 +        return neg(Integer.MAX_VALUE);
  15.149 +    }
  15.150 +    
  15.151 +    @Compare public int negateMinInt() {
  15.152 +        return neg(Integer.MIN_VALUE);
  15.153 +    }
  15.154 +    
  15.155 +    @Compare public int sumTwoDimensions() {
  15.156 +        int[][] matrix = createMatrix(4, 3);
  15.157 +        matrix[0][0] += 10;
  15.158 +        return matrix[0][0];
  15.159 +    }
  15.160 +    
  15.161 +    static int[][] createMatrix(int x, int y) {
  15.162 +        return new int[x][y];
  15.163 +    }
  15.164 +    
  15.165 +    @Factory
  15.166 +    public static Object[] create() {
  15.167 +        return VMTest.create(IntegerArithmeticTest.class);
  15.168 +    }
  15.169 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Sun Apr 28 10:26:08 2013 +0200
    16.3 @@ -0,0 +1,376 @@
    16.4 +/**
    16.5 + * Back 2 Browser Bytecode Translator
    16.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    16.7 + *
    16.8 + * This program is free software: you can redistribute it and/or modify
    16.9 + * it under the terms of the GNU General Public License as published by
   16.10 + * the Free Software Foundation, version 2 of the License.
   16.11 + *
   16.12 + * This program is distributed in the hope that it will be useful,
   16.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.15 + * GNU General Public License for more details.
   16.16 + *
   16.17 + * You should have received a copy of the GNU General Public License
   16.18 + * along with this program. Look for COPYING file in the top folder.
   16.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   16.20 + */
   16.21 +package org.apidesign.bck2brwsr.tck;
   16.22 +
   16.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   16.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   16.25 +import org.testng.annotations.Factory;
   16.26 +
   16.27 +/**
   16.28 + *
   16.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   16.30 + */
   16.31 +public class LongArithmeticTest {
   16.32 +
   16.33 +    private static long add(long x, long y) {
   16.34 +        return (x + y);
   16.35 +    }
   16.36 +
   16.37 +    private static long sub(long x, long y) {
   16.38 +        return (x - y);
   16.39 +    }
   16.40 +
   16.41 +    private static long mul(long x, long y) {
   16.42 +        return (x * y);
   16.43 +    }
   16.44 +
   16.45 +    private static long div(long x, long y) {
   16.46 +        return (x / y);
   16.47 +    }
   16.48 +
   16.49 +    private static long mod(long x, long y) {
   16.50 +        return (x % y);
   16.51 +    }
   16.52 +
   16.53 +    private static long neg(long x) {
   16.54 +        return (-x);
   16.55 +    }
   16.56 +
   16.57 +    private static long shl(long x, int b) {
   16.58 +        return (x << b);
   16.59 +    }
   16.60 +
   16.61 +    private static long shr(long x, int b) {
   16.62 +        return (x >> b);
   16.63 +    }
   16.64 +
   16.65 +    private static long ushr(long x, int b) {
   16.66 +        return (x >>> b);
   16.67 +    }
   16.68 +
   16.69 +    private static long and(long x, long y) {
   16.70 +        return (x & y);
   16.71 +    }
   16.72 +
   16.73 +    private static long or(long x, long y) {
   16.74 +        return (x | y);
   16.75 +    }
   16.76 +
   16.77 +    private static long xor(long x, long y) {
   16.78 +        return (x ^ y);
   16.79 +    }
   16.80 +
   16.81 +    private static float fadd(float x, float y) {
   16.82 +        return x + y;
   16.83 +    }
   16.84 +
   16.85 +    private static double dadd(double x, double y) {
   16.86 +        return x + y;
   16.87 +    }
   16.88 +
   16.89 +    public static int compare(long x, long y, int zero) {
   16.90 +        final int xyResult = compareL(x, y, zero);
   16.91 +        final int yxResult = compareL(y, x, zero);
   16.92 +
   16.93 +        return ((xyResult + yxResult) == 0) ? xyResult : -2;
   16.94 +    }
   16.95 +
   16.96 +    private static int compareL(long x, long y, int zero) {
   16.97 +        int result = -2;
   16.98 +        int trueCount = 0;
   16.99 +
  16.100 +        x += zero;
  16.101 +        if (x == y) {
  16.102 +            result = 0;
  16.103 +            ++trueCount;
  16.104 +        }
  16.105 +
  16.106 +        x += zero;
  16.107 +        if (x < y) {
  16.108 +            result = -1;
  16.109 +            ++trueCount;
  16.110 +        }
  16.111 +
  16.112 +        x += zero;
  16.113 +        if (x > y) {
  16.114 +            result = 1;
  16.115 +            ++trueCount;
  16.116 +        }
  16.117 +
  16.118 +        return (trueCount == 1) ? result : -2;
  16.119 +    }
  16.120 +
  16.121 +    @Compare public long conversion() {
  16.122 +        return Long.MAX_VALUE;
  16.123 +    }
  16.124 +
  16.125 +    @Compare public long negate1() {
  16.126 +        return neg(0x00fa37d7763e0ca1l);
  16.127 +    }
  16.128 +
  16.129 +    @Compare public long negate2() {
  16.130 +        return neg(0x80fa37d7763e0ca1l);
  16.131 +    }
  16.132 +
  16.133 +    @Compare public long negate3() {
  16.134 +        return neg(0xfffffffffffffeddl);
  16.135 +    }
  16.136 +
  16.137 +    @Compare public long addOverflow() {
  16.138 +        return add(Long.MAX_VALUE, 1l);
  16.139 +    }
  16.140 +
  16.141 +    @Compare public long subUnderflow() {
  16.142 +        return sub(Long.MIN_VALUE, 1l);
  16.143 +    }
  16.144 +
  16.145 +    @Compare public long addMaxLongAndMaxLong() {
  16.146 +        return add(Long.MAX_VALUE, Long.MAX_VALUE);
  16.147 +    }
  16.148 +
  16.149 +    @Compare public long subMinLongAndMinLong() {
  16.150 +        return sub(Long.MIN_VALUE, Long.MIN_VALUE);
  16.151 +    }
  16.152 +
  16.153 +    @Compare public long subMinLongAndMaxLong() {
  16.154 +        return sub(Long.MIN_VALUE, Long.MAX_VALUE);
  16.155 +    }
  16.156 +
  16.157 +    @Compare public long multiplyMaxLong() {
  16.158 +        return mul(Long.MAX_VALUE, 2l);
  16.159 +    }
  16.160 +
  16.161 +    @Compare public long multiplyMaxLongAndMaxLong() {
  16.162 +        return mul(Long.MAX_VALUE, Long.MAX_VALUE);
  16.163 +    }
  16.164 +
  16.165 +    @Compare public long multiplyMinLong() {
  16.166 +        return mul(Long.MIN_VALUE, 2l);
  16.167 +    }
  16.168 +
  16.169 +    @Compare public long multiplyMinLongAndMinLong() {
  16.170 +        return mul(Long.MIN_VALUE, Long.MIN_VALUE);
  16.171 +    }
  16.172 +
  16.173 +    @Compare public long multiplyPrecision() {
  16.174 +        return mul(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  16.175 +    }
  16.176 +
  16.177 +    @Compare public long divideSmallPositiveNumbers() {
  16.178 +        return div(0xabcdef, 0x123);
  16.179 +    }
  16.180 +
  16.181 +    @Compare public long divideSmallNegativeNumbers() {
  16.182 +        return div(-0xabcdef, -0x123);
  16.183 +    }
  16.184 +
  16.185 +    @Compare public long divideSmallMixedNumbers() {
  16.186 +        return div(0xabcdef, -0x123);
  16.187 +    }
  16.188 +
  16.189 +    @Compare public long dividePositiveNumbersOneDigitDenom() {
  16.190 +        return div(0xabcdef0102ffffl, 0x654);
  16.191 +    }
  16.192 +
  16.193 +    @Compare public long divideNegativeNumbersOneDigitDenom() {
  16.194 +        return div(-0xabcdef0102ffffl, -0x654);
  16.195 +    }
  16.196 +
  16.197 +    @Compare public long divideMixedNumbersOneDigitDenom() {
  16.198 +        return div(-0xabcdef0102ffffl, 0x654);
  16.199 +    }
  16.200 +
  16.201 +    @Compare public long dividePositiveNumbersMultiDigitDenom() {
  16.202 +        return div(0x7ffefc003322aabbl, 0x89ab1000l);
  16.203 +    }
  16.204 +
  16.205 +    @Compare public long divideNegativeNumbersMultiDigitDenom() {
  16.206 +        return div(-0x7ffefc003322aabbl, -0x123489ab1001l);
  16.207 +    }
  16.208 +
  16.209 +    @Compare public long divideMixedNumbersMultiDigitDenom() {
  16.210 +        return div(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  16.211 +    }
  16.212 +
  16.213 +    @Compare public long divideWithOverflow() {
  16.214 +        return div(0x8000fffe0000l, 0x8000ffffl);
  16.215 +    }
  16.216 +
  16.217 +    @Compare public long divideWithCorrection() {
  16.218 +        return div(0x7fff800000000000l, 0x800000000001l);
  16.219 +    }
  16.220 +
  16.221 +    @Compare public long moduloSmallPositiveNumbers() {
  16.222 +        return mod(0xabcdef, 0x123);
  16.223 +    }
  16.224 +
  16.225 +    @Compare public long moduloSmallNegativeNumbers() {
  16.226 +        return mod(-0xabcdef, -0x123);
  16.227 +    }
  16.228 +
  16.229 +    @Compare public long moduloSmallMixedNumbers() {
  16.230 +        return mod(0xabcdef, -0x123);
  16.231 +    }
  16.232 +
  16.233 +    @Compare public long moduloPositiveNumbersOneDigitDenom() {
  16.234 +        return mod(0xabcdef0102ffffl, 0x654);
  16.235 +    }
  16.236 +
  16.237 +    @Compare public long moduloNegativeNumbersOneDigitDenom() {
  16.238 +        return mod(-0xabcdef0102ffffl, -0x654);
  16.239 +    }
  16.240 +
  16.241 +    @Compare public long moduloMixedNumbersOneDigitDenom() {
  16.242 +        return mod(-0xabcdef0102ffffl, 0x654);
  16.243 +    }
  16.244 +
  16.245 +    @Compare public long moduloPositiveNumbersMultiDigitDenom() {
  16.246 +        return mod(0x7ffefc003322aabbl, 0x89ab1000l);
  16.247 +    }
  16.248 +
  16.249 +    @Compare public long moduloNegativeNumbersMultiDigitDenom() {
  16.250 +        return mod(-0x7ffefc003322aabbl, -0x123489ab1001l);
  16.251 +    }
  16.252 +
  16.253 +    @Compare public long moduloMixedNumbersMultiDigitDenom() {
  16.254 +        return mod(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  16.255 +    }
  16.256 +
  16.257 +    @Compare public long moduloWithOverflow() {
  16.258 +        return mod(0x8000fffe0000l, 0x8000ffffl);
  16.259 +    }
  16.260 +
  16.261 +    @Compare public long moduloWithCorrection() {
  16.262 +        return mod(0x7fff800000000000l, 0x800000000001l);
  16.263 +    }
  16.264 +
  16.265 +    @Compare public long conversionFromFloatPositive() {
  16.266 +        return (long) fadd(2, 0.6f);
  16.267 +    }
  16.268 +
  16.269 +    @Compare public long conversionFromFloatNegative() {
  16.270 +        return (long) fadd(-2, -0.6f);
  16.271 +    }
  16.272 +
  16.273 +    @Compare public long conversionFromDoublePositive() {
  16.274 +        return (long) dadd(0x20ffff0000L, 0.6);
  16.275 +    }
  16.276 +
  16.277 +    @Compare public long conversionFromDoubleNegative() {
  16.278 +        return (long) dadd(-0x20ffff0000L, -0.6);
  16.279 +    }
  16.280 +
  16.281 +    @Compare public boolean divByZeroThrowsArithmeticException() {
  16.282 +        try {
  16.283 +            div(1, 0);
  16.284 +            return false;
  16.285 +        } catch (final ArithmeticException e) {
  16.286 +            return true;
  16.287 +        }
  16.288 +    }
  16.289 +
  16.290 +    @Compare public boolean modByZeroThrowsArithmeticException() {
  16.291 +        try {
  16.292 +            mod(1, 0);
  16.293 +            return false;
  16.294 +        } catch (final ArithmeticException e) {
  16.295 +            return true;
  16.296 +        }
  16.297 +    }
  16.298 +
  16.299 +    @Compare public long shiftL1() {
  16.300 +        return shl(0x00fa37d7763e0ca1l, 5);
  16.301 +    }
  16.302 +
  16.303 +    @Compare public long shiftL2() {
  16.304 +        return shl(0x00fa37d7763e0ca1l, 32);
  16.305 +    }
  16.306 +
  16.307 +    @Compare public long shiftL3() {
  16.308 +        return shl(0x00fa37d7763e0ca1l, 45);
  16.309 +    }
  16.310 +
  16.311 +    @Compare public long shiftR1() {
  16.312 +        return shr(0x00fa37d7763e0ca1l, 5);
  16.313 +    }
  16.314 +
  16.315 +    @Compare public long shiftR2() {
  16.316 +        return shr(0x00fa37d7763e0ca1l, 32);
  16.317 +    }
  16.318 +
  16.319 +    @Compare public long shiftR3() {
  16.320 +        return shr(0x00fa37d7763e0ca1l, 45);
  16.321 +    }
  16.322 +
  16.323 +    @Compare public long uShiftR1() {
  16.324 +        return ushr(0x00fa37d7763e0ca1l, 5);
  16.325 +    }
  16.326 +
  16.327 +    @Compare public long uShiftR2() {
  16.328 +        return ushr(0x00fa37d7763e0ca1l, 45);
  16.329 +    }
  16.330 +
  16.331 +    @Compare public long uShiftR3() {
  16.332 +        return ushr(0xf0fa37d7763e0ca1l, 5);
  16.333 +    }
  16.334 +
  16.335 +    @Compare public long uShiftR4() {
  16.336 +        return ushr(0xf0fa37d7763e0ca1l, 45);
  16.337 +    }
  16.338 +
  16.339 +    @Compare public long and1() {
  16.340 +        return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  16.341 +    }
  16.342 +
  16.343 +    @Compare public long or1() {
  16.344 +        return or(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  16.345 +    }
  16.346 +
  16.347 +    @Compare public long xor1() {
  16.348 +        return xor(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  16.349 +    }
  16.350 +
  16.351 +    @Compare public long xor2() {
  16.352 +        return xor(0x00fa37d7763e0ca1l, 0x00000000ff00123el);
  16.353 +    }
  16.354 +
  16.355 +    @Compare public long xor3() {
  16.356 +        return xor(0x00000000763e0ca1l, 0x00000000ff00123el);
  16.357 +    }
  16.358 +
  16.359 +    @Compare public int compareSameNumbers() {
  16.360 +        return compare(0x0000000000000000l, 0x0000000000000000l, 0);
  16.361 +    }
  16.362 +
  16.363 +    @Compare public int comparePositiveNumbers() {
  16.364 +        return compare(0x0000000000200000l, 0x0000000010000000l, 0);
  16.365 +    }
  16.366 +
  16.367 +    @Compare public int compareNegativeNumbers() {
  16.368 +        return compare(0xffffffffffffffffl, 0xffffffff00000000l, 0);
  16.369 +    }
  16.370 +
  16.371 +    @Compare public int compareMixedNumbers() {
  16.372 +        return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
  16.373 +    }
  16.374 +    
  16.375 +    @Factory
  16.376 +    public static Object[] create() {
  16.377 +        return VMTest.create(LongArithmeticTest.class);
  16.378 +    }
  16.379 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java	Sun Apr 28 10:26:08 2013 +0200
    17.3 @@ -0,0 +1,161 @@
    17.4 +/**
    17.5 + * Back 2 Browser Bytecode Translator
    17.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    17.7 + *
    17.8 + * This program is free software: you can redistribute it and/or modify
    17.9 + * it under the terms of the GNU General Public License as published by
   17.10 + * the Free Software Foundation, version 2 of the License.
   17.11 + *
   17.12 + * This program is distributed in the hope that it will be useful,
   17.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.15 + * GNU General Public License for more details.
   17.16 + *
   17.17 + * You should have received a copy of the GNU General Public License
   17.18 + * along with this program. Look for COPYING file in the top folder.
   17.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   17.20 + */
   17.21 +package org.apidesign.bck2brwsr.tck;
   17.22 +
   17.23 +import java.lang.reflect.Array;
   17.24 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   17.25 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   17.26 +import org.apidesign.bck2brwsr.vmtest.Compare;
   17.27 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   17.28 +import org.testng.annotations.Factory;
   17.29 +
   17.30 +/**
   17.31 + *
   17.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   17.33 + */
   17.34 +public class ReflectionArrayTest {
   17.35 +    @Compare public int lengthOfStringArray() {
   17.36 +        String[] arr = (String[]) Array.newInstance(String.class, 10);
   17.37 +        return arr.length;
   17.38 +    }
   17.39 +    
   17.40 +    @Compare public int reflectiveLengthOfStringArray() {
   17.41 +        Object arr = Array.newInstance(String.class, 10);
   17.42 +        return Array.getLength(arr);
   17.43 +    }
   17.44 +
   17.45 +    @Compare public int reflectiveLengthOneNonArray() {
   17.46 +        Object arr = "non-array";
   17.47 +        return Array.getLength(arr);
   17.48 +    }
   17.49 +
   17.50 +    @Compare public String compTypeOfStringArray() {
   17.51 +        String[] arr = (String[]) Array.newInstance(String.class, 10);
   17.52 +        return arr.getClass().getComponentType().getName();
   17.53 +    }
   17.54 +
   17.55 +    @Compare public Object negativeArrayExcp() {
   17.56 +        return Array.newInstance(String.class, -5);
   17.57 +    }
   17.58 +    
   17.59 +    @Compare public int lengthOfIntArray() {
   17.60 +        int[] arr = (int[]) Array.newInstance(Integer.TYPE, 10);
   17.61 +        return arr.length;
   17.62 +    }
   17.63 +
   17.64 +    @Compare public int reflectiveLengthOfIntArray() {
   17.65 +        Object arr = Array.newInstance(Integer.TYPE, 10);
   17.66 +        return Array.getLength(arr);
   17.67 +    }
   17.68 +
   17.69 +    @Compare public String compTypeOfIntArray() {
   17.70 +        int[] arr = (int[]) Array.newInstance(int.class, 10);
   17.71 +        return arr.getClass().getComponentType().getName();
   17.72 +    }
   17.73 +
   17.74 +    @Compare public Object intNegativeArrayExcp() {
   17.75 +        return Array.newInstance(int.class, -5);
   17.76 +    }
   17.77 +
   17.78 +    @Compare public Integer verifyAutobox() {
   17.79 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   17.80 +        return (Integer) Array.get(arr, 0);
   17.81 +    }
   17.82 +    @Compare public String verifyObjectArray() {
   17.83 +        String[] arr = (String[]) Array.newInstance(String.class, 5);
   17.84 +        Array.set(arr, 0, "Hello");
   17.85 +        return (String) Array.get(arr, 0);
   17.86 +    }
   17.87 +    @Compare public int verifyInt() {
   17.88 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   17.89 +        return Array.getInt(arr, 0);
   17.90 +    }
   17.91 +    @Compare public long verifyConvertToLong() {
   17.92 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   17.93 +        return Array.getLong(arr, 0);
   17.94 +    }
   17.95 +
   17.96 +    @Compare public Object verifySetIntToObject() {
   17.97 +        try {
   17.98 +            Object[] arr = (Object[]) Array.newInstance(Object.class, 5);
   17.99 +            Array.setInt(arr, 0, 10);
  17.100 +            return Array.get(arr, 0);
  17.101 +        } catch (Exception exception) {
  17.102 +            return exception.getClass().getName();
  17.103 +        }
  17.104 +    }
  17.105 +    @Compare public long verifySetShort() {
  17.106 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  17.107 +        Array.setShort(arr, 0, (short)10);
  17.108 +        return Array.getLong(arr, 0);
  17.109 +    }
  17.110 +    @Compare public long verifyCantSetLong() {
  17.111 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  17.112 +        Array.setLong(arr, 0, 10);
  17.113 +        return Array.getLong(arr, 0);
  17.114 +    }
  17.115 +    @Compare public float verifyLongToFloat() {
  17.116 +        Object arr = Array.newInstance(float.class, 5);
  17.117 +        Array.setLong(arr, 0, 10);
  17.118 +        return Array.getFloat(arr, 0);
  17.119 +    }
  17.120 +
  17.121 +    @Compare public double verifyConvertToDouble() {
  17.122 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  17.123 +        return Array.getDouble(arr, 0);
  17.124 +    }
  17.125 +    
  17.126 +    @Compare public int multiIntArray() {
  17.127 +        int[][][] arr = (int[][][]) Array.newInstance(int.class, 3, 3, 3);
  17.128 +        return arr[0][1][2] + 5 + arr[2][2][0];
  17.129 +    }
  17.130 +
  17.131 +    @Compare public String multiIntArrayCompType() {
  17.132 +        return Array.newInstance(int.class, 3, 3, 3).getClass().getName();
  17.133 +    }
  17.134 +    
  17.135 +    @JavaScriptBody(args = {}, body = "return [1, 2];")
  17.136 +    private static native Object crtarr();
  17.137 +
  17.138 +    @JavaScriptBody(args = {}, body = "return new Object();")
  17.139 +    private static native Object newobj();
  17.140 +
  17.141 +    @BrwsrTest
  17.142 +    public static void toStringArray() {
  17.143 +        final Object arr = crtarr();
  17.144 +        final Object real = new Object[2];
  17.145 +        assert arr instanceof Object[] : "Any array is Java array: " + arr;
  17.146 +        assert arr.getClass() == real.getClass() : "Same classes " + arr + " and " + real.getClass();
  17.147 +        final String str = arr.toString();
  17.148 +        assert str != null;
  17.149 +        assert str.startsWith("[Ljava.lang.Object;@") : str;
  17.150 +    }
  17.151 +    
  17.152 +    @BrwsrTest
  17.153 +    public static void objectToString() {
  17.154 +        String s = newobj().toString();
  17.155 +        assert s != null : "Some string computed";
  17.156 +        assert s.startsWith("java.lang.Object@") : "Regular object toString(): " + s;
  17.157 +    }
  17.158 +
  17.159 +    
  17.160 +    @Factory
  17.161 +    public static Object[] create() {
  17.162 +        return VMTest.create(ReflectionArrayTest.class);
  17.163 +    }
  17.164 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Sun Apr 28 10:26:08 2013 +0200
    18.3 @@ -0,0 +1,272 @@
    18.4 +/**
    18.5 + * Back 2 Browser Bytecode Translator
    18.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    18.7 + *
    18.8 + * This program is free software: you can redistribute it and/or modify
    18.9 + * it under the terms of the GNU General Public License as published by
   18.10 + * the Free Software Foundation, version 2 of the License.
   18.11 + *
   18.12 + * This program is distributed in the hope that it will be useful,
   18.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18.15 + * GNU General Public License for more details.
   18.16 + *
   18.17 + * You should have received a copy of the GNU General Public License
   18.18 + * along with this program. Look for COPYING file in the top folder.
   18.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   18.20 + */
   18.21 +package org.apidesign.bck2brwsr.tck;
   18.22 +
   18.23 +import java.lang.annotation.Retention;
   18.24 +import java.lang.annotation.RetentionPolicy;
   18.25 +import java.lang.reflect.Method;
   18.26 +import java.util.Arrays;
   18.27 +import java.util.Collections;
   18.28 +import java.util.List;
   18.29 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   18.30 +import org.apidesign.bck2brwsr.vmtest.Compare;
   18.31 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   18.32 +import org.testng.annotations.Factory;
   18.33 +
   18.34 +/**
   18.35 + *
   18.36 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   18.37 + */
   18.38 +public class ReflectionTest {
   18.39 +    @Compare public boolean nonNullThis() {
   18.40 +        return this == null;
   18.41 +    }
   18.42 +    
   18.43 +    @Compare public String intType() {
   18.44 +        return Integer.TYPE.toString();
   18.45 +    }
   18.46 +
   18.47 +    @Compare public String voidType() throws Exception {
   18.48 +        return void.class.toString();
   18.49 +    }
   18.50 +
   18.51 +    @Compare public String longClass() {
   18.52 +        return long.class.toString();
   18.53 +    }
   18.54 +    
   18.55 +    @Compare public boolean isRunnableInterface() {
   18.56 +        return Runnable.class.isInterface();
   18.57 +    }
   18.58 +
   18.59 +    @Compare public boolean isAssignableToPrimitiveType() {
   18.60 +        return boolean.class.isAssignableFrom(Runnable.class);
   18.61 +    }
   18.62 +
   18.63 +    @Compare public boolean isAssignableFromPrimitiveType() {
   18.64 +        return Runnable.class.isAssignableFrom(boolean.class);
   18.65 +    }
   18.66 +
   18.67 +    @Compare public boolean isAssignableLongFromInt() {
   18.68 +        return long.class.isAssignableFrom(int.class);
   18.69 +    }
   18.70 +
   18.71 +    @Compare public boolean isAssignableIntFromLong() {
   18.72 +        return int.class.isAssignableFrom(long.class);
   18.73 +    }
   18.74 +
   18.75 +    @Compare public String isRunnableHasRunMethod() throws NoSuchMethodException {
   18.76 +        return Runnable.class.getMethod("run").getName();
   18.77 +    }
   18.78 +    
   18.79 +    @Compare public String namesOfMethods() {
   18.80 +        StringBuilder sb = new StringBuilder();
   18.81 +        String[] arr = new String[20];
   18.82 +        int i = 0;
   18.83 +        for (Method m : StaticUse.class.getMethods()) {
   18.84 +            arr[i++] = m.getName();
   18.85 +        }
   18.86 +        for (String s : sort(arr, i)) {
   18.87 +            sb.append(s).append("\n");
   18.88 +        }
   18.89 +        return sb.toString();
   18.90 +    }
   18.91 +
   18.92 +    @Compare public String namesOfDeclaringClassesOfMethods() {
   18.93 +        StringBuilder sb = new StringBuilder();
   18.94 +        String[] arr = new String[20];
   18.95 +        int i = 0;
   18.96 +        for (Method m : StaticUse.class.getMethods()) {
   18.97 +            arr[i++] = m.getName() + "@" + m.getDeclaringClass().getName();
   18.98 +        }
   18.99 +        for (String s : sort(arr, i)) {
  18.100 +            sb.append(s).append("\n");
  18.101 +        }
  18.102 +        return sb.toString();
  18.103 +    }
  18.104 +    
  18.105 +    @Compare public String cannotCallNonStaticMethodWithNull() throws Exception {
  18.106 +        StaticUse.class.getMethod("instanceMethod").invoke(null);
  18.107 +        return "should not happen";
  18.108 +    }
  18.109 +    
  18.110 +    @Compare public String classCastException() {
  18.111 +        try {
  18.112 +            Integer i = (Integer)StaticUseSub.getNonNull();
  18.113 +            return "" + i.intValue();
  18.114 +        } catch (ClassCastException ex) {
  18.115 +            return ex.getClass().getName();
  18.116 +        }
  18.117 +    }
  18.118 +
  18.119 +    @Compare public String methodThatThrowsException() throws Exception {
  18.120 +        StaticUse.class.getMethod("instanceMethod").invoke(new StaticUse());
  18.121 +        return "should not happen";
  18.122 +    }
  18.123 +
  18.124 +    @Compare public Object voidReturnType() throws Exception {
  18.125 +        return StaticUse.class.getMethod("instanceMethod").getReturnType();
  18.126 +    }
  18.127 +    
  18.128 +    @Retention(RetentionPolicy.RUNTIME)
  18.129 +    @interface Ann {
  18.130 +    }
  18.131 +    
  18.132 +    @Compare public String annoClass() throws Exception {
  18.133 +        Retention r = Ann.class.getAnnotation(Retention.class);
  18.134 +        assert r != null : "Annotation is present";
  18.135 +        assert r.value() == RetentionPolicy.RUNTIME : "Policy value is OK: " + r.value();
  18.136 +        return r.annotationType().getName();
  18.137 +    }
  18.138 +    
  18.139 +    @Compare public boolean isAnnotation() {
  18.140 +        return Ann.class.isAnnotation();
  18.141 +    }
  18.142 +    @Compare public boolean isNotAnnotation() {
  18.143 +        return String.class.isAnnotation();
  18.144 +    }
  18.145 +    @Compare public boolean isNotAnnotationEnum() {
  18.146 +        return E.class.isAnnotation();
  18.147 +    }
  18.148 +    enum E { A, B };
  18.149 +    @Compare public boolean isEnum() {
  18.150 +        return E.A.getClass().isEnum();
  18.151 +    }
  18.152 +
  18.153 +    @Compare public boolean isNotEnum() {
  18.154 +        return "".getClass().isEnum();
  18.155 +    }
  18.156 +    
  18.157 +    @Compare public String newInstanceFails() throws InstantiationException {
  18.158 +        try {
  18.159 +            return "success: " + StaticUseSub.class.newInstance();
  18.160 +        } catch (IllegalAccessException ex) {
  18.161 +            return ex.getClass().getName();
  18.162 +        }
  18.163 +    }
  18.164 +    
  18.165 +    @Compare public String paramTypes() throws Exception {
  18.166 +        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  18.167 +        final Class[] pt = plus.getParameterTypes();
  18.168 +        return pt[0].getName();
  18.169 +    }
  18.170 +    @Compare public String paramTypesNotFound() throws Exception {
  18.171 +        return StaticUse.class.getMethod("plus", int.class, double.class).toString();
  18.172 +    }
  18.173 +    @Compare public int methodWithArgs() throws Exception {
  18.174 +        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  18.175 +        return (Integer)plus.invoke(null, 2, 3);
  18.176 +    }
  18.177 +    
  18.178 +    @Compare public String classGetNameForByte() {
  18.179 +         return byte.class.getName();
  18.180 +    }
  18.181 +    @Compare public String classGetNameForBaseObject() {
  18.182 +        return newObject().getClass().getName();
  18.183 +    }
  18.184 +    @Compare public String classGetNameForJavaObject() {
  18.185 +        return new Object().getClass().getName();
  18.186 +    }
  18.187 +    @Compare public String classGetNameForObjectArray() {
  18.188 +        return (new Object[3]).getClass().getName();
  18.189 +    }
  18.190 +    @Compare public String classGetNameForSimpleIntArray() {
  18.191 +        return (new int[3]).getClass().getName();
  18.192 +    }
  18.193 +    @Compare public boolean sameClassGetNameForSimpleCharArray() {
  18.194 +        return (new char[3]).getClass() == (new char[34]).getClass();
  18.195 +    }
  18.196 +    @Compare public String classGetNameForMultiIntArray() {
  18.197 +        return (new int[3][4][5][6][7][8][9]).getClass().getName();
  18.198 +    }
  18.199 +    @Compare public String classGetNameForMultiIntArrayInner() {
  18.200 +        final int[][][][][][][] arr = new int[3][4][5][6][7][8][9];
  18.201 +        int[][][][][][] subarr = arr[0];
  18.202 +        int[][][][][] subsubarr = subarr[0];
  18.203 +        return subsubarr.getClass().getName();
  18.204 +    }
  18.205 +    @Compare public String classGetNameForMultiStringArray() {
  18.206 +        return (new String[3][4][5][6][7][8][9]).getClass().getName();
  18.207 +    }
  18.208 +    
  18.209 +    @Compare public String classForByte() throws Exception {
  18.210 +        return Class.forName("[Z").getName();
  18.211 +    }
  18.212 +
  18.213 +    @Compare public String classForUnknownArray() {
  18.214 +        try {
  18.215 +            return Class.forName("[W").getName();
  18.216 +        } catch (Exception ex) {
  18.217 +            return ex.getClass().getName();
  18.218 +        }
  18.219 +    }
  18.220 +    
  18.221 +    @Compare public String classForUnknownDeepArray() {
  18.222 +        try {
  18.223 +            return Class.forName("[[[[[W").getName();
  18.224 +        } catch (Exception ex) {
  18.225 +            return ex.getClass().getName();
  18.226 +        }
  18.227 +    }
  18.228 +    
  18.229 +    @Compare public String componentGetNameForObjectArray() {
  18.230 +        return (new Object[3]).getClass().getComponentType().getName();
  18.231 +    }
  18.232 +    @Compare public boolean sameComponentGetNameForObjectArray() {
  18.233 +        return (new Object[3]).getClass().getComponentType() == Object.class;
  18.234 +    }
  18.235 +    @Compare public String componentGetNameForSimpleIntArray() {
  18.236 +        return (new int[3]).getClass().getComponentType().getName();
  18.237 +    }
  18.238 +    @Compare public String componentGetNameForMultiIntArray() {
  18.239 +        return (new int[3][4][5][6][7][8][9]).getClass().getComponentType().getName();
  18.240 +    }
  18.241 +    @Compare public String componentGetNameForMultiStringArray() {
  18.242 +        Class<?> c = (new String[3][4][5][6][7][8][9]).getClass();
  18.243 +        StringBuilder sb = new StringBuilder();
  18.244 +        for (;;) {
  18.245 +            sb.append(c.getName()).append("\n");
  18.246 +            c = c.getComponentType();
  18.247 +            if (c == null) {
  18.248 +                break;
  18.249 +            }
  18.250 +        }
  18.251 +        return sb.toString();
  18.252 +    }
  18.253 +    
  18.254 +    @Compare public boolean isArray() {
  18.255 +        return new Object[0].getClass().isArray();
  18.256 +    }
  18.257 +    
  18.258 +    @JavaScriptBody(args = { "arr", "len" }, body="var a = arr.slice(0, len); a.sort(); return a;")
  18.259 +    private static String[] sort(String[] arr, int len) {
  18.260 +        List<String> list = Arrays.asList(arr).subList(0, len);
  18.261 +        Collections.sort(list);
  18.262 +        return list.toArray(new String[0]);
  18.263 +    }
  18.264 +    
  18.265 +    @JavaScriptBody(args = {}, body = "return new Object();")
  18.266 +    private static Object newObject() {
  18.267 +        return new Object();
  18.268 +    }
  18.269 +    
  18.270 +    @Factory
  18.271 +    public static Object[] create() {
  18.272 +        return VMTest.create(ReflectionTest.class);
  18.273 +    }
  18.274 +    
  18.275 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java	Sun Apr 28 10:26:08 2013 +0200
    19.3 @@ -0,0 +1,45 @@
    19.4 +/**
    19.5 + * Back 2 Browser Bytecode Translator
    19.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    19.7 + *
    19.8 + * This program is free software: you can redistribute it and/or modify
    19.9 + * it under the terms of the GNU General Public License as published by
   19.10 + * the Free Software Foundation, version 2 of the License.
   19.11 + *
   19.12 + * This program is distributed in the hope that it will be useful,
   19.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.15 + * GNU General Public License for more details.
   19.16 + *
   19.17 + * You should have received a copy of the GNU General Public License
   19.18 + * along with this program. Look for COPYING file in the top folder.
   19.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   19.20 + */
   19.21 +package org.apidesign.bck2brwsr.tck;
   19.22 +
   19.23 +import java.io.InputStream;
   19.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   19.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   19.26 +import org.testng.annotations.Factory;
   19.27 +
   19.28 +/**
   19.29 + *
   19.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   19.31 + */
   19.32 +public class ResourcesTest {
   19.33 +    
   19.34 +    @Compare public String readResourceAsStream() throws Exception {
   19.35 +        InputStream is = getClass().getResourceAsStream("Resources.txt");
   19.36 +        byte[] b = new byte[30];
   19.37 +        int len = is.read(b);
   19.38 +        StringBuilder sb = new StringBuilder();
   19.39 +        for (int i = 0; i < len; i++) {
   19.40 +            sb.append((char)b[i]);
   19.41 +        }
   19.42 +        return sb.toString();
   19.43 +    }
   19.44 +    
   19.45 +    @Factory public static Object[] create() {
   19.46 +        return VMTest.create(ResourcesTest.class);
   19.47 +    }
   19.48 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java	Sun Apr 28 10:26:08 2013 +0200
    20.3 @@ -0,0 +1,102 @@
    20.4 +/**
    20.5 + * Back 2 Browser Bytecode Translator
    20.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    20.7 + *
    20.8 + * This program is free software: you can redistribute it and/or modify
    20.9 + * it under the terms of the GNU General Public License as published by
   20.10 + * the Free Software Foundation, version 2 of the License.
   20.11 + *
   20.12 + * This program is distributed in the hope that it will be useful,
   20.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20.15 + * GNU General Public License for more details.
   20.16 + *
   20.17 + * You should have received a copy of the GNU General Public License
   20.18 + * along with this program. Look for COPYING file in the top folder.
   20.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   20.20 + */
   20.21 +package org.apidesign.bck2brwsr.tck;
   20.22 +
   20.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   20.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   20.25 +import org.testng.annotations.Factory;
   20.26 +
   20.27 +/**
   20.28 + *
   20.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   20.30 + */
   20.31 +public class ShortArithmeticTest {
   20.32 +    
   20.33 +    private static short add(short x, short y) {
   20.34 +        return (short)(x + y);
   20.35 +    }
   20.36 +    
   20.37 +    private static short sub(short x, short y) {
   20.38 +        return (short)(x - y);
   20.39 +    }
   20.40 +    
   20.41 +    private static short mul(short x, short y) {
   20.42 +        return (short)(x * y);
   20.43 +    }
   20.44 +    
   20.45 +    private static short div(short x, short y) {
   20.46 +        return (short)(x / y);
   20.47 +    }
   20.48 +    
   20.49 +    private static short mod(short x, short y) {
   20.50 +        return (short)(x % y);
   20.51 +    }
   20.52 +    
   20.53 +    @Compare public short conversion() {
   20.54 +        return (short)123456;
   20.55 +    }
   20.56 +    
   20.57 +    @Compare public short addOverflow() {
   20.58 +        return add(Short.MAX_VALUE, (short)1);
   20.59 +    }
   20.60 +    
   20.61 +    @Compare public short subUnderflow() {
   20.62 +        return sub(Short.MIN_VALUE, (short)1);
   20.63 +    }
   20.64 +    
   20.65 +    @Compare public short addMaxShortAndMaxShort() {
   20.66 +        return add(Short.MAX_VALUE, Short.MAX_VALUE);
   20.67 +    }
   20.68 +    
   20.69 +    @Compare public short subMinShortAndMinShort() {
   20.70 +        return sub(Short.MIN_VALUE, Short.MIN_VALUE);
   20.71 +    }
   20.72 +    
   20.73 +    @Compare public short multiplyMaxShort() {
   20.74 +        return mul(Short.MAX_VALUE, (short)2);
   20.75 +    }
   20.76 +    
   20.77 +    @Compare public short multiplyMaxShortAndMaxShort() {
   20.78 +        return mul(Short.MAX_VALUE, Short.MAX_VALUE);
   20.79 +    }
   20.80 +    
   20.81 +    @Compare public short multiplyMinShort() {
   20.82 +        return mul(Short.MIN_VALUE, (short)2);
   20.83 +    }
   20.84 +    
   20.85 +    @Compare public short multiplyMinShortAndMinShort() {
   20.86 +        return mul(Short.MIN_VALUE, Short.MIN_VALUE);
   20.87 +    }
   20.88 +    
   20.89 +    @Compare public short multiplyPrecision() {
   20.90 +        return mul((short)17638, (short)1103);
   20.91 +    }
   20.92 +    
   20.93 +    @Compare public short division() {
   20.94 +        return div((short)1, (short)2);
   20.95 +    }
   20.96 +    
   20.97 +    @Compare public short divisionReminder() {
   20.98 +        return mod((short)1, (short)2);
   20.99 +    }
  20.100 +    
  20.101 +    @Factory
  20.102 +    public static Object[] create() {
  20.103 +        return VMTest.create(ShortArithmeticTest.class);
  20.104 +    }
  20.105 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java	Sun Apr 28 10:26:08 2013 +0200
    21.3 @@ -0,0 +1,39 @@
    21.4 +/**
    21.5 + * Back 2 Browser Bytecode Translator
    21.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    21.7 + *
    21.8 + * This program is free software: you can redistribute it and/or modify
    21.9 + * it under the terms of the GNU General Public License as published by
   21.10 + * the Free Software Foundation, version 2 of the License.
   21.11 + *
   21.12 + * This program is distributed in the hope that it will be useful,
   21.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21.15 + * GNU General Public License for more details.
   21.16 + *
   21.17 + * You should have received a copy of the GNU General Public License
   21.18 + * along with this program. Look for COPYING file in the top folder.
   21.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   21.20 + */
   21.21 +package org.apidesign.bck2brwsr.tck;
   21.22 +
   21.23 +class StaticUse {
   21.24 +    public static final Object NON_NULL = new Object();
   21.25 +    public static int cnt;
   21.26 +    static {
   21.27 +        if (cnt++ != 0) {
   21.28 +            throw new IllegalStateException("Multiple initialization of a <cinit>");
   21.29 +        }
   21.30 +    }
   21.31 +    
   21.32 +    StaticUse() {
   21.33 +    }
   21.34 +    
   21.35 +    public void instanceMethod() {
   21.36 +        throw new IllegalStateException();
   21.37 +    }
   21.38 +
   21.39 +    public static int plus(int a, int b) {
   21.40 +        return a + b;
   21.41 +    }
   21.42 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java	Sun Apr 28 10:26:08 2013 +0200
    22.3 @@ -0,0 +1,30 @@
    22.4 +/**
    22.5 + * Back 2 Browser Bytecode Translator
    22.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    22.7 + *
    22.8 + * This program is free software: you can redistribute it and/or modify
    22.9 + * it under the terms of the GNU General Public License as published by
   22.10 + * the Free Software Foundation, version 2 of the License.
   22.11 + *
   22.12 + * This program is distributed in the hope that it will be useful,
   22.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   22.15 + * GNU General Public License for more details.
   22.16 + *
   22.17 + * You should have received a copy of the GNU General Public License
   22.18 + * along with this program. Look for COPYING file in the top folder.
   22.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   22.20 + */
   22.21 +package org.apidesign.bck2brwsr.tck;
   22.22 +
   22.23 +public class StaticUseSub extends StaticUse {
   22.24 +    private StaticUseSub() {
   22.25 +    }
   22.26 +    
   22.27 +    public static Object getNonNull() {
   22.28 +        return NON_NULL;
   22.29 +    }
   22.30 +    static Object getNull() {
   22.31 +        return null;
   22.32 +    }
   22.33 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java	Sun Apr 28 10:26:08 2013 +0200
    23.3 @@ -0,0 +1,45 @@
    23.4 +/**
    23.5 + * Back 2 Browser Bytecode Translator
    23.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    23.7 + *
    23.8 + * This program is free software: you can redistribute it and/or modify
    23.9 + * it under the terms of the GNU General Public License as published by
   23.10 + * the Free Software Foundation, version 2 of the License.
   23.11 + *
   23.12 + * This program is distributed in the hope that it will be useful,
   23.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   23.15 + * GNU General Public License for more details.
   23.16 + *
   23.17 + * You should have received a copy of the GNU General Public License
   23.18 + * along with this program. Look for COPYING file in the top folder.
   23.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   23.20 + */
   23.21 +package org.apidesign.bck2brwsr.tck;
   23.22 +
   23.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   23.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   23.25 +import org.testng.annotations.Factory;
   23.26 +
   23.27 +/**
   23.28 + *
   23.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   23.30 + */
   23.31 +public class StaticUseSubTest {
   23.32 +    @Compare public String staticFieldInitializationInSuperClass() throws Exception {
   23.33 +        Object ret = StaticUseSub.getNonNull();
   23.34 +        return ret.getClass().getName();
   23.35 +    }
   23.36 +    
   23.37 +    @Compare public String isNullPointerTheSame() throws Exception {
   23.38 +        try {
   23.39 +            return StaticUseSub.getNull().getClass().toString();
   23.40 +        } catch (NullPointerException ex) {
   23.41 +            return ex.getClass().getName();
   23.42 +        }
   23.43 +    }
   23.44 +
   23.45 +    @Factory public static Object[] create() {
   23.46 +        return VMTest.create(StaticUseSubTest.class);
   23.47 +    }
   23.48 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java	Sun Apr 28 10:26:08 2013 +0200
    24.3 @@ -0,0 +1,41 @@
    24.4 +/**
    24.5 + * Back 2 Browser Bytecode Translator
    24.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    24.7 + *
    24.8 + * This program is free software: you can redistribute it and/or modify
    24.9 + * it under the terms of the GNU General Public License as published by
   24.10 + * the Free Software Foundation, version 2 of the License.
   24.11 + *
   24.12 + * This program is distributed in the hope that it will be useful,
   24.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24.15 + * GNU General Public License for more details.
   24.16 + *
   24.17 + * You should have received a copy of the GNU General Public License
   24.18 + * along with this program. Look for COPYING file in the top folder.
   24.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   24.20 + */
   24.21 +package org.apidesign.bck2brwsr.vmtest.impl;
   24.22 +
   24.23 +import java.io.UnsupportedEncodingException;
   24.24 +import java.util.zip.CRC32;
   24.25 +import org.apidesign.bck2brwsr.vmtest.Compare;
   24.26 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   24.27 +import org.testng.annotations.Factory;
   24.28 +
   24.29 +/**
   24.30 + *
   24.31 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   24.32 + */
   24.33 +public class CRC32Test {
   24.34 +
   24.35 +    @Compare public long crc1() throws UnsupportedEncodingException {
   24.36 +        CRC32 crc = new CRC32();
   24.37 +        crc.update("Hello World!".getBytes("UTF-8"));
   24.38 +        return crc.getValue();
   24.39 +    }
   24.40 +    
   24.41 +    @Factory public static Object[] create() {
   24.42 +        return VMTest.create(CRC32Test.class);
   24.43 +    }
   24.44 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java	Sun Apr 28 10:26:08 2013 +0200
    25.3 @@ -0,0 +1,43 @@
    25.4 +/**
    25.5 + * Back 2 Browser Bytecode Translator
    25.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    25.7 + *
    25.8 + * This program is free software: you can redistribute it and/or modify
    25.9 + * it under the terms of the GNU General Public License as published by
   25.10 + * the Free Software Foundation, version 2 of the License.
   25.11 + *
   25.12 + * This program is distributed in the hope that it will be useful,
   25.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   25.15 + * GNU General Public License for more details.
   25.16 + *
   25.17 + * You should have received a copy of the GNU General Public License
   25.18 + * along with this program. Look for COPYING file in the top folder.
   25.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   25.20 + */
   25.21 +package org.apidesign.bck2brwsr.vmtest.impl;
   25.22 +
   25.23 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   25.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   25.25 +import org.testng.annotations.Factory;
   25.26 +
   25.27 +/**
   25.28 + *
   25.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   25.30 + */
   25.31 +public class CallMeTwiceTest {
   25.32 +    int cnt;
   25.33 +    
   25.34 +    @BrwsrTest public void callMeTwice() throws InterruptedException {
   25.35 +        if (cnt++ == 0) {
   25.36 +            throw new InterruptedException();
   25.37 +        }
   25.38 +        int prevCnt = cnt;
   25.39 +        cnt = 0;
   25.40 +        assert prevCnt == 2 : "We need to receive two calls " + prevCnt;
   25.41 +    }
   25.42 +    
   25.43 +    @Factory public static Object[] create() {
   25.44 +        return VMTest.create(CallMeTwiceTest.class);
   25.45 +    }
   25.46 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java	Sun Apr 28 10:26:08 2013 +0200
    26.3 @@ -0,0 +1,67 @@
    26.4 +/**
    26.5 + * Back 2 Browser Bytecode Translator
    26.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    26.7 + *
    26.8 + * This program is free software: you can redistribute it and/or modify
    26.9 + * it under the terms of the GNU General Public License as published by
   26.10 + * the Free Software Foundation, version 2 of the License.
   26.11 + *
   26.12 + * This program is distributed in the hope that it will be useful,
   26.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26.15 + * GNU General Public License for more details.
   26.16 + *
   26.17 + * You should have received a copy of the GNU General Public License
   26.18 + * along with this program. Look for COPYING file in the top folder.
   26.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   26.20 + */
   26.21 +package org.apidesign.bck2brwsr.vmtest.impl;
   26.22 +
   26.23 +import java.io.ByteArrayInputStream;
   26.24 +import java.io.IOException;
   26.25 +import java.io.InputStream;
   26.26 +import org.apidesign.bck2brwsr.emul.zip.FastJar;
   26.27 +import org.testng.annotations.Test;
   26.28 +import static org.testng.Assert.*;
   26.29 +
   26.30 +/**
   26.31 + *
   26.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   26.33 + */
   26.34 +@GenerateZip(name = "five.zip", contents = {
   26.35 +    "1.txt", "one",
   26.36 +    "2.txt", "duo",
   26.37 +    "3.txt", "three",
   26.38 +    "4.txt", "four",
   26.39 +    "5.txt", "five"
   26.40 +})
   26.41 +public class ZipEntryTest {
   26.42 +    @Test
   26.43 +    public void readEntriesEffectively() throws IOException {
   26.44 +        InputStream is = ZipEntryTest.class.getResourceAsStream("five.zip");
   26.45 +        byte[] arr = new byte[is.available()];
   26.46 +        int len = is.read(arr);
   26.47 +        assertEquals(len, arr.length, "Read fully");
   26.48 +        
   26.49 +        FastJar fj = new FastJar(arr);
   26.50 +        FastJar.Entry[] entrs = fj.list();
   26.51 +        
   26.52 +        assertEquals(5, entrs.length, "Five entries");
   26.53 +        
   26.54 +        for (int i = 1; i <= 5; i++) {
   26.55 +            FastJar.Entry en = entrs[i - 1];
   26.56 +            assertEquals(en.name, i + ".txt");
   26.57 +//            assertEquals(cis.cnt, 0, "Content of the file should be skipped, not read");
   26.58 +        }
   26.59 +        
   26.60 +        assertContent("three", fj.getInputStream(entrs[3 - 1]), "read OK");
   26.61 +        assertContent("five", fj.getInputStream(entrs[5 - 1]), "read OK");
   26.62 +    }
   26.63 +
   26.64 +    private static void assertContent(String exp, InputStream is, String msg) throws IOException {
   26.65 +        byte[] arr = new byte[512];
   26.66 +        int len = is.read(arr);
   26.67 +        String s = new String(arr, 0, len);
   26.68 +        assertEquals(exp, s, msg);
   26.69 +    }
   26.70 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java	Sun Apr 28 10:26:08 2013 +0200
    27.3 @@ -0,0 +1,108 @@
    27.4 +/**
    27.5 + * Back 2 Browser Bytecode Translator
    27.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    27.7 + *
    27.8 + * This program is free software: you can redistribute it and/or modify
    27.9 + * it under the terms of the GNU General Public License as published by
   27.10 + * the Free Software Foundation, version 2 of the License.
   27.11 + *
   27.12 + * This program is distributed in the hope that it will be useful,
   27.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.15 + * GNU General Public License for more details.
   27.16 + *
   27.17 + * You should have received a copy of the GNU General Public License
   27.18 + * along with this program. Look for COPYING file in the top folder.
   27.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   27.20 + */
   27.21 +package org.apidesign.bck2brwsr.vmtest.impl;
   27.22 +
   27.23 +import java.io.IOException;
   27.24 +import java.io.InputStream;
   27.25 +import java.util.Objects;
   27.26 +import java.util.zip.ZipEntry;
   27.27 +import java.util.zip.ZipInputStream;
   27.28 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   27.29 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   27.30 +import org.apidesign.bck2brwsr.vmtest.Compare;
   27.31 +import org.apidesign.bck2brwsr.vmtest.Http;
   27.32 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   27.33 +import org.testng.annotations.Factory;
   27.34 +
   27.35 +/**
   27.36 + *
   27.37 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   27.38 + */
   27.39 +@GenerateZip(name = "readAnEntry.zip", contents = { 
   27.40 +    "my/main/file.txt", "Hello World!"
   27.41 +})
   27.42 +public class ZipFileTest {
   27.43 +    
   27.44 +    @Compare public String readAnEntry() throws IOException {
   27.45 +        InputStream is = ZipFileTest.class.getResourceAsStream("readAnEntry.zip");
   27.46 +        ZipInputStream zip = new ZipInputStream(is);
   27.47 +        ZipEntry entry = zip.getNextEntry();
   27.48 +        assertEquals(entry.getName(), "my/main/file.txt", "Correct entry");
   27.49 +
   27.50 +        byte[] arr = new byte[4096];
   27.51 +        int len = zip.read(arr);
   27.52 +        
   27.53 +        assertEquals(zip.getNextEntry(), null, "No next entry");
   27.54 +        
   27.55 +        final String ret = new String(arr, 0, len, "UTF-8");
   27.56 +        return ret;
   27.57 +    }
   27.58 +    
   27.59 +    @JavaScriptBody(args = { "res", "path" }, body = 
   27.60 +          "var myvm = bck2brwsr.apply(null, path);\n"
   27.61 +        + "var cls = myvm.loadClass('java.lang.String');\n"
   27.62 +        + "return cls.getClass__Ljava_lang_Class_2().getResourceAsStream__Ljava_io_InputStream_2Ljava_lang_String_2(res);\n"
   27.63 +    )
   27.64 +    private static native Object loadVMResource(String res, String...path);
   27.65 +
   27.66 +    @Http({
   27.67 +        @Http.Resource(path = "/readAnEntry.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip")
   27.68 +    })
   27.69 +    @BrwsrTest  public void canVmLoadResourceFromZip() throws IOException {
   27.70 +        Object res = loadVMResource("/my/main/file.txt", "/readAnEntry.jar");
   27.71 +        assert res instanceof InputStream : "Got array of bytes: " + res;
   27.72 +        InputStream is = (InputStream)res;
   27.73 +        
   27.74 +        byte[] arr = new byte[4096];
   27.75 +        int len = is.read(arr);
   27.76 +        
   27.77 +        final String ret = new String(arr, 0, len, "UTF-8");
   27.78 +
   27.79 +        assertEquals(ret, "Hello World!", "Can read the bytes");
   27.80 +    }
   27.81 +    
   27.82 +    @GenerateZip(name = "cpattr.zip", contents = { 
   27.83 +        "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n"
   27.84 +        + "Created-By: hand\n"
   27.85 +        + "Class-Path: realJar.jar\n\n\n"
   27.86 +    })
   27.87 +    @Http({
   27.88 +        @Http.Resource(path = "/readComplexEntry.jar", mimeType = "x-application/zip", content = "", resource="cpattr.zip"),
   27.89 +        @Http.Resource(path = "/realJar.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip"),
   27.90 +    })
   27.91 +    @BrwsrTest  public void understandsClassPathAttr() throws IOException {
   27.92 +        Object res = loadVMResource("/my/main/file.txt", "/readComplexEntry.jar");
   27.93 +        assert res instanceof InputStream : "Got array of bytes: " + res;
   27.94 +        InputStream is = (InputStream)res;
   27.95 +        
   27.96 +        byte[] arr = new byte[4096];
   27.97 +        int len = is.read(arr);
   27.98 +        
   27.99 +        final String ret = new String(arr, 0, len, "UTF-8");
  27.100 +
  27.101 +        assertEquals(ret, "Hello World!", "Can read the bytes from secondary JAR");
  27.102 +    }
  27.103 +    
  27.104 +    private static void assertEquals(Object real, Object exp, String msg) {
  27.105 +        assert Objects.equals(exp, real) : msg + " exp: " + exp + " real: " + real;
  27.106 +    }
  27.107 +    
  27.108 +    @Factory public static Object[] create() {
  27.109 +        return VMTest.create(ZipFileTest.class);
  27.110 +    }
  27.111 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe	Sun Apr 28 10:26:08 2013 +0200
    28.3 @@ -0,0 +1,1 @@
    28.4    28.5 \ No newline at end of file
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt	Sun Apr 28 10:26:08 2013 +0200
    29.3 @@ -0,0 +1,1 @@
    29.4 +Ahoj
    30.1 --- a/rt/vmtest/pom.xml	Sun Apr 28 10:14:31 2013 +0200
    30.2 +++ b/rt/vmtest/pom.xml	Sun Apr 28 10:26:08 2013 +0200
    30.3 @@ -50,18 +50,6 @@
    30.4      </dependency>
    30.5      <dependency>
    30.6        <groupId>${project.groupId}</groupId>
    30.7 -      <artifactId>vm4brwsr</artifactId>
    30.8 -      <version>${project.version}</version>
    30.9 -      <type>jar</type>
   30.10 -    </dependency>
   30.11 -    <dependency>
   30.12 -      <groupId>${project.groupId}</groupId>
   30.13 -      <artifactId>emul.mini</artifactId>
   30.14 -      <version>${project.version}</version>
   30.15 -      <scope>test</scope>
   30.16 -    </dependency>
   30.17 -    <dependency>
   30.18 -      <groupId>${project.groupId}</groupId>
   30.19        <artifactId>launcher</artifactId>
   30.20        <version>${project.version}</version>
   30.21      </dependency>
    31.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java	Sun Apr 28 10:14:31 2013 +0200
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,43 +0,0 @@
    31.4 -/**
    31.5 - * Back 2 Browser Bytecode Translator
    31.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    31.7 - *
    31.8 - * This program is free software: you can redistribute it and/or modify
    31.9 - * it under the terms of the GNU General Public License as published by
   31.10 - * the Free Software Foundation, version 2 of the License.
   31.11 - *
   31.12 - * This program is distributed in the hope that it will be useful,
   31.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   31.15 - * GNU General Public License for more details.
   31.16 - *
   31.17 - * You should have received a copy of the GNU General Public License
   31.18 - * along with this program. Look for COPYING file in the top folder.
   31.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   31.20 - */
   31.21 -package org.apidesign.bck2brwsr.tck;
   31.22 -
   31.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   31.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   31.25 -import org.testng.annotations.Factory;
   31.26 -
   31.27 -/**
   31.28 - *
   31.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   31.30 - */
   31.31 -public class AssertionTest {
   31.32 -
   31.33 -    @Compare public Object checkAssert() throws ClassNotFoundException {
   31.34 -        try {
   31.35 -            assert false : "Is assertion status on?";
   31.36 -            return null;
   31.37 -        } catch (AssertionError ex) {
   31.38 -            return ex.getClass().getName();
   31.39 -        }
   31.40 -    }
   31.41 -    
   31.42 -    @Factory
   31.43 -    public static Object[] create() {
   31.44 -        return VMTest.create(AssertionTest.class);
   31.45 -    }
   31.46 -}
    32.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java	Sun Apr 28 10:14:31 2013 +0200
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,57 +0,0 @@
    32.4 -/**
    32.5 - * Back 2 Browser Bytecode Translator
    32.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    32.7 - *
    32.8 - * This program is free software: you can redistribute it and/or modify
    32.9 - * it under the terms of the GNU General Public License as published by
   32.10 - * the Free Software Foundation, version 2 of the License.
   32.11 - *
   32.12 - * This program is distributed in the hope that it will be useful,
   32.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   32.15 - * GNU General Public License for more details.
   32.16 - *
   32.17 - * You should have received a copy of the GNU General Public License
   32.18 - * along with this program. Look for COPYING file in the top folder.
   32.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   32.20 - */
   32.21 -package org.apidesign.bck2brwsr.tck;
   32.22 -
   32.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   32.24 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   32.25 -import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
   32.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   32.27 -import org.testng.annotations.Factory;
   32.28 -
   32.29 -/**
   32.30 - *
   32.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   32.32 - */
   32.33 -public class BrwsrCheckTest {
   32.34 -
   32.35 -    @BrwsrTest public void assertWindowObjectIsDefined() {
   32.36 -        assert window() != null : "No window object found!";
   32.37 -    }
   32.38 -
   32.39 -    
   32.40 -    
   32.41 -    
   32.42 -    @HtmlFragment("<h1 id='hello'>\n"
   32.43 -        + "Hello!\n"
   32.44 -        + "</h1>\n")
   32.45 -    @BrwsrTest public void accessProvidedFragment() {
   32.46 -        assert getElementById("hello") != null : "Element with 'hello' ID found";
   32.47 -    }
   32.48 -    
   32.49 -    @Factory
   32.50 -    public static Object[] create() {
   32.51 -        return VMTest.create(BrwsrCheckTest.class);
   32.52 -    }
   32.53 -    
   32.54 -
   32.55 -    @JavaScriptBody(args = {}, body = "return window;")
   32.56 -    private static native Object window();
   32.57 -
   32.58 -    @JavaScriptBody(args = { "id" }, body = "return window.document.getElementById(id);")
   32.59 -    private static native Object getElementById(String id);
   32.60 -}
    33.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java	Sun Apr 28 10:14:31 2013 +0200
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,147 +0,0 @@
    33.4 -/**
    33.5 - * Back 2 Browser Bytecode Translator
    33.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    33.7 - *
    33.8 - * This program is free software: you can redistribute it and/or modify
    33.9 - * it under the terms of the GNU General Public License as published by
   33.10 - * the Free Software Foundation, version 2 of the License.
   33.11 - *
   33.12 - * This program is distributed in the hope that it will be useful,
   33.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   33.15 - * GNU General Public License for more details.
   33.16 - *
   33.17 - * You should have received a copy of the GNU General Public License
   33.18 - * along with this program. Look for COPYING file in the top folder.
   33.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   33.20 - */
   33.21 -package org.apidesign.bck2brwsr.tck;
   33.22 -
   33.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   33.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   33.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   33.26 -import org.testng.annotations.Factory;
   33.27 -
   33.28 -/**
   33.29 - *
   33.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   33.31 - */
   33.32 -public class ByteArithmeticTest {
   33.33 -    
   33.34 -    private static byte add(byte x, byte y) {
   33.35 -        return (byte)(x + y);
   33.36 -    }
   33.37 -    
   33.38 -    private static byte sub(byte x, byte y) {
   33.39 -        return (byte)(x - y);
   33.40 -    }
   33.41 -    
   33.42 -    private static byte mul(byte x, byte y) {
   33.43 -        return (byte)(x * y);
   33.44 -    }
   33.45 -    
   33.46 -    private static byte div(byte x, byte y) {
   33.47 -        return (byte)(x / y);
   33.48 -    }
   33.49 -    
   33.50 -    private static byte mod(byte x, byte y) {
   33.51 -        return (byte)(x % y);
   33.52 -    }
   33.53 -    
   33.54 -    @Compare public byte conversion() {
   33.55 -        return (byte)123456;
   33.56 -    }
   33.57 -    
   33.58 -    @Compare public byte addOverflow() {
   33.59 -        return add(Byte.MAX_VALUE, (byte)1);
   33.60 -    }
   33.61 -    
   33.62 -    @Compare public byte subUnderflow() {
   33.63 -        return sub(Byte.MIN_VALUE, (byte)1);
   33.64 -    }
   33.65 -    
   33.66 -    @Compare public byte addMaxByteAndMaxByte() {
   33.67 -        return add(Byte.MAX_VALUE, Byte.MAX_VALUE);
   33.68 -    }
   33.69 -    
   33.70 -    @Compare public byte subMinByteAndMinByte() {
   33.71 -        return sub(Byte.MIN_VALUE, Byte.MIN_VALUE);
   33.72 -    }
   33.73 -    
   33.74 -    @Compare public byte multiplyMaxByte() {
   33.75 -        return mul(Byte.MAX_VALUE, (byte)2);
   33.76 -    }
   33.77 -    
   33.78 -    @Compare public byte multiplyMaxByteAndMaxByte() {
   33.79 -        return mul(Byte.MAX_VALUE, Byte.MAX_VALUE);
   33.80 -    }
   33.81 -    
   33.82 -    @Compare public byte multiplyMinByte() {
   33.83 -        return mul(Byte.MIN_VALUE, (byte)2);
   33.84 -    }
   33.85 -    
   33.86 -    @Compare public byte multiplyMinByteAndMinByte() {
   33.87 -        return mul(Byte.MIN_VALUE, Byte.MIN_VALUE);
   33.88 -    }
   33.89 -    
   33.90 -    @Compare public byte multiplyPrecision() {
   33.91 -        return mul((byte)17638, (byte)1103);
   33.92 -    }
   33.93 -    
   33.94 -    @Compare public byte division() {
   33.95 -        return div((byte)1, (byte)2);
   33.96 -    }
   33.97 -    
   33.98 -    @Compare public byte divisionReminder() {
   33.99 -        return mod((byte)1, (byte)2);
  33.100 -    }
  33.101 -
  33.102 -    private static int readShort(byte[] byteCodes, int offset) {
  33.103 -        int signed = byteCodes[offset];
  33.104 -        byte b0 = (byte)signed;
  33.105 -        return (b0 << 8) | (byteCodes[offset + 1] & 0xff);
  33.106 -    }
  33.107 -    
  33.108 -    private static int readShortArg(byte[] byteCodes, int offsetInstruction) {
  33.109 -        return readShort(byteCodes, offsetInstruction + 1);
  33.110 -    }
  33.111 -    
  33.112 -    @Compare public int readIntArgs255and156() {
  33.113 -        final byte[] arr = new byte[] { (byte)0, (byte)255, (byte)156 };
  33.114 -        
  33.115 -        assert arr[1] == -1 : "First byte: " + arr[1];
  33.116 -        assert arr[2] == -100 : "Second byte: " + arr[2];
  33.117 -        final int ret = readShortArg(arr, 0);
  33.118 -        assert ret < 65000: "Value: " + ret;
  33.119 -        return ret;
  33.120 -    }
  33.121 -    
  33.122 -    @JavaScriptBody(args = { "arr" }, body = "arr[1] = 255; arr[2] = 156; return arr;")
  33.123 -    private static byte[] fill255and156(byte[] arr) {
  33.124 -        arr[1] = (byte)255;
  33.125 -        arr[2] = (byte)156;
  33.126 -        return arr;
  33.127 -    }
  33.128 -
  33.129 -    @Compare public int readIntArgs255and156JSArray() {
  33.130 -        final byte[] arr = fill255and156(new byte[] { 0, 0, 0 });
  33.131 -        
  33.132 -        final int ret = readShortArg(arr, 0);
  33.133 -        assert ret < 65000: "Value: " + ret;
  33.134 -        return ret;
  33.135 -    }
  33.136 -    
  33.137 -    @Compare public int readIntArgsMinus1andMinus100() {
  33.138 -        final byte[] arr = new byte[] { (byte)0, (byte)-1, (byte)-100 };
  33.139 -        
  33.140 -        assert arr[1] == -1 : "First byte: " + arr[1];
  33.141 -        assert arr[2] == -100 : "Second byte: " + arr[2];
  33.142 -        
  33.143 -        return readShortArg(arr, 0);
  33.144 -    }
  33.145 -    
  33.146 -    @Factory
  33.147 -    public static Object[] create() {
  33.148 -        return VMTest.create(ByteArithmeticTest.class);
  33.149 -    }
  33.150 -}
    34.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Sun Apr 28 10:14:31 2013 +0200
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,73 +0,0 @@
    34.4 -/**
    34.5 - * Back 2 Browser Bytecode Translator
    34.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    34.7 - *
    34.8 - * This program is free software: you can redistribute it and/or modify
    34.9 - * it under the terms of the GNU General Public License as published by
   34.10 - * the Free Software Foundation, version 2 of the License.
   34.11 - *
   34.12 - * This program is distributed in the hope that it will be useful,
   34.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   34.15 - * GNU General Public License for more details.
   34.16 - *
   34.17 - * You should have received a copy of the GNU General Public License
   34.18 - * along with this program. Look for COPYING file in the top folder.
   34.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   34.20 - */
   34.21 -package org.apidesign.bck2brwsr.tck;
   34.22 -
   34.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   34.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   34.25 -import org.testng.annotations.Factory;
   34.26 -
   34.27 -/**
   34.28 - *
   34.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   34.30 - */
   34.31 -public class CloneTest {
   34.32 -    private int value;
   34.33 -    
   34.34 -    @Compare
   34.35 -    public Object notSupported() throws CloneNotSupportedException {
   34.36 -        return this.clone();
   34.37 -    }
   34.38 -
   34.39 -    @Compare public String sameClass() throws CloneNotSupportedException {
   34.40 -        return new Clnbl().clone().getClass().getName();
   34.41 -    }
   34.42 -
   34.43 -    @Compare public boolean differentInstance() throws CloneNotSupportedException {
   34.44 -        Clnbl orig = new Clnbl();
   34.45 -        return orig == orig.clone();
   34.46 -    }
   34.47 -
   34.48 -    @Compare public int sameReference() throws CloneNotSupportedException {
   34.49 -        CloneTest self = this;
   34.50 -        Clnbl orig = new Clnbl();
   34.51 -        self.value = 33;
   34.52 -        orig.ref = self;
   34.53 -        return ((Clnbl)orig.clone()).ref.value;
   34.54 -    }
   34.55 -
   34.56 -    @Compare public int sameValue() throws CloneNotSupportedException {
   34.57 -        Clnbl orig = new Clnbl();
   34.58 -        orig.value = 10;
   34.59 -        return ((Clnbl)orig.clone()).value;
   34.60 -    }
   34.61 -    
   34.62 -    @Factory
   34.63 -    public static Object[] create() {
   34.64 -        return VMTest.create(CloneTest.class);
   34.65 -    }
   34.66 -    
   34.67 -    public static final class Clnbl implements Cloneable {
   34.68 -        public CloneTest ref;
   34.69 -        private int value;
   34.70 -
   34.71 -        @Override
   34.72 -        public Object clone() throws CloneNotSupportedException {
   34.73 -            return super.clone();
   34.74 -        }
   34.75 -    }
   34.76 -}
    35.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java	Sun Apr 28 10:14:31 2013 +0200
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,103 +0,0 @@
    35.4 -/**
    35.5 - * Back 2 Browser Bytecode Translator
    35.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    35.7 - *
    35.8 - * This program is free software: you can redistribute it and/or modify
    35.9 - * it under the terms of the GNU General Public License as published by
   35.10 - * the Free Software Foundation, version 2 of the License.
   35.11 - *
   35.12 - * This program is distributed in the hope that it will be useful,
   35.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   35.15 - * GNU General Public License for more details.
   35.16 - *
   35.17 - * You should have received a copy of the GNU General Public License
   35.18 - * along with this program. Look for COPYING file in the top folder.
   35.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   35.20 - */
   35.21 -package org.apidesign.bck2brwsr.tck;
   35.22 -
   35.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   35.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   35.25 -import org.testng.annotations.Factory;
   35.26 -
   35.27 -/**
   35.28 - *
   35.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   35.30 - */
   35.31 -public class CompareByteArrayTest {
   35.32 -    @Compare public int byteArraySum() {
   35.33 -        byte[] arr = createArray();
   35.34 -        return sumByteArr(arr);
   35.35 -    }
   35.36 -    
   35.37 -    @Compare public int countZeros() {
   35.38 -        int zeros = 0;
   35.39 -        for (Byte b : createArray()) {
   35.40 -            if (b == 0) {
   35.41 -                zeros++;
   35.42 -            }
   35.43 -        }
   35.44 -        return zeros;
   35.45 -    }
   35.46 -    
   35.47 -    private static int sumByteArr(byte[] arr) {
   35.48 -        int sum = 0;
   35.49 -        for (int i = 0; i < arr.length; i++) {
   35.50 -            sum += arr[i];
   35.51 -        }
   35.52 -        return sum;
   35.53 -    }
   35.54 -    
   35.55 -    @Compare public String noOutOfBounds() {
   35.56 -        return atIndex(1);
   35.57 -    }
   35.58 -
   35.59 -    @Compare public String outOfBounds() {
   35.60 -        return atIndex(5);
   35.61 -    }
   35.62 -
   35.63 -    @Compare public String outOfBoundsMinus() {
   35.64 -        return atIndex(-1);
   35.65 -    }
   35.66 -
   35.67 -    @Compare public String toOfBounds() {
   35.68 -        return toIndex(5);
   35.69 -    }
   35.70 -
   35.71 -    @Compare public String toOfBoundsMinus() {
   35.72 -        return toIndex(-1);
   35.73 -    }
   35.74 -    
   35.75 -    @Compare public int multiArrayLength() {
   35.76 -         int[][] arr = new int[1][0];
   35.77 -         return arr[0].length;
   35.78 -    }
   35.79 -
   35.80 -    @Compare public int multiObjectArrayLength() {
   35.81 -         Object[][] arr = new Object[1][0];
   35.82 -         return arr[0].length;
   35.83 -    }
   35.84 -
   35.85 -    private static final int[] arr = { 0, 1, 2 };
   35.86 -    public static String atIndex(int at) {
   35.87 -        return "at@" + arr[at];
   35.88 -    }
   35.89 -    public static String toIndex(int at) {
   35.90 -        arr[at] = 10;
   35.91 -        return "ok";
   35.92 -    }
   35.93 -    
   35.94 -    
   35.95 -    @Factory
   35.96 -    public static Object[] create() {
   35.97 -        return VMTest.create(CompareByteArrayTest.class);
   35.98 -    }
   35.99 -
  35.100 -    private byte[] createArray() {
  35.101 -        byte[] arr = new byte[10];
  35.102 -        arr[5] = 3;
  35.103 -        arr[7] = 8;
  35.104 -        return arr;
  35.105 -    }
  35.106 -}
    36.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java	Sun Apr 28 10:14:31 2013 +0200
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,50 +0,0 @@
    36.4 -/**
    36.5 - * Back 2 Browser Bytecode Translator
    36.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    36.7 - *
    36.8 - * This program is free software: you can redistribute it and/or modify
    36.9 - * it under the terms of the GNU General Public License as published by
   36.10 - * the Free Software Foundation, version 2 of the License.
   36.11 - *
   36.12 - * This program is distributed in the hope that it will be useful,
   36.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   36.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   36.15 - * GNU General Public License for more details.
   36.16 - *
   36.17 - * You should have received a copy of the GNU General Public License
   36.18 - * along with this program. Look for COPYING file in the top folder.
   36.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   36.20 - */
   36.21 -package org.apidesign.bck2brwsr.tck;
   36.22 -
   36.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   36.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   36.25 -import org.testng.annotations.Factory;
   36.26 -
   36.27 -/**
   36.28 - *
   36.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   36.30 - */
   36.31 -public class CompareHashTest {
   36.32 -    @Compare public int hashOfString() {
   36.33 -        return "Ahoj".hashCode();
   36.34 -    }
   36.35 -    
   36.36 -    @Compare public int hashRemainsYieldsZero() {
   36.37 -        Object o = new Object();
   36.38 -        return o.hashCode() - o.hashCode();
   36.39 -    }
   36.40 -    
   36.41 -    @Compare public int initializeInStatic() {
   36.42 -        return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode();
   36.43 -    }
   36.44 -    
   36.45 -    @Compare public int hashOfInt() {
   36.46 -        return Integer.valueOf(Integer.MAX_VALUE).hashCode();
   36.47 -    }
   36.48 -    
   36.49 -    @Factory
   36.50 -    public static Object[] create() {
   36.51 -        return VMTest.create(CompareHashTest.class);
   36.52 -    }
   36.53 -}
    37.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java	Sun Apr 28 10:14:31 2013 +0200
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,63 +0,0 @@
    37.4 -/**
    37.5 - * Back 2 Browser Bytecode Translator
    37.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    37.7 - *
    37.8 - * This program is free software: you can redistribute it and/or modify
    37.9 - * it under the terms of the GNU General Public License as published by
   37.10 - * the Free Software Foundation, version 2 of the License.
   37.11 - *
   37.12 - * This program is distributed in the hope that it will be useful,
   37.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   37.15 - * GNU General Public License for more details.
   37.16 - *
   37.17 - * You should have received a copy of the GNU General Public License
   37.18 - * along with this program. Look for COPYING file in the top folder.
   37.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   37.20 - */
   37.21 -package org.apidesign.bck2brwsr.tck;
   37.22 -
   37.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   37.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   37.25 -import org.testng.annotations.Factory;
   37.26 -
   37.27 -/**
   37.28 - *
   37.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   37.30 - */
   37.31 -public class CompareIntArrayTest {
   37.32 -    @Compare public int integerArraySum() {
   37.33 -        int[] arr = createArray();
   37.34 -        return sumIntArr(arr);
   37.35 -    }
   37.36 -    
   37.37 -    @Compare public int countZeros() {
   37.38 -        int zeros = 0;
   37.39 -        for (Integer i : createArray()) {
   37.40 -            if (i == 0) {
   37.41 -                zeros++;
   37.42 -            }
   37.43 -        }
   37.44 -        return zeros;
   37.45 -    }
   37.46 -    
   37.47 -    private static int sumIntArr(int[] arr) {
   37.48 -        int sum = 0;
   37.49 -        for (int i = 0; i < arr.length; i++) {
   37.50 -            sum += arr[i];
   37.51 -        }
   37.52 -        return sum;
   37.53 -    }
   37.54 -    
   37.55 -    @Factory
   37.56 -    public static Object[] create() {
   37.57 -        return VMTest.create(CompareIntArrayTest.class);
   37.58 -    }
   37.59 -
   37.60 -    private int[] createArray() {
   37.61 -        int[] arr = new int[10];
   37.62 -        arr[5] = 3;
   37.63 -        arr[7] = 8;
   37.64 -        return arr;
   37.65 -    }
   37.66 -}
    38.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java	Sun Apr 28 10:14:31 2013 +0200
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,174 +0,0 @@
    38.4 -/**
    38.5 - * Back 2 Browser Bytecode Translator
    38.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    38.7 - *
    38.8 - * This program is free software: you can redistribute it and/or modify
    38.9 - * it under the terms of the GNU General Public License as published by
   38.10 - * the Free Software Foundation, version 2 of the License.
   38.11 - *
   38.12 - * This program is distributed in the hope that it will be useful,
   38.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   38.15 - * GNU General Public License for more details.
   38.16 - *
   38.17 - * You should have received a copy of the GNU General Public License
   38.18 - * along with this program. Look for COPYING file in the top folder.
   38.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   38.20 - */
   38.21 -package org.apidesign.bck2brwsr.tck;
   38.22 -
   38.23 -import java.io.UnsupportedEncodingException;
   38.24 -import java.net.MalformedURLException;
   38.25 -import java.net.URL;
   38.26 -import org.apidesign.bck2brwsr.vmtest.Compare;
   38.27 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   38.28 -import org.testng.annotations.Factory;
   38.29 -
   38.30 -/**
   38.31 - *
   38.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   38.33 - */
   38.34 -public class CompareStringsTest {
   38.35 -    @Compare public String firstChar() {
   38.36 -        return "" + ("Hello".toCharArray()[0]);
   38.37 -    }
   38.38 -    
   38.39 -    @Compare public String classCast() {
   38.40 -        Object o = firstChar();
   38.41 -        return String.class.cast(o);
   38.42 -    }
   38.43 -
   38.44 -    @Compare public String classCastThrown() {
   38.45 -        Object o = null;
   38.46 -        return String.class.cast(o);
   38.47 -    }
   38.48 -    
   38.49 -    @Compare public boolean equalToNull() {
   38.50 -        return "Ahoj".equals(null);
   38.51 -    }
   38.52 -    
   38.53 -    @Compare public int highByteLenght() {
   38.54 -        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   38.55 -        return new String(arr, 0).length();
   38.56 -    }
   38.57 -    
   38.58 -    @Compare public String highByte() {
   38.59 -        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   38.60 -        StringBuilder sb = new StringBuilder();
   38.61 -        sb.append("pref:");
   38.62 -        sb.append(new String(arr, 0));
   38.63 -        return sb.toString();
   38.64 -    }
   38.65 -    
   38.66 -    @Compare public static Object compareURLs() throws MalformedURLException {
   38.67 -        return new URL("http://apidesign.org:8080/wiki/").toExternalForm().toString();
   38.68 -    }
   38.69 -    
   38.70 -    @Compare public String deleteLastTwoCharacters() {
   38.71 -        StringBuilder sb = new StringBuilder();
   38.72 -        sb.append("453.0");
   38.73 -        if (sb.toString().endsWith(".0")) {
   38.74 -            final int l = sb.length();
   38.75 -            sb.delete(l - 2, l);
   38.76 -        }
   38.77 -        return sb.toString().toString();
   38.78 -    }
   38.79 -    
   38.80 -    @Compare public String nameOfStringClass() throws Exception {
   38.81 -        return Class.forName("java.lang.String").getName();
   38.82 -    }
   38.83 -    @Compare public String nameOfArrayClass() throws Exception {
   38.84 -        return Class.forName("org.apidesign.bck2brwsr.tck.CompareHashTest").getName();
   38.85 -    }
   38.86 -    
   38.87 -    @Compare public String lowerHello() {
   38.88 -        return "HeLlO".toLowerCase();
   38.89 -    }
   38.90 -    
   38.91 -    @Compare public String lowerA() {
   38.92 -        return String.valueOf(Character.toLowerCase('A')).toString();
   38.93 -    }
   38.94 -    @Compare public String upperHello() {
   38.95 -        return "hello".toUpperCase();
   38.96 -    }
   38.97 -    
   38.98 -    @Compare public String upperA() {
   38.99 -        return String.valueOf(Character.toUpperCase('a')).toString();
  38.100 -    }
  38.101 -    
  38.102 -    @Compare public boolean matchRegExp() throws Exception {
  38.103 -        return "58038503".matches("\\d*");
  38.104 -    }
  38.105 -
  38.106 -    @Compare public boolean doesNotMatchRegExp() throws Exception {
  38.107 -        return "58038503GH".matches("\\d*");
  38.108 -    }
  38.109 -
  38.110 -    @Compare public boolean doesNotMatchRegExpFully() throws Exception {
  38.111 -        return "Hello".matches("Hell");
  38.112 -    }
  38.113 -    
  38.114 -    @Compare public String emptyCharArray() {
  38.115 -        char[] arr = new char[10];
  38.116 -        return new String(arr);
  38.117 -    }
  38.118 -    
  38.119 -    @Compare public String variousCharacterTests() throws Exception {
  38.120 -        StringBuilder sb = new StringBuilder();
  38.121 -        
  38.122 -        sb.append(Character.isUpperCase('a'));
  38.123 -        sb.append(Character.isUpperCase('A'));
  38.124 -        sb.append(Character.isLowerCase('a'));
  38.125 -        sb.append(Character.isLowerCase('A'));
  38.126 -        
  38.127 -        sb.append(Character.isLetter('A'));
  38.128 -        sb.append(Character.isLetterOrDigit('9'));
  38.129 -        sb.append(Character.isLetterOrDigit('A'));
  38.130 -        sb.append(Character.isLetter('0'));
  38.131 -        
  38.132 -        return sb.toString().toString();
  38.133 -    }
  38.134 -        
  38.135 -    @Compare
  38.136 -    public String nullFieldInitialized() {
  38.137 -        NullField nf = new NullField();
  38.138 -        return ("" + nf.name).toString();
  38.139 -    }
  38.140 -    @Compare
  38.141 -    public String toUTFString() throws UnsupportedEncodingException {
  38.142 -        byte[] arr = {
  38.143 -            (byte) -59, (byte) -67, (byte) 108, (byte) 117, (byte) -59, (byte) -91,
  38.144 -            (byte) 111, (byte) 117, (byte) -60, (byte) -115, (byte) 107, (byte) -61,
  38.145 -            (byte) -67, (byte) 32, (byte) 107, (byte) -59, (byte) -81, (byte) -59,
  38.146 -            (byte) -120
  38.147 -        };
  38.148 -        return new String(arr, "utf-8");
  38.149 -    }
  38.150 -
  38.151 -    @Compare
  38.152 -    public int stringToBytesLenght() throws UnsupportedEncodingException {
  38.153 -        return "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148".getBytes("utf8").length;
  38.154 -    }
  38.155 -    
  38.156 -    @Compare public String replaceSeq() {
  38.157 -        return "Hello World.".replace(".", "!");
  38.158 -    }
  38.159 -    @Compare public String replaceSeqAll() {
  38.160 -        return "Hello World! Hello World.".replace("World", "Jarda");
  38.161 -    }
  38.162 -    @Compare public String replaceSeqAA() {
  38.163 -        String res = "aaa".replace("aa", "b");
  38.164 -        assert res.equals("ba") : "Expecting ba: " + res;
  38.165 -        return res;
  38.166 -    }
  38.167 -
  38.168 -    @Factory
  38.169 -    public static Object[] create() {
  38.170 -        return VMTest.create(CompareStringsTest.class);
  38.171 -    }
  38.172 -
  38.173 -    private static final class NullField {
  38.174 -
  38.175 -        String name;
  38.176 -    }
  38.177 -}
    39.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java	Sun Apr 28 10:14:31 2013 +0200
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,65 +0,0 @@
    39.4 -/**
    39.5 - * Back 2 Browser Bytecode Translator
    39.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    39.7 - *
    39.8 - * This program is free software: you can redistribute it and/or modify
    39.9 - * it under the terms of the GNU General Public License as published by
   39.10 - * the Free Software Foundation, version 2 of the License.
   39.11 - *
   39.12 - * This program is distributed in the hope that it will be useful,
   39.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   39.15 - * GNU General Public License for more details.
   39.16 - *
   39.17 - * You should have received a copy of the GNU General Public License
   39.18 - * along with this program. Look for COPYING file in the top folder.
   39.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   39.20 - */
   39.21 -package org.apidesign.bck2brwsr.tck;
   39.22 -
   39.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   39.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   39.25 -import org.testng.annotations.Factory;
   39.26 -
   39.27 -/**
   39.28 - *
   39.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   39.30 - */
   39.31 -public class DoubleTest {
   39.32 -    @Compare public String integerToString() {
   39.33 -        return toStr(1);
   39.34 -    }
   39.35 -
   39.36 -    @Compare public String integerAndHalfToString() {
   39.37 -        return toStr(1.5);
   39.38 -    }
   39.39 -
   39.40 -    @Compare public double longToAndBack() {
   39.41 -        return Double.parseDouble(toStr(Long.MAX_VALUE / 10));
   39.42 -    }
   39.43 -
   39.44 -    @Compare public String negativeIntToString() {
   39.45 -        return toStr(-10);
   39.46 -    }
   39.47 -
   39.48 -    @Compare public String negativeIntAndHalfToString() {
   39.49 -        return toStr(-10.5);
   39.50 -    }
   39.51 -
   39.52 -    @Compare public double negativeLongAndBack() {
   39.53 -        return Double.parseDouble(toStr(Long.MIN_VALUE / 10));
   39.54 -    }
   39.55 -    
   39.56 -    @Compare public double canParseExp() {
   39.57 -        return Double.parseDouble(toStr(1.7976931348623157e+308));
   39.58 -    }
   39.59 -    
   39.60 -    private static String toStr(double d) {
   39.61 -        return Double.toString(d);
   39.62 -    }
   39.63 -    
   39.64 -    @Factory 
   39.65 -    public static Object[] create() {
   39.66 -        return VMTest.create(DoubleTest.class);
   39.67 -    }
   39.68 -}
    40.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Sun Apr 28 10:14:31 2013 +0200
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,106 +0,0 @@
    40.4 -/**
    40.5 - * Back 2 Browser Bytecode Translator
    40.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    40.7 - *
    40.8 - * This program is free software: you can redistribute it and/or modify
    40.9 - * it under the terms of the GNU General Public License as published by
   40.10 - * the Free Software Foundation, version 2 of the License.
   40.11 - *
   40.12 - * This program is distributed in the hope that it will be useful,
   40.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   40.15 - * GNU General Public License for more details.
   40.16 - *
   40.17 - * You should have received a copy of the GNU General Public License
   40.18 - * along with this program. Look for COPYING file in the top folder.
   40.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   40.20 - */
   40.21 -package org.apidesign.bck2brwsr.tck;
   40.22 -
   40.23 -import java.io.InputStream;
   40.24 -import java.net.URL;
   40.25 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   40.26 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   40.27 -import org.apidesign.bck2brwsr.vmtest.Http;
   40.28 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   40.29 -import org.testng.annotations.Factory;
   40.30 -
   40.31 -/**
   40.32 - *
   40.33 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   40.34 - */
   40.35 -public class HttpResourceTest {
   40.36 -    
   40.37 -    @Http({
   40.38 -        @Http.Resource(path = "/xhr", content = "Hello Brwsr!", mimeType = "text/plain")
   40.39 -    })
   40.40 -    @BrwsrTest
   40.41 -    
   40.42 -    
   40.43 -    public String testReadContentViaXHR() throws Exception {
   40.44 -        String msg = read("/xhr");
   40.45 -        assert "Hello Brwsr!".equals(msg) : "The message was " + msg;
   40.46 -        return msg;
   40.47 -    }
   40.48 -
   40.49 -    @Http({
   40.50 -        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   40.51 -    })
   40.52 -    @BrwsrTest
   40.53 -    public String testReadContentViaURL() throws Exception {
   40.54 -        URL url = new URL("http:/url");
   40.55 -        String msg = (String) url.getContent();
   40.56 -        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   40.57 -        return msg;
   40.58 -    }
   40.59 -    @Http({
   40.60 -        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   40.61 -    })
   40.62 -    @BrwsrTest
   40.63 -    public String testReadContentViaURLWithStringParam() throws Exception {
   40.64 -        URL url = new URL("http:/url");
   40.65 -        String msg = (String) url.getContent(new Class[] { String.class });
   40.66 -        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   40.67 -        return msg;
   40.68 -    }
   40.69 -
   40.70 -    @Http({
   40.71 -        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   40.72 -    })
   40.73 -    @BrwsrTest
   40.74 -    public void testReadByte() throws Exception {
   40.75 -        URL url = new URL("http:/bytes");
   40.76 -        final Object res = url.getContent(new Class[] { byte[].class });
   40.77 -        assert res instanceof byte[] : "Expecting byte[]: " + res;
   40.78 -        byte[] arr = (byte[]) res;
   40.79 -        assert arr.length == 1 : "One byte " + arr.length;
   40.80 -        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   40.81 -    }
   40.82 -
   40.83 -    @Http({
   40.84 -        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   40.85 -    })
   40.86 -    @BrwsrTest
   40.87 -    public void testReadByteViaInputStream() throws Exception {
   40.88 -        URL url = new URL("http:/bytes");
   40.89 -        InputStream is = url.openStream();
   40.90 -        byte[] arr = new byte[10];
   40.91 -        int len = is.read(arr);
   40.92 -        assert len == 1 : "One byte " + len;
   40.93 -        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   40.94 -    }
   40.95 -    
   40.96 -    @JavaScriptBody(args = { "url" }, body = 
   40.97 -          "var req = new XMLHttpRequest();\n"
   40.98 -        + "req.open('GET', url, false);\n"
   40.99 -        + "req.send();\n"
  40.100 -        + "return req.responseText;"
  40.101 -    )
  40.102 -    private static native String read(String url);
  40.103 -    
  40.104 -    
  40.105 -    @Factory
  40.106 -    public static Object[] create() {
  40.107 -        return VMTest.create(HttpResourceTest.class);
  40.108 -    }
  40.109 -}
    41.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java	Sun Apr 28 10:14:31 2013 +0200
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,34 +0,0 @@
    41.4 -/**
    41.5 - * Back 2 Browser Bytecode Translator
    41.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    41.7 - *
    41.8 - * This program is free software: you can redistribute it and/or modify
    41.9 - * it under the terms of the GNU General Public License as published by
   41.10 - * the Free Software Foundation, version 2 of the License.
   41.11 - *
   41.12 - * This program is distributed in the hope that it will be useful,
   41.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   41.15 - * GNU General Public License for more details.
   41.16 - *
   41.17 - * You should have received a copy of the GNU General Public License
   41.18 - * along with this program. Look for COPYING file in the top folder.
   41.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   41.20 - */
   41.21 -package org.apidesign.bck2brwsr.tck;
   41.22 -
   41.23 -/**
   41.24 - *
   41.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   41.26 - */
   41.27 -public class InheritanceA {
   41.28 -    private String name;
   41.29 -    
   41.30 -    public void setA(String n) {
   41.31 -        this.name = n;
   41.32 -    }
   41.33 -    
   41.34 -    public String getA() {
   41.35 -        return name;
   41.36 -    }
   41.37 -}
    42.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java	Sun Apr 28 10:14:31 2013 +0200
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,34 +0,0 @@
    42.4 -/**
    42.5 - * Back 2 Browser Bytecode Translator
    42.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    42.7 - *
    42.8 - * This program is free software: you can redistribute it and/or modify
    42.9 - * it under the terms of the GNU General Public License as published by
   42.10 - * the Free Software Foundation, version 2 of the License.
   42.11 - *
   42.12 - * This program is distributed in the hope that it will be useful,
   42.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   42.15 - * GNU General Public License for more details.
   42.16 - *
   42.17 - * You should have received a copy of the GNU General Public License
   42.18 - * along with this program. Look for COPYING file in the top folder.
   42.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   42.20 - */
   42.21 -package org.apidesign.bck2brwsr.tck;
   42.22 -
   42.23 -/**
   42.24 - *
   42.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   42.26 - */
   42.27 -public class InheritanceB extends InheritanceA {
   42.28 -    private String name;
   42.29 -    
   42.30 -    public void setB(String n) {
   42.31 -        this.name = n;
   42.32 -    }
   42.33 -    
   42.34 -    public String getB() {
   42.35 -        return name;
   42.36 -    }
   42.37 -}
    43.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java	Sun Apr 28 10:14:31 2013 +0200
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,41 +0,0 @@
    43.4 -/**
    43.5 - * Back 2 Browser Bytecode Translator
    43.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    43.7 - *
    43.8 - * This program is free software: you can redistribute it and/or modify
    43.9 - * it under the terms of the GNU General Public License as published by
   43.10 - * the Free Software Foundation, version 2 of the License.
   43.11 - *
   43.12 - * This program is distributed in the hope that it will be useful,
   43.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   43.15 - * GNU General Public License for more details.
   43.16 - *
   43.17 - * You should have received a copy of the GNU General Public License
   43.18 - * along with this program. Look for COPYING file in the top folder.
   43.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   43.20 - */
   43.21 -package org.apidesign.bck2brwsr.tck;
   43.22 -
   43.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   43.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   43.25 -import org.testng.annotations.Factory;
   43.26 -
   43.27 -/**
   43.28 - *
   43.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   43.30 - */
   43.31 -public class InheritanceTest {
   43.32 -
   43.33 -    @Compare public String checkFieldsIndependent() throws ClassNotFoundException {
   43.34 -        InheritanceB ib = new InheritanceB();
   43.35 -        ib.setA("A");
   43.36 -        ib.setB("B");
   43.37 -        return "A: " + ib.getA() + " B: " + ib.getB();
   43.38 -    }
   43.39 -    
   43.40 -    @Factory
   43.41 -    public static Object[] create() {
   43.42 -        return VMTest.create(InheritanceTest.class);
   43.43 -    }
   43.44 -}
    44.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Sun Apr 28 10:14:31 2013 +0200
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,166 +0,0 @@
    44.4 -/**
    44.5 - * Back 2 Browser Bytecode Translator
    44.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    44.7 - *
    44.8 - * This program is free software: you can redistribute it and/or modify
    44.9 - * it under the terms of the GNU General Public License as published by
   44.10 - * the Free Software Foundation, version 2 of the License.
   44.11 - *
   44.12 - * This program is distributed in the hope that it will be useful,
   44.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   44.15 - * GNU General Public License for more details.
   44.16 - *
   44.17 - * You should have received a copy of the GNU General Public License
   44.18 - * along with this program. Look for COPYING file in the top folder.
   44.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   44.20 - */
   44.21 -package org.apidesign.bck2brwsr.tck;
   44.22 -
   44.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   44.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   44.25 -import org.testng.annotations.Factory;
   44.26 -
   44.27 -/**
   44.28 - *
   44.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   44.30 - */
   44.31 -public class IntegerArithmeticTest {
   44.32 -    
   44.33 -    private static int add(int x, int y) {
   44.34 -        return x + y;
   44.35 -    }
   44.36 -    
   44.37 -    private static int sub(int x, int y) {
   44.38 -        return x - y;
   44.39 -    }
   44.40 -    
   44.41 -    private static int mul(int x, int y) {
   44.42 -        return x * y;
   44.43 -    }
   44.44 -    
   44.45 -    private static int div(int x, int y) {
   44.46 -        return x / y;
   44.47 -    }
   44.48 -    
   44.49 -    private static int mod(int x, int y) {
   44.50 -        return x % y;
   44.51 -    }
   44.52 -    
   44.53 -    private static int neg(int x) {
   44.54 -        return (-x);
   44.55 -    }
   44.56 -
   44.57 -    private static float fadd(float x, float y) {
   44.58 -        return x + y;
   44.59 -    }
   44.60 -
   44.61 -    private static double dadd(double x, double y) {
   44.62 -        return x + y;
   44.63 -    }
   44.64 -    
   44.65 -    @Compare public int addOverflow() {
   44.66 -        return add(Integer.MAX_VALUE, 1);
   44.67 -    }
   44.68 -    
   44.69 -    @Compare public int subUnderflow() {
   44.70 -        return sub(Integer.MIN_VALUE, 1);
   44.71 -    }
   44.72 -    
   44.73 -    @Compare public int addMaxIntAndMaxInt() {
   44.74 -        return add(Integer.MAX_VALUE, Integer.MAX_VALUE);
   44.75 -    }
   44.76 -    
   44.77 -    @Compare public int subMinIntAndMinInt() {
   44.78 -        return sub(Integer.MIN_VALUE, Integer.MIN_VALUE);
   44.79 -    }
   44.80 -    
   44.81 -    @Compare public int multiplyMaxInt() {
   44.82 -        return mul(Integer.MAX_VALUE, 2);
   44.83 -    }
   44.84 -    
   44.85 -    @Compare public int multiplyMaxIntAndMaxInt() {
   44.86 -        return mul(Integer.MAX_VALUE, Integer.MAX_VALUE);
   44.87 -    }
   44.88 -    
   44.89 -    @Compare public int multiplyMinInt() {
   44.90 -        return mul(Integer.MIN_VALUE, 2);
   44.91 -    }
   44.92 -    
   44.93 -    @Compare public int multiplyMinIntAndMinInt() {
   44.94 -        return mul(Integer.MIN_VALUE, Integer.MIN_VALUE);
   44.95 -    }
   44.96 -    
   44.97 -    @Compare public int multiplyPrecision() {
   44.98 -        return mul(119106029, 1103515245);
   44.99 -    }
  44.100 -    
  44.101 -    @Compare public int division() {
  44.102 -        return div(1, 2);
  44.103 -    }
  44.104 -
  44.105 -    @Compare public int divisionReminder() {
  44.106 -        return mod(1, 2);
  44.107 -    }
  44.108 -
  44.109 -    @Compare public int negativeDivision() {
  44.110 -        return div(-7, 3);
  44.111 -    }
  44.112 -
  44.113 -    @Compare public int negativeDivisionReminder() {
  44.114 -        return mod(-7, 3);
  44.115 -    }
  44.116 -
  44.117 -    @Compare public int conversionFromFloat() {
  44.118 -        return (int) fadd(-2, -0.6f);
  44.119 -    }
  44.120 -
  44.121 -    @Compare public int conversionFromDouble() {
  44.122 -        return (int) dadd(-2, -0.6);
  44.123 -    }
  44.124 -
  44.125 -    @Compare public boolean divByZeroThrowsArithmeticException() {
  44.126 -        try {
  44.127 -            div(1, 0);
  44.128 -            return false;
  44.129 -        } catch (final ArithmeticException e) {
  44.130 -            return true;
  44.131 -        }
  44.132 -    }
  44.133 -
  44.134 -    @Compare public boolean modByZeroThrowsArithmeticException() {
  44.135 -        try {
  44.136 -            mod(1, 0);
  44.137 -            return false;
  44.138 -        } catch (final ArithmeticException e) {
  44.139 -            return true;
  44.140 -        }
  44.141 -    }
  44.142 -
  44.143 -    @Compare public int negate() {
  44.144 -        return neg(123456);
  44.145 -    }
  44.146 -    
  44.147 -    @Compare public int negateMaxInt() {
  44.148 -        return neg(Integer.MAX_VALUE);
  44.149 -    }
  44.150 -    
  44.151 -    @Compare public int negateMinInt() {
  44.152 -        return neg(Integer.MIN_VALUE);
  44.153 -    }
  44.154 -    
  44.155 -    @Compare public int sumTwoDimensions() {
  44.156 -        int[][] matrix = createMatrix(4, 3);
  44.157 -        matrix[0][0] += 10;
  44.158 -        return matrix[0][0];
  44.159 -    }
  44.160 -    
  44.161 -    static int[][] createMatrix(int x, int y) {
  44.162 -        return new int[x][y];
  44.163 -    }
  44.164 -    
  44.165 -    @Factory
  44.166 -    public static Object[] create() {
  44.167 -        return VMTest.create(IntegerArithmeticTest.class);
  44.168 -    }
  44.169 -}
    45.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Sun Apr 28 10:14:31 2013 +0200
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,376 +0,0 @@
    45.4 -/**
    45.5 - * Back 2 Browser Bytecode Translator
    45.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    45.7 - *
    45.8 - * This program is free software: you can redistribute it and/or modify
    45.9 - * it under the terms of the GNU General Public License as published by
   45.10 - * the Free Software Foundation, version 2 of the License.
   45.11 - *
   45.12 - * This program is distributed in the hope that it will be useful,
   45.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   45.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   45.15 - * GNU General Public License for more details.
   45.16 - *
   45.17 - * You should have received a copy of the GNU General Public License
   45.18 - * along with this program. Look for COPYING file in the top folder.
   45.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   45.20 - */
   45.21 -package org.apidesign.bck2brwsr.tck;
   45.22 -
   45.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   45.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   45.25 -import org.testng.annotations.Factory;
   45.26 -
   45.27 -/**
   45.28 - *
   45.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   45.30 - */
   45.31 -public class LongArithmeticTest {
   45.32 -
   45.33 -    private static long add(long x, long y) {
   45.34 -        return (x + y);
   45.35 -    }
   45.36 -
   45.37 -    private static long sub(long x, long y) {
   45.38 -        return (x - y);
   45.39 -    }
   45.40 -
   45.41 -    private static long mul(long x, long y) {
   45.42 -        return (x * y);
   45.43 -    }
   45.44 -
   45.45 -    private static long div(long x, long y) {
   45.46 -        return (x / y);
   45.47 -    }
   45.48 -
   45.49 -    private static long mod(long x, long y) {
   45.50 -        return (x % y);
   45.51 -    }
   45.52 -
   45.53 -    private static long neg(long x) {
   45.54 -        return (-x);
   45.55 -    }
   45.56 -
   45.57 -    private static long shl(long x, int b) {
   45.58 -        return (x << b);
   45.59 -    }
   45.60 -
   45.61 -    private static long shr(long x, int b) {
   45.62 -        return (x >> b);
   45.63 -    }
   45.64 -
   45.65 -    private static long ushr(long x, int b) {
   45.66 -        return (x >>> b);
   45.67 -    }
   45.68 -
   45.69 -    private static long and(long x, long y) {
   45.70 -        return (x & y);
   45.71 -    }
   45.72 -
   45.73 -    private static long or(long x, long y) {
   45.74 -        return (x | y);
   45.75 -    }
   45.76 -
   45.77 -    private static long xor(long x, long y) {
   45.78 -        return (x ^ y);
   45.79 -    }
   45.80 -
   45.81 -    private static float fadd(float x, float y) {
   45.82 -        return x + y;
   45.83 -    }
   45.84 -
   45.85 -    private static double dadd(double x, double y) {
   45.86 -        return x + y;
   45.87 -    }
   45.88 -
   45.89 -    public static int compare(long x, long y, int zero) {
   45.90 -        final int xyResult = compareL(x, y, zero);
   45.91 -        final int yxResult = compareL(y, x, zero);
   45.92 -
   45.93 -        return ((xyResult + yxResult) == 0) ? xyResult : -2;
   45.94 -    }
   45.95 -
   45.96 -    private static int compareL(long x, long y, int zero) {
   45.97 -        int result = -2;
   45.98 -        int trueCount = 0;
   45.99 -
  45.100 -        x += zero;
  45.101 -        if (x == y) {
  45.102 -            result = 0;
  45.103 -            ++trueCount;
  45.104 -        }
  45.105 -
  45.106 -        x += zero;
  45.107 -        if (x < y) {
  45.108 -            result = -1;
  45.109 -            ++trueCount;
  45.110 -        }
  45.111 -
  45.112 -        x += zero;
  45.113 -        if (x > y) {
  45.114 -            result = 1;
  45.115 -            ++trueCount;
  45.116 -        }
  45.117 -
  45.118 -        return (trueCount == 1) ? result : -2;
  45.119 -    }
  45.120 -
  45.121 -    @Compare public long conversion() {
  45.122 -        return Long.MAX_VALUE;
  45.123 -    }
  45.124 -
  45.125 -    @Compare public long negate1() {
  45.126 -        return neg(0x00fa37d7763e0ca1l);
  45.127 -    }
  45.128 -
  45.129 -    @Compare public long negate2() {
  45.130 -        return neg(0x80fa37d7763e0ca1l);
  45.131 -    }
  45.132 -
  45.133 -    @Compare public long negate3() {
  45.134 -        return neg(0xfffffffffffffeddl);
  45.135 -    }
  45.136 -
  45.137 -    @Compare public long addOverflow() {
  45.138 -        return add(Long.MAX_VALUE, 1l);
  45.139 -    }
  45.140 -
  45.141 -    @Compare public long subUnderflow() {
  45.142 -        return sub(Long.MIN_VALUE, 1l);
  45.143 -    }
  45.144 -
  45.145 -    @Compare public long addMaxLongAndMaxLong() {
  45.146 -        return add(Long.MAX_VALUE, Long.MAX_VALUE);
  45.147 -    }
  45.148 -
  45.149 -    @Compare public long subMinLongAndMinLong() {
  45.150 -        return sub(Long.MIN_VALUE, Long.MIN_VALUE);
  45.151 -    }
  45.152 -
  45.153 -    @Compare public long subMinLongAndMaxLong() {
  45.154 -        return sub(Long.MIN_VALUE, Long.MAX_VALUE);
  45.155 -    }
  45.156 -
  45.157 -    @Compare public long multiplyMaxLong() {
  45.158 -        return mul(Long.MAX_VALUE, 2l);
  45.159 -    }
  45.160 -
  45.161 -    @Compare public long multiplyMaxLongAndMaxLong() {
  45.162 -        return mul(Long.MAX_VALUE, Long.MAX_VALUE);
  45.163 -    }
  45.164 -
  45.165 -    @Compare public long multiplyMinLong() {
  45.166 -        return mul(Long.MIN_VALUE, 2l);
  45.167 -    }
  45.168 -
  45.169 -    @Compare public long multiplyMinLongAndMinLong() {
  45.170 -        return mul(Long.MIN_VALUE, Long.MIN_VALUE);
  45.171 -    }
  45.172 -
  45.173 -    @Compare public long multiplyPrecision() {
  45.174 -        return mul(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  45.175 -    }
  45.176 -
  45.177 -    @Compare public long divideSmallPositiveNumbers() {
  45.178 -        return div(0xabcdef, 0x123);
  45.179 -    }
  45.180 -
  45.181 -    @Compare public long divideSmallNegativeNumbers() {
  45.182 -        return div(-0xabcdef, -0x123);
  45.183 -    }
  45.184 -
  45.185 -    @Compare public long divideSmallMixedNumbers() {
  45.186 -        return div(0xabcdef, -0x123);
  45.187 -    }
  45.188 -
  45.189 -    @Compare public long dividePositiveNumbersOneDigitDenom() {
  45.190 -        return div(0xabcdef0102ffffl, 0x654);
  45.191 -    }
  45.192 -
  45.193 -    @Compare public long divideNegativeNumbersOneDigitDenom() {
  45.194 -        return div(-0xabcdef0102ffffl, -0x654);
  45.195 -    }
  45.196 -
  45.197 -    @Compare public long divideMixedNumbersOneDigitDenom() {
  45.198 -        return div(-0xabcdef0102ffffl, 0x654);
  45.199 -    }
  45.200 -
  45.201 -    @Compare public long dividePositiveNumbersMultiDigitDenom() {
  45.202 -        return div(0x7ffefc003322aabbl, 0x89ab1000l);
  45.203 -    }
  45.204 -
  45.205 -    @Compare public long divideNegativeNumbersMultiDigitDenom() {
  45.206 -        return div(-0x7ffefc003322aabbl, -0x123489ab1001l);
  45.207 -    }
  45.208 -
  45.209 -    @Compare public long divideMixedNumbersMultiDigitDenom() {
  45.210 -        return div(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  45.211 -    }
  45.212 -
  45.213 -    @Compare public long divideWithOverflow() {
  45.214 -        return div(0x8000fffe0000l, 0x8000ffffl);
  45.215 -    }
  45.216 -
  45.217 -    @Compare public long divideWithCorrection() {
  45.218 -        return div(0x7fff800000000000l, 0x800000000001l);
  45.219 -    }
  45.220 -
  45.221 -    @Compare public long moduloSmallPositiveNumbers() {
  45.222 -        return mod(0xabcdef, 0x123);
  45.223 -    }
  45.224 -
  45.225 -    @Compare public long moduloSmallNegativeNumbers() {
  45.226 -        return mod(-0xabcdef, -0x123);
  45.227 -    }
  45.228 -
  45.229 -    @Compare public long moduloSmallMixedNumbers() {
  45.230 -        return mod(0xabcdef, -0x123);
  45.231 -    }
  45.232 -
  45.233 -    @Compare public long moduloPositiveNumbersOneDigitDenom() {
  45.234 -        return mod(0xabcdef0102ffffl, 0x654);
  45.235 -    }
  45.236 -
  45.237 -    @Compare public long moduloNegativeNumbersOneDigitDenom() {
  45.238 -        return mod(-0xabcdef0102ffffl, -0x654);
  45.239 -    }
  45.240 -
  45.241 -    @Compare public long moduloMixedNumbersOneDigitDenom() {
  45.242 -        return mod(-0xabcdef0102ffffl, 0x654);
  45.243 -    }
  45.244 -
  45.245 -    @Compare public long moduloPositiveNumbersMultiDigitDenom() {
  45.246 -        return mod(0x7ffefc003322aabbl, 0x89ab1000l);
  45.247 -    }
  45.248 -
  45.249 -    @Compare public long moduloNegativeNumbersMultiDigitDenom() {
  45.250 -        return mod(-0x7ffefc003322aabbl, -0x123489ab1001l);
  45.251 -    }
  45.252 -
  45.253 -    @Compare public long moduloMixedNumbersMultiDigitDenom() {
  45.254 -        return mod(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  45.255 -    }
  45.256 -
  45.257 -    @Compare public long moduloWithOverflow() {
  45.258 -        return mod(0x8000fffe0000l, 0x8000ffffl);
  45.259 -    }
  45.260 -
  45.261 -    @Compare public long moduloWithCorrection() {
  45.262 -        return mod(0x7fff800000000000l, 0x800000000001l);
  45.263 -    }
  45.264 -
  45.265 -    @Compare public long conversionFromFloatPositive() {
  45.266 -        return (long) fadd(2, 0.6f);
  45.267 -    }
  45.268 -
  45.269 -    @Compare public long conversionFromFloatNegative() {
  45.270 -        return (long) fadd(-2, -0.6f);
  45.271 -    }
  45.272 -
  45.273 -    @Compare public long conversionFromDoublePositive() {
  45.274 -        return (long) dadd(0x20ffff0000L, 0.6);
  45.275 -    }
  45.276 -
  45.277 -    @Compare public long conversionFromDoubleNegative() {
  45.278 -        return (long) dadd(-0x20ffff0000L, -0.6);
  45.279 -    }
  45.280 -
  45.281 -    @Compare public boolean divByZeroThrowsArithmeticException() {
  45.282 -        try {
  45.283 -            div(1, 0);
  45.284 -            return false;
  45.285 -        } catch (final ArithmeticException e) {
  45.286 -            return true;
  45.287 -        }
  45.288 -    }
  45.289 -
  45.290 -    @Compare public boolean modByZeroThrowsArithmeticException() {
  45.291 -        try {
  45.292 -            mod(1, 0);
  45.293 -            return false;
  45.294 -        } catch (final ArithmeticException e) {
  45.295 -            return true;
  45.296 -        }
  45.297 -    }
  45.298 -
  45.299 -    @Compare public long shiftL1() {
  45.300 -        return shl(0x00fa37d7763e0ca1l, 5);
  45.301 -    }
  45.302 -
  45.303 -    @Compare public long shiftL2() {
  45.304 -        return shl(0x00fa37d7763e0ca1l, 32);
  45.305 -    }
  45.306 -
  45.307 -    @Compare public long shiftL3() {
  45.308 -        return shl(0x00fa37d7763e0ca1l, 45);
  45.309 -    }
  45.310 -
  45.311 -    @Compare public long shiftR1() {
  45.312 -        return shr(0x00fa37d7763e0ca1l, 5);
  45.313 -    }
  45.314 -
  45.315 -    @Compare public long shiftR2() {
  45.316 -        return shr(0x00fa37d7763e0ca1l, 32);
  45.317 -    }
  45.318 -
  45.319 -    @Compare public long shiftR3() {
  45.320 -        return shr(0x00fa37d7763e0ca1l, 45);
  45.321 -    }
  45.322 -
  45.323 -    @Compare public long uShiftR1() {
  45.324 -        return ushr(0x00fa37d7763e0ca1l, 5);
  45.325 -    }
  45.326 -
  45.327 -    @Compare public long uShiftR2() {
  45.328 -        return ushr(0x00fa37d7763e0ca1l, 45);
  45.329 -    }
  45.330 -
  45.331 -    @Compare public long uShiftR3() {
  45.332 -        return ushr(0xf0fa37d7763e0ca1l, 5);
  45.333 -    }
  45.334 -
  45.335 -    @Compare public long uShiftR4() {
  45.336 -        return ushr(0xf0fa37d7763e0ca1l, 45);
  45.337 -    }
  45.338 -
  45.339 -    @Compare public long and1() {
  45.340 -        return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  45.341 -    }
  45.342 -
  45.343 -    @Compare public long or1() {
  45.344 -        return or(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  45.345 -    }
  45.346 -
  45.347 -    @Compare public long xor1() {
  45.348 -        return xor(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  45.349 -    }
  45.350 -
  45.351 -    @Compare public long xor2() {
  45.352 -        return xor(0x00fa37d7763e0ca1l, 0x00000000ff00123el);
  45.353 -    }
  45.354 -
  45.355 -    @Compare public long xor3() {
  45.356 -        return xor(0x00000000763e0ca1l, 0x00000000ff00123el);
  45.357 -    }
  45.358 -
  45.359 -    @Compare public int compareSameNumbers() {
  45.360 -        return compare(0x0000000000000000l, 0x0000000000000000l, 0);
  45.361 -    }
  45.362 -
  45.363 -    @Compare public int comparePositiveNumbers() {
  45.364 -        return compare(0x0000000000200000l, 0x0000000010000000l, 0);
  45.365 -    }
  45.366 -
  45.367 -    @Compare public int compareNegativeNumbers() {
  45.368 -        return compare(0xffffffffffffffffl, 0xffffffff00000000l, 0);
  45.369 -    }
  45.370 -
  45.371 -    @Compare public int compareMixedNumbers() {
  45.372 -        return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
  45.373 -    }
  45.374 -    
  45.375 -    @Factory
  45.376 -    public static Object[] create() {
  45.377 -        return VMTest.create(LongArithmeticTest.class);
  45.378 -    }
  45.379 -}
    46.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java	Sun Apr 28 10:14:31 2013 +0200
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,161 +0,0 @@
    46.4 -/**
    46.5 - * Back 2 Browser Bytecode Translator
    46.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    46.7 - *
    46.8 - * This program is free software: you can redistribute it and/or modify
    46.9 - * it under the terms of the GNU General Public License as published by
   46.10 - * the Free Software Foundation, version 2 of the License.
   46.11 - *
   46.12 - * This program is distributed in the hope that it will be useful,
   46.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   46.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   46.15 - * GNU General Public License for more details.
   46.16 - *
   46.17 - * You should have received a copy of the GNU General Public License
   46.18 - * along with this program. Look for COPYING file in the top folder.
   46.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   46.20 - */
   46.21 -package org.apidesign.bck2brwsr.tck;
   46.22 -
   46.23 -import java.lang.reflect.Array;
   46.24 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   46.25 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   46.26 -import org.apidesign.bck2brwsr.vmtest.Compare;
   46.27 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   46.28 -import org.testng.annotations.Factory;
   46.29 -
   46.30 -/**
   46.31 - *
   46.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   46.33 - */
   46.34 -public class ReflectionArrayTest {
   46.35 -    @Compare public int lengthOfStringArray() {
   46.36 -        String[] arr = (String[]) Array.newInstance(String.class, 10);
   46.37 -        return arr.length;
   46.38 -    }
   46.39 -    
   46.40 -    @Compare public int reflectiveLengthOfStringArray() {
   46.41 -        Object arr = Array.newInstance(String.class, 10);
   46.42 -        return Array.getLength(arr);
   46.43 -    }
   46.44 -
   46.45 -    @Compare public int reflectiveLengthOneNonArray() {
   46.46 -        Object arr = "non-array";
   46.47 -        return Array.getLength(arr);
   46.48 -    }
   46.49 -
   46.50 -    @Compare public String compTypeOfStringArray() {
   46.51 -        String[] arr = (String[]) Array.newInstance(String.class, 10);
   46.52 -        return arr.getClass().getComponentType().getName();
   46.53 -    }
   46.54 -
   46.55 -    @Compare public Object negativeArrayExcp() {
   46.56 -        return Array.newInstance(String.class, -5);
   46.57 -    }
   46.58 -    
   46.59 -    @Compare public int lengthOfIntArray() {
   46.60 -        int[] arr = (int[]) Array.newInstance(Integer.TYPE, 10);
   46.61 -        return arr.length;
   46.62 -    }
   46.63 -
   46.64 -    @Compare public int reflectiveLengthOfIntArray() {
   46.65 -        Object arr = Array.newInstance(Integer.TYPE, 10);
   46.66 -        return Array.getLength(arr);
   46.67 -    }
   46.68 -
   46.69 -    @Compare public String compTypeOfIntArray() {
   46.70 -        int[] arr = (int[]) Array.newInstance(int.class, 10);
   46.71 -        return arr.getClass().getComponentType().getName();
   46.72 -    }
   46.73 -
   46.74 -    @Compare public Object intNegativeArrayExcp() {
   46.75 -        return Array.newInstance(int.class, -5);
   46.76 -    }
   46.77 -
   46.78 -    @Compare public Integer verifyAutobox() {
   46.79 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   46.80 -        return (Integer) Array.get(arr, 0);
   46.81 -    }
   46.82 -    @Compare public String verifyObjectArray() {
   46.83 -        String[] arr = (String[]) Array.newInstance(String.class, 5);
   46.84 -        Array.set(arr, 0, "Hello");
   46.85 -        return (String) Array.get(arr, 0);
   46.86 -    }
   46.87 -    @Compare public int verifyInt() {
   46.88 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   46.89 -        return Array.getInt(arr, 0);
   46.90 -    }
   46.91 -    @Compare public long verifyConvertToLong() {
   46.92 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   46.93 -        return Array.getLong(arr, 0);
   46.94 -    }
   46.95 -
   46.96 -    @Compare public Object verifySetIntToObject() {
   46.97 -        try {
   46.98 -            Object[] arr = (Object[]) Array.newInstance(Object.class, 5);
   46.99 -            Array.setInt(arr, 0, 10);
  46.100 -            return Array.get(arr, 0);
  46.101 -        } catch (Exception exception) {
  46.102 -            return exception.getClass().getName();
  46.103 -        }
  46.104 -    }
  46.105 -    @Compare public long verifySetShort() {
  46.106 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  46.107 -        Array.setShort(arr, 0, (short)10);
  46.108 -        return Array.getLong(arr, 0);
  46.109 -    }
  46.110 -    @Compare public long verifyCantSetLong() {
  46.111 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  46.112 -        Array.setLong(arr, 0, 10);
  46.113 -        return Array.getLong(arr, 0);
  46.114 -    }
  46.115 -    @Compare public float verifyLongToFloat() {
  46.116 -        Object arr = Array.newInstance(float.class, 5);
  46.117 -        Array.setLong(arr, 0, 10);
  46.118 -        return Array.getFloat(arr, 0);
  46.119 -    }
  46.120 -
  46.121 -    @Compare public double verifyConvertToDouble() {
  46.122 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  46.123 -        return Array.getDouble(arr, 0);
  46.124 -    }
  46.125 -    
  46.126 -    @Compare public int multiIntArray() {
  46.127 -        int[][][] arr = (int[][][]) Array.newInstance(int.class, 3, 3, 3);
  46.128 -        return arr[0][1][2] + 5 + arr[2][2][0];
  46.129 -    }
  46.130 -
  46.131 -    @Compare public String multiIntArrayCompType() {
  46.132 -        return Array.newInstance(int.class, 3, 3, 3).getClass().getName();
  46.133 -    }
  46.134 -    
  46.135 -    @JavaScriptBody(args = {}, body = "return [1, 2];")
  46.136 -    private static native Object crtarr();
  46.137 -
  46.138 -    @JavaScriptBody(args = {}, body = "return new Object();")
  46.139 -    private static native Object newobj();
  46.140 -
  46.141 -    @BrwsrTest
  46.142 -    public static void toStringArray() {
  46.143 -        final Object arr = crtarr();
  46.144 -        final Object real = new Object[2];
  46.145 -        assert arr instanceof Object[] : "Any array is Java array: " + arr;
  46.146 -        assert arr.getClass() == real.getClass() : "Same classes " + arr + " and " + real.getClass();
  46.147 -        final String str = arr.toString();
  46.148 -        assert str != null;
  46.149 -        assert str.startsWith("[Ljava.lang.Object;@") : str;
  46.150 -    }
  46.151 -    
  46.152 -    @BrwsrTest
  46.153 -    public static void objectToString() {
  46.154 -        String s = newobj().toString();
  46.155 -        assert s != null : "Some string computed";
  46.156 -        assert s.startsWith("java.lang.Object@") : "Regular object toString(): " + s;
  46.157 -    }
  46.158 -
  46.159 -    
  46.160 -    @Factory
  46.161 -    public static Object[] create() {
  46.162 -        return VMTest.create(ReflectionArrayTest.class);
  46.163 -    }
  46.164 -}
    47.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Sun Apr 28 10:14:31 2013 +0200
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,272 +0,0 @@
    47.4 -/**
    47.5 - * Back 2 Browser Bytecode Translator
    47.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    47.7 - *
    47.8 - * This program is free software: you can redistribute it and/or modify
    47.9 - * it under the terms of the GNU General Public License as published by
   47.10 - * the Free Software Foundation, version 2 of the License.
   47.11 - *
   47.12 - * This program is distributed in the hope that it will be useful,
   47.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   47.15 - * GNU General Public License for more details.
   47.16 - *
   47.17 - * You should have received a copy of the GNU General Public License
   47.18 - * along with this program. Look for COPYING file in the top folder.
   47.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   47.20 - */
   47.21 -package org.apidesign.bck2brwsr.tck;
   47.22 -
   47.23 -import java.lang.annotation.Retention;
   47.24 -import java.lang.annotation.RetentionPolicy;
   47.25 -import java.lang.reflect.Method;
   47.26 -import java.util.Arrays;
   47.27 -import java.util.Collections;
   47.28 -import java.util.List;
   47.29 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   47.30 -import org.apidesign.bck2brwsr.vmtest.Compare;
   47.31 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   47.32 -import org.testng.annotations.Factory;
   47.33 -
   47.34 -/**
   47.35 - *
   47.36 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   47.37 - */
   47.38 -public class ReflectionTest {
   47.39 -    @Compare public boolean nonNullThis() {
   47.40 -        return this == null;
   47.41 -    }
   47.42 -    
   47.43 -    @Compare public String intType() {
   47.44 -        return Integer.TYPE.toString();
   47.45 -    }
   47.46 -
   47.47 -    @Compare public String voidType() throws Exception {
   47.48 -        return void.class.toString();
   47.49 -    }
   47.50 -
   47.51 -    @Compare public String longClass() {
   47.52 -        return long.class.toString();
   47.53 -    }
   47.54 -    
   47.55 -    @Compare public boolean isRunnableInterface() {
   47.56 -        return Runnable.class.isInterface();
   47.57 -    }
   47.58 -
   47.59 -    @Compare public boolean isAssignableToPrimitiveType() {
   47.60 -        return boolean.class.isAssignableFrom(Runnable.class);
   47.61 -    }
   47.62 -
   47.63 -    @Compare public boolean isAssignableFromPrimitiveType() {
   47.64 -        return Runnable.class.isAssignableFrom(boolean.class);
   47.65 -    }
   47.66 -
   47.67 -    @Compare public boolean isAssignableLongFromInt() {
   47.68 -        return long.class.isAssignableFrom(int.class);
   47.69 -    }
   47.70 -
   47.71 -    @Compare public boolean isAssignableIntFromLong() {
   47.72 -        return int.class.isAssignableFrom(long.class);
   47.73 -    }
   47.74 -
   47.75 -    @Compare public String isRunnableHasRunMethod() throws NoSuchMethodException {
   47.76 -        return Runnable.class.getMethod("run").getName();
   47.77 -    }
   47.78 -    
   47.79 -    @Compare public String namesOfMethods() {
   47.80 -        StringBuilder sb = new StringBuilder();
   47.81 -        String[] arr = new String[20];
   47.82 -        int i = 0;
   47.83 -        for (Method m : StaticUse.class.getMethods()) {
   47.84 -            arr[i++] = m.getName();
   47.85 -        }
   47.86 -        for (String s : sort(arr, i)) {
   47.87 -            sb.append(s).append("\n");
   47.88 -        }
   47.89 -        return sb.toString();
   47.90 -    }
   47.91 -
   47.92 -    @Compare public String namesOfDeclaringClassesOfMethods() {
   47.93 -        StringBuilder sb = new StringBuilder();
   47.94 -        String[] arr = new String[20];
   47.95 -        int i = 0;
   47.96 -        for (Method m : StaticUse.class.getMethods()) {
   47.97 -            arr[i++] = m.getName() + "@" + m.getDeclaringClass().getName();
   47.98 -        }
   47.99 -        for (String s : sort(arr, i)) {
  47.100 -            sb.append(s).append("\n");
  47.101 -        }
  47.102 -        return sb.toString();
  47.103 -    }
  47.104 -    
  47.105 -    @Compare public String cannotCallNonStaticMethodWithNull() throws Exception {
  47.106 -        StaticUse.class.getMethod("instanceMethod").invoke(null);
  47.107 -        return "should not happen";
  47.108 -    }
  47.109 -    
  47.110 -    @Compare public String classCastException() {
  47.111 -        try {
  47.112 -            Integer i = (Integer)StaticUseSub.getNonNull();
  47.113 -            return "" + i.intValue();
  47.114 -        } catch (ClassCastException ex) {
  47.115 -            return ex.getClass().getName();
  47.116 -        }
  47.117 -    }
  47.118 -
  47.119 -    @Compare public String methodThatThrowsException() throws Exception {
  47.120 -        StaticUse.class.getMethod("instanceMethod").invoke(new StaticUse());
  47.121 -        return "should not happen";
  47.122 -    }
  47.123 -
  47.124 -    @Compare public Object voidReturnType() throws Exception {
  47.125 -        return StaticUse.class.getMethod("instanceMethod").getReturnType();
  47.126 -    }
  47.127 -    
  47.128 -    @Retention(RetentionPolicy.RUNTIME)
  47.129 -    @interface Ann {
  47.130 -    }
  47.131 -    
  47.132 -    @Compare public String annoClass() throws Exception {
  47.133 -        Retention r = Ann.class.getAnnotation(Retention.class);
  47.134 -        assert r != null : "Annotation is present";
  47.135 -        assert r.value() == RetentionPolicy.RUNTIME : "Policy value is OK: " + r.value();
  47.136 -        return r.annotationType().getName();
  47.137 -    }
  47.138 -    
  47.139 -    @Compare public boolean isAnnotation() {
  47.140 -        return Ann.class.isAnnotation();
  47.141 -    }
  47.142 -    @Compare public boolean isNotAnnotation() {
  47.143 -        return String.class.isAnnotation();
  47.144 -    }
  47.145 -    @Compare public boolean isNotAnnotationEnum() {
  47.146 -        return E.class.isAnnotation();
  47.147 -    }
  47.148 -    enum E { A, B };
  47.149 -    @Compare public boolean isEnum() {
  47.150 -        return E.A.getClass().isEnum();
  47.151 -    }
  47.152 -
  47.153 -    @Compare public boolean isNotEnum() {
  47.154 -        return "".getClass().isEnum();
  47.155 -    }
  47.156 -    
  47.157 -    @Compare public String newInstanceFails() throws InstantiationException {
  47.158 -        try {
  47.159 -            return "success: " + StaticUseSub.class.newInstance();
  47.160 -        } catch (IllegalAccessException ex) {
  47.161 -            return ex.getClass().getName();
  47.162 -        }
  47.163 -    }
  47.164 -    
  47.165 -    @Compare public String paramTypes() throws Exception {
  47.166 -        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  47.167 -        final Class[] pt = plus.getParameterTypes();
  47.168 -        return pt[0].getName();
  47.169 -    }
  47.170 -    @Compare public String paramTypesNotFound() throws Exception {
  47.171 -        return StaticUse.class.getMethod("plus", int.class, double.class).toString();
  47.172 -    }
  47.173 -    @Compare public int methodWithArgs() throws Exception {
  47.174 -        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  47.175 -        return (Integer)plus.invoke(null, 2, 3);
  47.176 -    }
  47.177 -    
  47.178 -    @Compare public String classGetNameForByte() {
  47.179 -         return byte.class.getName();
  47.180 -    }
  47.181 -    @Compare public String classGetNameForBaseObject() {
  47.182 -        return newObject().getClass().getName();
  47.183 -    }
  47.184 -    @Compare public String classGetNameForJavaObject() {
  47.185 -        return new Object().getClass().getName();
  47.186 -    }
  47.187 -    @Compare public String classGetNameForObjectArray() {
  47.188 -        return (new Object[3]).getClass().getName();
  47.189 -    }
  47.190 -    @Compare public String classGetNameForSimpleIntArray() {
  47.191 -        return (new int[3]).getClass().getName();
  47.192 -    }
  47.193 -    @Compare public boolean sameClassGetNameForSimpleCharArray() {
  47.194 -        return (new char[3]).getClass() == (new char[34]).getClass();
  47.195 -    }
  47.196 -    @Compare public String classGetNameForMultiIntArray() {
  47.197 -        return (new int[3][4][5][6][7][8][9]).getClass().getName();
  47.198 -    }
  47.199 -    @Compare public String classGetNameForMultiIntArrayInner() {
  47.200 -        final int[][][][][][][] arr = new int[3][4][5][6][7][8][9];
  47.201 -        int[][][][][][] subarr = arr[0];
  47.202 -        int[][][][][] subsubarr = subarr[0];
  47.203 -        return subsubarr.getClass().getName();
  47.204 -    }
  47.205 -    @Compare public String classGetNameForMultiStringArray() {
  47.206 -        return (new String[3][4][5][6][7][8][9]).getClass().getName();
  47.207 -    }
  47.208 -    
  47.209 -    @Compare public String classForByte() throws Exception {
  47.210 -        return Class.forName("[Z").getName();
  47.211 -    }
  47.212 -
  47.213 -    @Compare public String classForUnknownArray() {
  47.214 -        try {
  47.215 -            return Class.forName("[W").getName();
  47.216 -        } catch (Exception ex) {
  47.217 -            return ex.getClass().getName();
  47.218 -        }
  47.219 -    }
  47.220 -    
  47.221 -    @Compare public String classForUnknownDeepArray() {
  47.222 -        try {
  47.223 -            return Class.forName("[[[[[W").getName();
  47.224 -        } catch (Exception ex) {
  47.225 -            return ex.getClass().getName();
  47.226 -        }
  47.227 -    }
  47.228 -    
  47.229 -    @Compare public String componentGetNameForObjectArray() {
  47.230 -        return (new Object[3]).getClass().getComponentType().getName();
  47.231 -    }
  47.232 -    @Compare public boolean sameComponentGetNameForObjectArray() {
  47.233 -        return (new Object[3]).getClass().getComponentType() == Object.class;
  47.234 -    }
  47.235 -    @Compare public String componentGetNameForSimpleIntArray() {
  47.236 -        return (new int[3]).getClass().getComponentType().getName();
  47.237 -    }
  47.238 -    @Compare public String componentGetNameForMultiIntArray() {
  47.239 -        return (new int[3][4][5][6][7][8][9]).getClass().getComponentType().getName();
  47.240 -    }
  47.241 -    @Compare public String componentGetNameForMultiStringArray() {
  47.242 -        Class<?> c = (new String[3][4][5][6][7][8][9]).getClass();
  47.243 -        StringBuilder sb = new StringBuilder();
  47.244 -        for (;;) {
  47.245 -            sb.append(c.getName()).append("\n");
  47.246 -            c = c.getComponentType();
  47.247 -            if (c == null) {
  47.248 -                break;
  47.249 -            }
  47.250 -        }
  47.251 -        return sb.toString();
  47.252 -    }
  47.253 -    
  47.254 -    @Compare public boolean isArray() {
  47.255 -        return new Object[0].getClass().isArray();
  47.256 -    }
  47.257 -    
  47.258 -    @JavaScriptBody(args = { "arr", "len" }, body="var a = arr.slice(0, len); a.sort(); return a;")
  47.259 -    private static String[] sort(String[] arr, int len) {
  47.260 -        List<String> list = Arrays.asList(arr).subList(0, len);
  47.261 -        Collections.sort(list);
  47.262 -        return list.toArray(new String[0]);
  47.263 -    }
  47.264 -    
  47.265 -    @JavaScriptBody(args = {}, body = "return new Object();")
  47.266 -    private static Object newObject() {
  47.267 -        return new Object();
  47.268 -    }
  47.269 -    
  47.270 -    @Factory
  47.271 -    public static Object[] create() {
  47.272 -        return VMTest.create(ReflectionTest.class);
  47.273 -    }
  47.274 -    
  47.275 -}
    48.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java	Sun Apr 28 10:14:31 2013 +0200
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,45 +0,0 @@
    48.4 -/**
    48.5 - * Back 2 Browser Bytecode Translator
    48.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    48.7 - *
    48.8 - * This program is free software: you can redistribute it and/or modify
    48.9 - * it under the terms of the GNU General Public License as published by
   48.10 - * the Free Software Foundation, version 2 of the License.
   48.11 - *
   48.12 - * This program is distributed in the hope that it will be useful,
   48.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   48.15 - * GNU General Public License for more details.
   48.16 - *
   48.17 - * You should have received a copy of the GNU General Public License
   48.18 - * along with this program. Look for COPYING file in the top folder.
   48.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   48.20 - */
   48.21 -package org.apidesign.bck2brwsr.tck;
   48.22 -
   48.23 -import java.io.InputStream;
   48.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   48.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   48.26 -import org.testng.annotations.Factory;
   48.27 -
   48.28 -/**
   48.29 - *
   48.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   48.31 - */
   48.32 -public class ResourcesTest {
   48.33 -    
   48.34 -    @Compare public String readResourceAsStream() throws Exception {
   48.35 -        InputStream is = getClass().getResourceAsStream("Resources.txt");
   48.36 -        byte[] b = new byte[30];
   48.37 -        int len = is.read(b);
   48.38 -        StringBuilder sb = new StringBuilder();
   48.39 -        for (int i = 0; i < len; i++) {
   48.40 -            sb.append((char)b[i]);
   48.41 -        }
   48.42 -        return sb.toString();
   48.43 -    }
   48.44 -    
   48.45 -    @Factory public static Object[] create() {
   48.46 -        return VMTest.create(ResourcesTest.class);
   48.47 -    }
   48.48 -}
    49.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java	Sun Apr 28 10:14:31 2013 +0200
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,102 +0,0 @@
    49.4 -/**
    49.5 - * Back 2 Browser Bytecode Translator
    49.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    49.7 - *
    49.8 - * This program is free software: you can redistribute it and/or modify
    49.9 - * it under the terms of the GNU General Public License as published by
   49.10 - * the Free Software Foundation, version 2 of the License.
   49.11 - *
   49.12 - * This program is distributed in the hope that it will be useful,
   49.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   49.15 - * GNU General Public License for more details.
   49.16 - *
   49.17 - * You should have received a copy of the GNU General Public License
   49.18 - * along with this program. Look for COPYING file in the top folder.
   49.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   49.20 - */
   49.21 -package org.apidesign.bck2brwsr.tck;
   49.22 -
   49.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   49.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   49.25 -import org.testng.annotations.Factory;
   49.26 -
   49.27 -/**
   49.28 - *
   49.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   49.30 - */
   49.31 -public class ShortArithmeticTest {
   49.32 -    
   49.33 -    private static short add(short x, short y) {
   49.34 -        return (short)(x + y);
   49.35 -    }
   49.36 -    
   49.37 -    private static short sub(short x, short y) {
   49.38 -        return (short)(x - y);
   49.39 -    }
   49.40 -    
   49.41 -    private static short mul(short x, short y) {
   49.42 -        return (short)(x * y);
   49.43 -    }
   49.44 -    
   49.45 -    private static short div(short x, short y) {
   49.46 -        return (short)(x / y);
   49.47 -    }
   49.48 -    
   49.49 -    private static short mod(short x, short y) {
   49.50 -        return (short)(x % y);
   49.51 -    }
   49.52 -    
   49.53 -    @Compare public short conversion() {
   49.54 -        return (short)123456;
   49.55 -    }
   49.56 -    
   49.57 -    @Compare public short addOverflow() {
   49.58 -        return add(Short.MAX_VALUE, (short)1);
   49.59 -    }
   49.60 -    
   49.61 -    @Compare public short subUnderflow() {
   49.62 -        return sub(Short.MIN_VALUE, (short)1);
   49.63 -    }
   49.64 -    
   49.65 -    @Compare public short addMaxShortAndMaxShort() {
   49.66 -        return add(Short.MAX_VALUE, Short.MAX_VALUE);
   49.67 -    }
   49.68 -    
   49.69 -    @Compare public short subMinShortAndMinShort() {
   49.70 -        return sub(Short.MIN_VALUE, Short.MIN_VALUE);
   49.71 -    }
   49.72 -    
   49.73 -    @Compare public short multiplyMaxShort() {
   49.74 -        return mul(Short.MAX_VALUE, (short)2);
   49.75 -    }
   49.76 -    
   49.77 -    @Compare public short multiplyMaxShortAndMaxShort() {
   49.78 -        return mul(Short.MAX_VALUE, Short.MAX_VALUE);
   49.79 -    }
   49.80 -    
   49.81 -    @Compare public short multiplyMinShort() {
   49.82 -        return mul(Short.MIN_VALUE, (short)2);
   49.83 -    }
   49.84 -    
   49.85 -    @Compare public short multiplyMinShortAndMinShort() {
   49.86 -        return mul(Short.MIN_VALUE, Short.MIN_VALUE);
   49.87 -    }
   49.88 -    
   49.89 -    @Compare public short multiplyPrecision() {
   49.90 -        return mul((short)17638, (short)1103);
   49.91 -    }
   49.92 -    
   49.93 -    @Compare public short division() {
   49.94 -        return div((short)1, (short)2);
   49.95 -    }
   49.96 -    
   49.97 -    @Compare public short divisionReminder() {
   49.98 -        return mod((short)1, (short)2);
   49.99 -    }
  49.100 -    
  49.101 -    @Factory
  49.102 -    public static Object[] create() {
  49.103 -        return VMTest.create(ShortArithmeticTest.class);
  49.104 -    }
  49.105 -}
    50.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java	Sun Apr 28 10:14:31 2013 +0200
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,39 +0,0 @@
    50.4 -/**
    50.5 - * Back 2 Browser Bytecode Translator
    50.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    50.7 - *
    50.8 - * This program is free software: you can redistribute it and/or modify
    50.9 - * it under the terms of the GNU General Public License as published by
   50.10 - * the Free Software Foundation, version 2 of the License.
   50.11 - *
   50.12 - * This program is distributed in the hope that it will be useful,
   50.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   50.15 - * GNU General Public License for more details.
   50.16 - *
   50.17 - * You should have received a copy of the GNU General Public License
   50.18 - * along with this program. Look for COPYING file in the top folder.
   50.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   50.20 - */
   50.21 -package org.apidesign.bck2brwsr.tck;
   50.22 -
   50.23 -class StaticUse {
   50.24 -    public static final Object NON_NULL = new Object();
   50.25 -    public static int cnt;
   50.26 -    static {
   50.27 -        if (cnt++ != 0) {
   50.28 -            throw new IllegalStateException("Multiple initialization of a <cinit>");
   50.29 -        }
   50.30 -    }
   50.31 -    
   50.32 -    StaticUse() {
   50.33 -    }
   50.34 -    
   50.35 -    public void instanceMethod() {
   50.36 -        throw new IllegalStateException();
   50.37 -    }
   50.38 -
   50.39 -    public static int plus(int a, int b) {
   50.40 -        return a + b;
   50.41 -    }
   50.42 -}
    51.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java	Sun Apr 28 10:14:31 2013 +0200
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,30 +0,0 @@
    51.4 -/**
    51.5 - * Back 2 Browser Bytecode Translator
    51.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    51.7 - *
    51.8 - * This program is free software: you can redistribute it and/or modify
    51.9 - * it under the terms of the GNU General Public License as published by
   51.10 - * the Free Software Foundation, version 2 of the License.
   51.11 - *
   51.12 - * This program is distributed in the hope that it will be useful,
   51.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   51.15 - * GNU General Public License for more details.
   51.16 - *
   51.17 - * You should have received a copy of the GNU General Public License
   51.18 - * along with this program. Look for COPYING file in the top folder.
   51.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   51.20 - */
   51.21 -package org.apidesign.bck2brwsr.tck;
   51.22 -
   51.23 -public class StaticUseSub extends StaticUse {
   51.24 -    private StaticUseSub() {
   51.25 -    }
   51.26 -    
   51.27 -    public static Object getNonNull() {
   51.28 -        return NON_NULL;
   51.29 -    }
   51.30 -    static Object getNull() {
   51.31 -        return null;
   51.32 -    }
   51.33 -}
    52.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java	Sun Apr 28 10:14:31 2013 +0200
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,45 +0,0 @@
    52.4 -/**
    52.5 - * Back 2 Browser Bytecode Translator
    52.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    52.7 - *
    52.8 - * This program is free software: you can redistribute it and/or modify
    52.9 - * it under the terms of the GNU General Public License as published by
   52.10 - * the Free Software Foundation, version 2 of the License.
   52.11 - *
   52.12 - * This program is distributed in the hope that it will be useful,
   52.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   52.15 - * GNU General Public License for more details.
   52.16 - *
   52.17 - * You should have received a copy of the GNU General Public License
   52.18 - * along with this program. Look for COPYING file in the top folder.
   52.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   52.20 - */
   52.21 -package org.apidesign.bck2brwsr.tck;
   52.22 -
   52.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   52.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   52.25 -import org.testng.annotations.Factory;
   52.26 -
   52.27 -/**
   52.28 - *
   52.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   52.30 - */
   52.31 -public class StaticUseSubTest {
   52.32 -    @Compare public String staticFieldInitializationInSuperClass() throws Exception {
   52.33 -        Object ret = StaticUseSub.getNonNull();
   52.34 -        return ret.getClass().getName();
   52.35 -    }
   52.36 -    
   52.37 -    @Compare public String isNullPointerTheSame() throws Exception {
   52.38 -        try {
   52.39 -            return StaticUseSub.getNull().getClass().toString();
   52.40 -        } catch (NullPointerException ex) {
   52.41 -            return ex.getClass().getName();
   52.42 -        }
   52.43 -    }
   52.44 -
   52.45 -    @Factory public static Object[] create() {
   52.46 -        return VMTest.create(StaticUseSubTest.class);
   52.47 -    }
   52.48 -}
    53.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java	Sun Apr 28 10:14:31 2013 +0200
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,41 +0,0 @@
    53.4 -/**
    53.5 - * Back 2 Browser Bytecode Translator
    53.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    53.7 - *
    53.8 - * This program is free software: you can redistribute it and/or modify
    53.9 - * it under the terms of the GNU General Public License as published by
   53.10 - * the Free Software Foundation, version 2 of the License.
   53.11 - *
   53.12 - * This program is distributed in the hope that it will be useful,
   53.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   53.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   53.15 - * GNU General Public License for more details.
   53.16 - *
   53.17 - * You should have received a copy of the GNU General Public License
   53.18 - * along with this program. Look for COPYING file in the top folder.
   53.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   53.20 - */
   53.21 -package org.apidesign.bck2brwsr.vmtest.impl;
   53.22 -
   53.23 -import java.io.UnsupportedEncodingException;
   53.24 -import java.util.zip.CRC32;
   53.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
   53.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   53.27 -import org.testng.annotations.Factory;
   53.28 -
   53.29 -/**
   53.30 - *
   53.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   53.32 - */
   53.33 -public class CRC32Test {
   53.34 -
   53.35 -    @Compare public long crc1() throws UnsupportedEncodingException {
   53.36 -        CRC32 crc = new CRC32();
   53.37 -        crc.update("Hello World!".getBytes("UTF-8"));
   53.38 -        return crc.getValue();
   53.39 -    }
   53.40 -    
   53.41 -    @Factory public static Object[] create() {
   53.42 -        return VMTest.create(CRC32Test.class);
   53.43 -    }
   53.44 -}
    54.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java	Sun Apr 28 10:14:31 2013 +0200
    54.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.3 @@ -1,43 +0,0 @@
    54.4 -/**
    54.5 - * Back 2 Browser Bytecode Translator
    54.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    54.7 - *
    54.8 - * This program is free software: you can redistribute it and/or modify
    54.9 - * it under the terms of the GNU General Public License as published by
   54.10 - * the Free Software Foundation, version 2 of the License.
   54.11 - *
   54.12 - * This program is distributed in the hope that it will be useful,
   54.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   54.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   54.15 - * GNU General Public License for more details.
   54.16 - *
   54.17 - * You should have received a copy of the GNU General Public License
   54.18 - * along with this program. Look for COPYING file in the top folder.
   54.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   54.20 - */
   54.21 -package org.apidesign.bck2brwsr.vmtest.impl;
   54.22 -
   54.23 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   54.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   54.25 -import org.testng.annotations.Factory;
   54.26 -
   54.27 -/**
   54.28 - *
   54.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   54.30 - */
   54.31 -public class CallMeTwiceTest {
   54.32 -    int cnt;
   54.33 -    
   54.34 -    @BrwsrTest public void callMeTwice() throws InterruptedException {
   54.35 -        if (cnt++ == 0) {
   54.36 -            throw new InterruptedException();
   54.37 -        }
   54.38 -        int prevCnt = cnt;
   54.39 -        cnt = 0;
   54.40 -        assert prevCnt == 2 : "We need to receive two calls " + prevCnt;
   54.41 -    }
   54.42 -    
   54.43 -    @Factory public static Object[] create() {
   54.44 -        return VMTest.create(CallMeTwiceTest.class);
   54.45 -    }
   54.46 -}
    55.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java	Sun Apr 28 10:14:31 2013 +0200
    55.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.3 @@ -1,67 +0,0 @@
    55.4 -/**
    55.5 - * Back 2 Browser Bytecode Translator
    55.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    55.7 - *
    55.8 - * This program is free software: you can redistribute it and/or modify
    55.9 - * it under the terms of the GNU General Public License as published by
   55.10 - * the Free Software Foundation, version 2 of the License.
   55.11 - *
   55.12 - * This program is distributed in the hope that it will be useful,
   55.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   55.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   55.15 - * GNU General Public License for more details.
   55.16 - *
   55.17 - * You should have received a copy of the GNU General Public License
   55.18 - * along with this program. Look for COPYING file in the top folder.
   55.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   55.20 - */
   55.21 -package org.apidesign.bck2brwsr.vmtest.impl;
   55.22 -
   55.23 -import java.io.ByteArrayInputStream;
   55.24 -import java.io.IOException;
   55.25 -import java.io.InputStream;
   55.26 -import org.apidesign.bck2brwsr.emul.zip.FastJar;
   55.27 -import org.testng.annotations.Test;
   55.28 -import static org.testng.Assert.*;
   55.29 -
   55.30 -/**
   55.31 - *
   55.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   55.33 - */
   55.34 -@GenerateZip(name = "five.zip", contents = {
   55.35 -    "1.txt", "one",
   55.36 -    "2.txt", "duo",
   55.37 -    "3.txt", "three",
   55.38 -    "4.txt", "four",
   55.39 -    "5.txt", "five"
   55.40 -})
   55.41 -public class ZipEntryTest {
   55.42 -    @Test
   55.43 -    public void readEntriesEffectively() throws IOException {
   55.44 -        InputStream is = ZipEntryTest.class.getResourceAsStream("five.zip");
   55.45 -        byte[] arr = new byte[is.available()];
   55.46 -        int len = is.read(arr);
   55.47 -        assertEquals(len, arr.length, "Read fully");
   55.48 -        
   55.49 -        FastJar fj = new FastJar(arr);
   55.50 -        FastJar.Entry[] entrs = fj.list();
   55.51 -        
   55.52 -        assertEquals(5, entrs.length, "Five entries");
   55.53 -        
   55.54 -        for (int i = 1; i <= 5; i++) {
   55.55 -            FastJar.Entry en = entrs[i - 1];
   55.56 -            assertEquals(en.name, i + ".txt");
   55.57 -//            assertEquals(cis.cnt, 0, "Content of the file should be skipped, not read");
   55.58 -        }
   55.59 -        
   55.60 -        assertContent("three", fj.getInputStream(entrs[3 - 1]), "read OK");
   55.61 -        assertContent("five", fj.getInputStream(entrs[5 - 1]), "read OK");
   55.62 -    }
   55.63 -
   55.64 -    private static void assertContent(String exp, InputStream is, String msg) throws IOException {
   55.65 -        byte[] arr = new byte[512];
   55.66 -        int len = is.read(arr);
   55.67 -        String s = new String(arr, 0, len);
   55.68 -        assertEquals(exp, s, msg);
   55.69 -    }
   55.70 -}
    56.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java	Sun Apr 28 10:14:31 2013 +0200
    56.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.3 @@ -1,108 +0,0 @@
    56.4 -/**
    56.5 - * Back 2 Browser Bytecode Translator
    56.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    56.7 - *
    56.8 - * This program is free software: you can redistribute it and/or modify
    56.9 - * it under the terms of the GNU General Public License as published by
   56.10 - * the Free Software Foundation, version 2 of the License.
   56.11 - *
   56.12 - * This program is distributed in the hope that it will be useful,
   56.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   56.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   56.15 - * GNU General Public License for more details.
   56.16 - *
   56.17 - * You should have received a copy of the GNU General Public License
   56.18 - * along with this program. Look for COPYING file in the top folder.
   56.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   56.20 - */
   56.21 -package org.apidesign.bck2brwsr.vmtest.impl;
   56.22 -
   56.23 -import java.io.IOException;
   56.24 -import java.io.InputStream;
   56.25 -import java.util.Objects;
   56.26 -import java.util.zip.ZipEntry;
   56.27 -import java.util.zip.ZipInputStream;
   56.28 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   56.29 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   56.30 -import org.apidesign.bck2brwsr.vmtest.Compare;
   56.31 -import org.apidesign.bck2brwsr.vmtest.Http;
   56.32 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   56.33 -import org.testng.annotations.Factory;
   56.34 -
   56.35 -/**
   56.36 - *
   56.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   56.38 - */
   56.39 -@GenerateZip(name = "readAnEntry.zip", contents = { 
   56.40 -    "my/main/file.txt", "Hello World!"
   56.41 -})
   56.42 -public class ZipFileTest {
   56.43 -    
   56.44 -    @Compare public String readAnEntry() throws IOException {
   56.45 -        InputStream is = ZipFileTest.class.getResourceAsStream("readAnEntry.zip");
   56.46 -        ZipInputStream zip = new ZipInputStream(is);
   56.47 -        ZipEntry entry = zip.getNextEntry();
   56.48 -        assertEquals(entry.getName(), "my/main/file.txt", "Correct entry");
   56.49 -
   56.50 -        byte[] arr = new byte[4096];
   56.51 -        int len = zip.read(arr);
   56.52 -        
   56.53 -        assertEquals(zip.getNextEntry(), null, "No next entry");
   56.54 -        
   56.55 -        final String ret = new String(arr, 0, len, "UTF-8");
   56.56 -        return ret;
   56.57 -    }
   56.58 -    
   56.59 -    @JavaScriptBody(args = { "res", "path" }, body = 
   56.60 -          "var myvm = bck2brwsr.apply(null, path);\n"
   56.61 -        + "var cls = myvm.loadClass('java.lang.String');\n"
   56.62 -        + "return cls.getClass__Ljava_lang_Class_2().getResourceAsStream__Ljava_io_InputStream_2Ljava_lang_String_2(res);\n"
   56.63 -    )
   56.64 -    private static native Object loadVMResource(String res, String...path);
   56.65 -
   56.66 -    @Http({
   56.67 -        @Http.Resource(path = "/readAnEntry.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip")
   56.68 -    })
   56.69 -    @BrwsrTest  public void canVmLoadResourceFromZip() throws IOException {
   56.70 -        Object res = loadVMResource("/my/main/file.txt", "/readAnEntry.jar");
   56.71 -        assert res instanceof InputStream : "Got array of bytes: " + res;
   56.72 -        InputStream is = (InputStream)res;
   56.73 -        
   56.74 -        byte[] arr = new byte[4096];
   56.75 -        int len = is.read(arr);
   56.76 -        
   56.77 -        final String ret = new String(arr, 0, len, "UTF-8");
   56.78 -
   56.79 -        assertEquals(ret, "Hello World!", "Can read the bytes");
   56.80 -    }
   56.81 -    
   56.82 -    @GenerateZip(name = "cpattr.zip", contents = { 
   56.83 -        "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n"
   56.84 -        + "Created-By: hand\n"
   56.85 -        + "Class-Path: realJar.jar\n\n\n"
   56.86 -    })
   56.87 -    @Http({
   56.88 -        @Http.Resource(path = "/readComplexEntry.jar", mimeType = "x-application/zip", content = "", resource="cpattr.zip"),
   56.89 -        @Http.Resource(path = "/realJar.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip"),
   56.90 -    })
   56.91 -    @BrwsrTest  public void understandsClassPathAttr() throws IOException {
   56.92 -        Object res = loadVMResource("/my/main/file.txt", "/readComplexEntry.jar");
   56.93 -        assert res instanceof InputStream : "Got array of bytes: " + res;
   56.94 -        InputStream is = (InputStream)res;
   56.95 -        
   56.96 -        byte[] arr = new byte[4096];
   56.97 -        int len = is.read(arr);
   56.98 -        
   56.99 -        final String ret = new String(arr, 0, len, "UTF-8");
  56.100 -
  56.101 -        assertEquals(ret, "Hello World!", "Can read the bytes from secondary JAR");
  56.102 -    }
  56.103 -    
  56.104 -    private static void assertEquals(Object real, Object exp, String msg) {
  56.105 -        assert Objects.equals(exp, real) : msg + " exp: " + exp + " real: " + real;
  56.106 -    }
  56.107 -    
  56.108 -    @Factory public static Object[] create() {
  56.109 -        return VMTest.create(ZipFileTest.class);
  56.110 -    }
  56.111 -}
    57.1 --- a/rt/vmtest/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe	Sun Apr 28 10:14:31 2013 +0200
    57.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.3 @@ -1,1 +0,0 @@
    57.4    57.5 \ No newline at end of file
    58.1 --- a/rt/vmtest/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt	Sun Apr 28 10:14:31 2013 +0200
    58.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.3 @@ -1,1 +0,0 @@
    58.4 -Ahoj