vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareHashTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 26 Jan 2013 08:47:05 +0100
changeset 592 5e13b1ac2886
parent 427 12e866a32b40
permissions -rw-r--r--
In order to support fields of the same name in subclasses we are now prefixing them with name of the class that defines them. To provide convenient way to access them from generated bytecode and also directly from JavaScript, there is a getter/setter function for each field. It starts with _ followed by the field name. If called with a parameter, it sets the field, with a parameter it just returns it.
jaroslav@273
     1
/**
jaroslav@273
     2
 * Back 2 Browser Bytecode Translator
jaroslav@273
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@273
     4
 *
jaroslav@273
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@273
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@273
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@273
     8
 *
jaroslav@273
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@273
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@273
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@273
    12
 * GNU General Public License for more details.
jaroslav@273
    13
 *
jaroslav@273
    14
 * You should have received a copy of the GNU General Public License
jaroslav@273
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@273
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@273
    17
 */
jaroslav@346
    18
package org.apidesign.bck2brwsr.tck;
jaroslav@273
    19
jaroslav@346
    20
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@346
    21
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@273
    22
import org.testng.annotations.Factory;
jaroslav@273
    23
jaroslav@273
    24
/**
jaroslav@273
    25
 *
jaroslav@273
    26
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@273
    27
 */
jaroslav@273
    28
public class CompareHashTest {
jaroslav@273
    29
    @Compare public int hashOfString() {
jaroslav@273
    30
        return "Ahoj".hashCode();
jaroslav@273
    31
    }
jaroslav@273
    32
    
jaroslav@335
    33
    @Compare public int hashRemainsYieldsZero() {
jaroslav@335
    34
        Object o = new Object();
jaroslav@335
    35
        return o.hashCode() - o.hashCode();
jaroslav@335
    36
    }
jaroslav@335
    37
    
jaroslav@431
    38
    @Compare public int initializeInStatic() {
jaroslav@431
    39
        return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode();
jaroslav@431
    40
    }
jaroslav@431
    41
    
Martin@352
    42
    @Compare public int hashOfInt() {
Martin@352
    43
        return Integer.valueOf(Integer.MAX_VALUE).hashCode();
jaroslav@358
    44
    }
jaroslav@358
    45
    
jaroslav@273
    46
    @Factory
jaroslav@273
    47
    public static Object[] create() {
jaroslav@346
    48
        return VMTest.create(CompareHashTest.class);
jaroslav@273
    49
    }
jaroslav@273
    50
}