Long arithmetic prototype, Long currently represented by separate JavaScript object with two JS-Numbers.
Just few operation implemented to pass tests. Tests under vmtest directory are still failing.
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.vm4brwsr;
20 import javax.script.Invocable;
21 import javax.script.ScriptException;
22 import static org.testng.Assert.*;
26 static Object execCode(Invocable code, CharSequence codeSeq,
27 String msg, Class<?> clazz, String method, Object expRes, Object... args)
32 ret = code.invokeFunction("bck2brwsr");
33 ret = code.invokeMethod(ret, "loadClass", clazz.getName());
34 ret = code.invokeMethod(ret, method, args);
35 } catch (ScriptException ex) {
36 fail("Execution failed in " + StaticMethodTest.dumpJS(codeSeq), ex);
37 } catch (NoSuchMethodException ex) {
38 fail("Cannot find method in " + StaticMethodTest.dumpJS(codeSeq), ex);
40 if (ret == null && expRes == null) {
43 if (expRes.equals(ret)) {
46 if (expRes instanceof Number) {
47 // in case of Long it is necessary convert it to number
48 // since the Long is represented by two numbers in JavaScript
50 ret = code.invokeFunction("Number", ret);
51 } catch (ScriptException ex) {
52 fail("Conversion to number failed in " + StaticMethodTest.dumpJS(codeSeq), ex);
53 } catch (NoSuchMethodException ex) {
54 fail("Cannot find global Number(x) function in " + StaticMethodTest.dumpJS(codeSeq), ex);