emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/JFXIssuesTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 14:55:55 +0100
changeset 771 4252bfc396fc
parent 755 5652acd48509
permissions -rw-r--r--
Proper implementation of round and toInt32 conversions
jaroslav@733
     1
/**
jaroslav@733
     2
 * Back 2 Browser Bytecode Translator
jaroslav@733
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@733
     4
 *
jaroslav@733
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@733
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@733
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@733
     8
 *
jaroslav@733
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@733
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@733
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@733
    12
 * GNU General Public License for more details.
jaroslav@733
    13
 *
jaroslav@733
    14
 * You should have received a copy of the GNU General Public License
jaroslav@733
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@733
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@733
    17
 */
jaroslav@733
    18
package org.apidesign.bck2brwsr.compact.tck;
jaroslav@733
    19
jaroslav@733
    20
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@733
    21
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@733
    22
import org.testng.annotations.Factory;
jaroslav@733
    23
jaroslav@733
    24
jaroslav@733
    25
public class JFXIssuesTest {
jaroslav@733
    26
    private abstract class Application {
jaroslav@733
    27
        public abstract int getID();
jaroslav@733
    28
    }
jaroslav@733
    29
    
jaroslav@733
    30
    private class MyApplication extends Application {
jaroslav@733
    31
jaroslav@733
    32
        @Override
jaroslav@733
    33
        public int getID() {
jaroslav@733
    34
            return 1;
jaroslav@733
    35
        }
jaroslav@733
    36
        
jaroslav@733
    37
    } 
jaroslav@733
    38
    
jaroslav@733
    39
    @Compare public boolean isClassAssignable() {
jaroslav@733
    40
        return Application.class.isAssignableFrom(MyApplication.class);
jaroslav@733
    41
    }
lubomir@752
    42
lubomir@752
    43
    @Compare public boolean isNaN() {
lubomir@752
    44
        return Double.isNaN(Double.NaN);
lubomir@752
    45
    }
lubomir@752
    46
lubomir@752
    47
    @Compare public boolean isInfinite() {
lubomir@752
    48
        return Float.isInfinite(Float.NEGATIVE_INFINITY);
lubomir@752
    49
    }
lubomir@752
    50
lubomir@755
    51
    @Compare public boolean areTimesEqual() {
lubomir@755
    52
        long l1 = System.currentTimeMillis();
lubomir@755
    53
        long l2 = l1 + 0;
lubomir@755
    54
lubomir@755
    55
        return l1 == l2;
lubomir@755
    56
    }
jaroslav@771
    57
    
jaroslav@771
    58
    @Compare public boolean roundOnDouble() {
jaroslav@771
    59
        long l1 = Math.round(System.currentTimeMillis() / 1.1);
jaroslav@771
    60
        long l2 = l1 + 0;
jaroslav@771
    61
        
jaroslav@771
    62
        return l1 == l2;
jaroslav@771
    63
    }
lubomir@755
    64
jaroslav@771
    65
    private static long val = 1238078409318L;
jaroslav@771
    66
    
jaroslav@771
    67
    @Compare public int valueConvertedToString() {
jaroslav@771
    68
        return (int) val++;
jaroslav@771
    69
    }
jaroslav@771
    70
    
jaroslav@771
    71
    @Compare public boolean roundOnFloat() {
jaroslav@771
    72
        final float f = System.currentTimeMillis() / 1.1f;
jaroslav@771
    73
        int l1 = Math.round(f);
jaroslav@771
    74
        int l2 = l1 + 0;
jaroslav@771
    75
        
jaroslav@771
    76
        assert l1 == l2 : "Round " + l1 + " == " + l2;
jaroslav@771
    77
        
jaroslav@771
    78
        return l1 == l2;
jaroslav@771
    79
    }
jaroslav@771
    80
    
jaroslav@733
    81
    @Factory public static Object[] create() {
jaroslav@733
    82
        return VMTest.create(JFXIssuesTest.class);
jaroslav@733
    83
    }
jaroslav@733
    84
}