jaroslav@222: /** jaroslav@222: * Back 2 Browser Bytecode Translator jaroslav@222: * Copyright (C) 2012 Jaroslav Tulach jaroslav@222: * jaroslav@222: * This program is free software: you can redistribute it and/or modify jaroslav@222: * it under the terms of the GNU General Public License as published by jaroslav@222: * the Free Software Foundation, version 2 of the License. jaroslav@222: * jaroslav@222: * This program is distributed in the hope that it will be useful, jaroslav@222: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@222: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@222: * GNU General Public License for more details. jaroslav@222: * jaroslav@222: * You should have received a copy of the GNU General Public License jaroslav@222: * along with this program. Look for COPYING file in the top folder. jaroslav@222: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@222: */ jaroslav@222: package org.apidesign.vm4brwsr; jaroslav@222: jaroslav@222: import javax.script.Invocable; jaroslav@222: import org.testng.annotations.Test; jaroslav@222: import static org.testng.Assert.*; jaroslav@222: import org.testng.annotations.BeforeClass; jaroslav@222: jaroslav@222: /** jaroslav@222: * jaroslav@222: * @author Jaroslav Tulach jaroslav@222: */ jaroslav@222: public class ClassTest { jaroslav@222: jaroslav@222: @Test public void superClassEqualsGetSuperclass() { jaroslav@222: assertTrue(Classes.equalsClassesOfExceptions(), "Classes are equal"); jaroslav@222: } jaroslav@222: jaroslav@222: @Test public void jsSuperClassEqualsGetSuperclass() throws Exception { jaroslav@222: assertExec("Classes are equal", Classes.class, "equalsClassesOfExceptionsZ", Double.valueOf(1.0)); jaroslav@222: } jaroslav@222: jaroslav@222: @Test public void classesAreDifferent() { jaroslav@222: assertTrue(Classes.differenceInClasses(), "Classes are not equal"); jaroslav@222: } jaroslav@222: jaroslav@222: @Test public void jsClassesAreDifferent() throws Exception { jaroslav@222: assertExec("Classes are not equal", Classes.class, "differenceInClassesZ", Double.valueOf(1.0)); jaroslav@222: } jaroslav@222: jaroslav@222: private static CharSequence codeSeq; jaroslav@222: private static Invocable code; jaroslav@222: jaroslav@222: @BeforeClass jaroslav@222: public void compileTheCode() throws Exception { jaroslav@222: if (codeSeq == null) { jaroslav@222: StringBuilder sb = new StringBuilder(); jaroslav@222: code = StaticMethodTest.compileClass(sb, "org/apidesign/vm4brwsr/Classes"); jaroslav@222: codeSeq = sb; jaroslav@222: } jaroslav@222: } jaroslav@222: jaroslav@222: private void assertExec( jaroslav@222: String msg, Class clazz, String method, Object expRes, Object... args jaroslav@222: ) throws Exception { jaroslav@222: StaticMethodTest.assertExec(code, codeSeq, msg, clazz, method, expRes, args); jaroslav@222: } jaroslav@222: jaroslav@222: }