diff -r d8807b6a636a -r b9318fe303cd src/test/java/org/apidesign/java4browser/ArrayTest.java --- a/src/test/java/org/apidesign/java4browser/ArrayTest.java Mon Sep 24 09:35:00 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -Java 4 Browser Bytecode Translator -Copyright (C) 2012-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.java4browser; - -import javax.script.Invocable; -import javax.script.ScriptException; -import org.testng.annotations.Test; -import static org.testng.Assert.*; - -/** - * - * @author Jaroslav Tulach - */ -public class ArrayTest { - @Test public void verifySimpleIntOperation() throws Exception { - assertExec("CheckTheSum", "org_apidesign_java4browser_Array_simpleI", - Double.valueOf(15) - ); - } - @Test public void verifyOperationsOnArrays() throws Exception { - assertExec("The sum is 105", "org_apidesign_java4browser_Array_sumD", - Double.valueOf(105) - ); - } - - private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception { - StringBuilder sb = new StringBuilder(); - Invocable i = StaticMethodTest.compileClass(sb, - "org/apidesign/java4browser/Array" - ); - - Object ret = null; - try { - ret = i.invokeFunction(methodName, args); - } catch (ScriptException ex) { - fail("Execution failed in " + sb, ex); - } catch (NoSuchMethodException ex) { - fail("Cannot find method in " + sb, ex); - } - if (ret == null && expRes == null) { - return; - } - if (expRes.equals(ret)) { - return; - } - assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb); - } -}