Martin@582: /** Martin@582: * Back 2 Browser Bytecode Translator Martin@582: * Copyright (C) 2012 Jaroslav Tulach Martin@582: * Martin@582: * This program is free software: you can redistribute it and/or modify Martin@582: * it under the terms of the GNU General Public License as published by Martin@582: * the Free Software Foundation, version 2 of the License. Martin@582: * Martin@582: * This program is distributed in the hope that it will be useful, Martin@582: * but WITHOUT ANY WARRANTY; without even the implied warranty of Martin@582: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Martin@582: * GNU General Public License for more details. Martin@582: * Martin@582: * You should have received a copy of the GNU General Public License Martin@582: * along with this program. Look for COPYING file in the top folder. Martin@582: * If not, see http://opensource.org/licenses/GPL-2.0. Martin@582: */ Martin@582: package org.apidesign.bck2brwsr.tck; Martin@582: Martin@582: import org.apidesign.bck2brwsr.vmtest.Compare; Martin@582: import org.apidesign.bck2brwsr.vmtest.VMTest; Martin@582: import org.testng.annotations.Factory; Martin@582: Martin@582: /** Martin@582: * Martin@582: * @author Jaroslav Tulach Martin@582: */ Martin@582: public class LongArithmeticTest { Martin@582: Martin@582: private static long add(long x, long y) { Martin@582: return (x + y); Martin@582: } Martin@582: Martin@582: private static long sub(long x, long y) { Martin@582: return (x - y); Martin@582: } Martin@582: Martin@582: private static long mul(long x, long y) { Martin@582: return (x * y); Martin@582: } Martin@582: Martin@582: private static long div(long x, long y) { Martin@582: return (x / y); Martin@582: } Martin@582: Martin@582: private static long mod(long x, long y) { Martin@582: return (x % y); Martin@582: } Martin@582: Martin@582: @Compare public long conversion() { Martin@582: return Long.MAX_VALUE; Martin@582: } Martin@582: Martin@582: /* Martin@582: @Compare public long addOverflow() { Martin@582: return add(Long.MAX_VALUE, 1l); Martin@582: } Martin@582: Martin@582: @Compare public long subUnderflow() { Martin@582: return sub(Long.MIN_VALUE, 1l); Martin@582: } Martin@582: Martin@582: @Compare public long addMaxLongAndMaxLong() { Martin@582: return add(Long.MAX_VALUE, Long.MAX_VALUE); Martin@582: } Martin@582: Martin@582: @Compare public long subMinLongAndMinLong() { Martin@582: return sub(Long.MIN_VALUE, Long.MIN_VALUE); Martin@582: } Martin@582: Martin@582: @Compare public long multiplyMaxLong() { Martin@582: return mul(Long.MAX_VALUE, 2l); Martin@582: } Martin@582: Martin@582: @Compare public long multiplyMaxLongAndMaxLong() { Martin@582: return mul(Long.MAX_VALUE, Long.MAX_VALUE); Martin@582: } Martin@582: Martin@582: @Compare public long multiplyMinLong() { Martin@582: return mul(Long.MIN_VALUE, 2l); Martin@582: } Martin@582: Martin@582: @Compare public long multiplyMinLongAndMinLong() { Martin@582: return mul(Long.MIN_VALUE, Long.MIN_VALUE); Martin@582: } Martin@582: Martin@582: @Compare public long multiplyPrecision() { Martin@582: return mul(17638l, 1103l); Martin@582: } Martin@582: Martin@582: @Compare public long division() { Martin@582: return div(1l, 2l); Martin@582: } Martin@582: Martin@582: @Compare public long divisionReminder() { Martin@582: return mod(1l, 2l); Martin@582: } Martin@582: */ Martin@582: Martin@582: @Factory Martin@582: public static Object[] create() { Martin@582: return VMTest.create(LongArithmeticTest.class); Martin@582: } Martin@582: }