# HG changeset patch # User Jaroslav Tulach # Date 1358849640 -3600 # Node ID 70c062dbd783320b4ec297ebf859adc8b08ca8de # Parent 974bc55865c78756cc2bb57717074d14449bb349 Tests should run with assertions on diff -r 974bc55865c7 -r 70c062dbd783 emul/src/main/java/java/lang/Class.java --- a/emul/src/main/java/java/lang/Class.java Mon Jan 21 13:46:09 2013 +0100 +++ b/emul/src/main/java/java/lang/Class.java Tue Jan 22 11:14:00 2013 +0100 @@ -1198,7 +1198,8 @@ ) native static Class getPrimitiveClass(String type); - public boolean desiredAssertionStatus() { - return false; - } + @JavaScriptBody(args = {}, body = + "return vm.desiredAssertionStatus ? vm.desiredAssertionStatus : false;" + ) + public native boolean desiredAssertionStatus(); } diff -r 974bc55865c7 -r 70c062dbd783 launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Mon Jan 21 13:46:09 2013 +0100 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Tue Jan 22 11:14:00 2013 +0100 @@ -31,6 +31,9 @@ * @author Jaroslav Tulach */ public class Console { + static { + turnAssetionStatusOn(); + } public static String welcome() { return "HellofromBck2Brwsr"; } @@ -167,7 +170,7 @@ } else { res = found.invoke(c.newInstance()); } - } catch (Exception ex) { + } catch (Exception | Error ex) { res = ex.getClass().getName() + ":" + ex.getMessage(); } } else { @@ -175,6 +178,10 @@ } return res; } + + @JavaScriptBody(args = {}, body = "vm.desiredAssertionStatus = true;") + private static void turnAssetionStatusOn() { + } private static final class Case { private final Object data; diff -r 974bc55865c7 -r 70c062dbd783 vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/AssertionTest.java Tue Jan 22 11:14:00 2013 +0100 @@ -0,0 +1,39 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.tck; + +import org.apidesign.bck2brwsr.vmtest.Compare; +import org.apidesign.bck2brwsr.vmtest.VMTest; +import org.testng.annotations.Factory; + +/** + * + * @author Jaroslav Tulach + */ +public class AssertionTest { + + @Compare public Object checkAssert() throws ClassNotFoundException { + assert false : "Is assertion status on?"; + return null; + } + + @Factory + public static Object[] create() { + return VMTest.create(AssertionTest.class); + } +}