jaroslav@273: /** jaroslav@273: * Back 2 Browser Bytecode Translator jaroslav@273: * Copyright (C) 2012 Jaroslav Tulach jaroslav@273: * jaroslav@273: * This program is free software: you can redistribute it and/or modify jaroslav@273: * it under the terms of the GNU General Public License as published by jaroslav@273: * the Free Software Foundation, version 2 of the License. jaroslav@273: * jaroslav@273: * This program is distributed in the hope that it will be useful, jaroslav@273: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@273: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@273: * GNU General Public License for more details. jaroslav@273: * jaroslav@273: * You should have received a copy of the GNU General Public License jaroslav@273: * along with this program. Look for COPYING file in the top folder. jaroslav@273: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@273: */ jaroslav@346: package org.apidesign.bck2brwsr.tck; jaroslav@273: jaroslav@346: import org.apidesign.bck2brwsr.vmtest.Compare; jaroslav@346: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@273: import org.testng.annotations.Factory; jaroslav@273: jaroslav@273: /** jaroslav@273: * jaroslav@273: * @author Jaroslav Tulach jaroslav@273: */ jaroslav@273: public class CompareHashTest { jaroslav@273: @Compare public int hashOfString() { jaroslav@273: return "Ahoj".hashCode(); jaroslav@273: } jaroslav@273: jaroslav@1260: @Compare public boolean hashOfIntegerDifferentToOwnHash() { jaroslav@1260: Integer i = 120; jaroslav@1260: return System.identityHashCode(i) != i.hashCode(); jaroslav@1260: } jaroslav@1260: jaroslav@1260: @Compare public int hashOfObjectSameAsOwnHash() { jaroslav@1260: Object o = new Object(); jaroslav@1260: return System.identityHashCode(o) - o.hashCode(); jaroslav@1260: } jaroslav@1260: jaroslav@335: @Compare public int hashRemainsYieldsZero() { jaroslav@335: Object o = new Object(); jaroslav@335: return o.hashCode() - o.hashCode(); jaroslav@335: } jaroslav@335: jaroslav@431: @Compare public int initializeInStatic() { jaroslav@431: return StaticUse.NON_NULL.hashCode() - StaticUse.NON_NULL.hashCode(); jaroslav@431: } jaroslav@431: Martin@352: @Compare public int hashOfInt() { Martin@352: return Integer.valueOf(Integer.MAX_VALUE).hashCode(); jaroslav@358: } jaroslav@358: jaroslav@273: @Factory jaroslav@273: public static Object[] create() { jaroslav@346: return VMTest.create(CompareHashTest.class); jaroslav@273: } jaroslav@273: }