jaroslav@106: /** jaroslav@106: * Back 2 Browser Bytecode Translator jaroslav@106: * Copyright (C) 2012 Jaroslav Tulach jaroslav@106: * jaroslav@106: * This program is free software: you can redistribute it and/or modify jaroslav@106: * it under the terms of the GNU General Public License as published by jaroslav@106: * the Free Software Foundation, version 2 of the License. jaroslav@106: * jaroslav@106: * This program is distributed in the hope that it will be useful, jaroslav@106: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@106: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@106: * GNU General Public License for more details. jaroslav@106: * jaroslav@106: * You should have received a copy of the GNU General Public License jaroslav@106: * along with this program. Look for COPYING file in the top folder. jaroslav@106: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@106: */ jaroslav@22: package org.apidesign.vm4brwsr; jaroslav@21: jaroslav@21: import javax.script.Invocable; jaroslav@21: import javax.script.ScriptException; jaroslav@21: import static org.testng.Assert.*; jaroslav@103: import org.testng.annotations.BeforeClass; jtulach@128: import org.testng.annotations.Test; jaroslav@21: jaroslav@21: /** jaroslav@21: * tzezula@285: * @author Tomas Zezula jaroslav@21: */ tzezula@285: public class ExceptionsTest { tzezula@285: @Test tzezula@285: public void verifyMethodWithTryCatchNoThrow() throws Exception { tzezula@287: assertExec( tzezula@287: "No throw", tzezula@287: Exceptions.class, tzezula@287: "methodWithTryCatchNoThrow__I", tzezula@287: new Double(1.0)); jaroslav@21: } tzezula@285: tzezula@285: @Test tzezula@285: public void verifyMethodWithTryCatchThrow() throws Exception { tzezula@287: assertExec( tzezula@287: "Throw", tzezula@287: Exceptions.class, tzezula@287: "methodWithTryCatchThrow__I", tzezula@287: new Double(2.0)); jaroslav@104: } jaroslav@104: jaroslav@103: private static CharSequence codeSeq; jaroslav@103: private static Invocable code; jaroslav@103: jaroslav@103: @BeforeClass jaroslav@103: public void compileTheCode() throws Exception { jaroslav@21: StringBuilder sb = new StringBuilder(); jaroslav@103: code = StaticMethodTest.compileClass(sb, tzezula@285: "org/apidesign/vm4brwsr/Exceptions" jaroslav@21: ); jaroslav@103: codeSeq = sb; jaroslav@103: } jaroslav@203: private static void assertExec(String msg, Class clazz, String method, Object expRes, Object... args) throws Exception { jaroslav@203: StaticMethodTest.assertExec(code, codeSeq, msg, clazz, method, expRes, args); jaroslav@21: } jaroslav@21: }