rt/emul/brwsrtest/src/test/java/org/apidesign/bck2brwsr/brwsrtest/DoubleBitsTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 09 Mar 2013 11:58:50 +0100
changeset 826 fb751bcc23fd
child 1787 ea12a3bb4b33
permissions -rw-r--r--
doubleToLongBits and floatToIntBits implemented via typed arrays. Requires real browser (Rhino does not support typed arrays) and as such creating new module to hold the tests and execute them in 'brwsr' mode.
jaroslav@826
     1
/**
jaroslav@826
     2
 * Back 2 Browser Bytecode Translator
jaroslav@826
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@826
     4
 *
jaroslav@826
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@826
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@826
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@826
     8
 *
jaroslav@826
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@826
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@826
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@826
    12
 * GNU General Public License for more details.
jaroslav@826
    13
 *
jaroslav@826
    14
 * You should have received a copy of the GNU General Public License
jaroslav@826
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@826
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@826
    17
 */
jaroslav@826
    18
package org.apidesign.bck2brwsr.brwsrtest;
jaroslav@826
    19
jaroslav@826
    20
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@826
    21
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@826
    22
import org.testng.annotations.Factory;
jaroslav@826
    23
jaroslav@826
    24
/**
jaroslav@826
    25
 *
jaroslav@826
    26
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@826
    27
 */
jaroslav@826
    28
public class DoubleBitsTest {
jaroslav@826
    29
jaroslav@826
    30
    @Compare public String doubleToBits() {
jaroslav@826
    31
        long val = Double.doubleToLongBits(333.456);
jaroslav@826
    32
        return Long.toString(val);
jaroslav@826
    33
    }
jaroslav@826
    34
jaroslav@826
    35
    @Compare public int floatToBits() {
jaroslav@826
    36
        return Float.floatToIntBits(333.456f);
jaroslav@826
    37
    }
jaroslav@826
    38
    
jaroslav@826
    39
    @Factory public static Object[] create() {
jaroslav@826
    40
        return VMTest.create(DoubleBitsTest.class);
jaroslav@826
    41
    }
jaroslav@826
    42
}