vm/src/test/java/org/apidesign/vm4brwsr/tck/IntegerArithmeticTest.java
author Martin Soch <Martin.Soch@oracle.com>
Tue, 18 Dec 2012 11:41:09 +0100
brancharithmetic
changeset 345 f954edc48431
child 351 b7459b10d581
permissions -rw-r--r--
Added few test for integer arithmetic - should fail for now, but it doesn't.
Martin@345
     1
/**
Martin@345
     2
 * Back 2 Browser Bytecode Translator
Martin@345
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Martin@345
     4
 *
Martin@345
     5
 * This program is free software: you can redistribute it and/or modify
Martin@345
     6
 * it under the terms of the GNU General Public License as published by
Martin@345
     7
 * the Free Software Foundation, version 2 of the License.
Martin@345
     8
 *
Martin@345
     9
 * This program is distributed in the hope that it will be useful,
Martin@345
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Martin@345
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Martin@345
    12
 * GNU General Public License for more details.
Martin@345
    13
 *
Martin@345
    14
 * You should have received a copy of the GNU General Public License
Martin@345
    15
 * along with this program. Look for COPYING file in the top folder.
Martin@345
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
Martin@345
    17
 */
Martin@345
    18
package org.apidesign.vm4brwsr.tck;
Martin@345
    19
Martin@345
    20
import org.apidesign.bck2brwsr.core.JavaScriptBody;
Martin@345
    21
import org.apidesign.vm4brwsr.Compare;
Martin@345
    22
import org.apidesign.vm4brwsr.CompareVMs;
Martin@345
    23
import org.testng.annotations.Factory;
Martin@345
    24
Martin@345
    25
/**
Martin@345
    26
 *
Martin@345
    27
 * @author Jaroslav Tulach <jtulach@netbeans.org>
Martin@345
    28
 */
Martin@345
    29
public class IntegerArithmeticTest {
Martin@345
    30
    //@JavaScriptBody(args="msg", body="java.lang.System.out.println(msg.toString());")
Martin@345
    31
    //private static native void log(String msg);
Martin@345
    32
    
Martin@345
    33
    @Compare public int overflow() {
Martin@345
    34
        int v = Integer.MAX_VALUE + 1;
Martin@345
    35
        return v;
Martin@345
    36
    }
Martin@345
    37
    
Martin@345
    38
    @Compare public int underflow() {
Martin@345
    39
        int v = Integer.MIN_VALUE - 1;
Martin@345
    40
        return v;
Martin@345
    41
    }
Martin@345
    42
    
Martin@345
    43
    /* @Compare public int convertToInt() {
Martin@345
    44
        long v = Long.MAX_VALUE / 2;
Martin@345
    45
        log("convert: " + v);
Martin@345
    46
        return (int) v;
Martin@345
    47
    } */
Martin@345
    48
    @Compare public int addAndMaxInt() {
Martin@345
    49
        return Integer.MAX_VALUE + Integer.MAX_VALUE;
Martin@345
    50
    }
Martin@345
    51
    
Martin@345
    52
    @Compare public int multiplyMaxInt() {
Martin@345
    53
        return Integer.MAX_VALUE * Integer.MAX_VALUE;
Martin@345
    54
    }
Martin@345
    55
    
Martin@345
    56
    @Factory
Martin@345
    57
    public static Object[] create() {
Martin@345
    58
        return CompareVMs.create(IntegerArithmeticTest.class);
Martin@345
    59
    }
Martin@345
    60
}