jaroslav@1097: /** jaroslav@1097: * Back 2 Browser Bytecode Translator jaroslav@1097: * Copyright (C) 2012 Jaroslav Tulach jaroslav@1097: * jaroslav@1097: * This program is free software: you can redistribute it and/or modify jaroslav@1097: * it under the terms of the GNU General Public License as published by jaroslav@1097: * the Free Software Foundation, version 2 of the License. jaroslav@1097: * jaroslav@1097: * This program is distributed in the hope that it will be useful, jaroslav@1097: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1097: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1097: * GNU General Public License for more details. jaroslav@1097: * jaroslav@1097: * You should have received a copy of the GNU General Public License jaroslav@1097: * along with this program. Look for COPYING file in the top folder. jaroslav@1097: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1097: */ jaroslav@1097: package org.apidesign.bck2brwsr.brwsrtest; jaroslav@1097: jaroslav@1097: import org.apidesign.bck2brwsr.core.JavaScriptBody; jaroslav@1097: import org.apidesign.bck2brwsr.vmtest.BrwsrTest; jaroslav@1097: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@1097: import org.testng.annotations.Factory; jaroslav@1097: jaroslav@1097: /** jaroslav@1097: * jaroslav@1097: * @author Jaroslav Tulach jaroslav@1097: */ jaroslav@1097: public class BooleanTest { jaroslav@1097: @JavaScriptBody(args = { "tr" }, body = "return tr ? true : false;") jaroslav@1097: private static native Object trueFalse(boolean tr); jaroslav@1097: jaroslav@1097: @BrwsrTest public void isTrueInstanceOfBoolean() { jaroslav@1097: Object t = trueFalse(true); jaroslav@1097: assert t instanceof Boolean : "Should be boolean: " + t; jaroslav@1097: assert ((boolean)t) : "and is true"; jaroslav@1097: } jaroslav@1097: jaroslav@1097: @BrwsrTest public void isFalseInstanceOfBoolean() { jaroslav@1097: Object t = trueFalse(false); jaroslav@1097: assert t instanceof Boolean : "Should be boolean: " + t; jaroslav@1097: assert !((boolean)t) : "and is false: " + t; jaroslav@1097: } jaroslav@1097: jaroslav@1097: @Factory public static Object[] create() { jaroslav@1097: return VMTest.create(BooleanTest.class); jaroslav@1097: } jaroslav@1097: }