Separating compact profile tests into own project, so launcher.http can depend on compact profile JAR
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 19 Nov 2014 19:32:00 +0100
changeset 17233a1f262311cf
parent 1722 fd3a354d6e8f
child 1724 50ad005d1597
Separating compact profile tests into own project, so launcher.http can depend on compact profile JAR
launcher/http/pom.xml
rt/emul/compact/pom.xml
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/JFXIssuesTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/RandomTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ReaderTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ServiceLoaderTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AtomicTest.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/CharacterTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ClassLoaderTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ClassTest.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/ConcurrentTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ExceptionsTest.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/LoggerTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ProxyTest.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/RegExpReplaceAllTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpSplitTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourceBundleTest.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/tck/SystemTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/TimerTest.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/HtmlAnnotations.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Bundle.properties
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/console.js
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js
rt/emul/compacttest/pom.xml
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/JFXIssuesTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/RandomTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/ReaderTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/ServiceLoaderTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/AtomicTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CharacterTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ClassLoaderTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ClassTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ConcurrentTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ExceptionsTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LoggerTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ProxyTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/RegExpReplaceAllTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/RegExpSplitTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ResourceBundleTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/SystemTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/TimerTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotations.java
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java
rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe
rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/tck/Bundle.properties
rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt
rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/tck/console.js
rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js
rt/emul/pom.xml
rt/mojo/pom.xml
rt/vm/pom.xml
     1.1 --- a/launcher/http/pom.xml	Sun Nov 09 10:36:08 2014 +0100
     1.2 +++ b/launcher/http/pom.xml	Wed Nov 19 19:32:00 2014 +0100
     1.3 @@ -45,6 +45,12 @@
     1.4        <groupId>${project.groupId}</groupId>
     1.5        <artifactId>launcher.fx</artifactId>
     1.6        <version>${project.version}</version>
     1.7 +      <exclusions>
     1.8 +        <exclusion>
     1.9 +          <groupId>com.oracle</groupId>
    1.10 +          <artifactId>javafx</artifactId>
    1.11 +        </exclusion>
    1.12 +      </exclusions>
    1.13      </dependency>
    1.14      <dependency>
    1.15        <groupId>org.glassfish.grizzly</groupId>
    1.16 @@ -63,9 +69,9 @@
    1.17      </dependency>
    1.18      <dependency>
    1.19        <groupId>${project.groupId}</groupId>
    1.20 -      <artifactId>emul.mini</artifactId>
    1.21 +      <artifactId>emul</artifactId>
    1.22        <version>${project.version}</version>
    1.23 -      <scope>test</scope>
    1.24 +      <classifier>rt</classifier>
    1.25      </dependency>
    1.26      <dependency>
    1.27        <groupId>org.apidesign.bck2brwsr</groupId>
     2.1 --- a/rt/emul/compact/pom.xml	Sun Nov 09 10:36:08 2014 +0100
     2.2 +++ b/rt/emul/compact/pom.xml	Wed Nov 19 19:32:00 2014 +0100
     2.3 @@ -21,29 +21,6 @@
     2.4        <version>${project.version}</version>
     2.5        <scope>provided</scope>
     2.6      </dependency>
     2.7 -    <dependency>
     2.8 -      <groupId>${project.groupId}</groupId>
     2.9 -      <artifactId>vmtest</artifactId>
    2.10 -      <version>${project.version}</version>
    2.11 -      <scope>test</scope>
    2.12 -    </dependency>
    2.13 -    <dependency>
    2.14 -      <groupId>${project.groupId}</groupId>
    2.15 -      <artifactId>launcher.http</artifactId>
    2.16 -      <version>${project.version}</version>
    2.17 -      <scope>test</scope>
    2.18 -      <exclusions>
    2.19 -          <exclusion>
    2.20 -              <groupId>com.oracle</groupId>
    2.21 -              <artifactId>javafx</artifactId>
    2.22 -          </exclusion>
    2.23 -      </exclusions>
    2.24 -    </dependency>
    2.25 -    <dependency>
    2.26 -      <groupId>org.netbeans.api</groupId>
    2.27 -      <artifactId>org-openide-util-lookup</artifactId>
    2.28 -      <scope>test</scope>
    2.29 -    </dependency>
    2.30    </dependencies>
    2.31    <build>
    2.32        <plugins>
    2.33 @@ -87,24 +64,6 @@
    2.34                      </execution>
    2.35                  </executions>                
    2.36              </plugin> 
    2.37 -            <plugin>
    2.38 -                <groupId>org.apache.maven.plugins</groupId>
    2.39 -                <artifactId>maven-surefire-plugin</artifactId>
    2.40 -                <executions>
    2.41 -                    <execution>
    2.42 -                        <id>brwsr</id>
    2.43 -                        <goals>
    2.44 -                            <goal>test</goal>
    2.45 -                        </goals>
    2.46 -                        <phase>verify</phase>
    2.47 -                        <configuration>
    2.48 -                            <systemProperties>
    2.49 -                                <vmtest.js>brwsr</vmtest.js>
    2.50 -                            </systemProperties>
    2.51 -                        </configuration>
    2.52 -                    </execution>
    2.53 -                </executions>
    2.54 -            </plugin>     
    2.55        </plugins>
    2.56    </build>
    2.57  </project>
     3.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java	Sun Nov 09 10:36:08 2014 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,121 +0,0 @@
     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.compact.tck;
    3.22 -
    3.23 -import java.util.ArrayList;
    3.24 -import java.util.Arrays;
    3.25 -import java.util.Collection;
    3.26 -import java.util.Collections;
    3.27 -import java.util.Comparator;
    3.28 -import java.util.HashMap;
    3.29 -import java.util.HashSet;
    3.30 -import java.util.List;
    3.31 -import java.util.Map;
    3.32 -import java.util.Map.Entry;
    3.33 -import java.util.Vector;
    3.34 -import org.apidesign.bck2brwsr.vmtest.Compare;
    3.35 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    3.36 -import org.testng.annotations.Factory;
    3.37 -
    3.38 -/**
    3.39 - *
    3.40 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    3.41 - */
    3.42 -public class CollectionsTest {
    3.43 -    @Compare public String sortStringsInArray() {
    3.44 -        List<String> list = new ArrayList<>();
    3.45 -        list.add("one");
    3.46 -        list.add("two");
    3.47 -        list.add("three");
    3.48 -        list.add("four");
    3.49 -        list.add("five");
    3.50 -        list.add("six");
    3.51 -        list.add("seven");
    3.52 -        list.add("eight");
    3.53 -        list.add("nine");
    3.54 -        list.add("ten");
    3.55 -        
    3.56 -        String[] arr = list.toArray(new String[list.size()]);
    3.57 -        Arrays.sort(arr);
    3.58 -        
    3.59 -        return Arrays.asList(arr).toString();
    3.60 -    }
    3.61 -    
    3.62 -    @Compare public String sortStringsInHashSet() {
    3.63 -        Collection<String> list = new HashSet<>();
    3.64 -        list.add("one");
    3.65 -        list.add("two");
    3.66 -        list.add("three");
    3.67 -        list.add("four");
    3.68 -        list.add("five");
    3.69 -        list.add("six");
    3.70 -        list.add("seven");
    3.71 -        list.add("eight");
    3.72 -        list.add("nine");
    3.73 -        list.add("ten");
    3.74 -        
    3.75 -        String[] arr = list.toArray(new String[0]);
    3.76 -        Arrays.sort(arr);
    3.77 -        
    3.78 -        return Arrays.asList(arr).toString();
    3.79 -    }
    3.80 -
    3.81 -    @SuppressWarnings("unchecked")
    3.82 -    @Compare public String sortStringsInHashMapWithComparator() {
    3.83 -        class C implements Comparator<Map.Entry<String,Integer>> {
    3.84 -            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
    3.85 -                return o1.getKey().compareTo(o2.getKey());
    3.86 -            }
    3.87 -        }
    3.88 -        
    3.89 -        Map<String,Integer> map = new HashMap<>();
    3.90 -        map.put("one", 1);
    3.91 -        map.put("two", 2);
    3.92 -        map.put("three", 3);
    3.93 -        map.put("four", 4);
    3.94 -        map.put("five", 5);
    3.95 -        map.put("six", 6);
    3.96 -        map.put("seven", 7);
    3.97 -        map.put("eight", 8);
    3.98 -        map.put("nine", 9);
    3.99 -        map.put("ten", 10);
   3.100 -        
   3.101 -        List<Entry<String,Integer>> arr = new Vector<>();
   3.102 -        arr.addAll(map.entrySet());
   3.103 -        Collections.sort(arr, new C());
   3.104 -        return arr.toString();
   3.105 -    }
   3.106 -    
   3.107 -    @Compare public String jirkaToArray() {
   3.108 -        List<String> appfiles = new ArrayList<>();
   3.109 -        appfiles.add("onefile");
   3.110 -        appfiles.add("2ndfile");
   3.111 -        appfiles.add("3rdfile");
   3.112 -        String[] ret = appfiles.toArray(new String[appfiles.size()]);
   3.113 -        return 
   3.114 -            ret.getClass().getName() + ":" +
   3.115 -            ret.length + ":" +
   3.116 -            Arrays.toString(ret);
   3.117 -    }
   3.118 -    
   3.119 -    @Factory
   3.120 -    public static Object[] create() {
   3.121 -        return VMTest.create(CollectionsTest.class);
   3.122 -    }
   3.123 -    
   3.124 -}
     4.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/JFXIssuesTest.java	Sun Nov 09 10:36:08 2014 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,90 +0,0 @@
     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.compact.tck;
    4.22 -
    4.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
    4.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    4.25 -import org.testng.annotations.Factory;
    4.26 -
    4.27 -
    4.28 -public class JFXIssuesTest {
    4.29 -    private abstract class Application {
    4.30 -        public abstract int getID();
    4.31 -    }
    4.32 -    
    4.33 -    private class MyApplication extends Application {
    4.34 -
    4.35 -        @Override
    4.36 -        public int getID() {
    4.37 -            return 1;
    4.38 -        }
    4.39 -        
    4.40 -    } 
    4.41 -    
    4.42 -    @Compare public boolean isClassAssignable() {
    4.43 -        return Application.class.isAssignableFrom(MyApplication.class);
    4.44 -    }
    4.45 -
    4.46 -    @Compare public boolean isNaN() {
    4.47 -        return Double.isNaN(Double.NaN);
    4.48 -    }
    4.49 -
    4.50 -    @Compare public boolean isInfinite() {
    4.51 -        return Float.isInfinite(Float.NEGATIVE_INFINITY);
    4.52 -    }
    4.53 -
    4.54 -    @Compare public boolean areTimesEqual() {
    4.55 -        long l1 = System.currentTimeMillis();
    4.56 -        long l2 = l1 + 0;
    4.57 -
    4.58 -        return l1 == l2;
    4.59 -    }
    4.60 -    
    4.61 -    @Compare public boolean roundOnDouble() {
    4.62 -        long l1 = Math.round(System.currentTimeMillis() / 1.1);
    4.63 -        long l2 = l1 + 0;
    4.64 -        
    4.65 -        return l1 == l2;
    4.66 -    }
    4.67 -
    4.68 -    private static final long val = 1238078409318L;
    4.69 -    
    4.70 -    @Compare public int valueConvertedToString() {
    4.71 -        long[] arr = { val };
    4.72 -        return dumpValue(arr);
    4.73 -    }
    4.74 -    
    4.75 -    int dumpValue(long[] val) {
    4.76 -        return (int) val[0]++;
    4.77 -    }
    4.78 -    
    4.79 -    
    4.80 -    @Compare public boolean roundOnFloat() {
    4.81 -        final float f = System.currentTimeMillis() / 1.1f;
    4.82 -        int l1 = Math.round(f);
    4.83 -        int l2 = l1 + 0;
    4.84 -        
    4.85 -        assert l1 == l2 : "Round " + l1 + " == " + l2;
    4.86 -        
    4.87 -        return l1 == l2;
    4.88 -    }
    4.89 -    
    4.90 -    @Factory public static Object[] create() {
    4.91 -        return VMTest.create(JFXIssuesTest.class);
    4.92 -    }
    4.93 -}
     5.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/RandomTest.java	Sun Nov 09 10:36:08 2014 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,40 +0,0 @@
     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.compact.tck;
    5.22 -
    5.23 -import java.util.Random;
    5.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
    5.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    5.26 -import org.testng.annotations.Factory;
    5.27 -
    5.28 -/**
    5.29 - *
    5.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    5.31 - */
    5.32 -public class RandomTest {
    5.33 -    @Compare public boolean canInstantiateRandom() {
    5.34 -        Random r = new Random();
    5.35 -        r.nextInt();
    5.36 -        return r != null;
    5.37 -    }
    5.38 -
    5.39 -    
    5.40 -    @Factory public static Object[] create() {
    5.41 -        return VMTest.create(RandomTest.class);
    5.42 -    }
    5.43 -}
     6.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ReaderTest.java	Sun Nov 09 10:36:08 2014 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,78 +0,0 @@
     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.compact.tck;
    6.22 -
    6.23 -import java.io.ByteArrayInputStream;
    6.24 -import java.io.ByteArrayOutputStream;
    6.25 -import java.io.IOException;
    6.26 -import java.io.InputStreamReader;
    6.27 -import java.io.OutputStreamWriter;
    6.28 -import java.io.UnsupportedEncodingException;
    6.29 -import java.util.Arrays;
    6.30 -import org.apidesign.bck2brwsr.vmtest.Compare;
    6.31 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    6.32 -import org.testng.annotations.Factory;
    6.33 -
    6.34 -/**
    6.35 - *
    6.36 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    6.37 - */
    6.38 -public class ReaderTest {
    6.39 -    @Compare public String readUTFString() throws IOException {
    6.40 -        byte[] arr = { 
    6.41 -            (byte)-59, (byte)-67, (byte)108, (byte)117, (byte)-59, (byte)-91, 
    6.42 -            (byte)111, (byte)117, (byte)-60, (byte)-115, (byte)107, (byte)-61, 
    6.43 -            (byte)-67, (byte)32, (byte)107, (byte)-59, (byte)-81, (byte)-59, 
    6.44 -            (byte)-120 
    6.45 -        };
    6.46 -        ByteArrayInputStream is = new ByteArrayInputStream(arr);
    6.47 -        InputStreamReader r = new InputStreamReader(is, "UTF-8");
    6.48 -        return readReader(r);        
    6.49 -    }
    6.50 -
    6.51 -    private String readReader(InputStreamReader r) throws IOException {
    6.52 -        StringBuilder sb = new StringBuilder();
    6.53 -        for (;;) {
    6.54 -            int ch = r.read();
    6.55 -            if (ch == -1) {
    6.56 -                break;
    6.57 -            }
    6.58 -            sb.append((char)ch);
    6.59 -        }
    6.60 -        return sb.toString().toString();
    6.61 -    }
    6.62 -    @Compare public String stringToBytes() throws UnsupportedEncodingException {
    6.63 -        return Arrays.toString(YellowHorse.getBytes("UTF-8"));
    6.64 -    }
    6.65 -    private final String YellowHorse = "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148";
    6.66 -    
    6.67 -    @Compare public String readAndWrite() throws Exception {
    6.68 -        ByteArrayOutputStream arr = new ByteArrayOutputStream();
    6.69 -        OutputStreamWriter w = new OutputStreamWriter(arr);
    6.70 -        w.write(YellowHorse);
    6.71 -        w.close();
    6.72 -        
    6.73 -        ByteArrayInputStream is = new ByteArrayInputStream(arr.toByteArray());
    6.74 -        InputStreamReader r = new InputStreamReader(is, "UTF-8");
    6.75 -        return readReader(r);
    6.76 -    }
    6.77 -    
    6.78 -    @Factory public static Object[] create() {
    6.79 -        return VMTest.create(ReaderTest.class);
    6.80 -    }
    6.81 -}
     7.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ServiceLoaderTest.java	Sun Nov 09 10:36:08 2014 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,61 +0,0 @@
     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.compact.tck;
    7.22 -
    7.23 -import java.io.IOException;
    7.24 -import java.util.ServiceLoader;
    7.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
    7.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    7.27 -import org.openide.util.lookup.ServiceProvider;
    7.28 -import org.testng.annotations.Factory;
    7.29 -
    7.30 -/**
    7.31 - *
    7.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    7.33 - */
    7.34 -public class ServiceLoaderTest {
    7.35 -    @Compare//(scripting = false) 
    7.36 -    public Object findsIOException() {
    7.37 -//      delayStart();
    7.38 -        for (IOException e : ServiceLoader.load(IOException.class)) {
    7.39 -            return "Found service: " + e.getClass().getName();
    7.40 -        }
    7.41 -        return null;
    7.42 -    }
    7.43 -/*    
    7.44 -    @org.apidesign.bck2brwsr.core.JavaScriptBody(args = { "a" }, body = "alert(a);")
    7.45 -    private static void alert(String a) {
    7.46 -    }
    7.47 -    private void delayStart() {
    7.48 -        for (int i = 0; i < 10; i++) {
    7.49 -            alert("State: " + i);
    7.50 -            for (int j = 0; j < 493208409; j++) ;
    7.51 -        }
    7.52 -    }
    7.53 -*/
    7.54 -    
    7.55 -    @Factory
    7.56 -    public static Object[] create() {
    7.57 -        return VMTest.create(ServiceLoaderTest.class);
    7.58 -    }
    7.59 -
    7.60 -    
    7.61 -    @ServiceProvider(service = IOException.class)
    7.62 -    public static class MyException extends IOException {
    7.63 -    }
    7.64 -}
     8.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java	Sun Nov 09 10:36:08 2014 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,43 +0,0 @@
     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 AssertionTest {
    8.32 -
    8.33 -    @Compare public Object checkAssert() throws ClassNotFoundException {
    8.34 -        try {
    8.35 -            assert false : "Is assertion status on?";
    8.36 -            return null;
    8.37 -        } catch (AssertionError ex) {
    8.38 -            return ex.getClass().getName();
    8.39 -        }
    8.40 -    }
    8.41 -    
    8.42 -    @Factory
    8.43 -    public static Object[] create() {
    8.44 -        return VMTest.create(AssertionTest.class);
    8.45 -    }
    8.46 -}
     9.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/AtomicTest.java	Sun Nov 09 10:36:08 2014 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,54 +0,0 @@
     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.util.concurrent.atomic.AtomicBoolean;
    9.24 -import java.util.concurrent.atomic.AtomicInteger;
    9.25 -import java.util.concurrent.atomic.AtomicReference;
    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 AtomicTest {
    9.35 -    @Compare public boolean atomicBoolean() {
    9.36 -        AtomicBoolean ab = new AtomicBoolean();
    9.37 -        ab.set(true);
    9.38 -        return ab.compareAndSet(true, false);
    9.39 -    }
    9.40 -
    9.41 -    @Compare public int atomicInt() {
    9.42 -        AtomicInteger ab = new AtomicInteger();
    9.43 -        ab.set(30);
    9.44 -        assert ab.compareAndSet(30, 10);
    9.45 -        return ab.get();
    9.46 -    }
    9.47 -    
    9.48 -    @Compare public String atomicRef() {
    9.49 -        AtomicReference<String> ar = new AtomicReference<String>("Ahoj");
    9.50 -        assert ar.compareAndSet("Ahoj", "Hello");
    9.51 -        return ar.getAndSet("Other");
    9.52 -    }
    9.53 -    
    9.54 -    @Factory public static Object[] create() {
    9.55 -        return VMTest.create(AtomicTest.class);
    9.56 -    }
    9.57 -}
    10.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java	Sun Nov 09 10:36:08 2014 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,57 +0,0 @@
    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.core.JavaScriptBody;
   10.24 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   10.25 -import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
   10.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   10.27 -import org.testng.annotations.Factory;
   10.28 -
   10.29 -/**
   10.30 - *
   10.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   10.32 - */
   10.33 -public class BrwsrCheckTest {
   10.34 -
   10.35 -    @BrwsrTest public void assertWindowObjectIsDefined() {
   10.36 -        assert window() != null : "No window object found!";
   10.37 -    }
   10.38 -
   10.39 -    
   10.40 -    
   10.41 -    
   10.42 -    @HtmlFragment("<h1 id='hello'>\n"
   10.43 -        + "Hello!\n"
   10.44 -        + "</h1>\n")
   10.45 -    @BrwsrTest public void accessProvidedFragment() {
   10.46 -        assert getElementById("hello") != null : "Element with 'hello' ID found";
   10.47 -    }
   10.48 -    
   10.49 -    @Factory
   10.50 -    public static Object[] create() {
   10.51 -        return VMTest.create(BrwsrCheckTest.class);
   10.52 -    }
   10.53 -    
   10.54 -
   10.55 -    @JavaScriptBody(args = {}, body = "return window;")
   10.56 -    private static native Object window();
   10.57 -
   10.58 -    @JavaScriptBody(args = { "id" }, body = "return window.document.getElementById(id);")
   10.59 -    private static native Object getElementById(String id);
   10.60 -}
    11.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java	Sun Nov 09 10:36:08 2014 +0100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,147 +0,0 @@
    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 org.apidesign.bck2brwsr.core.JavaScriptBody;
   11.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   11.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   11.26 -import org.testng.annotations.Factory;
   11.27 -
   11.28 -/**
   11.29 - *
   11.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   11.31 - */
   11.32 -public class ByteArithmeticTest {
   11.33 -    
   11.34 -    private static byte add(byte x, byte y) {
   11.35 -        return (byte)(x + y);
   11.36 -    }
   11.37 -    
   11.38 -    private static byte sub(byte x, byte y) {
   11.39 -        return (byte)(x - y);
   11.40 -    }
   11.41 -    
   11.42 -    private static byte mul(byte x, byte y) {
   11.43 -        return (byte)(x * y);
   11.44 -    }
   11.45 -    
   11.46 -    private static byte div(byte x, byte y) {
   11.47 -        return (byte)(x / y);
   11.48 -    }
   11.49 -    
   11.50 -    private static byte mod(byte x, byte y) {
   11.51 -        return (byte)(x % y);
   11.52 -    }
   11.53 -    
   11.54 -    @Compare public byte conversion() {
   11.55 -        return (byte)123456;
   11.56 -    }
   11.57 -    
   11.58 -    @Compare public byte addOverflow() {
   11.59 -        return add(Byte.MAX_VALUE, (byte)1);
   11.60 -    }
   11.61 -    
   11.62 -    @Compare public byte subUnderflow() {
   11.63 -        return sub(Byte.MIN_VALUE, (byte)1);
   11.64 -    }
   11.65 -    
   11.66 -    @Compare public byte addMaxByteAndMaxByte() {
   11.67 -        return add(Byte.MAX_VALUE, Byte.MAX_VALUE);
   11.68 -    }
   11.69 -    
   11.70 -    @Compare public byte subMinByteAndMinByte() {
   11.71 -        return sub(Byte.MIN_VALUE, Byte.MIN_VALUE);
   11.72 -    }
   11.73 -    
   11.74 -    @Compare public byte multiplyMaxByte() {
   11.75 -        return mul(Byte.MAX_VALUE, (byte)2);
   11.76 -    }
   11.77 -    
   11.78 -    @Compare public byte multiplyMaxByteAndMaxByte() {
   11.79 -        return mul(Byte.MAX_VALUE, Byte.MAX_VALUE);
   11.80 -    }
   11.81 -    
   11.82 -    @Compare public byte multiplyMinByte() {
   11.83 -        return mul(Byte.MIN_VALUE, (byte)2);
   11.84 -    }
   11.85 -    
   11.86 -    @Compare public byte multiplyMinByteAndMinByte() {
   11.87 -        return mul(Byte.MIN_VALUE, Byte.MIN_VALUE);
   11.88 -    }
   11.89 -    
   11.90 -    @Compare public byte multiplyPrecision() {
   11.91 -        return mul((byte)17638, (byte)1103);
   11.92 -    }
   11.93 -    
   11.94 -    @Compare public byte division() {
   11.95 -        return div((byte)1, (byte)2);
   11.96 -    }
   11.97 -    
   11.98 -    @Compare public byte divisionReminder() {
   11.99 -        return mod((byte)1, (byte)2);
  11.100 -    }
  11.101 -
  11.102 -    private static int readShort(byte[] byteCodes, int offset) {
  11.103 -        int signed = byteCodes[offset];
  11.104 -        byte b0 = (byte)signed;
  11.105 -        return (b0 << 8) | (byteCodes[offset + 1] & 0xff);
  11.106 -    }
  11.107 -    
  11.108 -    private static int readShortArg(byte[] byteCodes, int offsetInstruction) {
  11.109 -        return readShort(byteCodes, offsetInstruction + 1);
  11.110 -    }
  11.111 -    
  11.112 -    @Compare public int readIntArgs255and156() {
  11.113 -        final byte[] arr = new byte[] { (byte)0, (byte)255, (byte)156 };
  11.114 -        
  11.115 -        assert arr[1] == -1 : "First byte: " + arr[1];
  11.116 -        assert arr[2] == -100 : "Second byte: " + arr[2];
  11.117 -        final int ret = readShortArg(arr, 0);
  11.118 -        assert ret < 65000: "Value: " + ret;
  11.119 -        return ret;
  11.120 -    }
  11.121 -    
  11.122 -    @JavaScriptBody(args = { "arr" }, body = "arr[1] = 255; arr[2] = 156; return arr;")
  11.123 -    private static byte[] fill255and156(byte[] arr) {
  11.124 -        arr[1] = (byte)255;
  11.125 -        arr[2] = (byte)156;
  11.126 -        return arr;
  11.127 -    }
  11.128 -
  11.129 -    @Compare public int readIntArgs255and156JSArray() {
  11.130 -        final byte[] arr = fill255and156(new byte[] { 0, 0, 0 });
  11.131 -        
  11.132 -        final int ret = readShortArg(arr, 0);
  11.133 -        assert ret < 65000: "Value: " + ret;
  11.134 -        return ret;
  11.135 -    }
  11.136 -    
  11.137 -    @Compare public int readIntArgsMinus1andMinus100() {
  11.138 -        final byte[] arr = new byte[] { (byte)0, (byte)-1, (byte)-100 };
  11.139 -        
  11.140 -        assert arr[1] == -1 : "First byte: " + arr[1];
  11.141 -        assert arr[2] == -100 : "Second byte: " + arr[2];
  11.142 -        
  11.143 -        return readShortArg(arr, 0);
  11.144 -    }
  11.145 -    
  11.146 -    @Factory
  11.147 -    public static Object[] create() {
  11.148 -        return VMTest.create(ByteArithmeticTest.class);
  11.149 -    }
  11.150 -}
    12.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CharacterTest.java	Sun Nov 09 10:36:08 2014 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,61 +0,0 @@
    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 -import org.apidesign.bck2brwsr.vmtest.Compare;
   12.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   12.25 -import org.testng.annotations.Factory;
   12.26 -
   12.27 -/**
   12.28 - *
   12.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   12.30 - */
   12.31 -public class CharacterTest {
   12.32 -    @Compare public boolean dolarJavaStart() {
   12.33 -        return Character.isJavaIdentifierStart('$');
   12.34 -    }
   12.35 -
   12.36 -    @Compare public boolean dolarJavaPart() {
   12.37 -        return Character.isJavaIdentifierPart('$');
   12.38 -    }
   12.39 -
   12.40 -    @Compare public boolean numberJavaStart() {
   12.41 -        return Character.isJavaIdentifierStart('3');
   12.42 -    }
   12.43 -
   12.44 -    @Compare public boolean numberJavaPart() {
   12.45 -        return Character.isJavaIdentifierPart('3');
   12.46 -    }
   12.47 -
   12.48 -    @Compare public String testWhiteSpaces() {
   12.49 -        StringBuilder sb = new StringBuilder();
   12.50 -        for (int i = 1; i < 128; i++) {
   12.51 -            char ch = (char)i;
   12.52 -            if (Character.isWhitespace(ch)) {
   12.53 -                sb.append(i).append(",");
   12.54 -            }
   12.55 -        }
   12.56 -        return sb.toString();
   12.57 -    }
   12.58 -    
   12.59 -    @Factory
   12.60 -    public static Object[] create() {
   12.61 -        return VMTest.create(CharacterTest.class);
   12.62 -    }
   12.63 -
   12.64 -}
    13.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ClassLoaderTest.java	Sun Nov 09 10:36:08 2014 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,41 +0,0 @@
    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 -import org.apidesign.bck2brwsr.vmtest.Compare;
   13.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   13.25 -import org.testng.annotations.Factory;
   13.26 -
   13.27 -/**
   13.28 - *
   13.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   13.30 - */
   13.31 -public class ClassLoaderTest {
   13.32 -    @Compare public Object unknownResource() {
   13.33 -        return ClassLoader.getSystemResource("really/unknown/resource.txt");
   13.34 -    }
   13.35 -    
   13.36 -    @Compare public boolean indenpotentSetOfClassloaderIsOK() {
   13.37 -        Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
   13.38 -        return Thread.currentThread().getContextClassLoader() == ClassLoader.getSystemClassLoader();
   13.39 -    }
   13.40 -
   13.41 -    @Factory public static Object[] create() {
   13.42 -        return VMTest.create(ClassLoaderTest.class);
   13.43 -    }
   13.44 -}
    14.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ClassTest.java	Sun Nov 09 10:36:08 2014 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,47 +0,0 @@
    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 ClassTest {
   14.32 -    @Compare
   14.33 -    public boolean isDoubleArrayAssignableToObject() throws Exception {
   14.34 -        double[] dbl = new double[0];
   14.35 -        Class<?> dblCls = dbl.getClass();
   14.36 -        return Object.class.isAssignableFrom(dblCls);
   14.37 -    }
   14.38 -
   14.39 -    @Compare
   14.40 -    public boolean isDoubleArrayAssignableToString() throws Exception {
   14.41 -        double[] dbl = new double[0];
   14.42 -        Class<?> dblCls = dbl.getClass();
   14.43 -        return String.class.isAssignableFrom(dblCls);
   14.44 -    }
   14.45 -    
   14.46 -    @Factory
   14.47 -    public static Object[] create() {
   14.48 -        return VMTest.create(ClassTest.class);
   14.49 -    }
   14.50 -}
    15.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Sun Nov 09 10:36:08 2014 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,73 +0,0 @@
    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 CloneTest {
   15.32 -    private int value;
   15.33 -    
   15.34 -    @Compare
   15.35 -    public Object notSupported() throws CloneNotSupportedException {
   15.36 -        return this.clone();
   15.37 -    }
   15.38 -
   15.39 -    @Compare public String sameClass() throws CloneNotSupportedException {
   15.40 -        return new Clnbl().clone().getClass().getName();
   15.41 -    }
   15.42 -
   15.43 -    @Compare public boolean differentInstance() throws CloneNotSupportedException {
   15.44 -        Clnbl orig = new Clnbl();
   15.45 -        return orig == orig.clone();
   15.46 -    }
   15.47 -
   15.48 -    @Compare public int sameReference() throws CloneNotSupportedException {
   15.49 -        CloneTest self = this;
   15.50 -        Clnbl orig = new Clnbl();
   15.51 -        self.value = 33;
   15.52 -        orig.ref = self;
   15.53 -        return ((Clnbl)orig.clone()).ref.value;
   15.54 -    }
   15.55 -
   15.56 -    @Compare public int sameValue() throws CloneNotSupportedException {
   15.57 -        Clnbl orig = new Clnbl();
   15.58 -        orig.value = 10;
   15.59 -        return ((Clnbl)orig.clone()).value;
   15.60 -    }
   15.61 -    
   15.62 -    @Factory
   15.63 -    public static Object[] create() {
   15.64 -        return VMTest.create(CloneTest.class);
   15.65 -    }
   15.66 -    
   15.67 -    public static final class Clnbl implements Cloneable {
   15.68 -        public CloneTest ref;
   15.69 -        private int value;
   15.70 -
   15.71 -        @Override
   15.72 -        public Object clone() throws CloneNotSupportedException {
   15.73 -            return super.clone();
   15.74 -        }
   15.75 -    }
   15.76 -}
    16.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java	Sun Nov 09 10:36:08 2014 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,103 +0,0 @@
    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 CompareByteArrayTest {
   16.32 -    @Compare public int byteArraySum() {
   16.33 -        byte[] arr = createArray();
   16.34 -        return sumByteArr(arr);
   16.35 -    }
   16.36 -    
   16.37 -    @Compare public int countZeros() {
   16.38 -        int zeros = 0;
   16.39 -        for (Byte b : createArray()) {
   16.40 -            if (b == 0) {
   16.41 -                zeros++;
   16.42 -            }
   16.43 -        }
   16.44 -        return zeros;
   16.45 -    }
   16.46 -    
   16.47 -    private static int sumByteArr(byte[] arr) {
   16.48 -        int sum = 0;
   16.49 -        for (int i = 0; i < arr.length; i++) {
   16.50 -            sum += arr[i];
   16.51 -        }
   16.52 -        return sum;
   16.53 -    }
   16.54 -    
   16.55 -    @Compare public String noOutOfBounds() {
   16.56 -        return atIndex(1);
   16.57 -    }
   16.58 -
   16.59 -    @Compare public String outOfBounds() {
   16.60 -        return atIndex(5);
   16.61 -    }
   16.62 -
   16.63 -    @Compare public String outOfBoundsMinus() {
   16.64 -        return atIndex(-1);
   16.65 -    }
   16.66 -
   16.67 -    @Compare public String toOfBounds() {
   16.68 -        return toIndex(5);
   16.69 -    }
   16.70 -
   16.71 -    @Compare public String toOfBoundsMinus() {
   16.72 -        return toIndex(-1);
   16.73 -    }
   16.74 -    
   16.75 -    @Compare public int multiArrayLength() {
   16.76 -         int[][] arr = new int[1][0];
   16.77 -         return arr[0].length;
   16.78 -    }
   16.79 -
   16.80 -    @Compare public int multiObjectArrayLength() {
   16.81 -         Object[][] arr = new Object[1][0];
   16.82 -         return arr[0].length;
   16.83 -    }
   16.84 -
   16.85 -    private static final int[] arr = { 0, 1, 2 };
   16.86 -    public static String atIndex(int at) {
   16.87 -        return "at@" + arr[at];
   16.88 -    }
   16.89 -    public static String toIndex(int at) {
   16.90 -        arr[at] = 10;
   16.91 -        return "ok";
   16.92 -    }
   16.93 -    
   16.94 -    
   16.95 -    @Factory
   16.96 -    public static Object[] create() {
   16.97 -        return VMTest.create(CompareByteArrayTest.class);
   16.98 -    }
   16.99 -
  16.100 -    private byte[] createArray() {
  16.101 -        byte[] arr = new byte[10];
  16.102 -        arr[5] = 3;
  16.103 -        arr[7] = 8;
  16.104 -        return arr;
  16.105 -    }
  16.106 -}
    17.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java	Sun Nov 09 10:36:08 2014 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,60 +0,0 @@
    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 org.apidesign.bck2brwsr.vmtest.Compare;
   17.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   17.25 -import org.testng.annotations.Factory;
   17.26 -
   17.27 -/**
   17.28 - *
   17.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   17.30 - */
   17.31 -public class CompareHashTest {
   17.32 -    @Compare public int hashOfString() {
   17.33 -        return "Ahoj".hashCode();
   17.34 -    }
   17.35 -    
   17.36 -    @Compare public boolean hashOfIntegerDifferentToOwnHash() {
   17.37 -        Integer i = 120;
   17.38 -        return System.identityHashCode(i) != i.hashCode();
   17.39 -    }
   17.40 -
   17.41 -    @Compare public int hashOfObjectSameAsOwnHash() {
   17.42 -        Object o = new Object();
   17.43 -        return System.identityHashCode(o) - o.hashCode();
   17.44 -    }
   17.45 -    
   17.46 -    @Compare public int hashRemainsYieldsZero() {
   17.47 -        Object o = new Object();
   17.48 -        return o.hashCode() - o.hashCode();
   17.49 -    }
   17.50 -    
   17.51 -    @Compare public int initializeInStatic() {
   17.52 -        return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode();
   17.53 -    }
   17.54 -    
   17.55 -    @Compare public int hashOfInt() {
   17.56 -        return Integer.valueOf(Integer.MAX_VALUE).hashCode();
   17.57 -    }
   17.58 -    
   17.59 -    @Factory
   17.60 -    public static Object[] create() {
   17.61 -        return VMTest.create(CompareHashTest.class);
   17.62 -    }
   17.63 -}
    18.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java	Sun Nov 09 10:36:08 2014 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,63 +0,0 @@
    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 org.apidesign.bck2brwsr.vmtest.Compare;
   18.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   18.25 -import org.testng.annotations.Factory;
   18.26 -
   18.27 -/**
   18.28 - *
   18.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   18.30 - */
   18.31 -public class CompareIntArrayTest {
   18.32 -    @Compare public int integerArraySum() {
   18.33 -        int[] arr = createArray();
   18.34 -        return sumIntArr(arr);
   18.35 -    }
   18.36 -    
   18.37 -    @Compare public int countZeros() {
   18.38 -        int zeros = 0;
   18.39 -        for (Integer i : createArray()) {
   18.40 -            if (i == 0) {
   18.41 -                zeros++;
   18.42 -            }
   18.43 -        }
   18.44 -        return zeros;
   18.45 -    }
   18.46 -    
   18.47 -    private static int sumIntArr(int[] arr) {
   18.48 -        int sum = 0;
   18.49 -        for (int i = 0; i < arr.length; i++) {
   18.50 -            sum += arr[i];
   18.51 -        }
   18.52 -        return sum;
   18.53 -    }
   18.54 -    
   18.55 -    @Factory
   18.56 -    public static Object[] create() {
   18.57 -        return VMTest.create(CompareIntArrayTest.class);
   18.58 -    }
   18.59 -
   18.60 -    private int[] createArray() {
   18.61 -        int[] arr = new int[10];
   18.62 -        arr[5] = 3;
   18.63 -        arr[7] = 8;
   18.64 -        return arr;
   18.65 -    }
   18.66 -}
    19.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java	Sun Nov 09 10:36:08 2014 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,209 +0,0 @@
    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.UnsupportedEncodingException;
   19.24 -import java.net.MalformedURLException;
   19.25 -import java.net.URISyntaxException;
   19.26 -import java.net.URL;
   19.27 -import java.util.Locale;
   19.28 -import org.apidesign.bck2brwsr.vmtest.Compare;
   19.29 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   19.30 -import org.testng.annotations.Factory;
   19.31 -
   19.32 -/**
   19.33 - *
   19.34 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   19.35 - */
   19.36 -public class CompareStringsTest {
   19.37 -    @Compare public String firstChar() {
   19.38 -        return "" + ("Hello".toCharArray()[0]);
   19.39 -    }
   19.40 -    
   19.41 -    @Compare public String classCast() {
   19.42 -        Object o = firstChar();
   19.43 -        return String.class.cast(o);
   19.44 -    }
   19.45 -
   19.46 -    @Compare public String classCastThrown() {
   19.47 -        Object o = null;
   19.48 -        return String.class.cast(o);
   19.49 -    }
   19.50 -    
   19.51 -    @Compare public boolean equalToNull() {
   19.52 -        return "Ahoj".equals(null);
   19.53 -    }
   19.54 -    
   19.55 -    @Compare public boolean internIsSame() {
   19.56 -        return new String("Ahoj").intern() == another();
   19.57 -    }
   19.58 -    
   19.59 -    private static String another() {
   19.60 -        return new String("Ahoj").intern();
   19.61 -    }
   19.62 -    
   19.63 -    @Compare public int highByteLenght() {
   19.64 -        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   19.65 -        return new String(arr, 0).length();
   19.66 -    }
   19.67 -    
   19.68 -    @Compare public String highByte() {
   19.69 -        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   19.70 -        StringBuilder sb = new StringBuilder();
   19.71 -        sb.append("pref:");
   19.72 -        sb.append(new String(arr, 0));
   19.73 -        return sb.toString();
   19.74 -    }
   19.75 -    
   19.76 -    @Compare public static Object compareURLs() throws MalformedURLException {
   19.77 -        return new URL("http://apidesign.org:8080/wiki/").toExternalForm().toString();
   19.78 -    }
   19.79 -
   19.80 -    @Compare public static Object compareURLsViaURIs() throws Exception {
   19.81 -        return new URL("http://apidesign.org:8080/wiki/").toURI().toString();
   19.82 -    }
   19.83 -    
   19.84 -    @Compare public String deleteLastTwoCharacters() {
   19.85 -        StringBuilder sb = new StringBuilder();
   19.86 -        sb.append("453.0");
   19.87 -        if (sb.toString().endsWith(".0")) {
   19.88 -            final int l = sb.length();
   19.89 -            sb.delete(l - 2, l);
   19.90 -        }
   19.91 -        return sb.toString().toString();
   19.92 -    }
   19.93 -    
   19.94 -    @Compare public String nameOfStringClass() throws Exception {
   19.95 -        return Class.forName("java.lang.String").getName();
   19.96 -    }
   19.97 -    @Compare public String nameOfArrayClass() throws Exception {
   19.98 -        return Class.forName("org.apidesign.bck2brwsr.tck.CompareHashTest").getName();
   19.99 -    }
  19.100 -    
  19.101 -    @Compare public String lowerHello() {
  19.102 -        return "HeLlO".toLowerCase();
  19.103 -    }
  19.104 -    
  19.105 -    @Compare public String lowerA() {
  19.106 -        return String.valueOf(Character.toLowerCase('A')).toString();
  19.107 -    }
  19.108 -    @Compare public String upperHello() {
  19.109 -        return "hello".toUpperCase();
  19.110 -    }
  19.111 -    
  19.112 -    @Compare public String upperA() {
  19.113 -        return String.valueOf(Character.toUpperCase('a')).toString();
  19.114 -    }
  19.115 -    
  19.116 -    @Compare public boolean matchRegExp() throws Exception {
  19.117 -        return "58038503".matches("\\d*");
  19.118 -    }
  19.119 -
  19.120 -    @Compare public boolean doesNotMatchRegExp() throws Exception {
  19.121 -        return "58038503GH".matches("\\d*");
  19.122 -    }
  19.123 -
  19.124 -    @Compare public boolean doesNotMatchRegExpFully() throws Exception {
  19.125 -        return "Hello".matches("Hell");
  19.126 -    }
  19.127 -    
  19.128 -    @Compare public String emptyCharArray() {
  19.129 -        char[] arr = new char[10];
  19.130 -        return new String(arr);
  19.131 -    }
  19.132 -    
  19.133 -    @Compare public String variousCharacterTests() throws Exception {
  19.134 -        StringBuilder sb = new StringBuilder();
  19.135 -        
  19.136 -        sb.append(Character.isUpperCase('a'));
  19.137 -        sb.append(Character.isUpperCase('A'));
  19.138 -        sb.append(Character.isLowerCase('a'));
  19.139 -        sb.append(Character.isLowerCase('A'));
  19.140 -        
  19.141 -        sb.append(Character.isLetter('A'));
  19.142 -        sb.append(Character.isLetterOrDigit('9'));
  19.143 -        sb.append(Character.isLetterOrDigit('A'));
  19.144 -        sb.append(Character.isLetter('0'));
  19.145 -        
  19.146 -        return sb.toString().toString();
  19.147 -    }
  19.148 -        
  19.149 -    @Compare
  19.150 -    public String nullFieldInitialized() {
  19.151 -        NullField nf = new NullField();
  19.152 -        return ("" + nf.name).toString();
  19.153 -    }
  19.154 -    @Compare
  19.155 -    public String toUTFString() throws UnsupportedEncodingException {
  19.156 -        byte[] arr = {
  19.157 -            (byte) -59, (byte) -67, (byte) 108, (byte) 117, (byte) -59, (byte) -91,
  19.158 -            (byte) 111, (byte) 117, (byte) -60, (byte) -115, (byte) 107, (byte) -61,
  19.159 -            (byte) -67, (byte) 32, (byte) 107, (byte) -59, (byte) -81, (byte) -59,
  19.160 -            (byte) -120
  19.161 -        };
  19.162 -        return new String(arr, "utf-8");
  19.163 -    }
  19.164 -
  19.165 -    @Compare
  19.166 -    public int stringToBytesLenght() throws UnsupportedEncodingException {
  19.167 -        return "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148".getBytes("utf8").length;
  19.168 -    }
  19.169 -    
  19.170 -    @Compare public String replaceSeq() {
  19.171 -        return "Hello World.".replace(".", "!");
  19.172 -    }
  19.173 -    @Compare public String replaceSeqAll() {
  19.174 -        return "Hello World! Hello World.".replace("World", "Jarda");
  19.175 -    }
  19.176 -    @Compare public String replaceSeqAA() {
  19.177 -        String res = "aaa".replace("aa", "b");
  19.178 -        assert res.equals("ba") : "Expecting ba: " + res;
  19.179 -        return res;
  19.180 -    }
  19.181 -    
  19.182 -    @Compare public String localeUS() {
  19.183 -        return Locale.US.toString();
  19.184 -    }
  19.185 -    
  19.186 -    @Compare public String localeFrench() {
  19.187 -        return Locale.FRENCH.toString();
  19.188 -    }
  19.189 -    
  19.190 -    
  19.191 -    @Compare public String formatSimple() {
  19.192 -        return String.format((Locale)null, "Hello %s!", "World");
  19.193 -    }
  19.194 -
  19.195 -    @Compare public String replaceWithItself() {
  19.196 -        return "org.apidesign.bck2brwsr.core.JavaScriptBody".replace(".", "\\.");
  19.197 -    }
  19.198 -    
  19.199 -    @Compare public boolean matchWithComplicatedRegExp() {
  19.200 -        return "Activates this model instance.".matches("(?sm).*^\\s*@deprecated( |$).*");
  19.201 -    }
  19.202 -    
  19.203 -    @Factory
  19.204 -    public static Object[] create() {
  19.205 -        return VMTest.create(CompareStringsTest.class);
  19.206 -    }
  19.207 -
  19.208 -    private static final class NullField {
  19.209 -
  19.210 -        String name;
  19.211 -    }
  19.212 -}
    20.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ConcurrentTest.java	Sun Nov 09 10:36:08 2014 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,40 +0,0 @@
    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 java.util.concurrent.ConcurrentHashMap;
   20.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   20.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   20.26 -import org.testng.annotations.Factory;
   20.27 -
   20.28 -/**
   20.29 - *
   20.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   20.31 - */
   20.32 -public class ConcurrentTest {
   20.33 -    @Compare public String mapIfAbsent() {
   20.34 -        ConcurrentHashMap<String,String> m = new ConcurrentHashMap<>();
   20.35 -        m.putIfAbsent("Ahoj", "Jardo");
   20.36 -        m.putIfAbsent("Ahoj", "Dardo");
   20.37 -        return m.get("Ahoj");
   20.38 -    }
   20.39 -    
   20.40 -    @Factory public static Object[] create() {
   20.41 -        return VMTest.create(ConcurrentTest.class);
   20.42 -    }
   20.43 -}
    21.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java	Sun Nov 09 10:36:08 2014 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,73 +0,0 @@
    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 -import org.apidesign.bck2brwsr.vmtest.Compare;
   21.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   21.25 -import org.testng.annotations.Factory;
   21.26 -
   21.27 -/**
   21.28 - *
   21.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   21.30 - */
   21.31 -public class DoubleTest {
   21.32 -    @Compare public boolean parsedDoubleIsDouble() {
   21.33 -        return Double.valueOf("1.1") instanceof Double;
   21.34 -    }
   21.35 -
   21.36 -    @Compare public boolean parsedFloatIsFloat() {
   21.37 -        return Float.valueOf("1.1") instanceof Float;
   21.38 -    }
   21.39 -    
   21.40 -    @Compare public String integerToString() {
   21.41 -        return toStr(1);
   21.42 -    }
   21.43 -
   21.44 -    @Compare public String integerAndHalfToString() {
   21.45 -        return toStr(1.5);
   21.46 -    }
   21.47 -
   21.48 -    @Compare public double longToAndBack() {
   21.49 -        return Double.parseDouble(toStr(Long.MAX_VALUE / 10));
   21.50 -    }
   21.51 -
   21.52 -    @Compare public String negativeIntToString() {
   21.53 -        return toStr(-10);
   21.54 -    }
   21.55 -
   21.56 -    @Compare public String negativeIntAndHalfToString() {
   21.57 -        return toStr(-10.5);
   21.58 -    }
   21.59 -
   21.60 -    @Compare public double negativeLongAndBack() {
   21.61 -        return Double.parseDouble(toStr(Long.MIN_VALUE / 10));
   21.62 -    }
   21.63 -    
   21.64 -    @Compare public double canParseExp() {
   21.65 -        return Double.parseDouble(toStr(1.7976931348623157e+308));
   21.66 -    }
   21.67 -    
   21.68 -    private static String toStr(double d) {
   21.69 -        return Double.toString(d);
   21.70 -    }
   21.71 -    
   21.72 -    @Factory 
   21.73 -    public static Object[] create() {
   21.74 -        return VMTest.create(DoubleTest.class);
   21.75 -    }
   21.76 -}
    22.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java	Sun Nov 09 10:36:08 2014 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,76 +0,0 @@
    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 -import java.util.EnumMap;
   22.24 -import java.util.EnumSet;
   22.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
   22.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   22.27 -import org.testng.annotations.Factory;
   22.28 -
   22.29 -/**
   22.30 - *
   22.31 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
   22.32 - */
   22.33 -public class EnumsTest {
   22.34 -    enum Color {
   22.35 -        B, W;
   22.36 -    }
   22.37 -
   22.38 -    @Compare public String enumSet() {
   22.39 -        try { throw new Exception(); } catch (Exception ex) {}
   22.40 -        EnumSet<Color> c = EnumSet.allOf(Color.class);
   22.41 -        return c.toString();
   22.42 -    }
   22.43 -
   22.44 -    @Compare public String enumSetOneByOne() {
   22.45 -        EnumSet<Color> c = EnumSet.of(Color.B, Color.W);
   22.46 -        return c.toString();
   22.47 -    }
   22.48 -
   22.49 -    @Compare public boolean enumFirstContains() {
   22.50 -        EnumSet<Color> c = EnumSet.of(Color.B);
   22.51 -        return c.contains(Color.B);
   22.52 -    }
   22.53 -
   22.54 -    @Compare public boolean enumFirstDoesNotContains() {
   22.55 -        EnumSet<Color> c = EnumSet.of(Color.B);
   22.56 -        return c.contains(Color.W);
   22.57 -    }
   22.58 -
   22.59 -    @Compare public boolean enumSndContains() {
   22.60 -        EnumSet<Color> c = EnumSet.of(Color.W);
   22.61 -        return c.contains(Color.W);
   22.62 -    }
   22.63 -
   22.64 -    @Compare public boolean enumSecondDoesNotContains() {
   22.65 -        EnumSet<Color> c = EnumSet.of(Color.W);
   22.66 -        return c.contains(Color.B);
   22.67 -    }
   22.68 -
   22.69 -    @Compare public String enumMap() {
   22.70 -        EnumMap<Color,String> c = new EnumMap(Color.class);
   22.71 -        c.put(Color.B, "Black");
   22.72 -        c.put(Color.W, "White");
   22.73 -        return c.toString();
   22.74 -    }
   22.75 -    
   22.76 -    @Factory public static Object[] create() {
   22.77 -        return VMTest.create(EnumsTest.class);
   22.78 -    }
   22.79 -}
    23.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ExceptionsTest.java	Sun Nov 09 10:36:08 2014 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,68 +0,0 @@
    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 java.io.ByteArrayOutputStream;
   23.24 -import java.io.PrintStream;
   23.25 -import java.io.PrintWriter;
   23.26 -import java.io.StringWriter;
   23.27 -import java.io.UnsupportedEncodingException;
   23.28 -import org.apidesign.bck2brwsr.vmtest.Compare;
   23.29 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   23.30 -import org.testng.annotations.Factory;
   23.31 -
   23.32 -/**
   23.33 - *
   23.34 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   23.35 - */
   23.36 -public class ExceptionsTest {
   23.37 -    @Compare public String firstLineIsTheSame() throws UnsupportedEncodingException {
   23.38 -        MyException ex = new MyException("Hello");
   23.39 -        ByteArrayOutputStream out = new ByteArrayOutputStream();
   23.40 -        PrintStream ps = new PrintStream(out);
   23.41 -        ex.printStackTrace(ps);
   23.42 -        ps.flush();
   23.43 -        
   23.44 -        String s = new String(out.toByteArray(), "UTF-8");
   23.45 -        int newLine = s.indexOf('\n');
   23.46 -        return s.substring(0, newLine);
   23.47 -    }
   23.48 -
   23.49 -    @Compare public String firstLineIsTheSameWithWriter() throws UnsupportedEncodingException {
   23.50 -        MyException ex = new MyException("Hello");
   23.51 -        StringWriter sw = new StringWriter();
   23.52 -        PrintWriter pw = new PrintWriter(sw);
   23.53 -        ex.printStackTrace(pw);
   23.54 -        pw.flush();
   23.55 -        
   23.56 -        String s = sw.toString();
   23.57 -        int newLine = s.indexOf('\n');
   23.58 -        return s.substring(0, newLine);
   23.59 -    }
   23.60 -    
   23.61 -    static class MyException extends Exception {
   23.62 -        public MyException(String message) {
   23.63 -            super(message);
   23.64 -        }
   23.65 -    }
   23.66 -    
   23.67 -    
   23.68 -    @Factory public static Object[] create() {
   23.69 -        return VMTest.create(ExceptionsTest.class);
   23.70 -    }
   23.71 -}
    24.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Sun Nov 09 10:36:08 2014 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,106 +0,0 @@
    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.tck;
   24.22 -
   24.23 -import java.io.InputStream;
   24.24 -import java.net.URL;
   24.25 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   24.26 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   24.27 -import org.apidesign.bck2brwsr.vmtest.Http;
   24.28 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   24.29 -import org.testng.annotations.Factory;
   24.30 -
   24.31 -/**
   24.32 - *
   24.33 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   24.34 - */
   24.35 -public class HttpResourceTest {
   24.36 -    
   24.37 -    @Http({
   24.38 -        @Http.Resource(path = "/xhr", content = "Hello Brwsr!", mimeType = "text/plain")
   24.39 -    })
   24.40 -    @BrwsrTest
   24.41 -    
   24.42 -    
   24.43 -    public String testReadContentViaXHR() throws Exception {
   24.44 -        String msg = read("/xhr");
   24.45 -        assert "Hello Brwsr!".equals(msg) : "The message was " + msg;
   24.46 -        return msg;
   24.47 -    }
   24.48 -
   24.49 -    @Http({
   24.50 -        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   24.51 -    })
   24.52 -    @BrwsrTest
   24.53 -    public String testReadContentViaURL() throws Exception {
   24.54 -        URL url = new URL("http:/url");
   24.55 -        String msg = (String) url.getContent();
   24.56 -        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   24.57 -        return msg;
   24.58 -    }
   24.59 -    @Http({
   24.60 -        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   24.61 -    })
   24.62 -    @BrwsrTest
   24.63 -    public String testReadContentViaURLWithStringParam() throws Exception {
   24.64 -        URL url = new URL("http:/url");
   24.65 -        String msg = (String) url.getContent(new Class[] { String.class });
   24.66 -        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   24.67 -        return msg;
   24.68 -    }
   24.69 -
   24.70 -    @Http({
   24.71 -        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   24.72 -    })
   24.73 -    @BrwsrTest
   24.74 -    public void testReadByte() throws Exception {
   24.75 -        URL url = new URL("http:/bytes");
   24.76 -        final Object res = url.getContent(new Class[] { byte[].class });
   24.77 -        assert res instanceof byte[] : "Expecting byte[]: " + res;
   24.78 -        byte[] arr = (byte[]) res;
   24.79 -        assert arr.length == 1 : "One byte " + arr.length;
   24.80 -        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   24.81 -    }
   24.82 -
   24.83 -    @Http({
   24.84 -        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   24.85 -    })
   24.86 -    @BrwsrTest
   24.87 -    public void testReadByteViaInputStream() throws Exception {
   24.88 -        URL url = new URL("http:/bytes");
   24.89 -        InputStream is = url.openStream();
   24.90 -        byte[] arr = new byte[10];
   24.91 -        int len = is.read(arr);
   24.92 -        assert len == 1 : "One byte " + len;
   24.93 -        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   24.94 -    }
   24.95 -    
   24.96 -    @JavaScriptBody(args = { "url" }, body = 
   24.97 -          "var req = new XMLHttpRequest();\n"
   24.98 -        + "req.open('GET', url, false);\n"
   24.99 -        + "req.send();\n"
  24.100 -        + "return req.responseText;"
  24.101 -    )
  24.102 -    private static native String read(String url);
  24.103 -    
  24.104 -    
  24.105 -    @Factory
  24.106 -    public static Object[] create() {
  24.107 -        return VMTest.create(HttpResourceTest.class);
  24.108 -    }
  24.109 -}
    25.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java	Sun Nov 09 10:36:08 2014 +0100
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,34 +0,0 @@
    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.tck;
   25.22 -
   25.23 -/**
   25.24 - *
   25.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   25.26 - */
   25.27 -public class InheritanceA {
   25.28 -    private String name;
   25.29 -    
   25.30 -    public void setA(String n) {
   25.31 -        this.name = n;
   25.32 -    }
   25.33 -    
   25.34 -    public String getA() {
   25.35 -        return name;
   25.36 -    }
   25.37 -}
    26.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java	Sun Nov 09 10:36:08 2014 +0100
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,34 +0,0 @@
    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.tck;
   26.22 -
   26.23 -/**
   26.24 - *
   26.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   26.26 - */
   26.27 -public class InheritanceB extends InheritanceA {
   26.28 -    private String name;
   26.29 -    
   26.30 -    public void setB(String n) {
   26.31 -        this.name = n;
   26.32 -    }
   26.33 -    
   26.34 -    public String getB() {
   26.35 -        return name;
   26.36 -    }
   26.37 -}
    27.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java	Sun Nov 09 10:36:08 2014 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,41 +0,0 @@
    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.tck;
   27.22 -
   27.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   27.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   27.25 -import org.testng.annotations.Factory;
   27.26 -
   27.27 -/**
   27.28 - *
   27.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   27.30 - */
   27.31 -public class InheritanceTest {
   27.32 -
   27.33 -    @Compare public String checkFieldsIndependent() throws ClassNotFoundException {
   27.34 -        InheritanceB ib = new InheritanceB();
   27.35 -        ib.setA("A");
   27.36 -        ib.setB("B");
   27.37 -        return "A: " + ib.getA() + " B: " + ib.getB();
   27.38 -    }
   27.39 -    
   27.40 -    @Factory
   27.41 -    public static Object[] create() {
   27.42 -        return VMTest.create(InheritanceTest.class);
   27.43 -    }
   27.44 -}
    28.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Sun Nov 09 10:36:08 2014 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,166 +0,0 @@
    28.4 -/**
    28.5 - * Back 2 Browser Bytecode Translator
    28.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    28.7 - *
    28.8 - * This program is free software: you can redistribute it and/or modify
    28.9 - * it under the terms of the GNU General Public License as published by
   28.10 - * the Free Software Foundation, version 2 of the License.
   28.11 - *
   28.12 - * This program is distributed in the hope that it will be useful,
   28.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.15 - * GNU General Public License for more details.
   28.16 - *
   28.17 - * You should have received a copy of the GNU General Public License
   28.18 - * along with this program. Look for COPYING file in the top folder.
   28.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   28.20 - */
   28.21 -package org.apidesign.bck2brwsr.tck;
   28.22 -
   28.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   28.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   28.25 -import org.testng.annotations.Factory;
   28.26 -
   28.27 -/**
   28.28 - *
   28.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   28.30 - */
   28.31 -public class IntegerArithmeticTest {
   28.32 -    
   28.33 -    private static int add(int x, int y) {
   28.34 -        return x + y;
   28.35 -    }
   28.36 -    
   28.37 -    private static int sub(int x, int y) {
   28.38 -        return x - y;
   28.39 -    }
   28.40 -    
   28.41 -    private static int mul(int x, int y) {
   28.42 -        return x * y;
   28.43 -    }
   28.44 -    
   28.45 -    private static int div(int x, int y) {
   28.46 -        return x / y;
   28.47 -    }
   28.48 -    
   28.49 -    private static int mod(int x, int y) {
   28.50 -        return x % y;
   28.51 -    }
   28.52 -    
   28.53 -    private static int neg(int x) {
   28.54 -        return (-x);
   28.55 -    }
   28.56 -
   28.57 -    private static float fadd(float x, float y) {
   28.58 -        return x + y;
   28.59 -    }
   28.60 -
   28.61 -    private static double dadd(double x, double y) {
   28.62 -        return x + y;
   28.63 -    }
   28.64 -    
   28.65 -    @Compare public int addOverflow() {
   28.66 -        return add(Integer.MAX_VALUE, 1);
   28.67 -    }
   28.68 -    
   28.69 -    @Compare public int subUnderflow() {
   28.70 -        return sub(Integer.MIN_VALUE, 1);
   28.71 -    }
   28.72 -    
   28.73 -    @Compare public int addMaxIntAndMaxInt() {
   28.74 -        return add(Integer.MAX_VALUE, Integer.MAX_VALUE);
   28.75 -    }
   28.76 -    
   28.77 -    @Compare public int subMinIntAndMinInt() {
   28.78 -        return sub(Integer.MIN_VALUE, Integer.MIN_VALUE);
   28.79 -    }
   28.80 -    
   28.81 -    @Compare public int multiplyMaxInt() {
   28.82 -        return mul(Integer.MAX_VALUE, 2);
   28.83 -    }
   28.84 -    
   28.85 -    @Compare public int multiplyMaxIntAndMaxInt() {
   28.86 -        return mul(Integer.MAX_VALUE, Integer.MAX_VALUE);
   28.87 -    }
   28.88 -    
   28.89 -    @Compare public int multiplyMinInt() {
   28.90 -        return mul(Integer.MIN_VALUE, 2);
   28.91 -    }
   28.92 -    
   28.93 -    @Compare public int multiplyMinIntAndMinInt() {
   28.94 -        return mul(Integer.MIN_VALUE, Integer.MIN_VALUE);
   28.95 -    }
   28.96 -    
   28.97 -    @Compare public int multiplyPrecision() {
   28.98 -        return mul(119106029, 1103515245);
   28.99 -    }
  28.100 -    
  28.101 -    @Compare public int division() {
  28.102 -        return div(1, 2);
  28.103 -    }
  28.104 -
  28.105 -    @Compare public int divisionReminder() {
  28.106 -        return mod(1, 2);
  28.107 -    }
  28.108 -
  28.109 -    @Compare public int negativeDivision() {
  28.110 -        return div(-7, 3);
  28.111 -    }
  28.112 -
  28.113 -    @Compare public int negativeDivisionReminder() {
  28.114 -        return mod(-7, 3);
  28.115 -    }
  28.116 -
  28.117 -    @Compare public int conversionFromFloat() {
  28.118 -        return (int) fadd(-2, -0.6f);
  28.119 -    }
  28.120 -
  28.121 -    @Compare public int conversionFromDouble() {
  28.122 -        return (int) dadd(-2, -0.6);
  28.123 -    }
  28.124 -
  28.125 -    @Compare public boolean divByZeroThrowsArithmeticException() {
  28.126 -        try {
  28.127 -            div(1, 0);
  28.128 -            return false;
  28.129 -        } catch (final ArithmeticException e) {
  28.130 -            return true;
  28.131 -        }
  28.132 -    }
  28.133 -
  28.134 -    @Compare public boolean modByZeroThrowsArithmeticException() {
  28.135 -        try {
  28.136 -            mod(1, 0);
  28.137 -            return false;
  28.138 -        } catch (final ArithmeticException e) {
  28.139 -            return true;
  28.140 -        }
  28.141 -    }
  28.142 -
  28.143 -    @Compare public int negate() {
  28.144 -        return neg(123456);
  28.145 -    }
  28.146 -    
  28.147 -    @Compare public int negateMaxInt() {
  28.148 -        return neg(Integer.MAX_VALUE);
  28.149 -    }
  28.150 -    
  28.151 -    @Compare public int negateMinInt() {
  28.152 -        return neg(Integer.MIN_VALUE);
  28.153 -    }
  28.154 -    
  28.155 -    @Compare public int sumTwoDimensions() {
  28.156 -        int[][] matrix = createMatrix(4, 3);
  28.157 -        matrix[0][0] += 10;
  28.158 -        return matrix[0][0];
  28.159 -    }
  28.160 -    
  28.161 -    static int[][] createMatrix(int x, int y) {
  28.162 -        return new int[x][y];
  28.163 -    }
  28.164 -    
  28.165 -    @Factory
  28.166 -    public static Object[] create() {
  28.167 -        return VMTest.create(IntegerArithmeticTest.class);
  28.168 -    }
  28.169 -}
    29.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LoggerTest.java	Sun Nov 09 10:36:08 2014 +0100
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,43 +0,0 @@
    29.4 -/**
    29.5 - * Back 2 Browser Bytecode Translator
    29.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    29.7 - *
    29.8 - * This program is free software: you can redistribute it and/or modify
    29.9 - * it under the terms of the GNU General Public License as published by
   29.10 - * the Free Software Foundation, version 2 of the License.
   29.11 - *
   29.12 - * This program is distributed in the hope that it will be useful,
   29.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   29.15 - * GNU General Public License for more details.
   29.16 - *
   29.17 - * You should have received a copy of the GNU General Public License
   29.18 - * along with this program. Look for COPYING file in the top folder.
   29.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   29.20 - */
   29.21 -package org.apidesign.bck2brwsr.tck;
   29.22 -
   29.23 -import java.util.logging.Logger;
   29.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   29.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   29.26 -import org.testng.annotations.Factory;
   29.27 -
   29.28 -/**
   29.29 - *
   29.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   29.31 - */
   29.32 -public class LoggerTest {
   29.33 -    @Compare public String parentLogger() {
   29.34 -        Logger lx = Logger.getLogger("x");
   29.35 -        assert lx != null;
   29.36 -        assert lx.getName().equals("x") : "Right name: " + lx.getName();
   29.37 -        Logger lxyz = Logger.getLogger("x.y.z");
   29.38 -        assert lxyz != null;
   29.39 -        assert lxyz.getName().equals("x.y.z") : "xyz name: " + lxyz.getName();
   29.40 -        return lxyz.getParent().getName();
   29.41 -    }
   29.42 -    
   29.43 -    @Factory public static Object[] create() {
   29.44 -        return VMTest.create(LoggerTest.class);
   29.45 -    }
   29.46 -}
    30.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Sun Nov 09 10:36:08 2014 +0100
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,418 +0,0 @@
    30.4 -/**
    30.5 - * Back 2 Browser Bytecode Translator
    30.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    30.7 - *
    30.8 - * This program is free software: you can redistribute it and/or modify
    30.9 - * it under the terms of the GNU General Public License as published by
   30.10 - * the Free Software Foundation, version 2 of the License.
   30.11 - *
   30.12 - * This program is distributed in the hope that it will be useful,
   30.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   30.15 - * GNU General Public License for more details.
   30.16 - *
   30.17 - * You should have received a copy of the GNU General Public License
   30.18 - * along with this program. Look for COPYING file in the top folder.
   30.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   30.20 - */
   30.21 -package org.apidesign.bck2brwsr.tck;
   30.22 -
   30.23 -import org.apidesign.bck2brwsr.vmtest.Compare;
   30.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   30.25 -import org.testng.annotations.Factory;
   30.26 -
   30.27 -/**
   30.28 - *
   30.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   30.30 - */
   30.31 -public class LongArithmeticTest {
   30.32 -
   30.33 -    private static long add(long x, long y) {
   30.34 -        return (x + y);
   30.35 -    }
   30.36 -
   30.37 -    private static long sub(long x, long y) {
   30.38 -        return (x - y);
   30.39 -    }
   30.40 -
   30.41 -    private static long mul(long x, long y) {
   30.42 -        return (x * y);
   30.43 -    }
   30.44 -
   30.45 -    private static long div(long x, long y) {
   30.46 -        return (x / y);
   30.47 -    }
   30.48 -
   30.49 -    private static long mod(long x, long y) {
   30.50 -        return (x % y);
   30.51 -    }
   30.52 -
   30.53 -    private static long neg(long x) {
   30.54 -        return (-x);
   30.55 -    }
   30.56 -
   30.57 -    private static long shl(long x, int b) {
   30.58 -        return (x << b);
   30.59 -    }
   30.60 -
   30.61 -    private static long shr(long x, int b) {
   30.62 -        return (x >> b);
   30.63 -    }
   30.64 -
   30.65 -    private static long ushr(long x, int b) {
   30.66 -        return (x >>> b);
   30.67 -    }
   30.68 -
   30.69 -    private static long and(long x, long y) {
   30.70 -        return (x & y);
   30.71 -    }
   30.72 -
   30.73 -    private static long or(long x, long y) {
   30.74 -        return (x | y);
   30.75 -    }
   30.76 -
   30.77 -    private static long xor(long x, long y) {
   30.78 -        return (x ^ y);
   30.79 -    }
   30.80 -
   30.81 -    private static float fadd(float x, float y) {
   30.82 -        return x + y;
   30.83 -    }
   30.84 -
   30.85 -    private static double dadd(double x, double y) {
   30.86 -        return x + y;
   30.87 -    }
   30.88 -
   30.89 -    public static int compare(long x, long y, int zero) {
   30.90 -        final int xyResult = compareL(x, y, zero);
   30.91 -        final int yxResult = compareL(y, x, zero);
   30.92 -
   30.93 -        return ((xyResult + yxResult) == 0) ? xyResult : -2;
   30.94 -    }
   30.95 -
   30.96 -    private static int compareL(long x, long y, int zero) {
   30.97 -        int result = -2;
   30.98 -        int trueCount = 0;
   30.99 -
  30.100 -        x += zero;
  30.101 -        if (x == y) {
  30.102 -            result = 0;
  30.103 -            ++trueCount;
  30.104 -        }
  30.105 -
  30.106 -        x += zero;
  30.107 -        if (x < y) {
  30.108 -            result = -1;
  30.109 -            ++trueCount;
  30.110 -        }
  30.111 -
  30.112 -        x += zero;
  30.113 -        if (x > y) {
  30.114 -            result = 1;
  30.115 -            ++trueCount;
  30.116 -        }
  30.117 -
  30.118 -        return (trueCount == 1) ? result : -2;
  30.119 -    }
  30.120 -    
  30.121 -    @Compare public int parameterSlotCount() {
  30.122 -        long argCounts = 281479271874563L;
  30.123 -        int x = unpack(argCounts, 2);
  30.124 -        return x;
  30.125 -    }
  30.126 -    private static char unpack(long packed, int word) { // word==0 => return a, ==3 => return d
  30.127 -        assert(word <= 3);
  30.128 -        final long val = packed >> ((3-word) * 16);
  30.129 -        return (char)val;
  30.130 -    }
  30.131 -    @Compare public long conversion() {
  30.132 -        return Long.MAX_VALUE;
  30.133 -    }
  30.134 -
  30.135 -    @Compare public long negate1() {
  30.136 -        return neg(0x00fa37d7763e0ca1l);
  30.137 -    }
  30.138 -
  30.139 -    @Compare public long negate2() {
  30.140 -        return neg(0x80fa37d7763e0ca1l);
  30.141 -    }
  30.142 -
  30.143 -    @Compare public long negate3() {
  30.144 -        return neg(0xfffffffffffffeddl);
  30.145 -    }
  30.146 -
  30.147 -    @Compare public long addOverflow() {
  30.148 -        return add(Long.MAX_VALUE, 1l);
  30.149 -    }
  30.150 -
  30.151 -    @Compare public long subUnderflow() {
  30.152 -        return sub(Long.MIN_VALUE, 1l);
  30.153 -    }
  30.154 -
  30.155 -    @Compare public long addMaxLongAndMaxLong() {
  30.156 -        return add(Long.MAX_VALUE, Long.MAX_VALUE);
  30.157 -    }
  30.158 -
  30.159 -    @Compare public long subMinLongAndMinLong() {
  30.160 -        return sub(Long.MIN_VALUE, Long.MIN_VALUE);
  30.161 -    }
  30.162 -
  30.163 -    @Compare public long subMinLongAndMaxLong() {
  30.164 -        return sub(Long.MIN_VALUE, Long.MAX_VALUE);
  30.165 -    }
  30.166 -
  30.167 -    @Compare public long multiplyMaxLong() {
  30.168 -        return mul(Long.MAX_VALUE, 2l);
  30.169 -    }
  30.170 -
  30.171 -    @Compare public long multiplyMaxLongAndMaxLong() {
  30.172 -        return mul(Long.MAX_VALUE, Long.MAX_VALUE);
  30.173 -    }
  30.174 -
  30.175 -    @Compare public long multiplyMinLong() {
  30.176 -        return mul(Long.MIN_VALUE, 2l);
  30.177 -    }
  30.178 -
  30.179 -    @Compare public long multiplyMinLongAndMinLong() {
  30.180 -        return mul(Long.MIN_VALUE, Long.MIN_VALUE);
  30.181 -    }
  30.182 -
  30.183 -    @Compare public long multiplyPrecision() {
  30.184 -        return mul(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  30.185 -    }
  30.186 -
  30.187 -    @Compare public long divideSmallPositiveNumbers() {
  30.188 -        return div(0xabcdef, 0x123);
  30.189 -    }
  30.190 -
  30.191 -    @Compare public long divideSmallNegativeNumbers() {
  30.192 -        return div(-0xabcdef, -0x123);
  30.193 -    }
  30.194 -
  30.195 -    @Compare public long divideSmallMixedNumbers() {
  30.196 -        return div(0xabcdef, -0x123);
  30.197 -    }
  30.198 -
  30.199 -    @Compare public long dividePositiveNumbersOneDigitDenom() {
  30.200 -        return div(0xabcdef0102ffffl, 0x654);
  30.201 -    }
  30.202 -
  30.203 -    @Compare public long divideNegativeNumbersOneDigitDenom() {
  30.204 -        return div(-0xabcdef0102ffffl, -0x654);
  30.205 -    }
  30.206 -
  30.207 -    @Compare public long divideMixedNumbersOneDigitDenom() {
  30.208 -        return div(-0xabcdef0102ffffl, 0x654);
  30.209 -    }
  30.210 -
  30.211 -    @Compare public long dividePositiveNumbersMultiDigitDenom() {
  30.212 -        return div(0x7ffefc003322aabbl, 0x89ab1000l);
  30.213 -    }
  30.214 -
  30.215 -    @Compare public long divideNegativeNumbersMultiDigitDenom() {
  30.216 -        return div(-0x7ffefc003322aabbl, -0x123489ab1001l);
  30.217 -    }
  30.218 -
  30.219 -    @Compare public long divideMixedNumbersMultiDigitDenom() {
  30.220 -        return div(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  30.221 -    }
  30.222 -
  30.223 -    @Compare public long divideWithOverflow() {
  30.224 -        return div(0x8000fffe0000l, 0x8000ffffl);
  30.225 -    }
  30.226 -
  30.227 -    @Compare public long divideWithCorrection() {
  30.228 -        return div(0x7fff800000000000l, 0x800000000001l);
  30.229 -    }
  30.230 -
  30.231 -    @Compare public long moduloSmallPositiveNumbers() {
  30.232 -        return mod(0xabcdef, 0x123);
  30.233 -    }
  30.234 -
  30.235 -    @Compare public long moduloSmallNegativeNumbers() {
  30.236 -        return mod(-0xabcdef, -0x123);
  30.237 -    }
  30.238 -
  30.239 -    @Compare public long moduloSmallMixedNumbers() {
  30.240 -        return mod(0xabcdef, -0x123);
  30.241 -    }
  30.242 -
  30.243 -    @Compare public long moduloPositiveNumbersOneDigitDenom() {
  30.244 -        return mod(0xabcdef0102ffffl, 0x654);
  30.245 -    }
  30.246 -
  30.247 -    @Compare public long moduloNegativeNumbersOneDigitDenom() {
  30.248 -        return mod(-0xabcdef0102ffffl, -0x654);
  30.249 -    }
  30.250 -
  30.251 -    @Compare public long moduloMixedNumbersOneDigitDenom() {
  30.252 -        return mod(-0xabcdef0102ffffl, 0x654);
  30.253 -    }
  30.254 -
  30.255 -    @Compare public long moduloPositiveNumbersMultiDigitDenom() {
  30.256 -        return mod(0x7ffefc003322aabbl, 0x89ab1000l);
  30.257 -    }
  30.258 -
  30.259 -    @Compare public long moduloNegativeNumbersMultiDigitDenom() {
  30.260 -        return mod(-0x7ffefc003322aabbl, -0x123489ab1001l);
  30.261 -    }
  30.262 -
  30.263 -    @Compare public long moduloMixedNumbersMultiDigitDenom() {
  30.264 -        return mod(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  30.265 -    }
  30.266 -
  30.267 -    @Compare public long moduloWithOverflow() {
  30.268 -        return mod(0x8000fffe0000l, 0x8000ffffl);
  30.269 -    }
  30.270 -
  30.271 -    @Compare public long moduloWithCorrection() {
  30.272 -        return mod(0x7fff800000000000l, 0x800000000001l);
  30.273 -    }
  30.274 -
  30.275 -    @Compare public long conversionFromFloatPositive() {
  30.276 -        return (long) fadd(2, 0.6f);
  30.277 -    }
  30.278 -
  30.279 -    @Compare public long conversionFromFloatNegative() {
  30.280 -        return (long) fadd(-2, -0.6f);
  30.281 -    }
  30.282 -
  30.283 -    @Compare public long conversionFromDoublePositive() {
  30.284 -        return (long) dadd(0x20ffff0000L, 0.6);
  30.285 -    }
  30.286 -
  30.287 -    @Compare public long conversionFromDoubleNegative() {
  30.288 -        return (long) dadd(-0x20ffff0000L, -0.6);
  30.289 -    }
  30.290 -
  30.291 -    @Compare public boolean divByZeroThrowsArithmeticException() {
  30.292 -        try {
  30.293 -            div(1, 0);
  30.294 -            return false;
  30.295 -        } catch (final ArithmeticException e) {
  30.296 -            return true;
  30.297 -        }
  30.298 -    }
  30.299 -
  30.300 -    @Compare public boolean modByZeroThrowsArithmeticException() {
  30.301 -        try {
  30.302 -            mod(1, 0);
  30.303 -            return false;
  30.304 -        } catch (final ArithmeticException e) {
  30.305 -            return true;
  30.306 -        }
  30.307 -    }
  30.308 -
  30.309 -    @Compare public long shiftL1() {
  30.310 -        return shl(0x00fa37d7763e0ca1l, 5);
  30.311 -    }
  30.312 -
  30.313 -    @Compare public long shiftL2() {
  30.314 -        return shl(0x00fa37d7763e0ca1l, 32);
  30.315 -    }
  30.316 -
  30.317 -    @Compare public long shiftL3() {
  30.318 -        return shl(0x00fa37d7763e0ca1l, 45);
  30.319 -    }
  30.320 -    
  30.321 -    @Compare public long shiftL4() {
  30.322 -        return shl(0x00fa37d7763e0ca1l, 0);
  30.323 -    }
  30.324 -    
  30.325 -    @Compare public long shiftL5() {
  30.326 -        return shl(0x00fa37d7763e0ca1l, 70);
  30.327 -    }
  30.328 -
  30.329 -    @Compare public long shiftR1() {
  30.330 -        return shr(0x00fa37d7763e0ca1l, 5);
  30.331 -    }
  30.332 -
  30.333 -    @Compare public long shiftR2() {
  30.334 -        return shr(0x00fa37d7763e0ca1l, 32);
  30.335 -    }
  30.336 -
  30.337 -    @Compare public long shiftR3() {
  30.338 -        return shr(0x00fa37d7763e0ca1l, 45);
  30.339 -    }
  30.340 -    
  30.341 -    @Compare public long shiftR4() {
  30.342 -        return shr(0x00fa37d7763e0ca1l, 0);
  30.343 -    }
  30.344 -    
  30.345 -    @Compare public long shiftR5() {
  30.346 -        return shr(0x00fa37d7763e0ca1l, 70);
  30.347 -    }
  30.348 -
  30.349 -    @Compare public long uShiftR1() {
  30.350 -        return ushr(0x00fa37d7763e0ca1l, 5);
  30.351 -    }
  30.352 -
  30.353 -    @Compare public long uShiftR2() {
  30.354 -        return ushr(0x00fa37d7763e0ca1l, 45);
  30.355 -    }
  30.356 -    
  30.357 -    @Compare public long uShiftR3() {
  30.358 -        return ushr(0x00fa37d7763e0ca1l, 0);
  30.359 -    }
  30.360 -    
  30.361 -    @Compare public long uShiftR4() {
  30.362 -        return ushr(0x00fa37d7763e0ca1l, 70);
  30.363 -    }
  30.364 -
  30.365 -    @Compare public long uShiftR5() {
  30.366 -        return ushr(0xf0fa37d7763e0ca1l, 5);
  30.367 -    }
  30.368 -
  30.369 -    @Compare public long uShiftR6() {
  30.370 -        return ushr(0xf0fa37d7763e0ca1l, 45);
  30.371 -    }
  30.372 -    
  30.373 -    @Compare public long uShiftR7() {
  30.374 -        return ushr(0xf0fa37d7763e0ca1l, 0);
  30.375 -    }
  30.376 -    
  30.377 -    @Compare public long uShiftR8() {
  30.378 -        return ushr(0xf0fa37d7763e0ca1l, 70);
  30.379 -    }
  30.380 -
  30.381 -    @Compare public long and1() {
  30.382 -        return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  30.383 -    }
  30.384 -
  30.385 -    @Compare public long or1() {
  30.386 -        return or(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  30.387 -    }
  30.388 -
  30.389 -    @Compare public long xor1() {
  30.390 -        return xor(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  30.391 -    }
  30.392 -
  30.393 -    @Compare public long xor2() {
  30.394 -        return xor(0x00fa37d7763e0ca1l, 0x00000000ff00123el);
  30.395 -    }
  30.396 -
  30.397 -    @Compare public long xor3() {
  30.398 -        return xor(0x00000000763e0ca1l, 0x00000000ff00123el);
  30.399 -    }
  30.400 -
  30.401 -    @Compare public int compareSameNumbers() {
  30.402 -        return compare(0x0000000000000000l, 0x0000000000000000l, 0);
  30.403 -    }
  30.404 -
  30.405 -    @Compare public int comparePositiveNumbers() {
  30.406 -        return compare(0x0000000000200000l, 0x0000000010000000l, 0);
  30.407 -    }
  30.408 -
  30.409 -    @Compare public int compareNegativeNumbers() {
  30.410 -        return compare(0xffffffffffffffffl, 0xffffffff00000000l, 0);
  30.411 -    }
  30.412 -
  30.413 -    @Compare public int compareMixedNumbers() {
  30.414 -        return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
  30.415 -    }
  30.416 -    
  30.417 -    @Factory
  30.418 -    public static Object[] create() {
  30.419 -        return VMTest.create(LongArithmeticTest.class);
  30.420 -    }
  30.421 -}
    31.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java	Sun Nov 09 10:36:08 2014 +0100
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,63 +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.BrwsrTest;
   31.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   31.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   31.26 -import org.testng.annotations.Factory;
   31.27 -
   31.28 -/**
   31.29 - *
   31.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   31.31 - */
   31.32 -public class NotifyWaitTest {
   31.33 -    
   31.34 -
   31.35 -    @Compare public synchronized String canCallNotify() throws Exception {
   31.36 -        notify();
   31.37 -        return "OK";
   31.38 -    }
   31.39 -
   31.40 -    @Compare public synchronized String canCallNotifyAll() throws Exception {
   31.41 -        notifyAll();
   31.42 -        return "OK";
   31.43 -    }
   31.44 -    
   31.45 -    @BrwsrTest public synchronized String throwsInterruptedException() {
   31.46 -        try {
   31.47 -            wait();
   31.48 -            throw new IllegalStateException();
   31.49 -        } catch (InterruptedException ex) {
   31.50 -            return "OK";
   31.51 -        }
   31.52 -    }
   31.53 -
   31.54 -    @BrwsrTest public synchronized String waitMsThrowsInterruptedException() {
   31.55 -        try {
   31.56 -            wait(32);
   31.57 -            throw new IllegalStateException();
   31.58 -        } catch (InterruptedException ex) {
   31.59 -            return "OK";
   31.60 -        }
   31.61 -    }
   31.62 -    
   31.63 -    @Factory public static Object[] create() {
   31.64 -        return VMTest.create(NotifyWaitTest.class);
   31.65 -    }
   31.66 -}
    32.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ProxyTest.java	Sun Nov 09 10:36:08 2014 +0100
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,71 +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 java.lang.reflect.InvocationHandler;
   32.24 -import java.lang.reflect.Method;
   32.25 -import java.lang.reflect.Proxy;
   32.26 -import org.apidesign.bck2brwsr.vmtest.Compare;
   32.27 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   32.28 -import org.testng.annotations.Factory;
   32.29 -
   32.30 -/**
   32.31 - *
   32.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   32.33 - */
   32.34 -public class ProxyTest {
   32.35 -    @Compare public String generateAnnotation() throws Exception {
   32.36 -        class InvHandler implements InvocationHandler {
   32.37 -            @Override
   32.38 -            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   32.39 -                return "Joe Hacker";
   32.40 -            }
   32.41 -        }
   32.42 -        Anno anno = (Anno) Proxy.newProxyInstance(
   32.43 -            Anno.class.getClassLoader(), 
   32.44 -            new Class[] { Anno.class }, 
   32.45 -            new InvHandler()
   32.46 -        );
   32.47 -        return anno.name();
   32.48 -    }
   32.49 -
   32.50 -    @Compare public int getPrimitiveType() throws Exception {
   32.51 -        class InvHandler implements InvocationHandler {
   32.52 -            @Override
   32.53 -            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   32.54 -                return 40;
   32.55 -            }
   32.56 -        }
   32.57 -        Anno anno = (Anno) Proxy.newProxyInstance(
   32.58 -            Anno.class.getClassLoader(), 
   32.59 -            new Class[] { Anno.class }, 
   32.60 -            new InvHandler()
   32.61 -        );
   32.62 -        return 2 + anno.age();
   32.63 -    }
   32.64 -    
   32.65 -    public static @interface Anno {
   32.66 -        public String name();
   32.67 -        public int age();
   32.68 -    }
   32.69 -    
   32.70 -    @Factory
   32.71 -    public static Object[] create() {
   32.72 -        return VMTest.create(ProxyTest.class);
   32.73 -    }
   32.74 -}
    33.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java	Sun Nov 09 10:36:08 2014 +0100
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,166 +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 java.lang.reflect.Array;
   33.24 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   33.25 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   33.26 -import org.apidesign.bck2brwsr.vmtest.Compare;
   33.27 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   33.28 -import org.testng.annotations.Factory;
   33.29 -
   33.30 -/**
   33.31 - *
   33.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   33.33 - */
   33.34 -public class ReflectionArrayTest {
   33.35 -    @Compare public int lengthOfStringArray() {
   33.36 -        String[] arr = (String[]) Array.newInstance(String.class, 10);
   33.37 -        return arr.length;
   33.38 -    }
   33.39 -    
   33.40 -    @Compare public String indexOutOfBounds() {
   33.41 -        String[] arr = { null, null };
   33.42 -        return arr[2];
   33.43 -    }
   33.44 -    
   33.45 -    @Compare public int reflectiveLengthOfStringArray() {
   33.46 -        Object arr = Array.newInstance(String.class, 10);
   33.47 -        return Array.getLength(arr);
   33.48 -    }
   33.49 -
   33.50 -    @Compare public int reflectiveLengthOneNonArray() {
   33.51 -        Object arr = "non-array";
   33.52 -        return Array.getLength(arr);
   33.53 -    }
   33.54 -
   33.55 -    @Compare public String compTypeOfStringArray() {
   33.56 -        String[] arr = (String[]) Array.newInstance(String.class, 10);
   33.57 -        return arr.getClass().getComponentType().getName();
   33.58 -    }
   33.59 -
   33.60 -    @Compare public Object negativeArrayExcp() {
   33.61 -        return Array.newInstance(String.class, -5);
   33.62 -    }
   33.63 -    
   33.64 -    @Compare public int lengthOfIntArray() {
   33.65 -        int[] arr = (int[]) Array.newInstance(Integer.TYPE, 10);
   33.66 -        return arr.length;
   33.67 -    }
   33.68 -
   33.69 -    @Compare public int reflectiveLengthOfIntArray() {
   33.70 -        Object arr = Array.newInstance(Integer.TYPE, 10);
   33.71 -        return Array.getLength(arr);
   33.72 -    }
   33.73 -
   33.74 -    @Compare public String compTypeOfIntArray() {
   33.75 -        int[] arr = (int[]) Array.newInstance(int.class, 10);
   33.76 -        return arr.getClass().getComponentType().getName();
   33.77 -    }
   33.78 -
   33.79 -    @Compare public Object intNegativeArrayExcp() {
   33.80 -        return Array.newInstance(int.class, -5);
   33.81 -    }
   33.82 -
   33.83 -    @Compare public Integer verifyAutobox() {
   33.84 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   33.85 -        return (Integer) Array.get(arr, 0);
   33.86 -    }
   33.87 -    @Compare public String verifyObjectArray() {
   33.88 -        String[] arr = (String[]) Array.newInstance(String.class, 5);
   33.89 -        Array.set(arr, 0, "Hello");
   33.90 -        return (String) Array.get(arr, 0);
   33.91 -    }
   33.92 -    @Compare public int verifyInt() {
   33.93 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   33.94 -        return Array.getInt(arr, 0);
   33.95 -    }
   33.96 -    @Compare public long verifyConvertToLong() {
   33.97 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
   33.98 -        return Array.getLong(arr, 0);
   33.99 -    }
  33.100 -
  33.101 -    @Compare public Object verifySetIntToObject() {
  33.102 -        try {
  33.103 -            Object[] arr = (Object[]) Array.newInstance(Object.class, 5);
  33.104 -            Array.setInt(arr, 0, 10);
  33.105 -            return Array.get(arr, 0);
  33.106 -        } catch (Exception exception) {
  33.107 -            return exception.getClass().getName();
  33.108 -        }
  33.109 -    }
  33.110 -    @Compare public long verifySetShort() {
  33.111 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  33.112 -        Array.setShort(arr, 0, (short)10);
  33.113 -        return Array.getLong(arr, 0);
  33.114 -    }
  33.115 -    @Compare public long verifyCantSetLong() {
  33.116 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  33.117 -        Array.setLong(arr, 0, 10);
  33.118 -        return Array.getLong(arr, 0);
  33.119 -    }
  33.120 -    @Compare public float verifyLongToFloat() {
  33.121 -        Object arr = Array.newInstance(float.class, 5);
  33.122 -        Array.setLong(arr, 0, 10);
  33.123 -        return Array.getFloat(arr, 0);
  33.124 -    }
  33.125 -
  33.126 -    @Compare public double verifyConvertToDouble() {
  33.127 -        int[] arr = (int[]) Array.newInstance(int.class, 5);
  33.128 -        return Array.getDouble(arr, 0);
  33.129 -    }
  33.130 -    
  33.131 -    @Compare public int multiIntArray() {
  33.132 -        int[][][] arr = (int[][][]) Array.newInstance(int.class, 3, 3, 3);
  33.133 -        return arr[0][1][2] + 5 + arr[2][2][0];
  33.134 -    }
  33.135 -
  33.136 -    @Compare public String multiIntArrayCompType() {
  33.137 -        return Array.newInstance(int.class, 3, 3, 3).getClass().getName();
  33.138 -    }
  33.139 -    
  33.140 -    @JavaScriptBody(args = {}, body = "return [1, 2];")
  33.141 -    private static native Object crtarr();
  33.142 -
  33.143 -    @JavaScriptBody(args = {}, body = "return new Object();")
  33.144 -    private static native Object newobj();
  33.145 -
  33.146 -    @BrwsrTest
  33.147 -    public static void toStringArray() {
  33.148 -        final Object arr = crtarr();
  33.149 -        final Object real = new Object[2];
  33.150 -        assert arr instanceof Object[] : "Any array is Java array: " + arr;
  33.151 -        assert arr.getClass() == real.getClass() : "Same classes " + arr + " and " + real.getClass();
  33.152 -        final String str = arr.toString();
  33.153 -        assert str != null;
  33.154 -        assert str.startsWith("[Ljava.lang.Object;@") : str;
  33.155 -    }
  33.156 -    
  33.157 -    @BrwsrTest
  33.158 -    public static void objectToString() {
  33.159 -        String s = newobj().toString();
  33.160 -        assert s != null : "Some string computed";
  33.161 -        assert s.startsWith("java.lang.Object@") : "Regular object toString(): " + s;
  33.162 -    }
  33.163 -
  33.164 -    
  33.165 -    @Factory
  33.166 -    public static Object[] create() {
  33.167 -        return VMTest.create(ReflectionArrayTest.class);
  33.168 -    }
  33.169 -}
    34.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Sun Nov 09 10:36:08 2014 +0100
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,315 +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 java.lang.annotation.Retention;
   34.24 -import java.lang.annotation.RetentionPolicy;
   34.25 -import java.lang.reflect.Constructor;
   34.26 -import java.lang.reflect.Method;
   34.27 -import java.lang.reflect.Proxy;
   34.28 -import java.util.Arrays;
   34.29 -import java.util.Collections;
   34.30 -import java.util.List;
   34.31 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   34.32 -import org.apidesign.bck2brwsr.vmtest.Compare;
   34.33 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   34.34 -import org.testng.annotations.Factory;
   34.35 -
   34.36 -/**
   34.37 - *
   34.38 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   34.39 - */
   34.40 -public class ReflectionTest {
   34.41 -    @Compare public boolean nonNullThis() {
   34.42 -        return this == null;
   34.43 -    }
   34.44 -    
   34.45 -    @Compare public String intType() {
   34.46 -        return Integer.TYPE.toString();
   34.47 -    }
   34.48 -
   34.49 -    @Compare public String voidType() throws Exception {
   34.50 -        return void.class.toString();
   34.51 -    }
   34.52 -
   34.53 -    @Compare public String longClass() {
   34.54 -        return long.class.toString();
   34.55 -    }
   34.56 -    
   34.57 -    @Compare public boolean isRunnableInterface() {
   34.58 -        return Runnable.class.isInterface();
   34.59 -    }
   34.60 -
   34.61 -    @Compare public boolean isAssignableToPrimitiveType() {
   34.62 -        return boolean.class.isAssignableFrom(Runnable.class);
   34.63 -    }
   34.64 -
   34.65 -    @Compare public boolean isAssignableFromPrimitiveType() {
   34.66 -        return Runnable.class.isAssignableFrom(boolean.class);
   34.67 -    }
   34.68 -
   34.69 -    @Compare public boolean isAssignableLongFromInt() {
   34.70 -        return long.class.isAssignableFrom(int.class);
   34.71 -    }
   34.72 -
   34.73 -    @Compare public boolean isAssignableIntFromLong() {
   34.74 -        return int.class.isAssignableFrom(long.class);
   34.75 -    }
   34.76 -
   34.77 -    @Compare public String isRunnableHasRunMethod() throws NoSuchMethodException {
   34.78 -        return Runnable.class.getMethod("run").getName();
   34.79 -    }
   34.80 -
   34.81 -    @Compare public String isRunnableDeclaresRunMethod() throws NoSuchMethodException {
   34.82 -        return Runnable.class.getDeclaredMethod("run").getName();
   34.83 -    }
   34.84 -    
   34.85 -    @Compare public String intValue() throws Exception {
   34.86 -        return Integer.class.getConstructor(int.class).newInstance(10).toString();
   34.87 -    }
   34.88 -    
   34.89 -    @Compare public String getMethodWithArray() throws Exception {
   34.90 -        return Proxy.class.getMethod("getProxyClass", ClassLoader.class, Class[].class).getName();
   34.91 -    }
   34.92 -    
   34.93 -    @Compare public String namesOfMethods() {
   34.94 -        StringBuilder sb = new StringBuilder();
   34.95 -        String[] arr = new String[20];
   34.96 -        int i = 0;
   34.97 -        for (Method m : StaticUse.class.getMethods()) {
   34.98 -            arr[i++] = m.getName();
   34.99 -        }
  34.100 -        for (String s : sort(arr, i)) {
  34.101 -            sb.append(s).append("\n");
  34.102 -        }
  34.103 -        return sb.toString();
  34.104 -    }
  34.105 -
  34.106 -    @Compare public String paramsOfConstructors() {
  34.107 -        StringBuilder sb = new StringBuilder();
  34.108 -        String[] arr = new String[20];
  34.109 -        int i = 0;
  34.110 -        for (Constructor<?> m : StaticUse.class.getConstructors()) {
  34.111 -            arr[i++] = m.getName();
  34.112 -        }
  34.113 -        for (String s : sort(arr, i)) {
  34.114 -            sb.append(s).append("\n");
  34.115 -        }
  34.116 -        return sb.toString();
  34.117 -    }
  34.118 -
  34.119 -    @Compare public String namesOfDeclaringClassesOfMethods() {
  34.120 -        StringBuilder sb = new StringBuilder();
  34.121 -        String[] arr = new String[20];
  34.122 -        int i = 0;
  34.123 -        for (Method m : StaticUse.class.getMethods()) {
  34.124 -            arr[i++] = m.getName() + "@" + m.getDeclaringClass().getName();
  34.125 -        }
  34.126 -        for (String s : sort(arr, i)) {
  34.127 -            sb.append(s).append("\n");
  34.128 -        }
  34.129 -        return sb.toString();
  34.130 -    }
  34.131 -    
  34.132 -    @Compare public String cannotCallNonStaticMethodWithNull() throws Exception {
  34.133 -        StaticUse.class.getMethod("instanceMethod").invoke(null);
  34.134 -        return "should not happen";
  34.135 -    }
  34.136 -    
  34.137 -    @Compare public String classCastException() {
  34.138 -        try {
  34.139 -            Integer i = (Integer)StaticUseSub.getNonNull();
  34.140 -            return "" + i.intValue();
  34.141 -        } catch (ClassCastException ex) {
  34.142 -            return ex.getClass().getName();
  34.143 -        }
  34.144 -    }
  34.145 -
  34.146 -    @Compare public String methodThatThrowsException() throws Exception {
  34.147 -        StaticUse.class.getMethod("instanceMethod").invoke(new StaticUse());
  34.148 -        return "should not happen";
  34.149 -    }
  34.150 -
  34.151 -    @Compare public Object voidReturnType() throws Exception {
  34.152 -        return StaticUse.class.getMethod("instanceMethod").getReturnType();
  34.153 -    }
  34.154 -    
  34.155 -    @Retention(RetentionPolicy.RUNTIME)
  34.156 -    @interface Ann {
  34.157 -    }
  34.158 -    
  34.159 -    @Compare public String annoClass() throws Exception {
  34.160 -        Retention r = Ann.class.getAnnotation(Retention.class);
  34.161 -        assert r != null : "Annotation is present";
  34.162 -        assert r.value() == RetentionPolicy.RUNTIME : "Policy value is OK: " + r.value();
  34.163 -        return r.annotationType().getName();
  34.164 -    }
  34.165 -    
  34.166 -    @Compare public boolean isAnnotation() {
  34.167 -        return Ann.class.isAnnotation();
  34.168 -    }
  34.169 -    @Compare public boolean isNotAnnotation() {
  34.170 -        return String.class.isAnnotation();
  34.171 -    }
  34.172 -    @Compare public boolean isNotAnnotationEnum() {
  34.173 -        return E.class.isAnnotation();
  34.174 -    }
  34.175 -    enum E { A, B };
  34.176 -    @Compare public boolean isEnum() {
  34.177 -        return E.A.getClass().isEnum();
  34.178 -    }
  34.179 -
  34.180 -    @Compare public boolean isNotEnum() {
  34.181 -        return "".getClass().isEnum();
  34.182 -    }
  34.183 -    
  34.184 -    @Compare public String newInstanceFails() {
  34.185 -        try {
  34.186 -            return "success: " + StaticUseSub.class.newInstance();
  34.187 -        } catch (IllegalAccessException ex) {
  34.188 -            return "failure";
  34.189 -        } catch (InstantiationException ex) {
  34.190 -            return "failure";
  34.191 -        }
  34.192 -    }
  34.193 -    
  34.194 -    @Compare public String paramTypes() throws Exception {
  34.195 -        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  34.196 -        final Class[] pt = plus.getParameterTypes();
  34.197 -        return pt[0].getName();
  34.198 -    }
  34.199 -    @Compare public String paramTypesNotFound() throws Exception {
  34.200 -        return StaticUse.class.getMethod("plus", int.class, double.class).toString();
  34.201 -    }
  34.202 -    @Compare public int methodWithArgs() throws Exception {
  34.203 -        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  34.204 -        return (Integer)plus.invoke(null, 2, 3);
  34.205 -    }
  34.206 -    
  34.207 -    @Compare public String classGetNameForByte() {
  34.208 -         return byte.class.getName();
  34.209 -    }
  34.210 -    @Compare public String classGetNameForBaseObject() {
  34.211 -        return newObject().getClass().getName();
  34.212 -    }
  34.213 -    @Compare public String classGetNameForJavaObject() {
  34.214 -        return new Object().getClass().getName();
  34.215 -    }
  34.216 -    @Compare public String classGetNameForObjectArray() {
  34.217 -        return (new Object[3]).getClass().getName();
  34.218 -    }
  34.219 -    @Compare public String classGetNameForSimpleIntArray() {
  34.220 -        return (new int[3]).getClass().getName();
  34.221 -    }
  34.222 -    @Compare public boolean sameClassGetNameForSimpleCharArray() {
  34.223 -        return (new char[3]).getClass() == (new char[34]).getClass();
  34.224 -    }
  34.225 -    @Compare public String classGetNameForMultiIntArray() {
  34.226 -        return (new int[3][4][5][6][7][8][9]).getClass().getName();
  34.227 -    }
  34.228 -    @Compare public String classGetNameForMultiIntArrayInner() {
  34.229 -        final int[][][][][][][] arr = new int[3][4][5][6][7][8][9];
  34.230 -        int[][][][][][] subarr = arr[0];
  34.231 -        int[][][][][] subsubarr = subarr[0];
  34.232 -        return subsubarr.getClass().getName();
  34.233 -    }
  34.234 -    @Compare public String classGetNameForMultiStringArray() {
  34.235 -        return (new String[3][4][5][6][7][8][9]).getClass().getName();
  34.236 -    }
  34.237 -    
  34.238 -    @Compare public String classForByte() throws Exception {
  34.239 -        return Class.forName("[Z").getName();
  34.240 -    }
  34.241 -
  34.242 -    @Compare public String classForUnknownArray() {
  34.243 -        try {
  34.244 -            return Class.forName("[W").getName();
  34.245 -        } catch (Exception ex) {
  34.246 -            return ex.getClass().getName();
  34.247 -        }
  34.248 -    }
  34.249 -    
  34.250 -    @Compare public String classForUnknownDeepArray() {
  34.251 -        try {
  34.252 -            return Class.forName("[[[[[W").getName();
  34.253 -        } catch (Exception ex) {
  34.254 -            return ex.getClass().getName();
  34.255 -        }
  34.256 -    }
  34.257 -    
  34.258 -    @Compare public int callAbst() throws Exception {
  34.259 -        class Impl extends Abst {
  34.260 -            @Override
  34.261 -            public int abst() {
  34.262 -                return 10;
  34.263 -            }
  34.264 -        }
  34.265 -        Abst impl = new Impl();
  34.266 -        return (int) Abst.class.getMethod("abst").invoke(impl);
  34.267 -    }
  34.268 -    
  34.269 -    @Compare public String componentGetNameForObjectArray() {
  34.270 -        return (new Object[3]).getClass().getComponentType().getName();
  34.271 -    }
  34.272 -    @Compare public boolean sameComponentGetNameForObjectArray() {
  34.273 -        return (new Object[3]).getClass().getComponentType() == Object.class;
  34.274 -    }
  34.275 -    @Compare public String componentGetNameForSimpleIntArray() {
  34.276 -        return (new int[3]).getClass().getComponentType().getName();
  34.277 -    }
  34.278 -    @Compare public String componentGetNameForMultiIntArray() {
  34.279 -        return (new int[3][4][5][6][7][8][9]).getClass().getComponentType().getName();
  34.280 -    }
  34.281 -    @Compare public String componentGetNameForMultiStringArray() {
  34.282 -        Class<?> c = (new String[3][4][5][6][7][8][9]).getClass();
  34.283 -        StringBuilder sb = new StringBuilder();
  34.284 -        for (;;) {
  34.285 -            sb.append(c.getName()).append("\n");
  34.286 -            c = c.getComponentType();
  34.287 -            if (c == null) {
  34.288 -                break;
  34.289 -            }
  34.290 -        }
  34.291 -        return sb.toString();
  34.292 -    }
  34.293 -    
  34.294 -    @Compare public boolean isArray() {
  34.295 -        return new Object[0].getClass().isArray();
  34.296 -    }
  34.297 -    
  34.298 -    @JavaScriptBody(args = { "arr", "len" }, body="var a = arr.slice(0, len); a.sort(); return a;")
  34.299 -    private static String[] sort(String[] arr, int len) {
  34.300 -        List<String> list = Arrays.asList(arr).subList(0, len);
  34.301 -        Collections.sort(list);
  34.302 -        return list.toArray(new String[0]);
  34.303 -    }
  34.304 -    
  34.305 -    @JavaScriptBody(args = {}, body = "return new Object();")
  34.306 -    private static Object newObject() {
  34.307 -        return new Object();
  34.308 -    }
  34.309 -    
  34.310 -    @Factory
  34.311 -    public static Object[] create() {
  34.312 -        return VMTest.create(ReflectionTest.class);
  34.313 -    }
  34.314 -    
  34.315 -    public static abstract class Abst {
  34.316 -        public abstract int abst();
  34.317 -    }
  34.318 -}
    35.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpReplaceAllTest.java	Sun Nov 09 10:36:08 2014 +0100
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,54 +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 <jaroslav.tulach@apidesign.org>
   35.30 - */
   35.31 -public class RegExpReplaceAllTest {
   35.32 -
   35.33 -    @Compare public String replaceAll() {
   35.34 -        return "JavaScript".replaceAll("Script", "One");
   35.35 -    }
   35.36 -
   35.37 -    @Compare public String replaceAllTwice() {
   35.38 -        return "Script JavaScript!".replaceAll("Script", "One");
   35.39 -    }
   35.40 -
   35.41 -    
   35.42 -    @Compare public String replaceAllRegexp() {
   35.43 -        return "JavaScript".replaceAll("S....t", "One");
   35.44 -    }
   35.45 -
   35.46 -    @Compare public String replaceAllRegexpTwice() {
   35.47 -        return "Script JavaScript!".replaceAll("S....t", "One");
   35.48 -    }
   35.49 -
   35.50 -    @Compare public String replaceFirstRegexpOnly() {
   35.51 -        return "Script JavaScript!".replaceFirst("S....t", "One");
   35.52 -    }
   35.53 -    
   35.54 -    @Factory public static Object[] create() {
   35.55 -        return VMTest.create(RegExpReplaceAllTest.class);
   35.56 -    }
   35.57 -}
    36.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpSplitTest.java	Sun Nov 09 10:36:08 2014 +0100
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,54 +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 java.util.Arrays;
   36.24 -import org.apidesign.bck2brwsr.vmtest.Compare;
   36.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   36.26 -import org.testng.annotations.Factory;
   36.27 -
   36.28 -/**
   36.29 - *
   36.30 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
   36.31 - */
   36.32 -public class RegExpSplitTest {
   36.33 -
   36.34 -    public @Compare Object splitSpace() {
   36.35 -        return Arrays.asList("How are you today?".split(" "));
   36.36 -    }
   36.37 -
   36.38 -    public @Compare String splitNewline() {
   36.39 -        return Arrays.toString("initializer must be able to complete normally".split("\n"));
   36.40 -    }
   36.41 -
   36.42 -    public @Compare Object splitSpaceTrimMinusOne() {
   36.43 -        return Arrays.asList(" How are you today? ".split(" ", -1));
   36.44 -    }
   36.45 -
   36.46 -    public @Compare Object splitSpaceTrimZero() {
   36.47 -        return Arrays.asList(" How are you today? ".split(" ", 0));
   36.48 -    }
   36.49 -
   36.50 -    public @Compare Object splitSpaceLimit2() {
   36.51 -        return Arrays.asList("How are you today?".split(" ", 2));
   36.52 -    }
   36.53 -    
   36.54 -    @Factory public static Object[] create() {
   36.55 -        return VMTest.create(RegExpSplitTest.class);
   36.56 -    }
   36.57 -}
    37.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourceBundleTest.java	Sun Nov 09 10:36:08 2014 +0100
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,45 +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 java.net.URL;
   37.24 -import java.util.ResourceBundle;
   37.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
   37.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   37.27 -import org.testng.annotations.Factory;
   37.28 -
   37.29 -/**
   37.30 - *
   37.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   37.32 - */
   37.33 -public class ResourceBundleTest {
   37.34 -    
   37.35 -    @Compare public String readFromBundle() throws Exception {
   37.36 -        ResourceBundle b = ResourceBundle.getBundle("org/apidesign/bck2brwsr/tck/Bundle");
   37.37 -        return b.getString("KEY");
   37.38 -    }
   37.39 -    
   37.40 -    @Compare public String toURIFromURL() throws Exception {
   37.41 -        URL u = new URL("http://apidesign.org");
   37.42 -        return u.toURI().toString();
   37.43 -    }
   37.44 -    
   37.45 -    @Factory public static Object[] create() {
   37.46 -        return VMTest.create(ResourceBundleTest.class);
   37.47 -    }
   37.48 -}
    38.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java	Sun Nov 09 10:36:08 2014 +0100
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,190 +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.ByteArrayInputStream;
   38.24 -import java.io.Closeable;
   38.25 -import java.io.IOException;
   38.26 -import java.io.InputStream;
   38.27 -import java.net.URL;
   38.28 -import java.net.URLConnection;
   38.29 -import java.util.Enumeration;
   38.30 -import net.java.html.js.JavaScriptBody;
   38.31 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   38.32 -import org.apidesign.bck2brwsr.vmtest.Compare;
   38.33 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   38.34 -import org.testng.annotations.Factory;
   38.35 -
   38.36 -/**
   38.37 - *
   38.38 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   38.39 - */
   38.40 -public class ResourcesTest {
   38.41 -    @Compare public String allManifests() throws Exception {
   38.42 -        Enumeration<URL> en = ClassLoader.getSystemResources("META-INF/MANIFEST.MF");
   38.43 -        assert en.hasMoreElements() : "Should have at least one manifest";
   38.44 -        String first = readString(en.nextElement().openStream());
   38.45 -        boolean different = false;
   38.46 -        int cnt = 1;
   38.47 -        while (en.hasMoreElements()) {
   38.48 -            URL url = en.nextElement();
   38.49 -            String now = readString(url.openStream());
   38.50 -            if (!first.equals(now)) {
   38.51 -                different = true;
   38.52 -            }
   38.53 -            cnt++;
   38.54 -            if (cnt > 500) {
   38.55 -                throw new IllegalStateException(
   38.56 -                    "Giving up. First manifest:\n" + first + 
   38.57 -                    "\nLast manifest:\n" + now
   38.58 -                );
   38.59 -            }
   38.60 -        }
   38.61 -        assert different : "Not all manifests should look like first one:\n" + first;
   38.62 -        if (cnt > 40 && cnt < 50) {
   38.63 -            return "OK";
   38.64 -        } else {
   38.65 -            return "" + cnt;
   38.66 -        }
   38.67 -    }
   38.68 -    
   38.69 -    @Compare public String readResourceAsStream() throws Exception {
   38.70 -        InputStream is = getClass().getResourceAsStream("Resources.txt");
   38.71 -        return readString(is);
   38.72 -    }
   38.73 -    
   38.74 -    @Compare public String readResourceViaXMLHttpRequest() throws Exception {
   38.75 -        return readResourceViaXHR("Resources.txt", null);
   38.76 -    }
   38.77 -    
   38.78 -    @BrwsrTest public void xhrTestedInBrowser() throws Exception {
   38.79 -        boolean[] run = { false };
   38.80 -        readResourceViaXHR("Resources.txt", run);
   38.81 -        assert run[0] : "XHR really used in browser";
   38.82 -    }
   38.83 -
   38.84 -    @Compare public String readBinaryResourceViaXMLHttpRequest() throws Exception {
   38.85 -        return readResourceViaXHR("0xfe", null);
   38.86 -    }
   38.87 -
   38.88 -    private String readResourceViaXHR(final String res, boolean[] exec) throws IOException {
   38.89 -        URL url = getClass().getResource(res);
   38.90 -        URLConnection conn = url.openConnection();
   38.91 -        String java = readBytes(url.openStream());
   38.92 -        String java2 = readBytes(conn.getInputStream());
   38.93 -        assert java.equals(java2) : "Java:\n" + java + "\nConn:\n" + java2;
   38.94 -        
   38.95 -        URL url2 = conn.getURL();
   38.96 -        String java3 = readBytes(url.openStream());
   38.97 -        assert java.equals(java3) : "Java:\n" + java + "\nConnURL:\n" + java3;
   38.98 -        
   38.99 -        
  38.100 -        byte[] xhr = readXHR(url2.toExternalForm());
  38.101 -        if (xhr != null) {
  38.102 -            if (exec != null) {
  38.103 -                exec[0] = true;
  38.104 -            }
  38.105 -            String s = readBytes(new ByteArrayInputStream(xhr));
  38.106 -            assert java.equals(s) : "Java:\n" + java + "\nXHR:\n" + s;
  38.107 -            
  38.108 -            assert conn instanceof Closeable : "Can be closed";
  38.109 -            
  38.110 -            Closeable c = (Closeable) conn;
  38.111 -            c.close();
  38.112 -            
  38.113 -            byte[] xhr2 = null;
  38.114 -            try {
  38.115 -                xhr2 = readXHR(url2.toExternalForm());
  38.116 -            } catch (Throwable t) {
  38.117 -                // OK, expecting error
  38.118 -            }
  38.119 -            assert xhr2 == null : "Cannot read the URL anymore";
  38.120 -        }
  38.121 -        return java;
  38.122 -    }
  38.123 -
  38.124 -    @JavaScriptBody(args = { "url" }, body =
  38.125 -        "if (typeof XMLHttpRequest === 'undefined') return null;\n" +
  38.126 -        "var xhr = new XMLHttpRequest();\n" +
  38.127 -        "xhr.overrideMimeType('text\\/plain; charset=x-user-defined');\n" +
  38.128 -        "xhr.open('GET', url, false);\n" +
  38.129 -        "xhr.send();\n" +
  38.130 -        "if (xhr.status >= 300) throw 'Status: ' + xhr.status + ' ' + xhr.statusText;\n" +
  38.131 -        "var ret = []\n" +
  38.132 -        "for (var i = 0; i < xhr.responseText.length; i++) {\n" +
  38.133 -        "  var b = xhr.responseText.charCodeAt(i) & 0xff;\n" +
  38.134 -        "  if (b > 127) b -= 256;\n" +
  38.135 -        "  ret.push(b);\n" +
  38.136 -        "}\n" +
  38.137 -        "return ret;\n"
  38.138 -    )
  38.139 -    private static byte[] readXHR(String url) {
  38.140 -        return null;
  38.141 -    }
  38.142 -    
  38.143 -    @Compare public String readResourceViaConnection() throws Exception {
  38.144 -        final URL url = getClass().getResource("Resources.txt");
  38.145 -        String str = url.toExternalForm();
  38.146 -        int idx = str.indexOf("org/apidesign/bck2brwsr/tck");
  38.147 -        assert idx >= 0 : "Package name found in the URL name: " + str;
  38.148 -        InputStream is = url.openConnection().getInputStream();
  38.149 -        return readString(is);
  38.150 -    }
  38.151 -
  38.152 -    private String readString(InputStream is) throws IOException {
  38.153 -        StringBuilder sb = new StringBuilder();
  38.154 -        byte[] b = new byte[512];
  38.155 -        for (;;) { 
  38.156 -            int len = is.read(b);
  38.157 -            if (len == -1) {
  38.158 -                return sb.toString();
  38.159 -            }
  38.160 -            for (int i = 0; i < len; i++) {
  38.161 -                sb.append((char)b[i]);
  38.162 -            }
  38.163 -        }
  38.164 -    }
  38.165 -
  38.166 -    private String readBytes(InputStream is) throws IOException {
  38.167 -        StringBuilder sb = new StringBuilder();
  38.168 -        byte[] b = new byte[512];
  38.169 -        for (;;) { 
  38.170 -            int len = is.read(b);
  38.171 -            if (len == -1) {
  38.172 -                return sb.toString();
  38.173 -            }
  38.174 -            for (int i = 0; i < len; i++) {
  38.175 -                sb.append((int)b[i]).append(" ");
  38.176 -            }
  38.177 -        }
  38.178 -    }
  38.179 -
  38.180 -    @Compare public String readResourceAsStreamFromClassLoader() throws Exception {
  38.181 -        InputStream is = getClass().getClassLoader().getResourceAsStream("org/apidesign/bck2brwsr/tck/Resources.txt");
  38.182 -        return readString(is);
  38.183 -    }
  38.184 -    
  38.185 -    @Compare public String toURIFromURL() throws Exception {
  38.186 -        URL u = new URL("http://apidesign.org");
  38.187 -        return u.toURI().toString();
  38.188 -    }
  38.189 -    
  38.190 -    @Factory public static Object[] create() {
  38.191 -        return VMTest.create(ResourcesTest.class);
  38.192 -    }
  38.193 -}
    39.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ShortArithmeticTest.java	Sun Nov 09 10:36:08 2014 +0100
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,102 +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 ShortArithmeticTest {
   39.32 -    
   39.33 -    private static short add(short x, short y) {
   39.34 -        return (short)(x + y);
   39.35 -    }
   39.36 -    
   39.37 -    private static short sub(short x, short y) {
   39.38 -        return (short)(x - y);
   39.39 -    }
   39.40 -    
   39.41 -    private static short mul(short x, short y) {
   39.42 -        return (short)(x * y);
   39.43 -    }
   39.44 -    
   39.45 -    private static short div(short x, short y) {
   39.46 -        return (short)(x / y);
   39.47 -    }
   39.48 -    
   39.49 -    private static short mod(short x, short y) {
   39.50 -        return (short)(x % y);
   39.51 -    }
   39.52 -    
   39.53 -    @Compare public short conversion() {
   39.54 -        return (short)123456;
   39.55 -    }
   39.56 -    
   39.57 -    @Compare public short addOverflow() {
   39.58 -        return add(Short.MAX_VALUE, (short)1);
   39.59 -    }
   39.60 -    
   39.61 -    @Compare public short subUnderflow() {
   39.62 -        return sub(Short.MIN_VALUE, (short)1);
   39.63 -    }
   39.64 -    
   39.65 -    @Compare public short addMaxShortAndMaxShort() {
   39.66 -        return add(Short.MAX_VALUE, Short.MAX_VALUE);
   39.67 -    }
   39.68 -    
   39.69 -    @Compare public short subMinShortAndMinShort() {
   39.70 -        return sub(Short.MIN_VALUE, Short.MIN_VALUE);
   39.71 -    }
   39.72 -    
   39.73 -    @Compare public short multiplyMaxShort() {
   39.74 -        return mul(Short.MAX_VALUE, (short)2);
   39.75 -    }
   39.76 -    
   39.77 -    @Compare public short multiplyMaxShortAndMaxShort() {
   39.78 -        return mul(Short.MAX_VALUE, Short.MAX_VALUE);
   39.79 -    }
   39.80 -    
   39.81 -    @Compare public short multiplyMinShort() {
   39.82 -        return mul(Short.MIN_VALUE, (short)2);
   39.83 -    }
   39.84 -    
   39.85 -    @Compare public short multiplyMinShortAndMinShort() {
   39.86 -        return mul(Short.MIN_VALUE, Short.MIN_VALUE);
   39.87 -    }
   39.88 -    
   39.89 -    @Compare public short multiplyPrecision() {
   39.90 -        return mul((short)17638, (short)1103);
   39.91 -    }
   39.92 -    
   39.93 -    @Compare public short division() {
   39.94 -        return div((short)1, (short)2);
   39.95 -    }
   39.96 -    
   39.97 -    @Compare public short divisionReminder() {
   39.98 -        return mod((short)1, (short)2);
   39.99 -    }
  39.100 -    
  39.101 -    @Factory
  39.102 -    public static Object[] create() {
  39.103 -        return VMTest.create(ShortArithmeticTest.class);
  39.104 -    }
  39.105 -}
    40.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java	Sun Nov 09 10:36:08 2014 +0100
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,39 +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 -class StaticUse {
   40.24 -    public static final Object NON_NULL = new Object();
   40.25 -    public static int cnt;
   40.26 -    static {
   40.27 -        if (cnt++ != 0) {
   40.28 -            throw new IllegalStateException("Multiple initialization of a <cinit>");
   40.29 -        }
   40.30 -    }
   40.31 -    
   40.32 -    StaticUse() {
   40.33 -    }
   40.34 -    
   40.35 -    public void instanceMethod() {
   40.36 -        throw new IllegalStateException();
   40.37 -    }
   40.38 -
   40.39 -    public static int plus(int a, int b) {
   40.40 -        return a + b;
   40.41 -    }
   40.42 -}
    41.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSub.java	Sun Nov 09 10:36:08 2014 +0100
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,30 +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 -public class StaticUseSub extends StaticUse {
   41.24 -    private StaticUseSub() {
   41.25 -    }
   41.26 -    
   41.27 -    public static Object getNonNull() {
   41.28 -        return NON_NULL;
   41.29 -    }
   41.30 -    static Object getNull() {
   41.31 -        return null;
   41.32 -    }
   41.33 -}
    42.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/StaticUseSubTest.java	Sun Nov 09 10:36:08 2014 +0100
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,45 +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 -import org.apidesign.bck2brwsr.vmtest.Compare;
   42.24 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   42.25 -import org.testng.annotations.Factory;
   42.26 -
   42.27 -/**
   42.28 - *
   42.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   42.30 - */
   42.31 -public class StaticUseSubTest {
   42.32 -    @Compare public String staticFieldInitializationInSuperClass() throws Exception {
   42.33 -        Object ret = StaticUseSub.getNonNull();
   42.34 -        return ret.getClass().getName();
   42.35 -    }
   42.36 -    
   42.37 -    @Compare public String isNullPointerTheSame() throws Exception {
   42.38 -        try {
   42.39 -            return StaticUseSub.getNull().getClass().toString();
   42.40 -        } catch (NullPointerException ex) {
   42.41 -            return ex.getClass().getName();
   42.42 -        }
   42.43 -    }
   42.44 -
   42.45 -    @Factory public static Object[] create() {
   42.46 -        return VMTest.create(StaticUseSubTest.class);
   42.47 -    }
   42.48 -}
    43.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/SystemTest.java	Sun Nov 09 10:36:08 2014 +0100
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,65 +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 java.io.ByteArrayOutputStream;
   43.24 -import java.io.PrintStream;
   43.25 -import org.apidesign.bck2brwsr.core.ExtraJavaScript;
   43.26 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   43.27 -import org.apidesign.bck2brwsr.vmtest.Compare;
   43.28 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   43.29 -import org.testng.annotations.Factory;
   43.30 -
   43.31 -/**
   43.32 - *
   43.33 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   43.34 - */
   43.35 -@ExtraJavaScript(resource = "/org/apidesign/bck2brwsr/tck/console.js")
   43.36 -public class SystemTest {
   43.37 -    @Compare public boolean nonNullOSName() {
   43.38 -        return System.getProperty("os.name") != null;
   43.39 -    }
   43.40 -
   43.41 -    @Compare public String captureStdOut() throws Exception {
   43.42 -        Object capture = initCapture();
   43.43 -        System.out.println("Ahoj");
   43.44 -        return textCapture(capture);
   43.45 -    }
   43.46 -    
   43.47 -    @JavaScriptBody(args = {}, body = ""
   43.48 -        + "var lines = [];"
   43.49 -        + "console.log = function(l) { lines.push(l); };"
   43.50 -        + "return lines;")
   43.51 -    Object initCapture() {
   43.52 -        ByteArrayOutputStream os = new ByteArrayOutputStream();
   43.53 -        PrintStream ps = new PrintStream(os);
   43.54 -        
   43.55 -        System.setOut(ps);
   43.56 -        return os;
   43.57 -    }
   43.58 -    
   43.59 -    @JavaScriptBody(args = { "o" }, body = "return o.join('');")
   43.60 -    String textCapture(Object o) throws java.io.IOException {
   43.61 -        ByteArrayOutputStream b = (ByteArrayOutputStream) o;
   43.62 -        return new String(b.toByteArray(), "UTF-8");
   43.63 -    }
   43.64 -    
   43.65 -    @Factory public static Object[] create() {
   43.66 -        return VMTest.create(SystemTest.class);
   43.67 -    }
   43.68 -}
    44.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/TimerTest.java	Sun Nov 09 10:36:08 2014 +0100
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,81 +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 java.util.Timer;
   44.24 -import java.util.TimerTask;
   44.25 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   44.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   44.27 -import org.testng.annotations.Factory;
   44.28 -
   44.29 -/**
   44.30 - *
   44.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   44.32 - */
   44.33 -public class TimerTest {
   44.34 -    int miss;
   44.35 -    int exec;
   44.36 -    
   44.37 -    public TimerTest() {
   44.38 -    }
   44.39 -    
   44.40 -    @BrwsrTest public void scheduleTick() throws Exception {
   44.41 -        Timer t = new Timer("MyTest");
   44.42 -        class TT extends TimerTask {
   44.43 -            @Override
   44.44 -            public void run() {
   44.45 -                exec++;
   44.46 -            }
   44.47 -        }
   44.48 -        TT task = new TT();
   44.49 -        t.schedule(task, 15);
   44.50 -        
   44.51 -        if (exec == 0) {
   44.52 -            miss++;
   44.53 -            throw new InterruptedException();
   44.54 -        }
   44.55 -        
   44.56 -        assert exec == 1 : "One exec: " + exec;
   44.57 -        assert miss == 1 : "One miss: " + miss;
   44.58 -    }
   44.59 -    
   44.60 -    @BrwsrTest public void repeatedTicks() throws Exception {
   44.61 -        Timer t = new Timer("MyTest");
   44.62 -        class TT extends TimerTask {
   44.63 -            @Override
   44.64 -            public void run() {
   44.65 -                exec++;
   44.66 -            }
   44.67 -        }
   44.68 -        TT task = new TT();
   44.69 -        t.scheduleAtFixedRate(task, 15, 10);
   44.70 -        
   44.71 -        if (exec != 2) {
   44.72 -            miss++;
   44.73 -            throw new InterruptedException();
   44.74 -        }
   44.75 -        
   44.76 -        assert exec == 2 : "Two execs: " + exec;
   44.77 -        assert miss == 2 : "Two misses: " + miss;
   44.78 -    }
   44.79 -    
   44.80 -    @Factory public static Object[] create() {
   44.81 -        return VMTest.create(TimerTest.class);
   44.82 -    }
   44.83 -    
   44.84 -}
    45.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CallMeTwiceTest.java	Sun Nov 09 10:36:08 2014 +0100
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,43 +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.vmtest.impl;
   45.22 -
   45.23 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   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 CallMeTwiceTest {
   45.32 -    int cnt;
   45.33 -    
   45.34 -    @BrwsrTest public void callMeTwice() throws InterruptedException {
   45.35 -        if (cnt++ == 0) {
   45.36 -            throw new InterruptedException();
   45.37 -        }
   45.38 -        int prevCnt = cnt;
   45.39 -        cnt = 0;
   45.40 -        assert prevCnt == 2 : "We need to receive two calls " + prevCnt;
   45.41 -    }
   45.42 -    
   45.43 -    @Factory public static Object[] create() {
   45.44 -        return VMTest.create(CallMeTwiceTest.class);
   45.45 -    }
   45.46 -}
    46.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotations.java	Sun Nov 09 10:36:08 2014 +0100
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,89 +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.vmtest.impl;
   46.22 -
   46.23 -import net.java.html.js.JavaScriptBody;
   46.24 -import net.java.html.js.JavaScriptResource;
   46.25 -
   46.26 -/**
   46.27 - *
   46.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   46.29 - */
   46.30 -@JavaScriptResource("htmlannotations.js")
   46.31 -public class HtmlAnnotations {
   46.32 -    private Object callback;
   46.33 -    
   46.34 -    
   46.35 -    @JavaScriptBody(args = {}, body = "return 42;")
   46.36 -    public static int fourtyTwo() {
   46.37 -        return -1;
   46.38 -    }
   46.39 -    
   46.40 -    @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
   46.41 -    public static native int useExternalMul(int x, int y);
   46.42 -    
   46.43 -    public static int callback() {
   46.44 -        final int[] arr = { 0 };
   46.45 -        callback(new Runnable() {
   46.46 -            @Override
   46.47 -            public void run() {
   46.48 -                arr[0]++;
   46.49 -            }
   46.50 -        });
   46.51 -        return arr[0];
   46.52 -    }
   46.53 -    
   46.54 -    @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
   46.55 -    private static native void callback(Runnable r);
   46.56 -
   46.57 -    @JavaScriptBody(args = {  }, javacall = true, body = "return @org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::callback()();")
   46.58 -    public static native int staticCallback();
   46.59 -
   46.60 -    @JavaScriptBody(args = {  }, wait4js = false, body = "/* do nothing */")
   46.61 -    public static native void empty();
   46.62 -    
   46.63 -    
   46.64 -    protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
   46.65 -        long l = 0;
   46.66 -        if (takeFirst) l += first;
   46.67 -        if (takeSecond) l += second;
   46.68 -        return l;
   46.69 -    }
   46.70 -    
   46.71 -    protected void onError(Object obj) throws Exception {
   46.72 -        callback = obj;
   46.73 -    }
   46.74 -    
   46.75 -    Object getError() {
   46.76 -        return callback;
   46.77 -    }
   46.78 -    
   46.79 -    public static Object create() {
   46.80 -        return new HtmlAnnotations();
   46.81 -    }
   46.82 -    @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body = 
   46.83 -        "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
   46.84 -    )
   46.85 -    public static native long first(Object impl, long a, long b);
   46.86 -    
   46.87 -    @JavaScriptBody(args = { "impl", "d" }, javacall = true, body = 
   46.88 -        "impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
   46.89 -        "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::getError()();"
   46.90 -    )
   46.91 -    public static native Double onError(Object impl, Double d);
   46.92 -}
    47.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java	Sun Nov 09 10:36:08 2014 +0100
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,90 +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.vmtest.impl;
   47.22 -
   47.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
   47.24 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   47.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
   47.26 -import org.testng.annotations.Factory;
   47.27 -
   47.28 -/** Verify cooperation with net.java.html.js annotations.
   47.29 - *
   47.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   47.31 - */
   47.32 -public class HtmlAnnotationsTest {
   47.33 -    static int firstCheck;
   47.34 -    
   47.35 -    private void assertMulNotDefinedForTheFirstTime() {
   47.36 -        if (firstCheck++ == 0) {
   47.37 -            Object mul = windowMul();
   47.38 -            assert mul == null : "htmlannotations.js should not be processed before first call to HtmlAnnotations class";
   47.39 -        }
   47.40 -    }
   47.41 -    
   47.42 -    @BrwsrTest public void fourtyTwo() throws Exception {
   47.43 -        assertMulNotDefinedForTheFirstTime();
   47.44 -        assertEquals(HtmlAnnotations.fourtyTwo(), 42);
   47.45 -    }
   47.46 -    
   47.47 -    @BrwsrTest public void externalMul() throws Exception {
   47.48 -        assertMulNotDefinedForTheFirstTime();
   47.49 -        assertEquals(HtmlAnnotations.useExternalMul(7, 6), 42);
   47.50 -    }
   47.51 -
   47.52 -    @BrwsrTest public void callRunnableFromJS() throws Exception {
   47.53 -        assertMulNotDefinedForTheFirstTime();
   47.54 -        assertEquals(HtmlAnnotations.callback(), 1);
   47.55 -    }
   47.56 -
   47.57 -    @BrwsrTest public void callStaticMethodFromJS() throws Exception {
   47.58 -        assertMulNotDefinedForTheFirstTime();
   47.59 -        assertEquals(HtmlAnnotations.staticCallback(), 1);
   47.60 -    }
   47.61 -
   47.62 -    @BrwsrTest public void callbackWithFourParamsAndReturnType() throws Exception {
   47.63 -        assertMulNotDefinedForTheFirstTime();
   47.64 -        Object instance = HtmlAnnotations.create();
   47.65 -        assertNotNull(instance, "Instance created");
   47.66 -        assertEquals(HtmlAnnotations.first(instance, 42, 31), 42);
   47.67 -    }
   47.68 -
   47.69 -    @BrwsrTest public void callbackWithObjectParamsAndReturnType() throws Exception {
   47.70 -        assertMulNotDefinedForTheFirstTime();
   47.71 -        Object instance = HtmlAnnotations.create();
   47.72 -        assertNotNull(instance, "Instance created");
   47.73 -        assertEquals(HtmlAnnotations.onError(instance, 42.0), 42.0);
   47.74 -    }
   47.75 -    
   47.76 -    private static void assertEquals(double real, double exp) {
   47.77 -        if (real - exp < 0.01) {
   47.78 -            return;
   47.79 -        }
   47.80 -        assert false : "Expecting " + exp + " but was " + real;
   47.81 -    }
   47.82 -
   47.83 -    private static void assertNotNull(Object obj, String msg) {
   47.84 -        assert obj != null : msg;
   47.85 -    }
   47.86 -    
   47.87 -    @JavaScriptBody(args = {}, body = "return window.mul ? window.mul : null;")
   47.88 -    private static native Object windowMul();
   47.89 -    
   47.90 -    @Factory public static Object[] create() {
   47.91 -        return VMTest.create(HtmlAnnotationsTest.class);
   47.92 -    }
   47.93 -}
    48.1 --- a/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/0xfe	Sun Nov 09 10:36:08 2014 +0100
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,1 +0,0 @@
    48.4 -
    48.5 \ No newline at end of file
    49.1 --- a/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Bundle.properties	Sun Nov 09 10:36:08 2014 +0100
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,2 +0,0 @@
    49.4 -KEY=Value
    49.5 -
    50.1 --- a/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/Resources.txt	Sun Nov 09 10:36:08 2014 +0100
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,1 +0,0 @@
    50.4 -Ahoj
    51.1 --- a/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/tck/console.js	Sun Nov 09 10:36:08 2014 +0100
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,22 +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 -
   51.22 -if (typeof console === 'undefined') {
   51.23 -    console = {};
   51.24 -}
   51.25 -
    52.1 --- a/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js	Sun Nov 09 10:36:08 2014 +0100
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,20 +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 -
   52.22 -function mul(x, y) { return x * y; }
   52.23 -window.mul = mul;
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/rt/emul/compacttest/pom.xml	Wed Nov 19 19:32:00 2014 +0100
    53.3 @@ -0,0 +1,73 @@
    53.4 +<?xml version="1.0"?>
    53.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    53.6 +    <modelVersion>4.0.0</modelVersion>
    53.7 +    <parent>
    53.8 +        <groupId>org.apidesign.bck2brwsr</groupId>
    53.9 +        <artifactId>emul.pom</artifactId>
   53.10 +        <version>1.0-SNAPSHOT</version>
   53.11 +    </parent>
   53.12 +    <groupId>org.apidesign.bck2brwsr</groupId>
   53.13 +    <artifactId>compacttest</artifactId>
   53.14 +    <version>1.0-SNAPSHOT</version>
   53.15 +    <name>Bck2Brwsr API Profile Tests</name>
   53.16 +    <url>http://maven.apache.org</url>
   53.17 +    <properties>
   53.18 +        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   53.19 +    </properties>
   53.20 +    <dependencies>
   53.21 +        <dependency>
   53.22 +            <groupId>${project.groupId}</groupId>
   53.23 +            <artifactId>vmtest</artifactId>
   53.24 +            <version>${project.version}</version>
   53.25 +            <scope>test</scope>
   53.26 +        </dependency>
   53.27 +        <dependency>
   53.28 +            <groupId>${project.groupId}</groupId>
   53.29 +            <artifactId>launcher.http</artifactId>
   53.30 +            <version>${project.version}</version>
   53.31 +            <scope>test</scope>
   53.32 +            <exclusions>
   53.33 +                <exclusion>
   53.34 +                    <groupId>com.oracle</groupId>
   53.35 +                    <artifactId>javafx</artifactId>
   53.36 +                </exclusion>
   53.37 +            </exclusions>
   53.38 +        </dependency>
   53.39 +        <dependency>
   53.40 +            <groupId>org.netbeans.api</groupId>
   53.41 +            <artifactId>org-openide-util-lookup</artifactId>
   53.42 +            <scope>test</scope>
   53.43 +        </dependency>
   53.44 +    </dependencies>
   53.45 +    <build>
   53.46 +        <plugins>
   53.47 +            <plugin>
   53.48 +                <groupId>org.apache.maven.plugins</groupId>
   53.49 +                <artifactId>maven-compiler-plugin</artifactId>
   53.50 +                <version>2.5.1</version>
   53.51 +                <configuration>
   53.52 +                    <source>1.7</source>
   53.53 +                    <target>1.7</target>
   53.54 +                </configuration>
   53.55 +            </plugin>
   53.56 +            <plugin>
   53.57 +                <groupId>org.apache.maven.plugins</groupId>
   53.58 +                <artifactId>maven-surefire-plugin</artifactId>
   53.59 +                <executions>
   53.60 +                    <execution>
   53.61 +                        <id>brwsr</id>
   53.62 +                        <goals>
   53.63 +                            <goal>test</goal>
   53.64 +                        </goals>
   53.65 +                        <phase>verify</phase>
   53.66 +                        <configuration>
   53.67 +                            <systemProperties>
   53.68 +                                <vmtest.js>brwsr</vmtest.js>
   53.69 +                            </systemProperties>
   53.70 +                        </configuration>
   53.71 +                    </execution>
   53.72 +                </executions>
   53.73 +            </plugin>     
   53.74 +        </plugins>
   53.75 +    </build>
   53.76 +</project>
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java	Wed Nov 19 19:32:00 2014 +0100
    54.3 @@ -0,0 +1,121 @@
    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.compact.tck;
   54.22 +
   54.23 +import java.util.ArrayList;
   54.24 +import java.util.Arrays;
   54.25 +import java.util.Collection;
   54.26 +import java.util.Collections;
   54.27 +import java.util.Comparator;
   54.28 +import java.util.HashMap;
   54.29 +import java.util.HashSet;
   54.30 +import java.util.List;
   54.31 +import java.util.Map;
   54.32 +import java.util.Map.Entry;
   54.33 +import java.util.Vector;
   54.34 +import org.apidesign.bck2brwsr.vmtest.Compare;
   54.35 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   54.36 +import org.testng.annotations.Factory;
   54.37 +
   54.38 +/**
   54.39 + *
   54.40 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   54.41 + */
   54.42 +public class CollectionsTest {
   54.43 +    @Compare public String sortStringsInArray() {
   54.44 +        List<String> list = new ArrayList<>();
   54.45 +        list.add("one");
   54.46 +        list.add("two");
   54.47 +        list.add("three");
   54.48 +        list.add("four");
   54.49 +        list.add("five");
   54.50 +        list.add("six");
   54.51 +        list.add("seven");
   54.52 +        list.add("eight");
   54.53 +        list.add("nine");
   54.54 +        list.add("ten");
   54.55 +        
   54.56 +        String[] arr = list.toArray(new String[list.size()]);
   54.57 +        Arrays.sort(arr);
   54.58 +        
   54.59 +        return Arrays.asList(arr).toString();
   54.60 +    }
   54.61 +    
   54.62 +    @Compare public String sortStringsInHashSet() {
   54.63 +        Collection<String> list = new HashSet<>();
   54.64 +        list.add("one");
   54.65 +        list.add("two");
   54.66 +        list.add("three");
   54.67 +        list.add("four");
   54.68 +        list.add("five");
   54.69 +        list.add("six");
   54.70 +        list.add("seven");
   54.71 +        list.add("eight");
   54.72 +        list.add("nine");
   54.73 +        list.add("ten");
   54.74 +        
   54.75 +        String[] arr = list.toArray(new String[0]);
   54.76 +        Arrays.sort(arr);
   54.77 +        
   54.78 +        return Arrays.asList(arr).toString();
   54.79 +    }
   54.80 +
   54.81 +    @SuppressWarnings("unchecked")
   54.82 +    @Compare public String sortStringsInHashMapWithComparator() {
   54.83 +        class C implements Comparator<Map.Entry<String,Integer>> {
   54.84 +            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
   54.85 +                return o1.getKey().compareTo(o2.getKey());
   54.86 +            }
   54.87 +        }
   54.88 +        
   54.89 +        Map<String,Integer> map = new HashMap<>();
   54.90 +        map.put("one", 1);
   54.91 +        map.put("two", 2);
   54.92 +        map.put("three", 3);
   54.93 +        map.put("four", 4);
   54.94 +        map.put("five", 5);
   54.95 +        map.put("six", 6);
   54.96 +        map.put("seven", 7);
   54.97 +        map.put("eight", 8);
   54.98 +        map.put("nine", 9);
   54.99 +        map.put("ten", 10);
  54.100 +        
  54.101 +        List<Entry<String,Integer>> arr = new Vector<>();
  54.102 +        arr.addAll(map.entrySet());
  54.103 +        Collections.sort(arr, new C());
  54.104 +        return arr.toString();
  54.105 +    }
  54.106 +    
  54.107 +    @Compare public String jirkaToArray() {
  54.108 +        List<String> appfiles = new ArrayList<>();
  54.109 +        appfiles.add("onefile");
  54.110 +        appfiles.add("2ndfile");
  54.111 +        appfiles.add("3rdfile");
  54.112 +        String[] ret = appfiles.toArray(new String[appfiles.size()]);
  54.113 +        return 
  54.114 +            ret.getClass().getName() + ":" +
  54.115 +            ret.length + ":" +
  54.116 +            Arrays.toString(ret);
  54.117 +    }
  54.118 +    
  54.119 +    @Factory
  54.120 +    public static Object[] create() {
  54.121 +        return VMTest.create(CollectionsTest.class);
  54.122 +    }
  54.123 +    
  54.124 +}
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/JFXIssuesTest.java	Wed Nov 19 19:32:00 2014 +0100
    55.3 @@ -0,0 +1,90 @@
    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.compact.tck;
   55.22 +
   55.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   55.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   55.25 +import org.testng.annotations.Factory;
   55.26 +
   55.27 +
   55.28 +public class JFXIssuesTest {
   55.29 +    private abstract class Application {
   55.30 +        public abstract int getID();
   55.31 +    }
   55.32 +    
   55.33 +    private class MyApplication extends Application {
   55.34 +
   55.35 +        @Override
   55.36 +        public int getID() {
   55.37 +            return 1;
   55.38 +        }
   55.39 +        
   55.40 +    } 
   55.41 +    
   55.42 +    @Compare public boolean isClassAssignable() {
   55.43 +        return Application.class.isAssignableFrom(MyApplication.class);
   55.44 +    }
   55.45 +
   55.46 +    @Compare public boolean isNaN() {
   55.47 +        return Double.isNaN(Double.NaN);
   55.48 +    }
   55.49 +
   55.50 +    @Compare public boolean isInfinite() {
   55.51 +        return Float.isInfinite(Float.NEGATIVE_INFINITY);
   55.52 +    }
   55.53 +
   55.54 +    @Compare public boolean areTimesEqual() {
   55.55 +        long l1 = System.currentTimeMillis();
   55.56 +        long l2 = l1 + 0;
   55.57 +
   55.58 +        return l1 == l2;
   55.59 +    }
   55.60 +    
   55.61 +    @Compare public boolean roundOnDouble() {
   55.62 +        long l1 = Math.round(System.currentTimeMillis() / 1.1);
   55.63 +        long l2 = l1 + 0;
   55.64 +        
   55.65 +        return l1 == l2;
   55.66 +    }
   55.67 +
   55.68 +    private static final long val = 1238078409318L;
   55.69 +    
   55.70 +    @Compare public int valueConvertedToString() {
   55.71 +        long[] arr = { val };
   55.72 +        return dumpValue(arr);
   55.73 +    }
   55.74 +    
   55.75 +    int dumpValue(long[] val) {
   55.76 +        return (int) val[0]++;
   55.77 +    }
   55.78 +    
   55.79 +    
   55.80 +    @Compare public boolean roundOnFloat() {
   55.81 +        final float f = System.currentTimeMillis() / 1.1f;
   55.82 +        int l1 = Math.round(f);
   55.83 +        int l2 = l1 + 0;
   55.84 +        
   55.85 +        assert l1 == l2 : "Round " + l1 + " == " + l2;
   55.86 +        
   55.87 +        return l1 == l2;
   55.88 +    }
   55.89 +    
   55.90 +    @Factory public static Object[] create() {
   55.91 +        return VMTest.create(JFXIssuesTest.class);
   55.92 +    }
   55.93 +}
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/RandomTest.java	Wed Nov 19 19:32:00 2014 +0100
    56.3 @@ -0,0 +1,40 @@
    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.compact.tck;
   56.22 +
   56.23 +import java.util.Random;
   56.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   56.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   56.26 +import org.testng.annotations.Factory;
   56.27 +
   56.28 +/**
   56.29 + *
   56.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   56.31 + */
   56.32 +public class RandomTest {
   56.33 +    @Compare public boolean canInstantiateRandom() {
   56.34 +        Random r = new Random();
   56.35 +        r.nextInt();
   56.36 +        return r != null;
   56.37 +    }
   56.38 +
   56.39 +    
   56.40 +    @Factory public static Object[] create() {
   56.41 +        return VMTest.create(RandomTest.class);
   56.42 +    }
   56.43 +}
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/ReaderTest.java	Wed Nov 19 19:32:00 2014 +0100
    57.3 @@ -0,0 +1,78 @@
    57.4 +/**
    57.5 + * Back 2 Browser Bytecode Translator
    57.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    57.7 + *
    57.8 + * This program is free software: you can redistribute it and/or modify
    57.9 + * it under the terms of the GNU General Public License as published by
   57.10 + * the Free Software Foundation, version 2 of the License.
   57.11 + *
   57.12 + * This program is distributed in the hope that it will be useful,
   57.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   57.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   57.15 + * GNU General Public License for more details.
   57.16 + *
   57.17 + * You should have received a copy of the GNU General Public License
   57.18 + * along with this program. Look for COPYING file in the top folder.
   57.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   57.20 + */
   57.21 +package org.apidesign.bck2brwsr.compact.tck;
   57.22 +
   57.23 +import java.io.ByteArrayInputStream;
   57.24 +import java.io.ByteArrayOutputStream;
   57.25 +import java.io.IOException;
   57.26 +import java.io.InputStreamReader;
   57.27 +import java.io.OutputStreamWriter;
   57.28 +import java.io.UnsupportedEncodingException;
   57.29 +import java.util.Arrays;
   57.30 +import org.apidesign.bck2brwsr.vmtest.Compare;
   57.31 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   57.32 +import org.testng.annotations.Factory;
   57.33 +
   57.34 +/**
   57.35 + *
   57.36 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   57.37 + */
   57.38 +public class ReaderTest {
   57.39 +    @Compare public String readUTFString() throws IOException {
   57.40 +        byte[] arr = { 
   57.41 +            (byte)-59, (byte)-67, (byte)108, (byte)117, (byte)-59, (byte)-91, 
   57.42 +            (byte)111, (byte)117, (byte)-60, (byte)-115, (byte)107, (byte)-61, 
   57.43 +            (byte)-67, (byte)32, (byte)107, (byte)-59, (byte)-81, (byte)-59, 
   57.44 +            (byte)-120 
   57.45 +        };
   57.46 +        ByteArrayInputStream is = new ByteArrayInputStream(arr);
   57.47 +        InputStreamReader r = new InputStreamReader(is, "UTF-8");
   57.48 +        return readReader(r);        
   57.49 +    }
   57.50 +
   57.51 +    private String readReader(InputStreamReader r) throws IOException {
   57.52 +        StringBuilder sb = new StringBuilder();
   57.53 +        for (;;) {
   57.54 +            int ch = r.read();
   57.55 +            if (ch == -1) {
   57.56 +                break;
   57.57 +            }
   57.58 +            sb.append((char)ch);
   57.59 +        }
   57.60 +        return sb.toString().toString();
   57.61 +    }
   57.62 +    @Compare public String stringToBytes() throws UnsupportedEncodingException {
   57.63 +        return Arrays.toString(YellowHorse.getBytes("UTF-8"));
   57.64 +    }
   57.65 +    private final String YellowHorse = "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148";
   57.66 +    
   57.67 +    @Compare public String readAndWrite() throws Exception {
   57.68 +        ByteArrayOutputStream arr = new ByteArrayOutputStream();
   57.69 +        OutputStreamWriter w = new OutputStreamWriter(arr);
   57.70 +        w.write(YellowHorse);
   57.71 +        w.close();
   57.72 +        
   57.73 +        ByteArrayInputStream is = new ByteArrayInputStream(arr.toByteArray());
   57.74 +        InputStreamReader r = new InputStreamReader(is, "UTF-8");
   57.75 +        return readReader(r);
   57.76 +    }
   57.77 +    
   57.78 +    @Factory public static Object[] create() {
   57.79 +        return VMTest.create(ReaderTest.class);
   57.80 +    }
   57.81 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/ServiceLoaderTest.java	Wed Nov 19 19:32:00 2014 +0100
    58.3 @@ -0,0 +1,61 @@
    58.4 +/**
    58.5 + * Back 2 Browser Bytecode Translator
    58.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    58.7 + *
    58.8 + * This program is free software: you can redistribute it and/or modify
    58.9 + * it under the terms of the GNU General Public License as published by
   58.10 + * the Free Software Foundation, version 2 of the License.
   58.11 + *
   58.12 + * This program is distributed in the hope that it will be useful,
   58.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   58.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   58.15 + * GNU General Public License for more details.
   58.16 + *
   58.17 + * You should have received a copy of the GNU General Public License
   58.18 + * along with this program. Look for COPYING file in the top folder.
   58.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   58.20 + */
   58.21 +package org.apidesign.bck2brwsr.compact.tck;
   58.22 +
   58.23 +import java.io.IOException;
   58.24 +import java.util.ServiceLoader;
   58.25 +import org.apidesign.bck2brwsr.vmtest.Compare;
   58.26 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   58.27 +import org.openide.util.lookup.ServiceProvider;
   58.28 +import org.testng.annotations.Factory;
   58.29 +
   58.30 +/**
   58.31 + *
   58.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   58.33 + */
   58.34 +public class ServiceLoaderTest {
   58.35 +    @Compare//(scripting = false) 
   58.36 +    public Object findsIOException() {
   58.37 +//      delayStart();
   58.38 +        for (IOException e : ServiceLoader.load(IOException.class)) {
   58.39 +            return "Found service: " + e.getClass().getName();
   58.40 +        }
   58.41 +        return null;
   58.42 +    }
   58.43 +/*    
   58.44 +    @org.apidesign.bck2brwsr.core.JavaScriptBody(args = { "a" }, body = "alert(a);")
   58.45 +    private static void alert(String a) {
   58.46 +    }
   58.47 +    private void delayStart() {
   58.48 +        for (int i = 0; i < 10; i++) {
   58.49 +            alert("State: " + i);
   58.50 +            for (int j = 0; j < 493208409; j++) ;
   58.51 +        }
   58.52 +    }
   58.53 +*/
   58.54 +    
   58.55 +    @Factory
   58.56 +    public static Object[] create() {
   58.57 +        return VMTest.create(ServiceLoaderTest.class);
   58.58 +    }
   58.59 +
   58.60 +    
   58.61 +    @ServiceProvider(service = IOException.class)
   58.62 +    public static class MyException extends IOException {
   58.63 +    }
   58.64 +}
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java	Wed Nov 19 19:32:00 2014 +0100
    59.3 @@ -0,0 +1,43 @@
    59.4 +/**
    59.5 + * Back 2 Browser Bytecode Translator
    59.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    59.7 + *
    59.8 + * This program is free software: you can redistribute it and/or modify
    59.9 + * it under the terms of the GNU General Public License as published by
   59.10 + * the Free Software Foundation, version 2 of the License.
   59.11 + *
   59.12 + * This program is distributed in the hope that it will be useful,
   59.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   59.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   59.15 + * GNU General Public License for more details.
   59.16 + *
   59.17 + * You should have received a copy of the GNU General Public License
   59.18 + * along with this program. Look for COPYING file in the top folder.
   59.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   59.20 + */
   59.21 +package org.apidesign.bck2brwsr.tck;
   59.22 +
   59.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   59.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   59.25 +import org.testng.annotations.Factory;
   59.26 +
   59.27 +/**
   59.28 + *
   59.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   59.30 + */
   59.31 +public class AssertionTest {
   59.32 +
   59.33 +    @Compare public Object checkAssert() throws ClassNotFoundException {
   59.34 +        try {
   59.35 +            assert false : "Is assertion status on?";
   59.36 +            return null;
   59.37 +        } catch (AssertionError ex) {
   59.38 +            return ex.getClass().getName();
   59.39 +        }
   59.40 +    }
   59.41 +    
   59.42 +    @Factory
   59.43 +    public static Object[] create() {
   59.44 +        return VMTest.create(AssertionTest.class);
   59.45 +    }
   59.46 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/AtomicTest.java	Wed Nov 19 19:32:00 2014 +0100
    60.3 @@ -0,0 +1,54 @@
    60.4 +/**
    60.5 + * Back 2 Browser Bytecode Translator
    60.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    60.7 + *
    60.8 + * This program is free software: you can redistribute it and/or modify
    60.9 + * it under the terms of the GNU General Public License as published by
   60.10 + * the Free Software Foundation, version 2 of the License.
   60.11 + *
   60.12 + * This program is distributed in the hope that it will be useful,
   60.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   60.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   60.15 + * GNU General Public License for more details.
   60.16 + *
   60.17 + * You should have received a copy of the GNU General Public License
   60.18 + * along with this program. Look for COPYING file in the top folder.
   60.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   60.20 + */
   60.21 +package org.apidesign.bck2brwsr.tck;
   60.22 +
   60.23 +import java.util.concurrent.atomic.AtomicBoolean;
   60.24 +import java.util.concurrent.atomic.AtomicInteger;
   60.25 +import java.util.concurrent.atomic.AtomicReference;
   60.26 +import org.apidesign.bck2brwsr.vmtest.Compare;
   60.27 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   60.28 +import org.testng.annotations.Factory;
   60.29 +
   60.30 +/**
   60.31 + *
   60.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   60.33 + */
   60.34 +public class AtomicTest {
   60.35 +    @Compare public boolean atomicBoolean() {
   60.36 +        AtomicBoolean ab = new AtomicBoolean();
   60.37 +        ab.set(true);
   60.38 +        return ab.compareAndSet(true, false);
   60.39 +    }
   60.40 +
   60.41 +    @Compare public int atomicInt() {
   60.42 +        AtomicInteger ab = new AtomicInteger();
   60.43 +        ab.set(30);
   60.44 +        assert ab.compareAndSet(30, 10);
   60.45 +        return ab.get();
   60.46 +    }
   60.47 +    
   60.48 +    @Compare public String atomicRef() {
   60.49 +        AtomicReference<String> ar = new AtomicReference<String>("Ahoj");
   60.50 +        assert ar.compareAndSet("Ahoj", "Hello");
   60.51 +        return ar.getAndSet("Other");
   60.52 +    }
   60.53 +    
   60.54 +    @Factory public static Object[] create() {
   60.55 +        return VMTest.create(AtomicTest.class);
   60.56 +    }
   60.57 +}
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/BrwsrCheckTest.java	Wed Nov 19 19:32:00 2014 +0100
    61.3 @@ -0,0 +1,57 @@
    61.4 +/**
    61.5 + * Back 2 Browser Bytecode Translator
    61.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    61.7 + *
    61.8 + * This program is free software: you can redistribute it and/or modify
    61.9 + * it under the terms of the GNU General Public License as published by
   61.10 + * the Free Software Foundation, version 2 of the License.
   61.11 + *
   61.12 + * This program is distributed in the hope that it will be useful,
   61.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   61.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   61.15 + * GNU General Public License for more details.
   61.16 + *
   61.17 + * You should have received a copy of the GNU General Public License
   61.18 + * along with this program. Look for COPYING file in the top folder.
   61.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   61.20 + */
   61.21 +package org.apidesign.bck2brwsr.tck;
   61.22 +
   61.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   61.24 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   61.25 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
   61.26 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   61.27 +import org.testng.annotations.Factory;
   61.28 +
   61.29 +/**
   61.30 + *
   61.31 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   61.32 + */
   61.33 +public class BrwsrCheckTest {
   61.34 +
   61.35 +    @BrwsrTest public void assertWindowObjectIsDefined() {
   61.36 +        assert window() != null : "No window object found!";
   61.37 +    }
   61.38 +
   61.39 +    
   61.40 +    
   61.41 +    
   61.42 +    @HtmlFragment("<h1 id='hello'>\n"
   61.43 +        + "Hello!\n"
   61.44 +        + "</h1>\n")
   61.45 +    @BrwsrTest public void accessProvidedFragment() {
   61.46 +        assert getElementById("hello") != null : "Element with 'hello' ID found";
   61.47 +    }
   61.48 +    
   61.49 +    @Factory
   61.50 +    public static Object[] create() {
   61.51 +        return VMTest.create(BrwsrCheckTest.class);
   61.52 +    }
   61.53 +    
   61.54 +
   61.55 +    @JavaScriptBody(args = {}, body = "return window;")
   61.56 +    private static native Object window();
   61.57 +
   61.58 +    @JavaScriptBody(args = { "id" }, body = "return window.document.getElementById(id);")
   61.59 +    private static native Object getElementById(String id);
   61.60 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ByteArithmeticTest.java	Wed Nov 19 19:32:00 2014 +0100
    62.3 @@ -0,0 +1,147 @@
    62.4 +/**
    62.5 + * Back 2 Browser Bytecode Translator
    62.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    62.7 + *
    62.8 + * This program is free software: you can redistribute it and/or modify
    62.9 + * it under the terms of the GNU General Public License as published by
   62.10 + * the Free Software Foundation, version 2 of the License.
   62.11 + *
   62.12 + * This program is distributed in the hope that it will be useful,
   62.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   62.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   62.15 + * GNU General Public License for more details.
   62.16 + *
   62.17 + * You should have received a copy of the GNU General Public License
   62.18 + * along with this program. Look for COPYING file in the top folder.
   62.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   62.20 + */
   62.21 +package org.apidesign.bck2brwsr.tck;
   62.22 +
   62.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   62.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   62.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   62.26 +import org.testng.annotations.Factory;
   62.27 +
   62.28 +/**
   62.29 + *
   62.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   62.31 + */
   62.32 +public class ByteArithmeticTest {
   62.33 +    
   62.34 +    private static byte add(byte x, byte y) {
   62.35 +        return (byte)(x + y);
   62.36 +    }
   62.37 +    
   62.38 +    private static byte sub(byte x, byte y) {
   62.39 +        return (byte)(x - y);
   62.40 +    }
   62.41 +    
   62.42 +    private static byte mul(byte x, byte y) {
   62.43 +        return (byte)(x * y);
   62.44 +    }
   62.45 +    
   62.46 +    private static byte div(byte x, byte y) {
   62.47 +        return (byte)(x / y);
   62.48 +    }
   62.49 +    
   62.50 +    private static byte mod(byte x, byte y) {
   62.51 +        return (byte)(x % y);
   62.52 +    }
   62.53 +    
   62.54 +    @Compare public byte conversion() {
   62.55 +        return (byte)123456;
   62.56 +    }
   62.57 +    
   62.58 +    @Compare public byte addOverflow() {
   62.59 +        return add(Byte.MAX_VALUE, (byte)1);
   62.60 +    }
   62.61 +    
   62.62 +    @Compare public byte subUnderflow() {
   62.63 +        return sub(Byte.MIN_VALUE, (byte)1);
   62.64 +    }
   62.65 +    
   62.66 +    @Compare public byte addMaxByteAndMaxByte() {
   62.67 +        return add(Byte.MAX_VALUE, Byte.MAX_VALUE);
   62.68 +    }
   62.69 +    
   62.70 +    @Compare public byte subMinByteAndMinByte() {
   62.71 +        return sub(Byte.MIN_VALUE, Byte.MIN_VALUE);
   62.72 +    }
   62.73 +    
   62.74 +    @Compare public byte multiplyMaxByte() {
   62.75 +        return mul(Byte.MAX_VALUE, (byte)2);
   62.76 +    }
   62.77 +    
   62.78 +    @Compare public byte multiplyMaxByteAndMaxByte() {
   62.79 +        return mul(Byte.MAX_VALUE, Byte.MAX_VALUE);
   62.80 +    }
   62.81 +    
   62.82 +    @Compare public byte multiplyMinByte() {
   62.83 +        return mul(Byte.MIN_VALUE, (byte)2);
   62.84 +    }
   62.85 +    
   62.86 +    @Compare public byte multiplyMinByteAndMinByte() {
   62.87 +        return mul(Byte.MIN_VALUE, Byte.MIN_VALUE);
   62.88 +    }
   62.89 +    
   62.90 +    @Compare public byte multiplyPrecision() {
   62.91 +        return mul((byte)17638, (byte)1103);
   62.92 +    }
   62.93 +    
   62.94 +    @Compare public byte division() {
   62.95 +        return div((byte)1, (byte)2);
   62.96 +    }
   62.97 +    
   62.98 +    @Compare public byte divisionReminder() {
   62.99 +        return mod((byte)1, (byte)2);
  62.100 +    }
  62.101 +
  62.102 +    private static int readShort(byte[] byteCodes, int offset) {
  62.103 +        int signed = byteCodes[offset];
  62.104 +        byte b0 = (byte)signed;
  62.105 +        return (b0 << 8) | (byteCodes[offset + 1] & 0xff);
  62.106 +    }
  62.107 +    
  62.108 +    private static int readShortArg(byte[] byteCodes, int offsetInstruction) {
  62.109 +        return readShort(byteCodes, offsetInstruction + 1);
  62.110 +    }
  62.111 +    
  62.112 +    @Compare public int readIntArgs255and156() {
  62.113 +        final byte[] arr = new byte[] { (byte)0, (byte)255, (byte)156 };
  62.114 +        
  62.115 +        assert arr[1] == -1 : "First byte: " + arr[1];
  62.116 +        assert arr[2] == -100 : "Second byte: " + arr[2];
  62.117 +        final int ret = readShortArg(arr, 0);
  62.118 +        assert ret < 65000: "Value: " + ret;
  62.119 +        return ret;
  62.120 +    }
  62.121 +    
  62.122 +    @JavaScriptBody(args = { "arr" }, body = "arr[1] = 255; arr[2] = 156; return arr;")
  62.123 +    private static byte[] fill255and156(byte[] arr) {
  62.124 +        arr[1] = (byte)255;
  62.125 +        arr[2] = (byte)156;
  62.126 +        return arr;
  62.127 +    }
  62.128 +
  62.129 +    @Compare public int readIntArgs255and156JSArray() {
  62.130 +        final byte[] arr = fill255and156(new byte[] { 0, 0, 0 });
  62.131 +        
  62.132 +        final int ret = readShortArg(arr, 0);
  62.133 +        assert ret < 65000: "Value: " + ret;
  62.134 +        return ret;
  62.135 +    }
  62.136 +    
  62.137 +    @Compare public int readIntArgsMinus1andMinus100() {
  62.138 +        final byte[] arr = new byte[] { (byte)0, (byte)-1, (byte)-100 };
  62.139 +        
  62.140 +        assert arr[1] == -1 : "First byte: " + arr[1];
  62.141 +        assert arr[2] == -100 : "Second byte: " + arr[2];
  62.142 +        
  62.143 +        return readShortArg(arr, 0);
  62.144 +    }
  62.145 +    
  62.146 +    @Factory
  62.147 +    public static Object[] create() {
  62.148 +        return VMTest.create(ByteArithmeticTest.class);
  62.149 +    }
  62.150 +}
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CharacterTest.java	Wed Nov 19 19:32:00 2014 +0100
    63.3 @@ -0,0 +1,61 @@
    63.4 +/**
    63.5 + * Back 2 Browser Bytecode Translator
    63.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    63.7 + *
    63.8 + * This program is free software: you can redistribute it and/or modify
    63.9 + * it under the terms of the GNU General Public License as published by
   63.10 + * the Free Software Foundation, version 2 of the License.
   63.11 + *
   63.12 + * This program is distributed in the hope that it will be useful,
   63.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   63.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   63.15 + * GNU General Public License for more details.
   63.16 + *
   63.17 + * You should have received a copy of the GNU General Public License
   63.18 + * along with this program. Look for COPYING file in the top folder.
   63.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   63.20 + */
   63.21 +package org.apidesign.bck2brwsr.tck;
   63.22 +
   63.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   63.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   63.25 +import org.testng.annotations.Factory;
   63.26 +
   63.27 +/**
   63.28 + *
   63.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   63.30 + */
   63.31 +public class CharacterTest {
   63.32 +    @Compare public boolean dolarJavaStart() {
   63.33 +        return Character.isJavaIdentifierStart('$');
   63.34 +    }
   63.35 +
   63.36 +    @Compare public boolean dolarJavaPart() {
   63.37 +        return Character.isJavaIdentifierPart('$');
   63.38 +    }
   63.39 +
   63.40 +    @Compare public boolean numberJavaStart() {
   63.41 +        return Character.isJavaIdentifierStart('3');
   63.42 +    }
   63.43 +
   63.44 +    @Compare public boolean numberJavaPart() {
   63.45 +        return Character.isJavaIdentifierPart('3');
   63.46 +    }
   63.47 +
   63.48 +    @Compare public String testWhiteSpaces() {
   63.49 +        StringBuilder sb = new StringBuilder();
   63.50 +        for (int i = 1; i < 128; i++) {
   63.51 +            char ch = (char)i;
   63.52 +            if (Character.isWhitespace(ch)) {
   63.53 +                sb.append(i).append(",");
   63.54 +            }
   63.55 +        }
   63.56 +        return sb.toString();
   63.57 +    }
   63.58 +    
   63.59 +    @Factory
   63.60 +    public static Object[] create() {
   63.61 +        return VMTest.create(CharacterTest.class);
   63.62 +    }
   63.63 +
   63.64 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ClassLoaderTest.java	Wed Nov 19 19:32:00 2014 +0100
    64.3 @@ -0,0 +1,41 @@
    64.4 +/**
    64.5 + * Back 2 Browser Bytecode Translator
    64.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    64.7 + *
    64.8 + * This program is free software: you can redistribute it and/or modify
    64.9 + * it under the terms of the GNU General Public License as published by
   64.10 + * the Free Software Foundation, version 2 of the License.
   64.11 + *
   64.12 + * This program is distributed in the hope that it will be useful,
   64.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   64.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   64.15 + * GNU General Public License for more details.
   64.16 + *
   64.17 + * You should have received a copy of the GNU General Public License
   64.18 + * along with this program. Look for COPYING file in the top folder.
   64.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   64.20 + */
   64.21 +package org.apidesign.bck2brwsr.tck;
   64.22 +
   64.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   64.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   64.25 +import org.testng.annotations.Factory;
   64.26 +
   64.27 +/**
   64.28 + *
   64.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   64.30 + */
   64.31 +public class ClassLoaderTest {
   64.32 +    @Compare public Object unknownResource() {
   64.33 +        return ClassLoader.getSystemResource("really/unknown/resource.txt");
   64.34 +    }
   64.35 +    
   64.36 +    @Compare public boolean indenpotentSetOfClassloaderIsOK() {
   64.37 +        Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
   64.38 +        return Thread.currentThread().getContextClassLoader() == ClassLoader.getSystemClassLoader();
   64.39 +    }
   64.40 +
   64.41 +    @Factory public static Object[] create() {
   64.42 +        return VMTest.create(ClassLoaderTest.class);
   64.43 +    }
   64.44 +}
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ClassTest.java	Wed Nov 19 19:32:00 2014 +0100
    65.3 @@ -0,0 +1,47 @@
    65.4 +/**
    65.5 + * Back 2 Browser Bytecode Translator
    65.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    65.7 + *
    65.8 + * This program is free software: you can redistribute it and/or modify
    65.9 + * it under the terms of the GNU General Public License as published by
   65.10 + * the Free Software Foundation, version 2 of the License.
   65.11 + *
   65.12 + * This program is distributed in the hope that it will be useful,
   65.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   65.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   65.15 + * GNU General Public License for more details.
   65.16 + *
   65.17 + * You should have received a copy of the GNU General Public License
   65.18 + * along with this program. Look for COPYING file in the top folder.
   65.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   65.20 + */
   65.21 +package org.apidesign.bck2brwsr.tck;
   65.22 +
   65.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   65.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   65.25 +import org.testng.annotations.Factory;
   65.26 +
   65.27 +/**
   65.28 + *
   65.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   65.30 + */
   65.31 +public class ClassTest {
   65.32 +    @Compare
   65.33 +    public boolean isDoubleArrayAssignableToObject() throws Exception {
   65.34 +        double[] dbl = new double[0];
   65.35 +        Class<?> dblCls = dbl.getClass();
   65.36 +        return Object.class.isAssignableFrom(dblCls);
   65.37 +    }
   65.38 +
   65.39 +    @Compare
   65.40 +    public boolean isDoubleArrayAssignableToString() throws Exception {
   65.41 +        double[] dbl = new double[0];
   65.42 +        Class<?> dblCls = dbl.getClass();
   65.43 +        return String.class.isAssignableFrom(dblCls);
   65.44 +    }
   65.45 +    
   65.46 +    @Factory
   65.47 +    public static Object[] create() {
   65.48 +        return VMTest.create(ClassTest.class);
   65.49 +    }
   65.50 +}
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java	Wed Nov 19 19:32:00 2014 +0100
    66.3 @@ -0,0 +1,73 @@
    66.4 +/**
    66.5 + * Back 2 Browser Bytecode Translator
    66.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    66.7 + *
    66.8 + * This program is free software: you can redistribute it and/or modify
    66.9 + * it under the terms of the GNU General Public License as published by
   66.10 + * the Free Software Foundation, version 2 of the License.
   66.11 + *
   66.12 + * This program is distributed in the hope that it will be useful,
   66.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   66.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   66.15 + * GNU General Public License for more details.
   66.16 + *
   66.17 + * You should have received a copy of the GNU General Public License
   66.18 + * along with this program. Look for COPYING file in the top folder.
   66.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   66.20 + */
   66.21 +package org.apidesign.bck2brwsr.tck;
   66.22 +
   66.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   66.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   66.25 +import org.testng.annotations.Factory;
   66.26 +
   66.27 +/**
   66.28 + *
   66.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   66.30 + */
   66.31 +public class CloneTest {
   66.32 +    private int value;
   66.33 +    
   66.34 +    @Compare
   66.35 +    public Object notSupported() throws CloneNotSupportedException {
   66.36 +        return this.clone();
   66.37 +    }
   66.38 +
   66.39 +    @Compare public String sameClass() throws CloneNotSupportedException {
   66.40 +        return new Clnbl().clone().getClass().getName();
   66.41 +    }
   66.42 +
   66.43 +    @Compare public boolean differentInstance() throws CloneNotSupportedException {
   66.44 +        Clnbl orig = new Clnbl();
   66.45 +        return orig == orig.clone();
   66.46 +    }
   66.47 +
   66.48 +    @Compare public int sameReference() throws CloneNotSupportedException {
   66.49 +        CloneTest self = this;
   66.50 +        Clnbl orig = new Clnbl();
   66.51 +        self.value = 33;
   66.52 +        orig.ref = self;
   66.53 +        return ((Clnbl)orig.clone()).ref.value;
   66.54 +    }
   66.55 +
   66.56 +    @Compare public int sameValue() throws CloneNotSupportedException {
   66.57 +        Clnbl orig = new Clnbl();
   66.58 +        orig.value = 10;
   66.59 +        return ((Clnbl)orig.clone()).value;
   66.60 +    }
   66.61 +    
   66.62 +    @Factory
   66.63 +    public static Object[] create() {
   66.64 +        return VMTest.create(CloneTest.class);
   66.65 +    }
   66.66 +    
   66.67 +    public static final class Clnbl implements Cloneable {
   66.68 +        public CloneTest ref;
   66.69 +        private int value;
   66.70 +
   66.71 +        @Override
   66.72 +        public Object clone() throws CloneNotSupportedException {
   66.73 +            return super.clone();
   66.74 +        }
   66.75 +    }
   66.76 +}
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java	Wed Nov 19 19:32:00 2014 +0100
    67.3 @@ -0,0 +1,103 @@
    67.4 +/**
    67.5 + * Back 2 Browser Bytecode Translator
    67.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    67.7 + *
    67.8 + * This program is free software: you can redistribute it and/or modify
    67.9 + * it under the terms of the GNU General Public License as published by
   67.10 + * the Free Software Foundation, version 2 of the License.
   67.11 + *
   67.12 + * This program is distributed in the hope that it will be useful,
   67.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   67.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   67.15 + * GNU General Public License for more details.
   67.16 + *
   67.17 + * You should have received a copy of the GNU General Public License
   67.18 + * along with this program. Look for COPYING file in the top folder.
   67.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   67.20 + */
   67.21 +package org.apidesign.bck2brwsr.tck;
   67.22 +
   67.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   67.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   67.25 +import org.testng.annotations.Factory;
   67.26 +
   67.27 +/**
   67.28 + *
   67.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   67.30 + */
   67.31 +public class CompareByteArrayTest {
   67.32 +    @Compare public int byteArraySum() {
   67.33 +        byte[] arr = createArray();
   67.34 +        return sumByteArr(arr);
   67.35 +    }
   67.36 +    
   67.37 +    @Compare public int countZeros() {
   67.38 +        int zeros = 0;
   67.39 +        for (Byte b : createArray()) {
   67.40 +            if (b == 0) {
   67.41 +                zeros++;
   67.42 +            }
   67.43 +        }
   67.44 +        return zeros;
   67.45 +    }
   67.46 +    
   67.47 +    private static int sumByteArr(byte[] arr) {
   67.48 +        int sum = 0;
   67.49 +        for (int i = 0; i < arr.length; i++) {
   67.50 +            sum += arr[i];
   67.51 +        }
   67.52 +        return sum;
   67.53 +    }
   67.54 +    
   67.55 +    @Compare public String noOutOfBounds() {
   67.56 +        return atIndex(1);
   67.57 +    }
   67.58 +
   67.59 +    @Compare public String outOfBounds() {
   67.60 +        return atIndex(5);
   67.61 +    }
   67.62 +
   67.63 +    @Compare public String outOfBoundsMinus() {
   67.64 +        return atIndex(-1);
   67.65 +    }
   67.66 +
   67.67 +    @Compare public String toOfBounds() {
   67.68 +        return toIndex(5);
   67.69 +    }
   67.70 +
   67.71 +    @Compare public String toOfBoundsMinus() {
   67.72 +        return toIndex(-1);
   67.73 +    }
   67.74 +    
   67.75 +    @Compare public int multiArrayLength() {
   67.76 +         int[][] arr = new int[1][0];
   67.77 +         return arr[0].length;
   67.78 +    }
   67.79 +
   67.80 +    @Compare public int multiObjectArrayLength() {
   67.81 +         Object[][] arr = new Object[1][0];
   67.82 +         return arr[0].length;
   67.83 +    }
   67.84 +
   67.85 +    private static final int[] arr = { 0, 1, 2 };
   67.86 +    public static String atIndex(int at) {
   67.87 +        return "at@" + arr[at];
   67.88 +    }
   67.89 +    public static String toIndex(int at) {
   67.90 +        arr[at] = 10;
   67.91 +        return "ok";
   67.92 +    }
   67.93 +    
   67.94 +    
   67.95 +    @Factory
   67.96 +    public static Object[] create() {
   67.97 +        return VMTest.create(CompareByteArrayTest.class);
   67.98 +    }
   67.99 +
  67.100 +    private byte[] createArray() {
  67.101 +        byte[] arr = new byte[10];
  67.102 +        arr[5] = 3;
  67.103 +        arr[7] = 8;
  67.104 +        return arr;
  67.105 +    }
  67.106 +}
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java	Wed Nov 19 19:32:00 2014 +0100
    68.3 @@ -0,0 +1,60 @@
    68.4 +/**
    68.5 + * Back 2 Browser Bytecode Translator
    68.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    68.7 + *
    68.8 + * This program is free software: you can redistribute it and/or modify
    68.9 + * it under the terms of the GNU General Public License as published by
   68.10 + * the Free Software Foundation, version 2 of the License.
   68.11 + *
   68.12 + * This program is distributed in the hope that it will be useful,
   68.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   68.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   68.15 + * GNU General Public License for more details.
   68.16 + *
   68.17 + * You should have received a copy of the GNU General Public License
   68.18 + * along with this program. Look for COPYING file in the top folder.
   68.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   68.20 + */
   68.21 +package org.apidesign.bck2brwsr.tck;
   68.22 +
   68.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   68.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   68.25 +import org.testng.annotations.Factory;
   68.26 +
   68.27 +/**
   68.28 + *
   68.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   68.30 + */
   68.31 +public class CompareHashTest {
   68.32 +    @Compare public int hashOfString() {
   68.33 +        return "Ahoj".hashCode();
   68.34 +    }
   68.35 +    
   68.36 +    @Compare public boolean hashOfIntegerDifferentToOwnHash() {
   68.37 +        Integer i = 120;
   68.38 +        return System.identityHashCode(i) != i.hashCode();
   68.39 +    }
   68.40 +
   68.41 +    @Compare public int hashOfObjectSameAsOwnHash() {
   68.42 +        Object o = new Object();
   68.43 +        return System.identityHashCode(o) - o.hashCode();
   68.44 +    }
   68.45 +    
   68.46 +    @Compare public int hashRemainsYieldsZero() {
   68.47 +        Object o = new Object();
   68.48 +        return o.hashCode() - o.hashCode();
   68.49 +    }
   68.50 +    
   68.51 +    @Compare public int initializeInStatic() {
   68.52 +        return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode();
   68.53 +    }
   68.54 +    
   68.55 +    @Compare public int hashOfInt() {
   68.56 +        return Integer.valueOf(Integer.MAX_VALUE).hashCode();
   68.57 +    }
   68.58 +    
   68.59 +    @Factory
   68.60 +    public static Object[] create() {
   68.61 +        return VMTest.create(CompareHashTest.class);
   68.62 +    }
   68.63 +}
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareIntArrayTest.java	Wed Nov 19 19:32:00 2014 +0100
    69.3 @@ -0,0 +1,63 @@
    69.4 +/**
    69.5 + * Back 2 Browser Bytecode Translator
    69.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    69.7 + *
    69.8 + * This program is free software: you can redistribute it and/or modify
    69.9 + * it under the terms of the GNU General Public License as published by
   69.10 + * the Free Software Foundation, version 2 of the License.
   69.11 + *
   69.12 + * This program is distributed in the hope that it will be useful,
   69.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   69.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   69.15 + * GNU General Public License for more details.
   69.16 + *
   69.17 + * You should have received a copy of the GNU General Public License
   69.18 + * along with this program. Look for COPYING file in the top folder.
   69.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   69.20 + */
   69.21 +package org.apidesign.bck2brwsr.tck;
   69.22 +
   69.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   69.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   69.25 +import org.testng.annotations.Factory;
   69.26 +
   69.27 +/**
   69.28 + *
   69.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   69.30 + */
   69.31 +public class CompareIntArrayTest {
   69.32 +    @Compare public int integerArraySum() {
   69.33 +        int[] arr = createArray();
   69.34 +        return sumIntArr(arr);
   69.35 +    }
   69.36 +    
   69.37 +    @Compare public int countZeros() {
   69.38 +        int zeros = 0;
   69.39 +        for (Integer i : createArray()) {
   69.40 +            if (i == 0) {
   69.41 +                zeros++;
   69.42 +            }
   69.43 +        }
   69.44 +        return zeros;
   69.45 +    }
   69.46 +    
   69.47 +    private static int sumIntArr(int[] arr) {
   69.48 +        int sum = 0;
   69.49 +        for (int i = 0; i < arr.length; i++) {
   69.50 +            sum += arr[i];
   69.51 +        }
   69.52 +        return sum;
   69.53 +    }
   69.54 +    
   69.55 +    @Factory
   69.56 +    public static Object[] create() {
   69.57 +        return VMTest.create(CompareIntArrayTest.class);
   69.58 +    }
   69.59 +
   69.60 +    private int[] createArray() {
   69.61 +        int[] arr = new int[10];
   69.62 +        arr[5] = 3;
   69.63 +        arr[7] = 8;
   69.64 +        return arr;
   69.65 +    }
   69.66 +}
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/CompareStringsTest.java	Wed Nov 19 19:32:00 2014 +0100
    70.3 @@ -0,0 +1,209 @@
    70.4 +/**
    70.5 + * Back 2 Browser Bytecode Translator
    70.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    70.7 + *
    70.8 + * This program is free software: you can redistribute it and/or modify
    70.9 + * it under the terms of the GNU General Public License as published by
   70.10 + * the Free Software Foundation, version 2 of the License.
   70.11 + *
   70.12 + * This program is distributed in the hope that it will be useful,
   70.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   70.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   70.15 + * GNU General Public License for more details.
   70.16 + *
   70.17 + * You should have received a copy of the GNU General Public License
   70.18 + * along with this program. Look for COPYING file in the top folder.
   70.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   70.20 + */
   70.21 +package org.apidesign.bck2brwsr.tck;
   70.22 +
   70.23 +import java.io.UnsupportedEncodingException;
   70.24 +import java.net.MalformedURLException;
   70.25 +import java.net.URISyntaxException;
   70.26 +import java.net.URL;
   70.27 +import java.util.Locale;
   70.28 +import org.apidesign.bck2brwsr.vmtest.Compare;
   70.29 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   70.30 +import org.testng.annotations.Factory;
   70.31 +
   70.32 +/**
   70.33 + *
   70.34 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   70.35 + */
   70.36 +public class CompareStringsTest {
   70.37 +    @Compare public String firstChar() {
   70.38 +        return "" + ("Hello".toCharArray()[0]);
   70.39 +    }
   70.40 +    
   70.41 +    @Compare public String classCast() {
   70.42 +        Object o = firstChar();
   70.43 +        return String.class.cast(o);
   70.44 +    }
   70.45 +
   70.46 +    @Compare public String classCastThrown() {
   70.47 +        Object o = null;
   70.48 +        return String.class.cast(o);
   70.49 +    }
   70.50 +    
   70.51 +    @Compare public boolean equalToNull() {
   70.52 +        return "Ahoj".equals(null);
   70.53 +    }
   70.54 +    
   70.55 +    @Compare public boolean internIsSame() {
   70.56 +        return new String("Ahoj").intern() == another();
   70.57 +    }
   70.58 +    
   70.59 +    private static String another() {
   70.60 +        return new String("Ahoj").intern();
   70.61 +    }
   70.62 +    
   70.63 +    @Compare public int highByteLenght() {
   70.64 +        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   70.65 +        return new String(arr, 0).length();
   70.66 +    }
   70.67 +    
   70.68 +    @Compare public String highByte() {
   70.69 +        byte[] arr= { 77,97,110,105,102,101,115,116,45,86,101,114,115,105,111,110 };
   70.70 +        StringBuilder sb = new StringBuilder();
   70.71 +        sb.append("pref:");
   70.72 +        sb.append(new String(arr, 0));
   70.73 +        return sb.toString();
   70.74 +    }
   70.75 +    
   70.76 +    @Compare public static Object compareURLs() throws MalformedURLException {
   70.77 +        return new URL("http://apidesign.org:8080/wiki/").toExternalForm().toString();
   70.78 +    }
   70.79 +
   70.80 +    @Compare public static Object compareURLsViaURIs() throws Exception {
   70.81 +        return new URL("http://apidesign.org:8080/wiki/").toURI().toString();
   70.82 +    }
   70.83 +    
   70.84 +    @Compare public String deleteLastTwoCharacters() {
   70.85 +        StringBuilder sb = new StringBuilder();
   70.86 +        sb.append("453.0");
   70.87 +        if (sb.toString().endsWith(".0")) {
   70.88 +            final int l = sb.length();
   70.89 +            sb.delete(l - 2, l);
   70.90 +        }
   70.91 +        return sb.toString().toString();
   70.92 +    }
   70.93 +    
   70.94 +    @Compare public String nameOfStringClass() throws Exception {
   70.95 +        return Class.forName("java.lang.String").getName();
   70.96 +    }
   70.97 +    @Compare public String nameOfArrayClass() throws Exception {
   70.98 +        return Class.forName("org.apidesign.bck2brwsr.tck.CompareHashTest").getName();
   70.99 +    }
  70.100 +    
  70.101 +    @Compare public String lowerHello() {
  70.102 +        return "HeLlO".toLowerCase();
  70.103 +    }
  70.104 +    
  70.105 +    @Compare public String lowerA() {
  70.106 +        return String.valueOf(Character.toLowerCase('A')).toString();
  70.107 +    }
  70.108 +    @Compare public String upperHello() {
  70.109 +        return "hello".toUpperCase();
  70.110 +    }
  70.111 +    
  70.112 +    @Compare public String upperA() {
  70.113 +        return String.valueOf(Character.toUpperCase('a')).toString();
  70.114 +    }
  70.115 +    
  70.116 +    @Compare public boolean matchRegExp() throws Exception {
  70.117 +        return "58038503".matches("\\d*");
  70.118 +    }
  70.119 +
  70.120 +    @Compare public boolean doesNotMatchRegExp() throws Exception {
  70.121 +        return "58038503GH".matches("\\d*");
  70.122 +    }
  70.123 +
  70.124 +    @Compare public boolean doesNotMatchRegExpFully() throws Exception {
  70.125 +        return "Hello".matches("Hell");
  70.126 +    }
  70.127 +    
  70.128 +    @Compare public String emptyCharArray() {
  70.129 +        char[] arr = new char[10];
  70.130 +        return new String(arr);
  70.131 +    }
  70.132 +    
  70.133 +    @Compare public String variousCharacterTests() throws Exception {
  70.134 +        StringBuilder sb = new StringBuilder();
  70.135 +        
  70.136 +        sb.append(Character.isUpperCase('a'));
  70.137 +        sb.append(Character.isUpperCase('A'));
  70.138 +        sb.append(Character.isLowerCase('a'));
  70.139 +        sb.append(Character.isLowerCase('A'));
  70.140 +        
  70.141 +        sb.append(Character.isLetter('A'));
  70.142 +        sb.append(Character.isLetterOrDigit('9'));
  70.143 +        sb.append(Character.isLetterOrDigit('A'));
  70.144 +        sb.append(Character.isLetter('0'));
  70.145 +        
  70.146 +        return sb.toString().toString();
  70.147 +    }
  70.148 +        
  70.149 +    @Compare
  70.150 +    public String nullFieldInitialized() {
  70.151 +        NullField nf = new NullField();
  70.152 +        return ("" + nf.name).toString();
  70.153 +    }
  70.154 +    @Compare
  70.155 +    public String toUTFString() throws UnsupportedEncodingException {
  70.156 +        byte[] arr = {
  70.157 +            (byte) -59, (byte) -67, (byte) 108, (byte) 117, (byte) -59, (byte) -91,
  70.158 +            (byte) 111, (byte) 117, (byte) -60, (byte) -115, (byte) 107, (byte) -61,
  70.159 +            (byte) -67, (byte) 32, (byte) 107, (byte) -59, (byte) -81, (byte) -59,
  70.160 +            (byte) -120
  70.161 +        };
  70.162 +        return new String(arr, "utf-8");
  70.163 +    }
  70.164 +
  70.165 +    @Compare
  70.166 +    public int stringToBytesLenght() throws UnsupportedEncodingException {
  70.167 +        return "\u017dlu\u0165ou\u010dk\u00fd k\u016f\u0148".getBytes("utf8").length;
  70.168 +    }
  70.169 +    
  70.170 +    @Compare public String replaceSeq() {
  70.171 +        return "Hello World.".replace(".", "!");
  70.172 +    }
  70.173 +    @Compare public String replaceSeqAll() {
  70.174 +        return "Hello World! Hello World.".replace("World", "Jarda");
  70.175 +    }
  70.176 +    @Compare public String replaceSeqAA() {
  70.177 +        String res = "aaa".replace("aa", "b");
  70.178 +        assert res.equals("ba") : "Expecting ba: " + res;
  70.179 +        return res;
  70.180 +    }
  70.181 +    
  70.182 +    @Compare public String localeUS() {
  70.183 +        return Locale.US.toString();
  70.184 +    }
  70.185 +    
  70.186 +    @Compare public String localeFrench() {
  70.187 +        return Locale.FRENCH.toString();
  70.188 +    }
  70.189 +    
  70.190 +    
  70.191 +    @Compare public String formatSimple() {
  70.192 +        return String.format((Locale)null, "Hello %s!", "World");
  70.193 +    }
  70.194 +
  70.195 +    @Compare public String replaceWithItself() {
  70.196 +        return "org.apidesign.bck2brwsr.core.JavaScriptBody".replace(".", "\\.");
  70.197 +    }
  70.198 +    
  70.199 +    @Compare public boolean matchWithComplicatedRegExp() {
  70.200 +        return "Activates this model instance.".matches("(?sm).*^\\s*@deprecated( |$).*");
  70.201 +    }
  70.202 +    
  70.203 +    @Factory
  70.204 +    public static Object[] create() {
  70.205 +        return VMTest.create(CompareStringsTest.class);
  70.206 +    }
  70.207 +
  70.208 +    private static final class NullField {
  70.209 +
  70.210 +        String name;
  70.211 +    }
  70.212 +}
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ConcurrentTest.java	Wed Nov 19 19:32:00 2014 +0100
    71.3 @@ -0,0 +1,40 @@
    71.4 +/**
    71.5 + * Back 2 Browser Bytecode Translator
    71.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    71.7 + *
    71.8 + * This program is free software: you can redistribute it and/or modify
    71.9 + * it under the terms of the GNU General Public License as published by
   71.10 + * the Free Software Foundation, version 2 of the License.
   71.11 + *
   71.12 + * This program is distributed in the hope that it will be useful,
   71.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   71.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   71.15 + * GNU General Public License for more details.
   71.16 + *
   71.17 + * You should have received a copy of the GNU General Public License
   71.18 + * along with this program. Look for COPYING file in the top folder.
   71.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   71.20 + */
   71.21 +package org.apidesign.bck2brwsr.tck;
   71.22 +
   71.23 +import java.util.concurrent.ConcurrentHashMap;
   71.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   71.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   71.26 +import org.testng.annotations.Factory;
   71.27 +
   71.28 +/**
   71.29 + *
   71.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   71.31 + */
   71.32 +public class ConcurrentTest {
   71.33 +    @Compare public String mapIfAbsent() {
   71.34 +        ConcurrentHashMap<String,String> m = new ConcurrentHashMap<>();
   71.35 +        m.putIfAbsent("Ahoj", "Jardo");
   71.36 +        m.putIfAbsent("Ahoj", "Dardo");
   71.37 +        return m.get("Ahoj");
   71.38 +    }
   71.39 +    
   71.40 +    @Factory public static Object[] create() {
   71.41 +        return VMTest.create(ConcurrentTest.class);
   71.42 +    }
   71.43 +}
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/DoubleTest.java	Wed Nov 19 19:32:00 2014 +0100
    72.3 @@ -0,0 +1,73 @@
    72.4 +/**
    72.5 + * Back 2 Browser Bytecode Translator
    72.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    72.7 + *
    72.8 + * This program is free software: you can redistribute it and/or modify
    72.9 + * it under the terms of the GNU General Public License as published by
   72.10 + * the Free Software Foundation, version 2 of the License.
   72.11 + *
   72.12 + * This program is distributed in the hope that it will be useful,
   72.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   72.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   72.15 + * GNU General Public License for more details.
   72.16 + *
   72.17 + * You should have received a copy of the GNU General Public License
   72.18 + * along with this program. Look for COPYING file in the top folder.
   72.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   72.20 + */
   72.21 +package org.apidesign.bck2brwsr.tck;
   72.22 +
   72.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   72.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   72.25 +import org.testng.annotations.Factory;
   72.26 +
   72.27 +/**
   72.28 + *
   72.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   72.30 + */
   72.31 +public class DoubleTest {
   72.32 +    @Compare public boolean parsedDoubleIsDouble() {
   72.33 +        return Double.valueOf("1.1") instanceof Double;
   72.34 +    }
   72.35 +
   72.36 +    @Compare public boolean parsedFloatIsFloat() {
   72.37 +        return Float.valueOf("1.1") instanceof Float;
   72.38 +    }
   72.39 +    
   72.40 +    @Compare public String integerToString() {
   72.41 +        return toStr(1);
   72.42 +    }
   72.43 +
   72.44 +    @Compare public String integerAndHalfToString() {
   72.45 +        return toStr(1.5);
   72.46 +    }
   72.47 +
   72.48 +    @Compare public double longToAndBack() {
   72.49 +        return Double.parseDouble(toStr(Long.MAX_VALUE / 10));
   72.50 +    }
   72.51 +
   72.52 +    @Compare public String negativeIntToString() {
   72.53 +        return toStr(-10);
   72.54 +    }
   72.55 +
   72.56 +    @Compare public String negativeIntAndHalfToString() {
   72.57 +        return toStr(-10.5);
   72.58 +    }
   72.59 +
   72.60 +    @Compare public double negativeLongAndBack() {
   72.61 +        return Double.parseDouble(toStr(Long.MIN_VALUE / 10));
   72.62 +    }
   72.63 +    
   72.64 +    @Compare public double canParseExp() {
   72.65 +        return Double.parseDouble(toStr(1.7976931348623157e+308));
   72.66 +    }
   72.67 +    
   72.68 +    private static String toStr(double d) {
   72.69 +        return Double.toString(d);
   72.70 +    }
   72.71 +    
   72.72 +    @Factory 
   72.73 +    public static Object[] create() {
   72.74 +        return VMTest.create(DoubleTest.class);
   72.75 +    }
   72.76 +}
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java	Wed Nov 19 19:32:00 2014 +0100
    73.3 @@ -0,0 +1,76 @@
    73.4 +/**
    73.5 + * Back 2 Browser Bytecode Translator
    73.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    73.7 + *
    73.8 + * This program is free software: you can redistribute it and/or modify
    73.9 + * it under the terms of the GNU General Public License as published by
   73.10 + * the Free Software Foundation, version 2 of the License.
   73.11 + *
   73.12 + * This program is distributed in the hope that it will be useful,
   73.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   73.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   73.15 + * GNU General Public License for more details.
   73.16 + *
   73.17 + * You should have received a copy of the GNU General Public License
   73.18 + * along with this program. Look for COPYING file in the top folder.
   73.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   73.20 + */
   73.21 +package org.apidesign.bck2brwsr.tck;
   73.22 +
   73.23 +import java.util.EnumMap;
   73.24 +import java.util.EnumSet;
   73.25 +import org.apidesign.bck2brwsr.vmtest.Compare;
   73.26 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   73.27 +import org.testng.annotations.Factory;
   73.28 +
   73.29 +/**
   73.30 + *
   73.31 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
   73.32 + */
   73.33 +public class EnumsTest {
   73.34 +    enum Color {
   73.35 +        B, W;
   73.36 +    }
   73.37 +
   73.38 +    @Compare public String enumSet() {
   73.39 +        try { throw new Exception(); } catch (Exception ex) {}
   73.40 +        EnumSet<Color> c = EnumSet.allOf(Color.class);
   73.41 +        return c.toString();
   73.42 +    }
   73.43 +
   73.44 +    @Compare public String enumSetOneByOne() {
   73.45 +        EnumSet<Color> c = EnumSet.of(Color.B, Color.W);
   73.46 +        return c.toString();
   73.47 +    }
   73.48 +
   73.49 +    @Compare public boolean enumFirstContains() {
   73.50 +        EnumSet<Color> c = EnumSet.of(Color.B);
   73.51 +        return c.contains(Color.B);
   73.52 +    }
   73.53 +
   73.54 +    @Compare public boolean enumFirstDoesNotContains() {
   73.55 +        EnumSet<Color> c = EnumSet.of(Color.B);
   73.56 +        return c.contains(Color.W);
   73.57 +    }
   73.58 +
   73.59 +    @Compare public boolean enumSndContains() {
   73.60 +        EnumSet<Color> c = EnumSet.of(Color.W);
   73.61 +        return c.contains(Color.W);
   73.62 +    }
   73.63 +
   73.64 +    @Compare public boolean enumSecondDoesNotContains() {
   73.65 +        EnumSet<Color> c = EnumSet.of(Color.W);
   73.66 +        return c.contains(Color.B);
   73.67 +    }
   73.68 +
   73.69 +    @Compare public String enumMap() {
   73.70 +        EnumMap<Color,String> c = new EnumMap(Color.class);
   73.71 +        c.put(Color.B, "Black");
   73.72 +        c.put(Color.W, "White");
   73.73 +        return c.toString();
   73.74 +    }
   73.75 +    
   73.76 +    @Factory public static Object[] create() {
   73.77 +        return VMTest.create(EnumsTest.class);
   73.78 +    }
   73.79 +}
    74.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ExceptionsTest.java	Wed Nov 19 19:32:00 2014 +0100
    74.3 @@ -0,0 +1,68 @@
    74.4 +/**
    74.5 + * Back 2 Browser Bytecode Translator
    74.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    74.7 + *
    74.8 + * This program is free software: you can redistribute it and/or modify
    74.9 + * it under the terms of the GNU General Public License as published by
   74.10 + * the Free Software Foundation, version 2 of the License.
   74.11 + *
   74.12 + * This program is distributed in the hope that it will be useful,
   74.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   74.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   74.15 + * GNU General Public License for more details.
   74.16 + *
   74.17 + * You should have received a copy of the GNU General Public License
   74.18 + * along with this program. Look for COPYING file in the top folder.
   74.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   74.20 + */
   74.21 +package org.apidesign.bck2brwsr.tck;
   74.22 +
   74.23 +import java.io.ByteArrayOutputStream;
   74.24 +import java.io.PrintStream;
   74.25 +import java.io.PrintWriter;
   74.26 +import java.io.StringWriter;
   74.27 +import java.io.UnsupportedEncodingException;
   74.28 +import org.apidesign.bck2brwsr.vmtest.Compare;
   74.29 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   74.30 +import org.testng.annotations.Factory;
   74.31 +
   74.32 +/**
   74.33 + *
   74.34 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   74.35 + */
   74.36 +public class ExceptionsTest {
   74.37 +    @Compare public String firstLineIsTheSame() throws UnsupportedEncodingException {
   74.38 +        MyException ex = new MyException("Hello");
   74.39 +        ByteArrayOutputStream out = new ByteArrayOutputStream();
   74.40 +        PrintStream ps = new PrintStream(out);
   74.41 +        ex.printStackTrace(ps);
   74.42 +        ps.flush();
   74.43 +        
   74.44 +        String s = new String(out.toByteArray(), "UTF-8");
   74.45 +        int newLine = s.indexOf('\n');
   74.46 +        return s.substring(0, newLine);
   74.47 +    }
   74.48 +
   74.49 +    @Compare public String firstLineIsTheSameWithWriter() throws UnsupportedEncodingException {
   74.50 +        MyException ex = new MyException("Hello");
   74.51 +        StringWriter sw = new StringWriter();
   74.52 +        PrintWriter pw = new PrintWriter(sw);
   74.53 +        ex.printStackTrace(pw);
   74.54 +        pw.flush();
   74.55 +        
   74.56 +        String s = sw.toString();
   74.57 +        int newLine = s.indexOf('\n');
   74.58 +        return s.substring(0, newLine);
   74.59 +    }
   74.60 +    
   74.61 +    static class MyException extends Exception {
   74.62 +        public MyException(String message) {
   74.63 +            super(message);
   74.64 +        }
   74.65 +    }
   74.66 +    
   74.67 +    
   74.68 +    @Factory public static Object[] create() {
   74.69 +        return VMTest.create(ExceptionsTest.class);
   74.70 +    }
   74.71 +}
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Wed Nov 19 19:32:00 2014 +0100
    75.3 @@ -0,0 +1,106 @@
    75.4 +/**
    75.5 + * Back 2 Browser Bytecode Translator
    75.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    75.7 + *
    75.8 + * This program is free software: you can redistribute it and/or modify
    75.9 + * it under the terms of the GNU General Public License as published by
   75.10 + * the Free Software Foundation, version 2 of the License.
   75.11 + *
   75.12 + * This program is distributed in the hope that it will be useful,
   75.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   75.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   75.15 + * GNU General Public License for more details.
   75.16 + *
   75.17 + * You should have received a copy of the GNU General Public License
   75.18 + * along with this program. Look for COPYING file in the top folder.
   75.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   75.20 + */
   75.21 +package org.apidesign.bck2brwsr.tck;
   75.22 +
   75.23 +import java.io.InputStream;
   75.24 +import java.net.URL;
   75.25 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   75.26 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   75.27 +import org.apidesign.bck2brwsr.vmtest.Http;
   75.28 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   75.29 +import org.testng.annotations.Factory;
   75.30 +
   75.31 +/**
   75.32 + *
   75.33 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   75.34 + */
   75.35 +public class HttpResourceTest {
   75.36 +    
   75.37 +    @Http({
   75.38 +        @Http.Resource(path = "/xhr", content = "Hello Brwsr!", mimeType = "text/plain")
   75.39 +    })
   75.40 +    @BrwsrTest
   75.41 +    
   75.42 +    
   75.43 +    public String testReadContentViaXHR() throws Exception {
   75.44 +        String msg = read("/xhr");
   75.45 +        assert "Hello Brwsr!".equals(msg) : "The message was " + msg;
   75.46 +        return msg;
   75.47 +    }
   75.48 +
   75.49 +    @Http({
   75.50 +        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   75.51 +    })
   75.52 +    @BrwsrTest
   75.53 +    public String testReadContentViaURL() throws Exception {
   75.54 +        URL url = new URL("http:/url");
   75.55 +        String msg = (String) url.getContent();
   75.56 +        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   75.57 +        return msg;
   75.58 +    }
   75.59 +    @Http({
   75.60 +        @Http.Resource(path = "/url", content = "Hello via URL!", mimeType = "text/plain")
   75.61 +    })
   75.62 +    @BrwsrTest
   75.63 +    public String testReadContentViaURLWithStringParam() throws Exception {
   75.64 +        URL url = new URL("http:/url");
   75.65 +        String msg = (String) url.getContent(new Class[] { String.class });
   75.66 +        assert "Hello via URL!".equals(msg) : "The message was " + msg;
   75.67 +        return msg;
   75.68 +    }
   75.69 +
   75.70 +    @Http({
   75.71 +        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   75.72 +    })
   75.73 +    @BrwsrTest
   75.74 +    public void testReadByte() throws Exception {
   75.75 +        URL url = new URL("http:/bytes");
   75.76 +        final Object res = url.getContent(new Class[] { byte[].class });
   75.77 +        assert res instanceof byte[] : "Expecting byte[]: " + res;
   75.78 +        byte[] arr = (byte[]) res;
   75.79 +        assert arr.length == 1 : "One byte " + arr.length;
   75.80 +        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   75.81 +    }
   75.82 +
   75.83 +    @Http({
   75.84 +        @Http.Resource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
   75.85 +    })
   75.86 +    @BrwsrTest
   75.87 +    public void testReadByteViaInputStream() throws Exception {
   75.88 +        URL url = new URL("http:/bytes");
   75.89 +        InputStream is = url.openStream();
   75.90 +        byte[] arr = new byte[10];
   75.91 +        int len = is.read(arr);
   75.92 +        assert len == 1 : "One byte " + len;
   75.93 +        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
   75.94 +    }
   75.95 +    
   75.96 +    @JavaScriptBody(args = { "url" }, body = 
   75.97 +          "var req = new XMLHttpRequest();\n"
   75.98 +        + "req.open('GET', url, false);\n"
   75.99 +        + "req.send();\n"
  75.100 +        + "return req.responseText;"
  75.101 +    )
  75.102 +    private static native String read(String url);
  75.103 +    
  75.104 +    
  75.105 +    @Factory
  75.106 +    public static Object[] create() {
  75.107 +        return VMTest.create(HttpResourceTest.class);
  75.108 +    }
  75.109 +}
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceA.java	Wed Nov 19 19:32:00 2014 +0100
    76.3 @@ -0,0 +1,34 @@
    76.4 +/**
    76.5 + * Back 2 Browser Bytecode Translator
    76.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    76.7 + *
    76.8 + * This program is free software: you can redistribute it and/or modify
    76.9 + * it under the terms of the GNU General Public License as published by
   76.10 + * the Free Software Foundation, version 2 of the License.
   76.11 + *
   76.12 + * This program is distributed in the hope that it will be useful,
   76.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   76.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   76.15 + * GNU General Public License for more details.
   76.16 + *
   76.17 + * You should have received a copy of the GNU General Public License
   76.18 + * along with this program. Look for COPYING file in the top folder.
   76.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   76.20 + */
   76.21 +package org.apidesign.bck2brwsr.tck;
   76.22 +
   76.23 +/**
   76.24 + *
   76.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   76.26 + */
   76.27 +public class InheritanceA {
   76.28 +    private String name;
   76.29 +    
   76.30 +    public void setA(String n) {
   76.31 +        this.name = n;
   76.32 +    }
   76.33 +    
   76.34 +    public String getA() {
   76.35 +        return name;
   76.36 +    }
   76.37 +}
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceB.java	Wed Nov 19 19:32:00 2014 +0100
    77.3 @@ -0,0 +1,34 @@
    77.4 +/**
    77.5 + * Back 2 Browser Bytecode Translator
    77.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    77.7 + *
    77.8 + * This program is free software: you can redistribute it and/or modify
    77.9 + * it under the terms of the GNU General Public License as published by
   77.10 + * the Free Software Foundation, version 2 of the License.
   77.11 + *
   77.12 + * This program is distributed in the hope that it will be useful,
   77.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   77.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   77.15 + * GNU General Public License for more details.
   77.16 + *
   77.17 + * You should have received a copy of the GNU General Public License
   77.18 + * along with this program. Look for COPYING file in the top folder.
   77.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   77.20 + */
   77.21 +package org.apidesign.bck2brwsr.tck;
   77.22 +
   77.23 +/**
   77.24 + *
   77.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   77.26 + */
   77.27 +public class InheritanceB extends InheritanceA {
   77.28 +    private String name;
   77.29 +    
   77.30 +    public void setB(String n) {
   77.31 +        this.name = n;
   77.32 +    }
   77.33 +    
   77.34 +    public String getB() {
   77.35 +        return name;
   77.36 +    }
   77.37 +}
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/InheritanceTest.java	Wed Nov 19 19:32:00 2014 +0100
    78.3 @@ -0,0 +1,41 @@
    78.4 +/**
    78.5 + * Back 2 Browser Bytecode Translator
    78.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    78.7 + *
    78.8 + * This program is free software: you can redistribute it and/or modify
    78.9 + * it under the terms of the GNU General Public License as published by
   78.10 + * the Free Software Foundation, version 2 of the License.
   78.11 + *
   78.12 + * This program is distributed in the hope that it will be useful,
   78.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   78.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   78.15 + * GNU General Public License for more details.
   78.16 + *
   78.17 + * You should have received a copy of the GNU General Public License
   78.18 + * along with this program. Look for COPYING file in the top folder.
   78.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   78.20 + */
   78.21 +package org.apidesign.bck2brwsr.tck;
   78.22 +
   78.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   78.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   78.25 +import org.testng.annotations.Factory;
   78.26 +
   78.27 +/**
   78.28 + *
   78.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   78.30 + */
   78.31 +public class InheritanceTest {
   78.32 +
   78.33 +    @Compare public String checkFieldsIndependent() throws ClassNotFoundException {
   78.34 +        InheritanceB ib = new InheritanceB();
   78.35 +        ib.setA("A");
   78.36 +        ib.setB("B");
   78.37 +        return "A: " + ib.getA() + " B: " + ib.getB();
   78.38 +    }
   78.39 +    
   78.40 +    @Factory
   78.41 +    public static Object[] create() {
   78.42 +        return VMTest.create(InheritanceTest.class);
   78.43 +    }
   78.44 +}
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Wed Nov 19 19:32:00 2014 +0100
    79.3 @@ -0,0 +1,166 @@
    79.4 +/**
    79.5 + * Back 2 Browser Bytecode Translator
    79.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    79.7 + *
    79.8 + * This program is free software: you can redistribute it and/or modify
    79.9 + * it under the terms of the GNU General Public License as published by
   79.10 + * the Free Software Foundation, version 2 of the License.
   79.11 + *
   79.12 + * This program is distributed in the hope that it will be useful,
   79.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   79.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   79.15 + * GNU General Public License for more details.
   79.16 + *
   79.17 + * You should have received a copy of the GNU General Public License
   79.18 + * along with this program. Look for COPYING file in the top folder.
   79.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   79.20 + */
   79.21 +package org.apidesign.bck2brwsr.tck;
   79.22 +
   79.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   79.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   79.25 +import org.testng.annotations.Factory;
   79.26 +
   79.27 +/**
   79.28 + *
   79.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   79.30 + */
   79.31 +public class IntegerArithmeticTest {
   79.32 +    
   79.33 +    private static int add(int x, int y) {
   79.34 +        return x + y;
   79.35 +    }
   79.36 +    
   79.37 +    private static int sub(int x, int y) {
   79.38 +        return x - y;
   79.39 +    }
   79.40 +    
   79.41 +    private static int mul(int x, int y) {
   79.42 +        return x * y;
   79.43 +    }
   79.44 +    
   79.45 +    private static int div(int x, int y) {
   79.46 +        return x / y;
   79.47 +    }
   79.48 +    
   79.49 +    private static int mod(int x, int y) {
   79.50 +        return x % y;
   79.51 +    }
   79.52 +    
   79.53 +    private static int neg(int x) {
   79.54 +        return (-x);
   79.55 +    }
   79.56 +
   79.57 +    private static float fadd(float x, float y) {
   79.58 +        return x + y;
   79.59 +    }
   79.60 +
   79.61 +    private static double dadd(double x, double y) {
   79.62 +        return x + y;
   79.63 +    }
   79.64 +    
   79.65 +    @Compare public int addOverflow() {
   79.66 +        return add(Integer.MAX_VALUE, 1);
   79.67 +    }
   79.68 +    
   79.69 +    @Compare public int subUnderflow() {
   79.70 +        return sub(Integer.MIN_VALUE, 1);
   79.71 +    }
   79.72 +    
   79.73 +    @Compare public int addMaxIntAndMaxInt() {
   79.74 +        return add(Integer.MAX_VALUE, Integer.MAX_VALUE);
   79.75 +    }
   79.76 +    
   79.77 +    @Compare public int subMinIntAndMinInt() {
   79.78 +        return sub(Integer.MIN_VALUE, Integer.MIN_VALUE);
   79.79 +    }
   79.80 +    
   79.81 +    @Compare public int multiplyMaxInt() {
   79.82 +        return mul(Integer.MAX_VALUE, 2);
   79.83 +    }
   79.84 +    
   79.85 +    @Compare public int multiplyMaxIntAndMaxInt() {
   79.86 +        return mul(Integer.MAX_VALUE, Integer.MAX_VALUE);
   79.87 +    }
   79.88 +    
   79.89 +    @Compare public int multiplyMinInt() {
   79.90 +        return mul(Integer.MIN_VALUE, 2);
   79.91 +    }
   79.92 +    
   79.93 +    @Compare public int multiplyMinIntAndMinInt() {
   79.94 +        return mul(Integer.MIN_VALUE, Integer.MIN_VALUE);
   79.95 +    }
   79.96 +    
   79.97 +    @Compare public int multiplyPrecision() {
   79.98 +        return mul(119106029, 1103515245);
   79.99 +    }
  79.100 +    
  79.101 +    @Compare public int division() {
  79.102 +        return div(1, 2);
  79.103 +    }
  79.104 +
  79.105 +    @Compare public int divisionReminder() {
  79.106 +        return mod(1, 2);
  79.107 +    }
  79.108 +
  79.109 +    @Compare public int negativeDivision() {
  79.110 +        return div(-7, 3);
  79.111 +    }
  79.112 +
  79.113 +    @Compare public int negativeDivisionReminder() {
  79.114 +        return mod(-7, 3);
  79.115 +    }
  79.116 +
  79.117 +    @Compare public int conversionFromFloat() {
  79.118 +        return (int) fadd(-2, -0.6f);
  79.119 +    }
  79.120 +
  79.121 +    @Compare public int conversionFromDouble() {
  79.122 +        return (int) dadd(-2, -0.6);
  79.123 +    }
  79.124 +
  79.125 +    @Compare public boolean divByZeroThrowsArithmeticException() {
  79.126 +        try {
  79.127 +            div(1, 0);
  79.128 +            return false;
  79.129 +        } catch (final ArithmeticException e) {
  79.130 +            return true;
  79.131 +        }
  79.132 +    }
  79.133 +
  79.134 +    @Compare public boolean modByZeroThrowsArithmeticException() {
  79.135 +        try {
  79.136 +            mod(1, 0);
  79.137 +            return false;
  79.138 +        } catch (final ArithmeticException e) {
  79.139 +            return true;
  79.140 +        }
  79.141 +    }
  79.142 +
  79.143 +    @Compare public int negate() {
  79.144 +        return neg(123456);
  79.145 +    }
  79.146 +    
  79.147 +    @Compare public int negateMaxInt() {
  79.148 +        return neg(Integer.MAX_VALUE);
  79.149 +    }
  79.150 +    
  79.151 +    @Compare public int negateMinInt() {
  79.152 +        return neg(Integer.MIN_VALUE);
  79.153 +    }
  79.154 +    
  79.155 +    @Compare public int sumTwoDimensions() {
  79.156 +        int[][] matrix = createMatrix(4, 3);
  79.157 +        matrix[0][0] += 10;
  79.158 +        return matrix[0][0];
  79.159 +    }
  79.160 +    
  79.161 +    static int[][] createMatrix(int x, int y) {
  79.162 +        return new int[x][y];
  79.163 +    }
  79.164 +    
  79.165 +    @Factory
  79.166 +    public static Object[] create() {
  79.167 +        return VMTest.create(IntegerArithmeticTest.class);
  79.168 +    }
  79.169 +}
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LoggerTest.java	Wed Nov 19 19:32:00 2014 +0100
    80.3 @@ -0,0 +1,43 @@
    80.4 +/**
    80.5 + * Back 2 Browser Bytecode Translator
    80.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    80.7 + *
    80.8 + * This program is free software: you can redistribute it and/or modify
    80.9 + * it under the terms of the GNU General Public License as published by
   80.10 + * the Free Software Foundation, version 2 of the License.
   80.11 + *
   80.12 + * This program is distributed in the hope that it will be useful,
   80.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   80.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   80.15 + * GNU General Public License for more details.
   80.16 + *
   80.17 + * You should have received a copy of the GNU General Public License
   80.18 + * along with this program. Look for COPYING file in the top folder.
   80.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   80.20 + */
   80.21 +package org.apidesign.bck2brwsr.tck;
   80.22 +
   80.23 +import java.util.logging.Logger;
   80.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   80.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   80.26 +import org.testng.annotations.Factory;
   80.27 +
   80.28 +/**
   80.29 + *
   80.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   80.31 + */
   80.32 +public class LoggerTest {
   80.33 +    @Compare public String parentLogger() {
   80.34 +        Logger lx = Logger.getLogger("x");
   80.35 +        assert lx != null;
   80.36 +        assert lx.getName().equals("x") : "Right name: " + lx.getName();
   80.37 +        Logger lxyz = Logger.getLogger("x.y.z");
   80.38 +        assert lxyz != null;
   80.39 +        assert lxyz.getName().equals("x.y.z") : "xyz name: " + lxyz.getName();
   80.40 +        return lxyz.getParent().getName();
   80.41 +    }
   80.42 +    
   80.43 +    @Factory public static Object[] create() {
   80.44 +        return VMTest.create(LoggerTest.class);
   80.45 +    }
   80.46 +}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Wed Nov 19 19:32:00 2014 +0100
    81.3 @@ -0,0 +1,418 @@
    81.4 +/**
    81.5 + * Back 2 Browser Bytecode Translator
    81.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    81.7 + *
    81.8 + * This program is free software: you can redistribute it and/or modify
    81.9 + * it under the terms of the GNU General Public License as published by
   81.10 + * the Free Software Foundation, version 2 of the License.
   81.11 + *
   81.12 + * This program is distributed in the hope that it will be useful,
   81.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   81.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   81.15 + * GNU General Public License for more details.
   81.16 + *
   81.17 + * You should have received a copy of the GNU General Public License
   81.18 + * along with this program. Look for COPYING file in the top folder.
   81.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   81.20 + */
   81.21 +package org.apidesign.bck2brwsr.tck;
   81.22 +
   81.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   81.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   81.25 +import org.testng.annotations.Factory;
   81.26 +
   81.27 +/**
   81.28 + *
   81.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   81.30 + */
   81.31 +public class LongArithmeticTest {
   81.32 +
   81.33 +    private static long add(long x, long y) {
   81.34 +        return (x + y);
   81.35 +    }
   81.36 +
   81.37 +    private static long sub(long x, long y) {
   81.38 +        return (x - y);
   81.39 +    }
   81.40 +
   81.41 +    private static long mul(long x, long y) {
   81.42 +        return (x * y);
   81.43 +    }
   81.44 +
   81.45 +    private static long div(long x, long y) {
   81.46 +        return (x / y);
   81.47 +    }
   81.48 +
   81.49 +    private static long mod(long x, long y) {
   81.50 +        return (x % y);
   81.51 +    }
   81.52 +
   81.53 +    private static long neg(long x) {
   81.54 +        return (-x);
   81.55 +    }
   81.56 +
   81.57 +    private static long shl(long x, int b) {
   81.58 +        return (x << b);
   81.59 +    }
   81.60 +
   81.61 +    private static long shr(long x, int b) {
   81.62 +        return (x >> b);
   81.63 +    }
   81.64 +
   81.65 +    private static long ushr(long x, int b) {
   81.66 +        return (x >>> b);
   81.67 +    }
   81.68 +
   81.69 +    private static long and(long x, long y) {
   81.70 +        return (x & y);
   81.71 +    }
   81.72 +
   81.73 +    private static long or(long x, long y) {
   81.74 +        return (x | y);
   81.75 +    }
   81.76 +
   81.77 +    private static long xor(long x, long y) {
   81.78 +        return (x ^ y);
   81.79 +    }
   81.80 +
   81.81 +    private static float fadd(float x, float y) {
   81.82 +        return x + y;
   81.83 +    }
   81.84 +
   81.85 +    private static double dadd(double x, double y) {
   81.86 +        return x + y;
   81.87 +    }
   81.88 +
   81.89 +    public static int compare(long x, long y, int zero) {
   81.90 +        final int xyResult = compareL(x, y, zero);
   81.91 +        final int yxResult = compareL(y, x, zero);
   81.92 +
   81.93 +        return ((xyResult + yxResult) == 0) ? xyResult : -2;
   81.94 +    }
   81.95 +
   81.96 +    private static int compareL(long x, long y, int zero) {
   81.97 +        int result = -2;
   81.98 +        int trueCount = 0;
   81.99 +
  81.100 +        x += zero;
  81.101 +        if (x == y) {
  81.102 +            result = 0;
  81.103 +            ++trueCount;
  81.104 +        }
  81.105 +
  81.106 +        x += zero;
  81.107 +        if (x < y) {
  81.108 +            result = -1;
  81.109 +            ++trueCount;
  81.110 +        }
  81.111 +
  81.112 +        x += zero;
  81.113 +        if (x > y) {
  81.114 +            result = 1;
  81.115 +            ++trueCount;
  81.116 +        }
  81.117 +
  81.118 +        return (trueCount == 1) ? result : -2;
  81.119 +    }
  81.120 +    
  81.121 +    @Compare public int parameterSlotCount() {
  81.122 +        long argCounts = 281479271874563L;
  81.123 +        int x = unpack(argCounts, 2);
  81.124 +        return x;
  81.125 +    }
  81.126 +    private static char unpack(long packed, int word) { // word==0 => return a, ==3 => return d
  81.127 +        assert(word <= 3);
  81.128 +        final long val = packed >> ((3-word) * 16);
  81.129 +        return (char)val;
  81.130 +    }
  81.131 +    @Compare public long conversion() {
  81.132 +        return Long.MAX_VALUE;
  81.133 +    }
  81.134 +
  81.135 +    @Compare public long negate1() {
  81.136 +        return neg(0x00fa37d7763e0ca1l);
  81.137 +    }
  81.138 +
  81.139 +    @Compare public long negate2() {
  81.140 +        return neg(0x80fa37d7763e0ca1l);
  81.141 +    }
  81.142 +
  81.143 +    @Compare public long negate3() {
  81.144 +        return neg(0xfffffffffffffeddl);
  81.145 +    }
  81.146 +
  81.147 +    @Compare public long addOverflow() {
  81.148 +        return add(Long.MAX_VALUE, 1l);
  81.149 +    }
  81.150 +
  81.151 +    @Compare public long subUnderflow() {
  81.152 +        return sub(Long.MIN_VALUE, 1l);
  81.153 +    }
  81.154 +
  81.155 +    @Compare public long addMaxLongAndMaxLong() {
  81.156 +        return add(Long.MAX_VALUE, Long.MAX_VALUE);
  81.157 +    }
  81.158 +
  81.159 +    @Compare public long subMinLongAndMinLong() {
  81.160 +        return sub(Long.MIN_VALUE, Long.MIN_VALUE);
  81.161 +    }
  81.162 +
  81.163 +    @Compare public long subMinLongAndMaxLong() {
  81.164 +        return sub(Long.MIN_VALUE, Long.MAX_VALUE);
  81.165 +    }
  81.166 +
  81.167 +    @Compare public long multiplyMaxLong() {
  81.168 +        return mul(Long.MAX_VALUE, 2l);
  81.169 +    }
  81.170 +
  81.171 +    @Compare public long multiplyMaxLongAndMaxLong() {
  81.172 +        return mul(Long.MAX_VALUE, Long.MAX_VALUE);
  81.173 +    }
  81.174 +
  81.175 +    @Compare public long multiplyMinLong() {
  81.176 +        return mul(Long.MIN_VALUE, 2l);
  81.177 +    }
  81.178 +
  81.179 +    @Compare public long multiplyMinLongAndMinLong() {
  81.180 +        return mul(Long.MIN_VALUE, Long.MIN_VALUE);
  81.181 +    }
  81.182 +
  81.183 +    @Compare public long multiplyPrecision() {
  81.184 +        return mul(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  81.185 +    }
  81.186 +
  81.187 +    @Compare public long divideSmallPositiveNumbers() {
  81.188 +        return div(0xabcdef, 0x123);
  81.189 +    }
  81.190 +
  81.191 +    @Compare public long divideSmallNegativeNumbers() {
  81.192 +        return div(-0xabcdef, -0x123);
  81.193 +    }
  81.194 +
  81.195 +    @Compare public long divideSmallMixedNumbers() {
  81.196 +        return div(0xabcdef, -0x123);
  81.197 +    }
  81.198 +
  81.199 +    @Compare public long dividePositiveNumbersOneDigitDenom() {
  81.200 +        return div(0xabcdef0102ffffl, 0x654);
  81.201 +    }
  81.202 +
  81.203 +    @Compare public long divideNegativeNumbersOneDigitDenom() {
  81.204 +        return div(-0xabcdef0102ffffl, -0x654);
  81.205 +    }
  81.206 +
  81.207 +    @Compare public long divideMixedNumbersOneDigitDenom() {
  81.208 +        return div(-0xabcdef0102ffffl, 0x654);
  81.209 +    }
  81.210 +
  81.211 +    @Compare public long dividePositiveNumbersMultiDigitDenom() {
  81.212 +        return div(0x7ffefc003322aabbl, 0x89ab1000l);
  81.213 +    }
  81.214 +
  81.215 +    @Compare public long divideNegativeNumbersMultiDigitDenom() {
  81.216 +        return div(-0x7ffefc003322aabbl, -0x123489ab1001l);
  81.217 +    }
  81.218 +
  81.219 +    @Compare public long divideMixedNumbersMultiDigitDenom() {
  81.220 +        return div(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  81.221 +    }
  81.222 +
  81.223 +    @Compare public long divideWithOverflow() {
  81.224 +        return div(0x8000fffe0000l, 0x8000ffffl);
  81.225 +    }
  81.226 +
  81.227 +    @Compare public long divideWithCorrection() {
  81.228 +        return div(0x7fff800000000000l, 0x800000000001l);
  81.229 +    }
  81.230 +
  81.231 +    @Compare public long moduloSmallPositiveNumbers() {
  81.232 +        return mod(0xabcdef, 0x123);
  81.233 +    }
  81.234 +
  81.235 +    @Compare public long moduloSmallNegativeNumbers() {
  81.236 +        return mod(-0xabcdef, -0x123);
  81.237 +    }
  81.238 +
  81.239 +    @Compare public long moduloSmallMixedNumbers() {
  81.240 +        return mod(0xabcdef, -0x123);
  81.241 +    }
  81.242 +
  81.243 +    @Compare public long moduloPositiveNumbersOneDigitDenom() {
  81.244 +        return mod(0xabcdef0102ffffl, 0x654);
  81.245 +    }
  81.246 +
  81.247 +    @Compare public long moduloNegativeNumbersOneDigitDenom() {
  81.248 +        return mod(-0xabcdef0102ffffl, -0x654);
  81.249 +    }
  81.250 +
  81.251 +    @Compare public long moduloMixedNumbersOneDigitDenom() {
  81.252 +        return mod(-0xabcdef0102ffffl, 0x654);
  81.253 +    }
  81.254 +
  81.255 +    @Compare public long moduloPositiveNumbersMultiDigitDenom() {
  81.256 +        return mod(0x7ffefc003322aabbl, 0x89ab1000l);
  81.257 +    }
  81.258 +
  81.259 +    @Compare public long moduloNegativeNumbersMultiDigitDenom() {
  81.260 +        return mod(-0x7ffefc003322aabbl, -0x123489ab1001l);
  81.261 +    }
  81.262 +
  81.263 +    @Compare public long moduloMixedNumbersMultiDigitDenom() {
  81.264 +        return mod(0x7ffefc003322aabbl, -0x38f49b0b7574e36l);
  81.265 +    }
  81.266 +
  81.267 +    @Compare public long moduloWithOverflow() {
  81.268 +        return mod(0x8000fffe0000l, 0x8000ffffl);
  81.269 +    }
  81.270 +
  81.271 +    @Compare public long moduloWithCorrection() {
  81.272 +        return mod(0x7fff800000000000l, 0x800000000001l);
  81.273 +    }
  81.274 +
  81.275 +    @Compare public long conversionFromFloatPositive() {
  81.276 +        return (long) fadd(2, 0.6f);
  81.277 +    }
  81.278 +
  81.279 +    @Compare public long conversionFromFloatNegative() {
  81.280 +        return (long) fadd(-2, -0.6f);
  81.281 +    }
  81.282 +
  81.283 +    @Compare public long conversionFromDoublePositive() {
  81.284 +        return (long) dadd(0x20ffff0000L, 0.6);
  81.285 +    }
  81.286 +
  81.287 +    @Compare public long conversionFromDoubleNegative() {
  81.288 +        return (long) dadd(-0x20ffff0000L, -0.6);
  81.289 +    }
  81.290 +
  81.291 +    @Compare public boolean divByZeroThrowsArithmeticException() {
  81.292 +        try {
  81.293 +            div(1, 0);
  81.294 +            return false;
  81.295 +        } catch (final ArithmeticException e) {
  81.296 +            return true;
  81.297 +        }
  81.298 +    }
  81.299 +
  81.300 +    @Compare public boolean modByZeroThrowsArithmeticException() {
  81.301 +        try {
  81.302 +            mod(1, 0);
  81.303 +            return false;
  81.304 +        } catch (final ArithmeticException e) {
  81.305 +            return true;
  81.306 +        }
  81.307 +    }
  81.308 +
  81.309 +    @Compare public long shiftL1() {
  81.310 +        return shl(0x00fa37d7763e0ca1l, 5);
  81.311 +    }
  81.312 +
  81.313 +    @Compare public long shiftL2() {
  81.314 +        return shl(0x00fa37d7763e0ca1l, 32);
  81.315 +    }
  81.316 +
  81.317 +    @Compare public long shiftL3() {
  81.318 +        return shl(0x00fa37d7763e0ca1l, 45);
  81.319 +    }
  81.320 +    
  81.321 +    @Compare public long shiftL4() {
  81.322 +        return shl(0x00fa37d7763e0ca1l, 0);
  81.323 +    }
  81.324 +    
  81.325 +    @Compare public long shiftL5() {
  81.326 +        return shl(0x00fa37d7763e0ca1l, 70);
  81.327 +    }
  81.328 +
  81.329 +    @Compare public long shiftR1() {
  81.330 +        return shr(0x00fa37d7763e0ca1l, 5);
  81.331 +    }
  81.332 +
  81.333 +    @Compare public long shiftR2() {
  81.334 +        return shr(0x00fa37d7763e0ca1l, 32);
  81.335 +    }
  81.336 +
  81.337 +    @Compare public long shiftR3() {
  81.338 +        return shr(0x00fa37d7763e0ca1l, 45);
  81.339 +    }
  81.340 +    
  81.341 +    @Compare public long shiftR4() {
  81.342 +        return shr(0x00fa37d7763e0ca1l, 0);
  81.343 +    }
  81.344 +    
  81.345 +    @Compare public long shiftR5() {
  81.346 +        return shr(0x00fa37d7763e0ca1l, 70);
  81.347 +    }
  81.348 +
  81.349 +    @Compare public long uShiftR1() {
  81.350 +        return ushr(0x00fa37d7763e0ca1l, 5);
  81.351 +    }
  81.352 +
  81.353 +    @Compare public long uShiftR2() {
  81.354 +        return ushr(0x00fa37d7763e0ca1l, 45);
  81.355 +    }
  81.356 +    
  81.357 +    @Compare public long uShiftR3() {
  81.358 +        return ushr(0x00fa37d7763e0ca1l, 0);
  81.359 +    }
  81.360 +    
  81.361 +    @Compare public long uShiftR4() {
  81.362 +        return ushr(0x00fa37d7763e0ca1l, 70);
  81.363 +    }
  81.364 +
  81.365 +    @Compare public long uShiftR5() {
  81.366 +        return ushr(0xf0fa37d7763e0ca1l, 5);
  81.367 +    }
  81.368 +
  81.369 +    @Compare public long uShiftR6() {
  81.370 +        return ushr(0xf0fa37d7763e0ca1l, 45);
  81.371 +    }
  81.372 +    
  81.373 +    @Compare public long uShiftR7() {
  81.374 +        return ushr(0xf0fa37d7763e0ca1l, 0);
  81.375 +    }
  81.376 +    
  81.377 +    @Compare public long uShiftR8() {
  81.378 +        return ushr(0xf0fa37d7763e0ca1l, 70);
  81.379 +    }
  81.380 +
  81.381 +    @Compare public long and1() {
  81.382 +        return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  81.383 +    }
  81.384 +
  81.385 +    @Compare public long or1() {
  81.386 +        return or(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  81.387 +    }
  81.388 +
  81.389 +    @Compare public long xor1() {
  81.390 +        return xor(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  81.391 +    }
  81.392 +
  81.393 +    @Compare public long xor2() {
  81.394 +        return xor(0x00fa37d7763e0ca1l, 0x00000000ff00123el);
  81.395 +    }
  81.396 +
  81.397 +    @Compare public long xor3() {
  81.398 +        return xor(0x00000000763e0ca1l, 0x00000000ff00123el);
  81.399 +    }
  81.400 +
  81.401 +    @Compare public int compareSameNumbers() {
  81.402 +        return compare(0x0000000000000000l, 0x0000000000000000l, 0);
  81.403 +    }
  81.404 +
  81.405 +    @Compare public int comparePositiveNumbers() {
  81.406 +        return compare(0x0000000000200000l, 0x0000000010000000l, 0);
  81.407 +    }
  81.408 +
  81.409 +    @Compare public int compareNegativeNumbers() {
  81.410 +        return compare(0xffffffffffffffffl, 0xffffffff00000000l, 0);
  81.411 +    }
  81.412 +
  81.413 +    @Compare public int compareMixedNumbers() {
  81.414 +        return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
  81.415 +    }
  81.416 +    
  81.417 +    @Factory
  81.418 +    public static Object[] create() {
  81.419 +        return VMTest.create(LongArithmeticTest.class);
  81.420 +    }
  81.421 +}
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java	Wed Nov 19 19:32:00 2014 +0100
    82.3 @@ -0,0 +1,63 @@
    82.4 +/**
    82.5 + * Back 2 Browser Bytecode Translator
    82.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    82.7 + *
    82.8 + * This program is free software: you can redistribute it and/or modify
    82.9 + * it under the terms of the GNU General Public License as published by
   82.10 + * the Free Software Foundation, version 2 of the License.
   82.11 + *
   82.12 + * This program is distributed in the hope that it will be useful,
   82.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   82.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   82.15 + * GNU General Public License for more details.
   82.16 + *
   82.17 + * You should have received a copy of the GNU General Public License
   82.18 + * along with this program. Look for COPYING file in the top folder.
   82.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   82.20 + */
   82.21 +package org.apidesign.bck2brwsr.tck;
   82.22 +
   82.23 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   82.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
   82.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   82.26 +import org.testng.annotations.Factory;
   82.27 +
   82.28 +/**
   82.29 + *
   82.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   82.31 + */
   82.32 +public class NotifyWaitTest {
   82.33 +    
   82.34 +
   82.35 +    @Compare public synchronized String canCallNotify() throws Exception {
   82.36 +        notify();
   82.37 +        return "OK";
   82.38 +    }
   82.39 +
   82.40 +    @Compare public synchronized String canCallNotifyAll() throws Exception {
   82.41 +        notifyAll();
   82.42 +        return "OK";
   82.43 +    }
   82.44 +    
   82.45 +    @BrwsrTest public synchronized String throwsInterruptedException() {
   82.46 +        try {
   82.47 +            wait();
   82.48 +            throw new IllegalStateException();
   82.49 +        } catch (InterruptedException ex) {
   82.50 +            return "OK";
   82.51 +        }
   82.52 +    }
   82.53 +
   82.54 +    @BrwsrTest public synchronized String waitMsThrowsInterruptedException() {
   82.55 +        try {
   82.56 +            wait(32);
   82.57 +            throw new IllegalStateException();
   82.58 +        } catch (InterruptedException ex) {
   82.59 +            return "OK";
   82.60 +        }
   82.61 +    }
   82.62 +    
   82.63 +    @Factory public static Object[] create() {
   82.64 +        return VMTest.create(NotifyWaitTest.class);
   82.65 +    }
   82.66 +}
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ProxyTest.java	Wed Nov 19 19:32:00 2014 +0100
    83.3 @@ -0,0 +1,71 @@
    83.4 +/**
    83.5 + * Back 2 Browser Bytecode Translator
    83.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    83.7 + *
    83.8 + * This program is free software: you can redistribute it and/or modify
    83.9 + * it under the terms of the GNU General Public License as published by
   83.10 + * the Free Software Foundation, version 2 of the License.
   83.11 + *
   83.12 + * This program is distributed in the hope that it will be useful,
   83.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   83.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   83.15 + * GNU General Public License for more details.
   83.16 + *
   83.17 + * You should have received a copy of the GNU General Public License
   83.18 + * along with this program. Look for COPYING file in the top folder.
   83.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   83.20 + */
   83.21 +package org.apidesign.bck2brwsr.tck;
   83.22 +
   83.23 +import java.lang.reflect.InvocationHandler;
   83.24 +import java.lang.reflect.Method;
   83.25 +import java.lang.reflect.Proxy;
   83.26 +import org.apidesign.bck2brwsr.vmtest.Compare;
   83.27 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   83.28 +import org.testng.annotations.Factory;
   83.29 +
   83.30 +/**
   83.31 + *
   83.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   83.33 + */
   83.34 +public class ProxyTest {
   83.35 +    @Compare public String generateAnnotation() throws Exception {
   83.36 +        class InvHandler implements InvocationHandler {
   83.37 +            @Override
   83.38 +            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   83.39 +                return "Joe Hacker";
   83.40 +            }
   83.41 +        }
   83.42 +        Anno anno = (Anno) Proxy.newProxyInstance(
   83.43 +            Anno.class.getClassLoader(), 
   83.44 +            new Class[] { Anno.class }, 
   83.45 +            new InvHandler()
   83.46 +        );
   83.47 +        return anno.name();
   83.48 +    }
   83.49 +
   83.50 +    @Compare public int getPrimitiveType() throws Exception {
   83.51 +        class InvHandler implements InvocationHandler {
   83.52 +            @Override
   83.53 +            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   83.54 +                return 40;
   83.55 +            }
   83.56 +        }
   83.57 +        Anno anno = (Anno) Proxy.newProxyInstance(
   83.58 +            Anno.class.getClassLoader(), 
   83.59 +            new Class[] { Anno.class }, 
   83.60 +            new InvHandler()
   83.61 +        );
   83.62 +        return 2 + anno.age();
   83.63 +    }
   83.64 +    
   83.65 +    public static @interface Anno {
   83.66 +        public String name();
   83.67 +        public int age();
   83.68 +    }
   83.69 +    
   83.70 +    @Factory
   83.71 +    public static Object[] create() {
   83.72 +        return VMTest.create(ProxyTest.class);
   83.73 +    }
   83.74 +}
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionArrayTest.java	Wed Nov 19 19:32:00 2014 +0100
    84.3 @@ -0,0 +1,166 @@
    84.4 +/**
    84.5 + * Back 2 Browser Bytecode Translator
    84.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    84.7 + *
    84.8 + * This program is free software: you can redistribute it and/or modify
    84.9 + * it under the terms of the GNU General Public License as published by
   84.10 + * the Free Software Foundation, version 2 of the License.
   84.11 + *
   84.12 + * This program is distributed in the hope that it will be useful,
   84.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   84.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   84.15 + * GNU General Public License for more details.
   84.16 + *
   84.17 + * You should have received a copy of the GNU General Public License
   84.18 + * along with this program. Look for COPYING file in the top folder.
   84.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   84.20 + */
   84.21 +package org.apidesign.bck2brwsr.tck;
   84.22 +
   84.23 +import java.lang.reflect.Array;
   84.24 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   84.25 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
   84.26 +import org.apidesign.bck2brwsr.vmtest.Compare;
   84.27 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   84.28 +import org.testng.annotations.Factory;
   84.29 +
   84.30 +/**
   84.31 + *
   84.32 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   84.33 + */
   84.34 +public class ReflectionArrayTest {
   84.35 +    @Compare public int lengthOfStringArray() {
   84.36 +        String[] arr = (String[]) Array.newInstance(String.class, 10);
   84.37 +        return arr.length;
   84.38 +    }
   84.39 +    
   84.40 +    @Compare public String indexOutOfBounds() {
   84.41 +        String[] arr = { null, null };
   84.42 +        return arr[2];
   84.43 +    }
   84.44 +    
   84.45 +    @Compare public int reflectiveLengthOfStringArray() {
   84.46 +        Object arr = Array.newInstance(String.class, 10);
   84.47 +        return Array.getLength(arr);
   84.48 +    }
   84.49 +
   84.50 +    @Compare public int reflectiveLengthOneNonArray() {
   84.51 +        Object arr = "non-array";
   84.52 +        return Array.getLength(arr);
   84.53 +    }
   84.54 +
   84.55 +    @Compare public String compTypeOfStringArray() {
   84.56 +        String[] arr = (String[]) Array.newInstance(String.class, 10);
   84.57 +        return arr.getClass().getComponentType().getName();
   84.58 +    }
   84.59 +
   84.60 +    @Compare public Object negativeArrayExcp() {
   84.61 +        return Array.newInstance(String.class, -5);
   84.62 +    }
   84.63 +    
   84.64 +    @Compare public int lengthOfIntArray() {
   84.65 +        int[] arr = (int[]) Array.newInstance(Integer.TYPE, 10);
   84.66 +        return arr.length;
   84.67 +    }
   84.68 +
   84.69 +    @Compare public int reflectiveLengthOfIntArray() {
   84.70 +        Object arr = Array.newInstance(Integer.TYPE, 10);
   84.71 +        return Array.getLength(arr);
   84.72 +    }
   84.73 +
   84.74 +    @Compare public String compTypeOfIntArray() {
   84.75 +        int[] arr = (int[]) Array.newInstance(int.class, 10);
   84.76 +        return arr.getClass().getComponentType().getName();
   84.77 +    }
   84.78 +
   84.79 +    @Compare public Object intNegativeArrayExcp() {
   84.80 +        return Array.newInstance(int.class, -5);
   84.81 +    }
   84.82 +
   84.83 +    @Compare public Integer verifyAutobox() {
   84.84 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   84.85 +        return (Integer) Array.get(arr, 0);
   84.86 +    }
   84.87 +    @Compare public String verifyObjectArray() {
   84.88 +        String[] arr = (String[]) Array.newInstance(String.class, 5);
   84.89 +        Array.set(arr, 0, "Hello");
   84.90 +        return (String) Array.get(arr, 0);
   84.91 +    }
   84.92 +    @Compare public int verifyInt() {
   84.93 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   84.94 +        return Array.getInt(arr, 0);
   84.95 +    }
   84.96 +    @Compare public long verifyConvertToLong() {
   84.97 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
   84.98 +        return Array.getLong(arr, 0);
   84.99 +    }
  84.100 +
  84.101 +    @Compare public Object verifySetIntToObject() {
  84.102 +        try {
  84.103 +            Object[] arr = (Object[]) Array.newInstance(Object.class, 5);
  84.104 +            Array.setInt(arr, 0, 10);
  84.105 +            return Array.get(arr, 0);
  84.106 +        } catch (Exception exception) {
  84.107 +            return exception.getClass().getName();
  84.108 +        }
  84.109 +    }
  84.110 +    @Compare public long verifySetShort() {
  84.111 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  84.112 +        Array.setShort(arr, 0, (short)10);
  84.113 +        return Array.getLong(arr, 0);
  84.114 +    }
  84.115 +    @Compare public long verifyCantSetLong() {
  84.116 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  84.117 +        Array.setLong(arr, 0, 10);
  84.118 +        return Array.getLong(arr, 0);
  84.119 +    }
  84.120 +    @Compare public float verifyLongToFloat() {
  84.121 +        Object arr = Array.newInstance(float.class, 5);
  84.122 +        Array.setLong(arr, 0, 10);
  84.123 +        return Array.getFloat(arr, 0);
  84.124 +    }
  84.125 +
  84.126 +    @Compare public double verifyConvertToDouble() {
  84.127 +        int[] arr = (int[]) Array.newInstance(int.class, 5);
  84.128 +        return Array.getDouble(arr, 0);
  84.129 +    }
  84.130 +    
  84.131 +    @Compare public int multiIntArray() {
  84.132 +        int[][][] arr = (int[][][]) Array.newInstance(int.class, 3, 3, 3);
  84.133 +        return arr[0][1][2] + 5 + arr[2][2][0];
  84.134 +    }
  84.135 +
  84.136 +    @Compare public String multiIntArrayCompType() {
  84.137 +        return Array.newInstance(int.class, 3, 3, 3).getClass().getName();
  84.138 +    }
  84.139 +    
  84.140 +    @JavaScriptBody(args = {}, body = "return [1, 2];")
  84.141 +    private static native Object crtarr();
  84.142 +
  84.143 +    @JavaScriptBody(args = {}, body = "return new Object();")
  84.144 +    private static native Object newobj();
  84.145 +
  84.146 +    @BrwsrTest
  84.147 +    public static void toStringArray() {
  84.148 +        final Object arr = crtarr();
  84.149 +        final Object real = new Object[2];
  84.150 +        assert arr instanceof Object[] : "Any array is Java array: " + arr;
  84.151 +        assert arr.getClass() == real.getClass() : "Same classes " + arr + " and " + real.getClass();
  84.152 +        final String str = arr.toString();
  84.153 +        assert str != null;
  84.154 +        assert str.startsWith("[Ljava.lang.Object;@") : str;
  84.155 +    }
  84.156 +    
  84.157 +    @BrwsrTest
  84.158 +    public static void objectToString() {
  84.159 +        String s = newobj().toString();
  84.160 +        assert s != null : "Some string computed";
  84.161 +        assert s.startsWith("java.lang.Object@") : "Regular object toString(): " + s;
  84.162 +    }
  84.163 +
  84.164 +    
  84.165 +    @Factory
  84.166 +    public static Object[] create() {
  84.167 +        return VMTest.create(ReflectionArrayTest.class);
  84.168 +    }
  84.169 +}
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Wed Nov 19 19:32:00 2014 +0100
    85.3 @@ -0,0 +1,315 @@
    85.4 +/**
    85.5 + * Back 2 Browser Bytecode Translator
    85.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    85.7 + *
    85.8 + * This program is free software: you can redistribute it and/or modify
    85.9 + * it under the terms of the GNU General Public License as published by
   85.10 + * the Free Software Foundation, version 2 of the License.
   85.11 + *
   85.12 + * This program is distributed in the hope that it will be useful,
   85.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   85.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   85.15 + * GNU General Public License for more details.
   85.16 + *
   85.17 + * You should have received a copy of the GNU General Public License
   85.18 + * along with this program. Look for COPYING file in the top folder.
   85.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   85.20 + */
   85.21 +package org.apidesign.bck2brwsr.tck;
   85.22 +
   85.23 +import java.lang.annotation.Retention;
   85.24 +import java.lang.annotation.RetentionPolicy;
   85.25 +import java.lang.reflect.Constructor;
   85.26 +import java.lang.reflect.Method;
   85.27 +import java.lang.reflect.Proxy;
   85.28 +import java.util.Arrays;
   85.29 +import java.util.Collections;
   85.30 +import java.util.List;
   85.31 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
   85.32 +import org.apidesign.bck2brwsr.vmtest.Compare;
   85.33 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   85.34 +import org.testng.annotations.Factory;
   85.35 +
   85.36 +/**
   85.37 + *
   85.38 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   85.39 + */
   85.40 +public class ReflectionTest {
   85.41 +    @Compare public boolean nonNullThis() {
   85.42 +        return this == null;
   85.43 +    }
   85.44 +    
   85.45 +    @Compare public String intType() {
   85.46 +        return Integer.TYPE.toString();
   85.47 +    }
   85.48 +
   85.49 +    @Compare public String voidType() throws Exception {
   85.50 +        return void.class.toString();
   85.51 +    }
   85.52 +
   85.53 +    @Compare public String longClass() {
   85.54 +        return long.class.toString();
   85.55 +    }
   85.56 +    
   85.57 +    @Compare public boolean isRunnableInterface() {
   85.58 +        return Runnable.class.isInterface();
   85.59 +    }
   85.60 +
   85.61 +    @Compare public boolean isAssignableToPrimitiveType() {
   85.62 +        return boolean.class.isAssignableFrom(Runnable.class);
   85.63 +    }
   85.64 +
   85.65 +    @Compare public boolean isAssignableFromPrimitiveType() {
   85.66 +        return Runnable.class.isAssignableFrom(boolean.class);
   85.67 +    }
   85.68 +
   85.69 +    @Compare public boolean isAssignableLongFromInt() {
   85.70 +        return long.class.isAssignableFrom(int.class);
   85.71 +    }
   85.72 +
   85.73 +    @Compare public boolean isAssignableIntFromLong() {
   85.74 +        return int.class.isAssignableFrom(long.class);
   85.75 +    }
   85.76 +
   85.77 +    @Compare public String isRunnableHasRunMethod() throws NoSuchMethodException {
   85.78 +        return Runnable.class.getMethod("run").getName();
   85.79 +    }
   85.80 +
   85.81 +    @Compare public String isRunnableDeclaresRunMethod() throws NoSuchMethodException {
   85.82 +        return Runnable.class.getDeclaredMethod("run").getName();
   85.83 +    }
   85.84 +    
   85.85 +    @Compare public String intValue() throws Exception {
   85.86 +        return Integer.class.getConstructor(int.class).newInstance(10).toString();
   85.87 +    }
   85.88 +    
   85.89 +    @Compare public String getMethodWithArray() throws Exception {
   85.90 +        return Proxy.class.getMethod("getProxyClass", ClassLoader.class, Class[].class).getName();
   85.91 +    }
   85.92 +    
   85.93 +    @Compare public String namesOfMethods() {
   85.94 +        StringBuilder sb = new StringBuilder();
   85.95 +        String[] arr = new String[20];
   85.96 +        int i = 0;
   85.97 +        for (Method m : StaticUse.class.getMethods()) {
   85.98 +            arr[i++] = m.getName();
   85.99 +        }
  85.100 +        for (String s : sort(arr, i)) {
  85.101 +            sb.append(s).append("\n");
  85.102 +        }
  85.103 +        return sb.toString();
  85.104 +    }
  85.105 +
  85.106 +    @Compare public String paramsOfConstructors() {
  85.107 +        StringBuilder sb = new StringBuilder();
  85.108 +        String[] arr = new String[20];
  85.109 +        int i = 0;
  85.110 +        for (Constructor<?> m : StaticUse.class.getConstructors()) {
  85.111 +            arr[i++] = m.getName();
  85.112 +        }
  85.113 +        for (String s : sort(arr, i)) {
  85.114 +            sb.append(s).append("\n");
  85.115 +        }
  85.116 +        return sb.toString();
  85.117 +    }
  85.118 +
  85.119 +    @Compare public String namesOfDeclaringClassesOfMethods() {
  85.120 +        StringBuilder sb = new StringBuilder();
  85.121 +        String[] arr = new String[20];
  85.122 +        int i = 0;
  85.123 +        for (Method m : StaticUse.class.getMethods()) {
  85.124 +            arr[i++] = m.getName() + "@" + m.getDeclaringClass().getName();
  85.125 +        }
  85.126 +        for (String s : sort(arr, i)) {
  85.127 +            sb.append(s).append("\n");
  85.128 +        }
  85.129 +        return sb.toString();
  85.130 +    }
  85.131 +    
  85.132 +    @Compare public String cannotCallNonStaticMethodWithNull() throws Exception {
  85.133 +        StaticUse.class.getMethod("instanceMethod").invoke(null);
  85.134 +        return "should not happen";
  85.135 +    }
  85.136 +    
  85.137 +    @Compare public String classCastException() {
  85.138 +        try {
  85.139 +            Integer i = (Integer)StaticUseSub.getNonNull();
  85.140 +            return "" + i.intValue();
  85.141 +        } catch (ClassCastException ex) {
  85.142 +            return ex.getClass().getName();
  85.143 +        }
  85.144 +    }
  85.145 +
  85.146 +    @Compare public String methodThatThrowsException() throws Exception {
  85.147 +        StaticUse.class.getMethod("instanceMethod").invoke(new StaticUse());
  85.148 +        return "should not happen";
  85.149 +    }
  85.150 +
  85.151 +    @Compare public Object voidReturnType() throws Exception {
  85.152 +        return StaticUse.class.getMethod("instanceMethod").getReturnType();
  85.153 +    }
  85.154 +    
  85.155 +    @Retention(RetentionPolicy.RUNTIME)
  85.156 +    @interface Ann {
  85.157 +    }
  85.158 +    
  85.159 +    @Compare public String annoClass() throws Exception {
  85.160 +        Retention r = Ann.class.getAnnotation(Retention.class);
  85.161 +        assert r != null : "Annotation is present";
  85.162 +        assert r.value() == RetentionPolicy.RUNTIME : "Policy value is OK: " + r.value();
  85.163 +        return r.annotationType().getName();
  85.164 +    }
  85.165 +    
  85.166 +    @Compare public boolean isAnnotation() {
  85.167 +        return Ann.class.isAnnotation();
  85.168 +    }
  85.169 +    @Compare public boolean isNotAnnotation() {
  85.170 +        return String.class.isAnnotation();
  85.171 +    }
  85.172 +    @Compare public boolean isNotAnnotationEnum() {
  85.173 +        return E.class.isAnnotation();
  85.174 +    }
  85.175 +    enum E { A, B };
  85.176 +    @Compare public boolean isEnum() {
  85.177 +        return E.A.getClass().isEnum();
  85.178 +    }
  85.179 +
  85.180 +    @Compare public boolean isNotEnum() {
  85.181 +        return "".getClass().isEnum();
  85.182 +    }
  85.183 +    
  85.184 +    @Compare public String newInstanceFails() {
  85.185 +        try {
  85.186 +            return "success: " + StaticUseSub.class.newInstance();
  85.187 +        } catch (IllegalAccessException ex) {
  85.188 +            return "failure";
  85.189 +        } catch (InstantiationException ex) {
  85.190 +            return "failure";
  85.191 +        }
  85.192 +    }
  85.193 +    
  85.194 +    @Compare public String paramTypes() throws Exception {
  85.195 +        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  85.196 +        final Class[] pt = plus.getParameterTypes();
  85.197 +        return pt[0].getName();
  85.198 +    }
  85.199 +    @Compare public String paramTypesNotFound() throws Exception {
  85.200 +        return StaticUse.class.getMethod("plus", int.class, double.class).toString();
  85.201 +    }
  85.202 +    @Compare public int methodWithArgs() throws Exception {
  85.203 +        Method plus = StaticUse.class.getMethod("plus", int.class, Integer.TYPE);
  85.204 +        return (Integer)plus.invoke(null, 2, 3);
  85.205 +    }
  85.206 +    
  85.207 +    @Compare public String classGetNameForByte() {
  85.208 +         return byte.class.getName();
  85.209 +    }
  85.210 +    @Compare public String classGetNameForBaseObject() {
  85.211 +        return newObject().getClass().getName();
  85.212 +    }
  85.213 +    @Compare public String classGetNameForJavaObject() {
  85.214 +        return new Object().getClass().getName();
  85.215 +    }
  85.216 +    @Compare public String classGetNameForObjectArray() {
  85.217 +        return (new Object[3]).getClass().getName();
  85.218 +    }
  85.219 +    @Compare public String classGetNameForSimpleIntArray() {
  85.220 +        return (new int[3]).getClass().getName();
  85.221 +    }
  85.222 +    @Compare public boolean sameClassGetNameForSimpleCharArray() {
  85.223 +        return (new char[3]).getClass() == (new char[34]).getClass();
  85.224 +    }
  85.225 +    @Compare public String classGetNameForMultiIntArray() {
  85.226 +        return (new int[3][4][5][6][7][8][9]).getClass().getName();
  85.227 +    }
  85.228 +    @Compare public String classGetNameForMultiIntArrayInner() {
  85.229 +        final int[][][][][][][] arr = new int[3][4][5][6][7][8][9];
  85.230 +        int[][][][][][] subarr = arr[0];
  85.231 +        int[][][][][] subsubarr = subarr[0];
  85.232 +        return subsubarr.getClass().getName();
  85.233 +    }
  85.234 +    @Compare public String classGetNameForMultiStringArray() {
  85.235 +        return (new String[3][4][5][6][7][8][9]).getClass().getName();
  85.236 +    }
  85.237 +    
  85.238 +    @Compare public String classForByte() throws Exception {
  85.239 +        return Class.forName("[Z").getName();
  85.240 +    }
  85.241 +
  85.242 +    @Compare public String classForUnknownArray() {
  85.243 +        try {
  85.244 +            return Class.forName("[W").getName();
  85.245 +        } catch (Exception ex) {
  85.246 +            return ex.getClass().getName();
  85.247 +        }
  85.248 +    }
  85.249 +    
  85.250 +    @Compare public String classForUnknownDeepArray() {
  85.251 +        try {
  85.252 +            return Class.forName("[[[[[W").getName();
  85.253 +        } catch (Exception ex) {
  85.254 +            return ex.getClass().getName();
  85.255 +        }
  85.256 +    }
  85.257 +    
  85.258 +    @Compare public int callAbst() throws Exception {
  85.259 +        class Impl extends Abst {
  85.260 +            @Override
  85.261 +            public int abst() {
  85.262 +                return 10;
  85.263 +            }
  85.264 +        }
  85.265 +        Abst impl = new Impl();
  85.266 +        return (int) Abst.class.getMethod("abst").invoke(impl);
  85.267 +    }
  85.268 +    
  85.269 +    @Compare public String componentGetNameForObjectArray() {
  85.270 +        return (new Object[3]).getClass().getComponentType().getName();
  85.271 +    }
  85.272 +    @Compare public boolean sameComponentGetNameForObjectArray() {
  85.273 +        return (new Object[3]).getClass().getComponentType() == Object.class;
  85.274 +    }
  85.275 +    @Compare public String componentGetNameForSimpleIntArray() {
  85.276 +        return (new int[3]).getClass().getComponentType().getName();
  85.277 +    }
  85.278 +    @Compare public String componentGetNameForMultiIntArray() {
  85.279 +        return (new int[3][4][5][6][7][8][9]).getClass().getComponentType().getName();
  85.280 +    }
  85.281 +    @Compare public String componentGetNameForMultiStringArray() {
  85.282 +        Class<?> c = (new String[3][4][5][6][7][8][9]).getClass();
  85.283 +        StringBuilder sb = new StringBuilder();
  85.284 +        for (;;) {
  85.285 +            sb.append(c.getName()).append("\n");
  85.286 +            c = c.getComponentType();
  85.287 +            if (c == null) {
  85.288 +                break;
  85.289 +            }
  85.290 +        }
  85.291 +        return sb.toString();
  85.292 +    }
  85.293 +    
  85.294 +    @Compare public boolean isArray() {
  85.295 +        return new Object[0].getClass().isArray();
  85.296 +    }
  85.297 +    
  85.298 +    @JavaScriptBody(args = { "arr", "len" }, body="var a = arr.slice(0, len); a.sort(); return a;")
  85.299 +    private static String[] sort(String[] arr, int len) {
  85.300 +        List<String> list = Arrays.asList(arr).subList(0, len);
  85.301 +        Collections.sort(list);
  85.302 +        return list.toArray(new String[0]);
  85.303 +    }
  85.304 +    
  85.305 +    @JavaScriptBody(args = {}, body = "return new Object();")
  85.306 +    private static Object newObject() {
  85.307 +        return new Object();
  85.308 +    }
  85.309 +    
  85.310 +    @Factory
  85.311 +    public static Object[] create() {
  85.312 +        return VMTest.create(ReflectionTest.class);
  85.313 +    }
  85.314 +    
  85.315 +    public static abstract class Abst {
  85.316 +        public abstract int abst();
  85.317 +    }
  85.318 +}
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/RegExpReplaceAllTest.java	Wed Nov 19 19:32:00 2014 +0100
    86.3 @@ -0,0 +1,54 @@
    86.4 +/**
    86.5 + * Back 2 Browser Bytecode Translator
    86.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    86.7 + *
    86.8 + * This program is free software: you can redistribute it and/or modify
    86.9 + * it under the terms of the GNU General Public License as published by
   86.10 + * the Free Software Foundation, version 2 of the License.
   86.11 + *
   86.12 + * This program is distributed in the hope that it will be useful,
   86.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   86.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   86.15 + * GNU General Public License for more details.
   86.16 + *
   86.17 + * You should have received a copy of the GNU General Public License
   86.18 + * along with this program. Look for COPYING file in the top folder.
   86.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   86.20 + */
   86.21 +package org.apidesign.bck2brwsr.tck;
   86.22 +
   86.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
   86.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
   86.25 +import org.testng.annotations.Factory;
   86.26 +
   86.27 +/**
   86.28 + *
   86.29 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
   86.30 + */
   86.31 +public class RegExpReplaceAllTest {
   86.32 +
   86.33 +    @Compare public String replaceAll() {
   86.34 +        return "JavaScript".replaceAll("Script", "One");
   86.35 +    }
   86.36 +
   86.37 +    @Compare public String replaceAllTwice() {
   86.38 +        return "Script JavaScript!".replaceAll("Script", "One");
   86.39 +    }
   86.40 +
   86.41 +    
   86.42 +    @Compare public String replaceAllRegexp() {
   86.43 +        return "JavaScript".replaceAll("S....t", "One");
   86.44 +    }
   86.45 +
   86.46 +    @Compare public String replaceAllRegexpTwice() {
   86.47 +        return "Script JavaScript!".replaceAll("S....t", "One");
   86.48 +    }
   86.49 +