Tests should run with assertions on
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 22 Jan 2013 11:14:00 +0100
changeset 51770c062dbd783
parent 504 974bc55865c7
child 518 5df0a239ebeb
Tests should run with assertions on
emul/src/main/java/java/lang/Class.java
launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java
vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java
     1.1 --- a/emul/src/main/java/java/lang/Class.java	Mon Jan 21 13:46:09 2013 +0100
     1.2 +++ b/emul/src/main/java/java/lang/Class.java	Tue Jan 22 11:14:00 2013 +0100
     1.3 @@ -1198,7 +1198,8 @@
     1.4      )
     1.5      native static Class getPrimitiveClass(String type);
     1.6  
     1.7 -    public boolean desiredAssertionStatus() {
     1.8 -        return false;
     1.9 -    }
    1.10 +    @JavaScriptBody(args = {}, body = 
    1.11 +        "return vm.desiredAssertionStatus ? vm.desiredAssertionStatus : false;"
    1.12 +    )
    1.13 +    public native boolean desiredAssertionStatus();
    1.14  }
     2.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java	Mon Jan 21 13:46:09 2013 +0100
     2.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java	Tue Jan 22 11:14:00 2013 +0100
     2.3 @@ -31,6 +31,9 @@
     2.4   * @author Jaroslav Tulach <jtulach@netbeans.org>
     2.5   */
     2.6  public class Console {
     2.7 +    static {
     2.8 +        turnAssetionStatusOn();
     2.9 +    }
    2.10      public static String welcome() {
    2.11          return "HellofromBck2Brwsr";
    2.12      }
    2.13 @@ -167,7 +170,7 @@
    2.14                  } else {
    2.15                      res = found.invoke(c.newInstance());
    2.16                  }
    2.17 -            } catch (Exception ex) {
    2.18 +            } catch (Exception | Error ex) {
    2.19                  res = ex.getClass().getName() + ":" + ex.getMessage();
    2.20              }
    2.21          } else {
    2.22 @@ -175,6 +178,10 @@
    2.23          }
    2.24          return res;
    2.25      }
    2.26 +
    2.27 +    @JavaScriptBody(args = {}, body = "vm.desiredAssertionStatus = true;")
    2.28 +    private static void turnAssetionStatusOn() {
    2.29 +    }
    2.30      
    2.31      private static final class Case {
    2.32          private final Object data;
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java	Tue Jan 22 11:14:00 2013 +0100
     3.3 @@ -0,0 +1,39 @@
     3.4 +/**
     3.5 + * Back 2 Browser Bytecode Translator
     3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     3.7 + *
     3.8 + * This program is free software: you can redistribute it and/or modify
     3.9 + * it under the terms of the GNU General Public License as published by
    3.10 + * the Free Software Foundation, version 2 of the License.
    3.11 + *
    3.12 + * This program is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + * GNU General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU General Public License
    3.18 + * along with this program. Look for COPYING file in the top folder.
    3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    3.20 + */
    3.21 +package org.apidesign.bck2brwsr.tck;
    3.22 +
    3.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    3.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    3.25 +import org.testng.annotations.Factory;
    3.26 +
    3.27 +/**
    3.28 + *
    3.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    3.30 + */
    3.31 +public class AssertionTest {
    3.32 +
    3.33 +    @Compare public Object checkAssert() throws ClassNotFoundException {
    3.34 +        assert false : "Is assertion status on?";
    3.35 +        return null;
    3.36 +    }
    3.37 +    
    3.38 +    @Factory
    3.39 +    public static Object[] create() {
    3.40 +        return VMTest.create(AssertionTest.class);
    3.41 +    }
    3.42 +}