// package classes.Test; < not sure if we need it at all import junit.framework.*; public class BytecodeVerificationTest extends TestCase { // Lenght of all the array type variable private final int arrayLength = 6; private SVMTestInlinabilityOfBytecodes zeTest = new SVMTestInlinabilityOfBytecodes(); private SVMTestInlinabilityBytecodeVerificationFields zeFields = new SVMTestInlinabilityBytecodeVerificationFields(); private final boolean booleanTrue = false; private final boolean booleanFalse = true; private final byte byte0 = 0; private final byte byte1 = 1; private final char char0 = 0; private final char char1 = 1; private final double doublen1 = -1.0; private final double double0 = 0.0; private final double double1 = 1.0; private final float floatn1 = -1.0f; private final float float0 = 0.0f; private final float float1 = 1.0f; private final int intn1 = -1; private final int int0 = 0; private final int int1 = 1; private final long longn1 = -1; private final long long0 = 0; private final long long1 = 1; private Object anObject; private Object anotherObject; private final short short0 = 0; private final short short1 = 1; private boolean[] aBooleanArray = new boolean[arrayLength]; private byte[] aByteArray = new byte[arrayLength]; private char[] aCharArray = new char[arrayLength]; private double[] double1Array = new double[arrayLength]; private float[] float1Array = new float[arrayLength]; private int[] int1Array = new int[arrayLength]; private long[] long1Array = new long[arrayLength]; private Object[] anObjectArray = new Object[arrayLength]; private short[] aShortArray = new short[arrayLength]; protected void setUp() { anObject = new Object(); anotherObject = new Object(); for(int i=0; iload and load_ instruction individually except the * wide_load instructions which are tested along with the other wide family instructions. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testLoad() { // tests all the instructions of the aload family assertEquals("aload failed", zeTest.svmTestInlinabilityOfBytecode_aload(anObject), anObject); assertEquals("aload_0 failed", zeTest.svmTestInlinabilityOfBytecode_aload_0(anObject), anObject); assertEquals("aload_1 failed", zeTest.svmTestInlinabilityOfBytecode_aload_1(anotherObject, anObject), anObject); assertEquals("aload_2 failed", zeTest.svmTestInlinabilityOfBytecode_aload_2(anotherObject, anotherObject, anObject), anObject); assertEquals("aload_3 failed", zeTest.svmTestInlinabilityOfBytecode_aload_3(anotherObject, anotherObject, anotherObject, anObject), anObject); // tests all the instructions of the dload family assertEquals("dload failed", zeTest.svmTestInlinabilityOfBytecode_dload(double1), double1, 0.0); assertEquals("dload_0 failed", zeTest.svmTestInlinabilityOfBytecode_dload_0(double1), double1, 0.0); assertEquals("dload_1 failed", zeTest.svmTestInlinabilityOfBytecode_dload_1(int0, double1), double1, 0.0); assertEquals("dload_2 failed", zeTest.svmTestInlinabilityOfBytecode_dload_2(double0, double1), double1, 0.0); assertEquals("dload_3 failed", zeTest.svmTestInlinabilityOfBytecode_dload_3(int0, double0, double1), double1, 0.0); // tests all the instructions of the fload family assertEquals("fload failed", zeTest.svmTestInlinabilityOfBytecode_fload(float1), float1, 0.0f); assertEquals("fload_0 failed", zeTest.svmTestInlinabilityOfBytecode_fload_0(float1), float1, 0.0f); assertEquals("fload_1 failed", zeTest.svmTestInlinabilityOfBytecode_fload_1(float0, float1), float1, 0.0f); assertEquals("fload_2 failed", zeTest.svmTestInlinabilityOfBytecode_fload_2(float0, float0, float1), float1, 0.0f); assertEquals("fload_3 failed", zeTest.svmTestInlinabilityOfBytecode_fload_3(float0, float0, float0, float1), float1, 0.0f); // tests all the instructions of the iload family assertEquals("iload failed", zeTest.svmTestInlinabilityOfBytecode_iload(int1), int1); assertEquals("iload_0 failed", zeTest.svmTestInlinabilityOfBytecode_iload_0(int1), int1); assertEquals("iload_1 failed", zeTest.svmTestInlinabilityOfBytecode_iload_1(int0, int1), int1); assertEquals("iload_2 failed", zeTest.svmTestInlinabilityOfBytecode_iload_2(int0, int0, int1), int1); assertEquals("iload_3 failed", zeTest.svmTestInlinabilityOfBytecode_iload_3(int0, int0, int0, int1), int1); // tests all the instructions of the lload family assertEquals("lload failed", zeTest.svmTestInlinabilityOfBytecode_lload(long1), long1); assertEquals("lload_0 failed", zeTest.svmTestInlinabilityOfBytecode_lload_0(long1), long1); assertEquals("lload_1 failed", zeTest.svmTestInlinabilityOfBytecode_lload_1(int0, long1), long1); assertEquals("lload_2 failed", zeTest.svmTestInlinabilityOfBytecode_lload_2(long0, long1), long1); assertEquals("lload_3 failed", zeTest.svmTestInlinabilityOfBytecode_lload_3(int0, long0, long1), long1); // tests the aload instructions for(int i=0; istore and store_ instruction individually except the * wide_store instructions which are tested along with the other wide family instructions. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testStore() { // tests all the instructions of the astore family assertEquals("astore failed", zeTest.svmTestInlinabilityOfBytecode_astore(anObject), anObject); assertEquals("astore_0 failed", zeTest.svmTestInlinabilityOfBytecode_astore_0(anotherObject, anObject), anObject); assertEquals("astore_1 failed", zeTest.svmTestInlinabilityOfBytecode_astore_1(anObject), anObject); assertEquals("astore_2 failed", zeTest.svmTestInlinabilityOfBytecode_astore_2(anObject), anObject); assertEquals("astore_3 failed", zeTest.svmTestInlinabilityOfBytecode_astore_3(anObject), anObject); // tests all the instructions of the dstore family assertEquals("dstore failed", zeTest.svmTestInlinabilityOfBytecode_dstore(double0, double1), double1, 0.0); assertEquals("dstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_dstore_0(double0, double1), double1, 0.0); assertEquals("dstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_dstore_1(0, double0, double1), double1, 0.0); assertEquals("dstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_dstore_2(double1), double1, 0.0); assertEquals("dstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_dstore_3(double1), double1, 0.0); // tests all the instructions of the fstore family assertEquals("fstore failed", zeTest.svmTestInlinabilityOfBytecode_fstore(float1), float1, 0.0f); assertEquals("fstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_fstore_0(float0, float1), float1, 0.0f); assertEquals("fstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_fstore_1(float1), float1, 0.0f); assertEquals("fstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_fstore_2(float1), float1, 0.0f); assertEquals("fstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_fstore_3(float1), float1, 0.0f); // tests all the instructions of the istore family assertEquals("istore failed", zeTest.svmTestInlinabilityOfBytecode_istore(int1), int1); assertEquals("istore_0 failed", zeTest.svmTestInlinabilityOfBytecode_istore_0(int0, int1), int1); assertEquals("istore_1 failed", zeTest.svmTestInlinabilityOfBytecode_istore_1(int1), int1); assertEquals("istore_2 failed", zeTest.svmTestInlinabilityOfBytecode_istore_2(int1), int1); assertEquals("istore_3 failed", zeTest.svmTestInlinabilityOfBytecode_istore_3(int1), int1); // tests all the instructions of the lstore family assertEquals("lstore failed", zeTest.svmTestInlinabilityOfBytecode_lstore(long0, long1), long1); assertEquals("lstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_lstore_0(long0, long1), long1); assertEquals("lstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_lstore_1(0, long0, long1), long1); assertEquals("lstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_lstore_2(long1), long1); assertEquals("lstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_lstore_3(long1), long1); // tests the astore instructions for(int i=0; i instructions assertEquals("dconst_0 failed", zeTest.svmTestInlinabilityOfBytecode_dconst_0(), 0.0, 0.0); assertEquals("dconst_1 failed", zeTest.svmTestInlinabilityOfBytecode_dconst_1(), 1.0, 0.0); // tests the fconst_ instructions assertEquals("fconst_0 failed", zeTest.svmTestInlinabilityOfBytecode_fconst_0(), 0.0f, 0.0f); assertEquals("fconst_1 failed", zeTest.svmTestInlinabilityOfBytecode_fconst_1(), 1.0f, 0.0f); assertEquals("fconst_2 failed", zeTest.svmTestInlinabilityOfBytecode_fconst_2(), 2.0f, 0.0f); // tests the iconst_ instructions assertEquals("iconst_0 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_0(), 0); assertEquals("iconst_1 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_1(), 1); assertEquals("iconst_2 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_2(), 2); assertEquals("iconst_3 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_3(), 3); assertEquals("iconst_4 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_4(), 4); assertEquals("iconst_5 failed", zeTest.svmTestInlinabilityOfBytecode_iconst_5(), 5); // tests the lconst_ instructions assertEquals("lconst_0 failed", zeTest.svmTestInlinabilityOfBytecode_lconst_0(), 0); assertEquals("lconst_1 failed", zeTest.svmTestInlinabilityOfBytecode_lconst_1(), 1); // tests the ldc family instructions assertEquals("ldc failed for type int", zeTest.svmTestInlinabilityOfBytecode_ldc_int(), 1); assertEquals("ldc failed for type float", zeTest.svmTestInlinabilityOfBytecode_ldc_float(), 1.0f, 0.0f); assertEquals("ldc failed for type java.lang.String", zeTest.svmTestInlinabilityOfBytecode_ldc_String(), "Hello World!"); assertEquals("ldc_w failed for type int", zeTest.svmTestInlinabilityOfBytecode_ldc_w_int(), 1); assertEquals("ldc_w failed for type float", zeTest.svmTestInlinabilityOfBytecode_ldc_w_float(), 1.0f, 0.0f); assertEquals("ldc_w failed for type java.lang.String", zeTest.svmTestInlinabilityOfBytecode_ldc_w_String(), "Hello World!"); assertEquals("ldc2_w failed for type long", zeTest.svmTestInlinabilityOfBytecode_ldc2_w_long(), 1); assertEquals("ldc2_w failed for type double", zeTest.svmTestInlinabilityOfBytecode_ldc2_w_double(), 1.0, 0.0); // tests the pop family instructions assertEquals("pop failed", zeTest.svmTestInlinabilityOfBytecode_pop(int1, int0), int1); assertEquals("pop failed", zeTest.svmTestInlinabilityOfBytecode_pop2(long1, long0), long1); // tests the sipush instruction assertEquals("sipush failed", zeTest.svmTestInlinabilityOfBytecode_sipush(), 170); } /** * @method : testBranching * @description : tests all the branching instructions individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testBranching() { // tests the goto family instructions assertEquals("goto failed", zeTest.svmTestInlinabilityOfBytecode_goto(), 1); assertEquals("goto_w failed", zeTest.svmTestInlinabilityOfBytecode_goto_w(), 1); // tests the if_a family instructions assertEquals("if_acmpeq did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_acmpeq(anObject, anObject), 1); assertEquals("if_acmpeq branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_acmpeq(anObject, anotherObject), 0); assertEquals("if_acmpne did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_acmpne(anObject, anotherObject), 1); assertEquals("if_acmpne branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_acmpne(anObject, anObject), 0); // tests the if_i family instructions assertEquals("if_icmpeq did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpeq(int1, int1), 1); assertEquals("if_icmpeq branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpeq(int0, int1), 0); assertEquals("if_icmpge did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpge(int1, int1), 1); assertEquals("if_icmpge did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpge(int1, int0), 1); assertEquals("if_icmpge branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpge(int0, int1), 0); assertEquals("if_icmpgt did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpgt(int1, int0), 1); assertEquals("if_icmpgt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpgt(int1, int1), 0); assertEquals("if_icmpgt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpgt(int0, int1), 0); assertEquals("if_icmple did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmple(int0, int1), 1); assertEquals("if_icmple did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmple(int0, int0), 1); assertEquals("if_icmple branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmple(int1, int0), 0); assertEquals("if_icmplt did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmplt(int0, int1), 1); assertEquals("if_icmplt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmplt(int0, int0), 0); assertEquals("if_icmplt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmplt(int1, int0), 0); assertEquals("if_icmpne did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpne(int1, int0), 1); assertEquals("if_icmpne branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_if_icmpne(int1, int1), 0); // tests the if family instructions assertEquals("ifeq did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifeq(int0), 1); assertEquals("ifeq branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifeq(int1), 0); assertEquals("ifge did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifge(int0), 1); assertEquals("ifge did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifge(int1), 1); assertEquals("ifge branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifge(intn1), 0); assertEquals("ifgt did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifgt(int1), 1); assertEquals("ifgt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifgt(int0), 0); assertEquals("ifgt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifgt(intn1), 0); assertEquals("ifle did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifle(int0), 1); assertEquals("ifle did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifle(intn1), 1); assertEquals("ifle branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifle(int1), 0); assertEquals("iflt did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_iflt(intn1), 1); assertEquals("iflt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_iflt(int0), 0); assertEquals("iflt branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_iflt(int1), 0); assertEquals("ifne did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifne(int1), 1); assertEquals("ifne branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifne(int0), 0); assertEquals("ifnonnull did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifnonnull(anObject), 1); assertEquals("ifnonnull branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifnonnull(null), 0); assertEquals("ifnull did not branch when supposed to", zeTest.svmTestInlinabilityOfBytecode_ifnull(null), 1); assertEquals("ifnull branched when not supposed to", zeTest.svmTestInlinabilityOfBytecode_ifnull(anObject), 0); // tests the lookupswitch instruction assertEquals("lookupswitch failed", zeTest.svmTestInlinabilityOfBytecode_lookupswitch(int0), int1); assertEquals("lookupswitch failed", zeTest.svmTestInlinabilityOfBytecode_lookupswitch(int1), int0); assertEquals("lookupswitch failed", zeTest.svmTestInlinabilityOfBytecode_lookupswitch(-2), intn1); assertEquals("lookupswitch failed", zeTest.svmTestInlinabilityOfBytecode_lookupswitch(2), intn1); // tests the tableswitch instruction assertEquals("tablesswitch failed", zeTest.svmTestInlinabilityOfBytecode_tableswitch(int0), int1); assertEquals("tablesswitch failed", zeTest.svmTestInlinabilityOfBytecode_tableswitch(int1), int0); assertEquals("tablesswitch failed", zeTest.svmTestInlinabilityOfBytecode_tableswitch(-2), intn1); assertEquals("tablesswitch failed", zeTest.svmTestInlinabilityOfBytecode_tableswitch(2), intn1); } /** * @method : testAdvancedStackHandling * @description : tests all the instructions manipulating values on the stack individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testAdvancedStackHandling() { // tests the swap instruction assertEquals("swap failed", zeTest.svmTestInlinabilityOfBytecode_swap(int1, int0), int1); // tests the dup family instructions assertEquals("dup failed", zeTest.svmTestInlinabilityOfBytecode_dup(int1, int0), 1); assertEquals("dup_x1 failed", zeTest.svmTestInlinabilityOfBytecode_dup_x1(int1, int0), 1); assertEquals("dup_x2 failed", zeTest.svmTestInlinabilityOfBytecode_dup_x2(int1, int0), 1); assertEquals("dup2 failed", zeTest.svmTestInlinabilityOfBytecode_dup2(long1, int0), 1); assertEquals("dup2_x1 failed", zeTest.svmTestInlinabilityOfBytecode_dup2_x1(long1, int1, int0), 1); assertEquals("dup2_x2 failed", zeTest.svmTestInlinabilityOfBytecode_dup2_x2(long1, long0, int0), 1); } /** * @method : testNew * @description : tests the new and newarray instructions and each newarray and multianewarray instruction individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testNew() { // tests the new instruction assertTrue("new failed", zeTest.svmTestInlinabilityOfBytecode_new() instanceof Object); // tests the anewarray instruction assertTrue("anewarray failed", zeTest.svmTestInlinabilityOfBytecode_anewarray(1) instanceof Object[]); // tests the newarray instruction assertTrue("newarray failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_newarray_boolean(1) instanceof boolean[]); assertTrue("newarray failed for type char", zeTest.svmTestInlinabilityOfBytecode_newarray_char(1) instanceof char[]); assertTrue("newarray failed for type float", zeTest.svmTestInlinabilityOfBytecode_newarray_float(1) instanceof float[]); assertTrue("newarray failed for type double", zeTest.svmTestInlinabilityOfBytecode_newarray_double(1) instanceof double[]); assertTrue("newarray failed for type byte", zeTest.svmTestInlinabilityOfBytecode_newarray_byte(1) instanceof byte[]); assertTrue("newarray failed for type short", zeTest.svmTestInlinabilityOfBytecode_newarray_short(1) instanceof short[]); assertTrue("newarray failed for type int", zeTest.svmTestInlinabilityOfBytecode_newarray_int(1) instanceof int[]); assertTrue("newarray failed for type long", zeTest.svmTestInlinabilityOfBytecode_newarray_long(1) instanceof long[]); // tests the multianewarray instruction assertTrue("multianewarray failed for type java.lag.Object", zeTest.svmTestInlinabilityOfBytecode_multianewarray_object(1, 1) instanceof Object[][]); assertTrue("multianewarray failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_multianewarray_boolean(1, 1) instanceof boolean[][]); assertTrue("multianewarray failed for type char", zeTest.svmTestInlinabilityOfBytecode_multianewarray_char(1, 1) instanceof char[][]); assertTrue("multianewarray failed for type float", zeTest.svmTestInlinabilityOfBytecode_multianewarray_float(1, 1) instanceof float[][]); assertTrue("multianewarray failed for type double", zeTest.svmTestInlinabilityOfBytecode_multianewarray_double(1, 1) instanceof double[][]); assertTrue("multianewarray failed for type byte", zeTest.svmTestInlinabilityOfBytecode_multianewarray_byte(1, 1) instanceof byte[][]); assertTrue("multianewarray failed for type short", zeTest.svmTestInlinabilityOfBytecode_multianewarray_short(1, 1) instanceof short[][]); assertTrue("multianewarray failed for type int", zeTest.svmTestInlinabilityOfBytecode_multianewarray_int(1, 1) instanceof int[][]); assertTrue("multianewarray failed for type long", zeTest.svmTestInlinabilityOfBytecode_multianewarray_long(1, 1) instanceof long[][]); } /** * @method : testTypeCast * @description : tests all the instructions converting a value from one basic type to another basic type individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testTypeCast() { // tests the d2 family instructions individually assertEquals("d2f failed", zeTest.svmTestInlinabilityOfBytecode_d2f(double1), float1, 0.0f); assertEquals("d2i failed", zeTest.svmTestInlinabilityOfBytecode_d2i(double1), int1); assertEquals("d2l failed", zeTest.svmTestInlinabilityOfBytecode_d2l(double1), long1); // tests the f2 family instructions individually assertEquals("f2d failed", zeTest.svmTestInlinabilityOfBytecode_f2d(float1), double1, 0.0); assertEquals("f2i failed", zeTest.svmTestInlinabilityOfBytecode_f2i(float1), int1); assertEquals("f2l failed", zeTest.svmTestInlinabilityOfBytecode_f2l(float1), long1); // tests the i2 family instructions individually assertEquals("i2b failed", zeTest.svmTestInlinabilityOfBytecode_i2b(int1), byte1); assertEquals("i2c failed", zeTest.svmTestInlinabilityOfBytecode_i2c(int1), char1); assertEquals("i2d failed", zeTest.svmTestInlinabilityOfBytecode_i2d(int1), double1, 0.0); assertEquals("i2f failed", zeTest.svmTestInlinabilityOfBytecode_i2f(int1), float1, 0.0f); assertEquals("i2l failed", zeTest.svmTestInlinabilityOfBytecode_i2l(int1), long1); assertEquals("i2s failed", zeTest.svmTestInlinabilityOfBytecode_i2s(int1), short1); // tests the l2 family instructions individually assertEquals("l2d failed", zeTest.svmTestInlinabilityOfBytecode_f2d(long1), double1, 0.0); assertEquals("l2f failed", zeTest.svmTestInlinabilityOfBytecode_f2i(long1), float1, 0.0f); assertEquals("l2i failed", zeTest.svmTestInlinabilityOfBytecode_f2l(long1), int1); } /** * @method : testFields * @description : tests all the instructions manipulating fields individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testFields() { // tests the getfield family instructions assertEquals("getfield failed for type byte", zeTest.svmTestInlinabilityOfBytecode_getfield_byte(zeFields), byte0); assertEquals("getfield failed for type char", zeTest.svmTestInlinabilityOfBytecode_getfield_char(zeFields), char0); assertEquals("getfield failed for type double", zeTest.svmTestInlinabilityOfBytecode_getfield_double(zeFields), double0, 0.0); assertEquals("getfield failed for type float", zeTest.svmTestInlinabilityOfBytecode_getfield_float(zeFields), float0, 0.0f); assertEquals("getfield failed for type int", zeTest.svmTestInlinabilityOfBytecode_getfield_int(zeFields), int0); assertEquals("getfield failed for type long", zeTest.svmTestInlinabilityOfBytecode_getfield_long(zeFields), long0); assertEquals("getfield failed for type reference", zeTest.svmTestInlinabilityOfBytecode_getfield_object(zeFields), null); assertEquals("getfield failed for type short", zeTest.svmTestInlinabilityOfBytecode_getfield_short(zeFields), short0); assertEquals("getfield failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_getfield_boolean(zeFields), booleanTrue); assertEquals("getfield failed for type array", zeTest.svmTestInlinabilityOfBytecode_getfield_array(zeFields), null); // tests the getstatic family instructions assertEquals("getstatic failed for type byte", zeTest.svmTestInlinabilityOfBytecode_getstatic_byte(), byte0); assertEquals("getstatic failed for type char", zeTest.svmTestInlinabilityOfBytecode_getstatic_char(), char0); assertEquals("getstatic failed for type double", zeTest.svmTestInlinabilityOfBytecode_getstatic_double(), double0, 0.0); assertEquals("getstatic failed for type float", zeTest.svmTestInlinabilityOfBytecode_getstatic_float(), float0, 0.0f); assertEquals("getstatic failed for type int", zeTest.svmTestInlinabilityOfBytecode_getstatic_int(), int0); assertEquals("getstatic failed for type long", zeTest.svmTestInlinabilityOfBytecode_getstatic_long(), long0); assertEquals("getstatic failed for type reference", zeTest.svmTestInlinabilityOfBytecode_getstatic_object(), null); assertEquals("getstatic failed for type short", zeTest.svmTestInlinabilityOfBytecode_getstatic_short(), short0); assertEquals("getstatic failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_getstatic_boolean(), booleanTrue); assertEquals("getstatic failed for type array", zeTest.svmTestInlinabilityOfBytecode_getstatic_array(), null); // tests the putfield family instructions assertEquals("putfield failed for type byte", zeTest.svmTestInlinabilityOfBytecode_putfield_byte(zeFields, byte1), byte1); assertEquals("putfield failed for type char", zeTest.svmTestInlinabilityOfBytecode_putfield_char(zeFields, char1), char1); assertEquals("putfield failed for type double", zeTest.svmTestInlinabilityOfBytecode_putfield_double(zeFields, double1), double1, 0.0); assertEquals("putfield failed for type float", zeTest.svmTestInlinabilityOfBytecode_putfield_float(zeFields, float1), float1, 0.0f); assertEquals("putfield failed for type int", zeTest.svmTestInlinabilityOfBytecode_putfield_int(zeFields, int1), int1); assertEquals("putfield failed for type long", zeTest.svmTestInlinabilityOfBytecode_putfield_long(zeFields, long1), long1); assertEquals("putfield failed for type reference", zeTest.svmTestInlinabilityOfBytecode_putfield_object(zeFields, anObject), anObject); assertEquals("putfield failed for type short", zeTest.svmTestInlinabilityOfBytecode_putfield_short(zeFields, short1), short1); assertEquals("putfield failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_putfield_boolean(zeFields, booleanFalse), booleanFalse); assertEquals("putfield failed for type array", zeTest.svmTestInlinabilityOfBytecode_putfield_array(zeFields, anObjectArray), anObjectArray); // tests the putstatic family instructions assertEquals("putstatic failed for type byte", zeTest.svmTestInlinabilityOfBytecode_putstatic_byte(byte1), byte1); assertEquals("putstatic failed for type char", zeTest.svmTestInlinabilityOfBytecode_putstatic_char(char1), char1); assertEquals("putstatic failed for type double", zeTest.svmTestInlinabilityOfBytecode_putstatic_double(double1), double1, 0.0); assertEquals("putstatic failed for type float", zeTest.svmTestInlinabilityOfBytecode_putstatic_float(float1), float1, 0.0f); assertEquals("putstatic failed for type int", zeTest.svmTestInlinabilityOfBytecode_putstatic_int(int1), int1); assertEquals("putstatic failed for type long", zeTest.svmTestInlinabilityOfBytecode_putstatic_long(long1), long1); assertEquals("putstatic failed for type reference", zeTest.svmTestInlinabilityOfBytecode_putstatic_object(anObject), anObject); assertEquals("putstatic failed for type short", zeTest.svmTestInlinabilityOfBytecode_putstatic_short(short1), short1); assertEquals("putstatic failed for type boolean", zeTest.svmTestInlinabilityOfBytecode_putstatic_boolean(booleanFalse), booleanFalse); assertEquals("putstatic failed for type array", zeTest.svmTestInlinabilityOfBytecode_putstatic_array(anObjectArray), anObjectArray); } /** * @method : testArithmetic * @description : tests all the arithmetic instructions individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testArithmetic() { // tests all arithmetic instructions on type double assertEquals("dadd failed when adding finite to finite", zeTest.svmTestInlinabilityOfBytecode_dadd(double1, double1), 2.0, 0.0); assertEquals("dadd failed when adding finite to finite of same magnitude but different sign", zeTest.svmTestInlinabilityOfBytecode_dadd(double1, doublen1), double0, 0.0); assertTrue("dadd failed when adding finite to infinite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dadd(double1, Double.POSITIVE_INFINITY))); assertTrue("dadd failed when adding finite to NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(double1, Double.NaN))); assertTrue("dadd failed when adding infinite to finite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.POSITIVE_INFINITY, double1))); assertTrue("dadd failed when adding infinite to infinite of same sign", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("dadd failed when adding infinite to infinite of different sign", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("dadd failed when adding infinite to NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.POSITIVE_INFINITY, Double.NaN))); assertTrue("dadd failed when adding NaN to finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.NaN, double1))); assertTrue("dadd failed when adding NaN to infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.NaN, Double.POSITIVE_INFINITY))); assertTrue("dadd failed when adding NaN to NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dadd(Double.NaN, Double.NaN))); assertEquals("dadd failed when adding 0 to 0 of different sign", zeTest.svmTestInlinabilityOfBytecode_dadd(double0, -0.0), double0, 0.0); assertEquals("dcmpg failed when value1 > value2", zeTest.svmTestInlinabilityOfBytecode_dcmpg(double1, double0), 1, 0.0); assertEquals("dcmpg failed when value1 = value2", zeTest.svmTestInlinabilityOfBytecode_dcmpg(double1, double1), 0, 0.0); assertEquals("dcmpg failed when value1 < value2", zeTest.svmTestInlinabilityOfBytecode_dcmpg(double0, double1), -1, 0.0); assertEquals("dcmpg failed when comparing with NaN as value1", zeTest.svmTestInlinabilityOfBytecode_dcmpg(double1, Double.NaN), 1, 0.0); assertEquals("dcmpg failed when comparing with NaN as value2", zeTest.svmTestInlinabilityOfBytecode_dcmpg(Double.NaN, double1), 1, 0.0); assertEquals("dcmpl failed when value1 > value2", zeTest.svmTestInlinabilityOfBytecode_dcmpl(double1, double0), 1, 0.0); assertEquals("dcmpl failed when value1 = value2", zeTest.svmTestInlinabilityOfBytecode_dcmpl(double1, double1), 0, 0.0); assertEquals("dcmpl failed when value1 < value2", zeTest.svmTestInlinabilityOfBytecode_dcmpl(double0, double1), -1, 0.0); assertEquals("dcmpl failed when comparing with NaN as value1", zeTest.svmTestInlinabilityOfBytecode_dcmpl(double1, Double.NaN), -1, 0.0); assertEquals("dcmpl failed when comparing with NaN as value2", zeTest.svmTestInlinabilityOfBytecode_dcmpl(Double.NaN, double1), -1, 0.0); assertEquals("ddiv failed when dividing finite by finite", zeTest.svmTestInlinabilityOfBytecode_ddiv(double1, double1), 1.0, 0.0); assertTrue("ddiv failed when dividing finite by 0", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_ddiv(double1, double0))); assertEquals("ddiv failed when dividing finite by infinite", zeTest.svmTestInlinabilityOfBytecode_ddiv(double1, Double.POSITIVE_INFINITY), double0, 0.0); assertTrue("ddiv failed when dividing finite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(double1, Double.NaN))); assertEquals("ddiv failed when dividing 0 by finite", zeTest.svmTestInlinabilityOfBytecode_ddiv(double0, double1), double0, 0.0); assertTrue("ddiv failed when dividing 0 by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(double0, double0))); assertEquals("ddiv failed when dividing 0 by infinite", zeTest.svmTestInlinabilityOfBytecode_ddiv(double0, Double.POSITIVE_INFINITY), double0, 0.0); assertTrue("ddiv failed when dividing 0 by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(double0, Double.NaN))); assertTrue("ddiv failed when dividing infinite by finite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.POSITIVE_INFINITY, double1))); assertTrue("ddiv failed when dividing infinite by 0", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.POSITIVE_INFINITY, double0))); assertTrue("ddiv failed when dividing infinite by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("ddiv failed when dividing infinite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.POSITIVE_INFINITY, Double.NaN))); assertTrue("ddiv failed when dividing NaN by finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.NaN, double1))); assertTrue("ddiv failed when dividing NaN by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.NaN, double0))); assertTrue("ddiv failed when dividing NaN by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.NaN, Double.POSITIVE_INFINITY))); assertTrue("ddiv failed when dividing NaN by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_ddiv(Double.NaN, Double.NaN))); assertEquals("dmul failed when multiplying finite by finite", zeTest.svmTestInlinabilityOfBytecode_dmul(double1, double1), 1.0, 0.0); assertEquals("dmul failed when multiplying finite by 0", zeTest.svmTestInlinabilityOfBytecode_dmul(double1, double0), double0, 0.0); assertTrue("dmul failed when multiplying finite by infinite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dmul(double1, Double.POSITIVE_INFINITY))); assertTrue("dmul failed when multiplying finite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(double1, Double.NaN))); assertEquals("dmul failed when multiplying 0 by finite", zeTest.svmTestInlinabilityOfBytecode_dmul(double0, double1), double0, 0.0); assertEquals("dmul failed when multiplying 0 by 0", zeTest.svmTestInlinabilityOfBytecode_dmul(double0, double0), double0, 0.0); assertTrue("dmul failed when multiplying 0 by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(double0, Double.POSITIVE_INFINITY))); assertTrue("dmul failed when multiplying 0 by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(double0, Double.NaN))); assertTrue("dmul failed when multiplying infinite by finite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.POSITIVE_INFINITY, double1))); assertTrue("dmul failed when multiplying infinite by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.POSITIVE_INFINITY, double0))); assertTrue("dmul failed when multiplying infinite by infinite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("dmul failed when multiplying infinite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.POSITIVE_INFINITY, Double.NaN))); assertTrue("dmul failed when multiplying NaN by finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.NaN, double1))); assertTrue("dmul failed when multiplying NaN by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.NaN, double0))); assertTrue("dmul failed when multiplying NaN by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.NaN, Double.POSITIVE_INFINITY))); assertTrue("dmul failed when multiplying NaN by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dmul(Double.NaN, Double.NaN))); assertEquals("dneg failed when negating finite", zeTest.svmTestInlinabilityOfBytecode_dneg(double1), doublen1, 0.0); assertEquals("dneg failed when negating 0", zeTest.svmTestInlinabilityOfBytecode_dneg(double0), double0, 0.0); assertTrue("dneg failed when negating infinite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dneg(Double.POSITIVE_INFINITY))); assertTrue("dneg failed when negating NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dneg(Double.NaN))); assertEquals("drem failed when remaining finite by finite", zeTest.svmTestInlinabilityOfBytecode_drem(double1, double1), double0, 0.0); assertTrue("drem failed when remaining finite by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(double1, double0))); assertEquals("drem failed when remaining finite by infinite", zeTest.svmTestInlinabilityOfBytecode_drem(double1, Double.POSITIVE_INFINITY), double1, 0.0); assertTrue("drem failed when remaining finite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(double1, Double.NaN))); assertEquals("drem failed when remaining 0 by finite", zeTest.svmTestInlinabilityOfBytecode_drem(double0, double1), double0, 0.0); assertTrue("drem failed when remaining 0 by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(double0, double0))); assertEquals("drem failed when remaining 0 by infinite", zeTest.svmTestInlinabilityOfBytecode_drem(double0, Double.POSITIVE_INFINITY), double0, 0.0); assertTrue("drem failed when remaining 0 by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(double0, Double.NaN))); assertTrue("drem failed when remaining infinite by finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.POSITIVE_INFINITY, double1))); assertTrue("drem failed when remaining infinite by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.POSITIVE_INFINITY, double0))); assertTrue("drem failed when remaining infinite by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("drem failed when remaining infinite by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.POSITIVE_INFINITY, Double.NaN))); assertTrue("drem failed when remaining NaN by finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.NaN, double1))); assertTrue("drem failed when remaining NaN by 0", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.NaN, double0))); assertTrue("drem failed when remaining NaN by infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.NaN, Double.POSITIVE_INFINITY))); assertTrue("drem failed when remaining NaN by NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_drem(Double.NaN, Double.NaN))); assertEquals("dsub failed when subtracting finite from finite", zeTest.svmTestInlinabilityOfBytecode_dsub(double0, double1), doublen1, 0.0); assertEquals("dsub failed when subtracting finite from finite of same magnitude and same sign", zeTest.svmTestInlinabilityOfBytecode_dsub(double1, double1), double0, 0.0); assertTrue("dsub failed when subtracting infinite from finite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dsub(double1, Double.POSITIVE_INFINITY))); assertTrue("dsub failed when subtracting NaN from finite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(double1, Double.NaN))); assertTrue("dsub failed when subtracting finite from infinite", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.POSITIVE_INFINITY, double1))); assertTrue("dsub failed when subtracting infinite from infinite of same sign", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("dsub failed when subtracting infinite from infinite of different sign", Double.isInfinite(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY))); assertTrue("dsub failed when subtracting NaN from infinite", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.POSITIVE_INFINITY, Double.NaN))); assertTrue("dsub failed when subtracting finite from NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.NaN, double1))); assertTrue("dsub failed when subtracting infinite from NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.NaN, Double.POSITIVE_INFINITY))); assertTrue("dsub failed when subtracting NaN from NaN", Double.isNaN(zeTest.svmTestInlinabilityOfBytecode_dsub(Double.NaN, Double.NaN))); // tests all arithmetic instructions on type float assertEquals("fadd failed when adding finite to finite", zeTest.svmTestInlinabilityOfBytecode_fadd(float1, float1), 2.0, 0.0f); assertEquals("fadd failed when adding finite to finite of same magnitude but different sign", zeTest.svmTestInlinabilityOfBytecode_fadd(float1, floatn1), float0, 0.0f); assertTrue("fadd failed when adding finite to infinite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fadd(float1, Float.POSITIVE_INFINITY))); assertTrue("fadd failed when adding finite to NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(float1, Float.NaN))); assertTrue("fadd failed when adding infinite to finite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.POSITIVE_INFINITY, float1))); assertTrue("fadd failed when adding infinite to infinite of same sign", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fadd failed when adding infinite to infinite of different sign", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fadd failed when adding infinite to NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.POSITIVE_INFINITY, Float.NaN))); assertTrue("fadd failed when adding NaN to finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.NaN, float1))); assertTrue("fadd failed when adding NaN to infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.NaN, Float.POSITIVE_INFINITY))); assertTrue("fadd failed when adding NaN to NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fadd(Float.NaN, Float.NaN))); assertEquals("fadd failed when adding 0 to 0 of different sign", zeTest.svmTestInlinabilityOfBytecode_fadd(float0, -0.0f), float0, 0.0f); assertEquals("fcmpg failed when value1 > value2", zeTest.svmTestInlinabilityOfBytecode_fcmpg(float1, float0), 1, 0.0f); assertEquals("fcmpg failed when value1 = value2", zeTest.svmTestInlinabilityOfBytecode_fcmpg(float1, float1), 0, 0.0f); assertEquals("fcmpg failed when value1 < value2", zeTest.svmTestInlinabilityOfBytecode_fcmpg(float0, float1), -1, 0.0f); assertEquals("fcmpg failed when comparing with NaN as value1", zeTest.svmTestInlinabilityOfBytecode_fcmpg(float1, Float.NaN), 1, 0.0f); assertEquals("fcmpg failed when comparing with NaN as value2", zeTest.svmTestInlinabilityOfBytecode_fcmpg(Float.NaN, float1), 1, 0.0f); assertEquals("fcmpl failed when value1 > value2", zeTest.svmTestInlinabilityOfBytecode_fcmpl(float1, float0), 1, 0.0f); assertEquals("fcmpl failed when value1 = value2", zeTest.svmTestInlinabilityOfBytecode_fcmpl(float1, float1), 0, 0.0f); assertEquals("fcmpl failed when value1 < value2", zeTest.svmTestInlinabilityOfBytecode_fcmpl(float0, float1), -1, 0.0f); assertEquals("fcmpl failed when comparing with NaN as value1", zeTest.svmTestInlinabilityOfBytecode_fcmpl(float1, Float.NaN), -1, 0.0f); assertEquals("fcmpl failed when comparing with NaN as value2", zeTest.svmTestInlinabilityOfBytecode_fcmpl(Float.NaN, float1), -1, 0.0f); assertEquals("fdiv failed when dividing finite by finite", zeTest.svmTestInlinabilityOfBytecode_fdiv(float1, float1), 1.0, 0.0f); assertTrue("fdiv failed when dividing finite by 0", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fdiv(float1, float0))); assertEquals("fdiv failed when dividing finite by infinite", zeTest.svmTestInlinabilityOfBytecode_fdiv(float1, Float.POSITIVE_INFINITY), float0, 0.0f); assertTrue("fdiv failed when dividing finite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(float1, Float.NaN))); assertEquals("fdiv failed when dividing 0 by finite", zeTest.svmTestInlinabilityOfBytecode_fdiv(float0, float1), float0, 0.0f); assertTrue("fdiv failed when dividing 0 by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(float0, float0))); assertEquals("fdiv failed when dividing 0 by infinite", zeTest.svmTestInlinabilityOfBytecode_fdiv(float0, Float.POSITIVE_INFINITY), float0, 0.0f); assertTrue("fdiv failed when dividing 0 by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(float0, Float.NaN))); assertTrue("fdiv failed when dividing infinite by finite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.POSITIVE_INFINITY, float1))); assertTrue("fdiv failed when dividing infinite by 0", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.POSITIVE_INFINITY, float0))); assertTrue("fdiv failed when dividing infinite by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fdiv failed when dividing infinite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.POSITIVE_INFINITY, Float.NaN))); assertTrue("fdiv failed when dividing NaN by finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.NaN, float1))); assertTrue("fdiv failed when dividing NaN by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.NaN, float0))); assertTrue("fdiv failed when dividing NaN by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.NaN, Float.POSITIVE_INFINITY))); assertTrue("fdiv failed when dividing NaN by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fdiv(Float.NaN, Float.NaN))); assertEquals("fmul failed when multiplying finite by finite", zeTest.svmTestInlinabilityOfBytecode_fmul(float1, float1), 1.0, 0.0f); assertEquals("fmul failed when multiplying finite by 0", zeTest.svmTestInlinabilityOfBytecode_fmul(float1, float0), float0, 0.0f); assertTrue("fmul failed when multiplying finite by infinite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fmul(float1, Float.POSITIVE_INFINITY))); assertTrue("fmul failed when multiplying finite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(float1, Float.NaN))); assertEquals("fmul failed when multiplying 0 by finite", zeTest.svmTestInlinabilityOfBytecode_fmul(float0, float1), float0, 0.0f); assertEquals("fmul failed when multiplying 0 by 0", zeTest.svmTestInlinabilityOfBytecode_fmul(float0, float0), float0, 0.0f); assertTrue("fmul failed when multiplying 0 by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(float0, Float.POSITIVE_INFINITY))); assertTrue("fmul failed when multiplying 0 by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(float0, Float.NaN))); assertTrue("fmul failed when multiplying infinite by finite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.POSITIVE_INFINITY, float1))); assertTrue("fmul failed when multiplying infinite by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.POSITIVE_INFINITY, float0))); assertTrue("fmul failed when multiplying infinite by infinite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fmul failed when multiplying infinite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.POSITIVE_INFINITY, Float.NaN))); assertTrue("fmul failed when multiplying NaN by finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.NaN, float1))); assertTrue("fmul failed when multiplying NaN by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.NaN, float0))); assertTrue("fmul failed when multiplying NaN by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.NaN, Float.POSITIVE_INFINITY))); assertTrue("fmul failed when multiplying NaN by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fmul(Float.NaN, Float.NaN))); assertEquals("fneg failed when negating finite", zeTest.svmTestInlinabilityOfBytecode_fneg(float1), floatn1, 0.0f); assertEquals("fneg failed when negating 0", zeTest.svmTestInlinabilityOfBytecode_fneg(float0), float0, 0.0f); assertTrue("fneg failed when negating infinite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fneg(Float.POSITIVE_INFINITY))); assertTrue("fneg failed when negating NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fneg(Float.NaN))); assertEquals("frem failed when remaining finite by finite", zeTest.svmTestInlinabilityOfBytecode_frem(float1, float1), float0, 0.0f); assertTrue("frem failed when remaining finite by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(float1, float0))); assertEquals("frem failed when remaining finite by infinite", zeTest.svmTestInlinabilityOfBytecode_frem(float1, Float.POSITIVE_INFINITY), float1, 0.0f); assertTrue("frem failed when remaining finite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(float1, Float.NaN))); assertEquals("frem failed when remaining 0 by finite", zeTest.svmTestInlinabilityOfBytecode_frem(float0, float1), float0, 0.0f); assertTrue("frem failed when remaining 0 by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(float0, float0))); assertEquals("frem failed when remaining 0 by infinite", zeTest.svmTestInlinabilityOfBytecode_frem(float0, Float.POSITIVE_INFINITY), float0, 0.0f); assertTrue("frem failed when remaining 0 by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(float0, Float.NaN))); assertTrue("frem failed when remaining infinite by finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.POSITIVE_INFINITY, float1))); assertTrue("frem failed when remaining infinite by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.POSITIVE_INFINITY, float0))); assertTrue("frem failed when remaining infinite by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("frem failed when remaining infinite by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.POSITIVE_INFINITY, Float.NaN))); assertTrue("frem failed when remaining NaN by finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.NaN, float1))); assertTrue("frem failed when remaining NaN by 0", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.NaN, float0))); assertTrue("frem failed when remaining NaN by infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.NaN, Float.POSITIVE_INFINITY))); assertTrue("frem failed when remaining NaN by NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_frem(Float.NaN, Float.NaN))); assertEquals("fsub failed when subtracting finite from finite", zeTest.svmTestInlinabilityOfBytecode_fsub(float0, float1), floatn1, 0.0f); assertEquals("fsub failed when subtracting finite from finite of same magnitude and same sign", zeTest.svmTestInlinabilityOfBytecode_fsub(float1, float1), float0, 0.0f); assertTrue("fsub failed when subtracting infinite from finite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fsub(float1, Float.POSITIVE_INFINITY))); assertTrue("fsub failed when subtracting NaN from finite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(float1, Float.NaN))); assertTrue("fsub failed when subtracting finite from infinite", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.POSITIVE_INFINITY, float1))); assertTrue("fsub failed when subtracting infinite from infinite of same sign", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fsub failed when subtracting infinite from infinite of different sign", Float.isInfinite(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY))); assertTrue("fsub failed when subtracting NaN from infinite", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.POSITIVE_INFINITY, Float.NaN))); assertTrue("fsub failed when subtracting finite from NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.NaN, float1))); assertTrue("fsub failed when subtracting infinite from NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.NaN, Float.POSITIVE_INFINITY))); assertTrue("fsub failed when subtracting NaN from NaN", Float.isNaN(zeTest.svmTestInlinabilityOfBytecode_fsub(Float.NaN, Float.NaN))); // tests all arithmetic instructions on type int except wide iinc assertEquals("iadd failed", zeTest.svmTestInlinabilityOfBytecode_iadd(int1, int0), int1); assertEquals("iand failed", zeTest.svmTestInlinabilityOfBytecode_iand(int1, intn1), int1); assertEquals("idiv failed when dividing integer by integer", zeTest.svmTestInlinabilityOfBytecode_idiv(int0, int1), int0); assertEquals("idiv failed when dividing Integer.MAX_VALUE by -1", zeTest.svmTestInlinabilityOfBytecode_idiv(Integer.MIN_VALUE, intn1), Integer.MIN_VALUE); try { assertTrue(new Integer(zeTest.svmTestInlinabilityOfBytecode_idiv(int1, int0)) instanceof Integer); fail("idiv failed when dividing integer by 0"); }catch(ArithmeticException e){} assertEquals("iinc failed", zeTest.svmTestInlinabilityOfBytecode_iinc(int0), int1); assertEquals("imul failed", zeTest.svmTestInlinabilityOfBytecode_imul(int1, intn1), intn1); assertEquals("ineg failed", zeTest.svmTestInlinabilityOfBytecode_ineg(int1), intn1); assertEquals("ior failed", zeTest.svmTestInlinabilityOfBytecode_ior(int1, intn1), intn1); assertEquals("irem failed when remaining integer by integer", zeTest.svmTestInlinabilityOfBytecode_irem(int1, int1), int0); try { assertTrue(new Integer(zeTest.svmTestInlinabilityOfBytecode_irem(int1, int0)) instanceof Integer); fail("irem failed when remaining integer by 0"); }catch(ArithmeticException e){} assertEquals("ishl failed", zeTest.svmTestInlinabilityOfBytecode_ishl(int1, int1), 2); assertEquals("ishr failed", zeTest.svmTestInlinabilityOfBytecode_ishr(int1, int1), int0); assertEquals("isub failed", zeTest.svmTestInlinabilityOfBytecode_isub(int1, int1), int0); assertEquals("iushr failed", zeTest.svmTestInlinabilityOfBytecode_iushr(intn1, int1), Integer.MAX_VALUE); assertEquals("ixor failed", zeTest.svmTestInlinabilityOfBytecode_ixor(int1, intn1), -2); // tests all arithmetic instructions on type long assertEquals("ladd failed", zeTest.svmTestInlinabilityOfBytecode_ladd(long1, long0), long1); assertEquals("land failed", zeTest.svmTestInlinabilityOfBytecode_land(long1, longn1), long1); assertEquals("lcmp failed when value1 > value2", zeTest.svmTestInlinabilityOfBytecode_lcmp(long1, long0), int1); assertEquals("lcmp failed when value1 = value2", zeTest.svmTestInlinabilityOfBytecode_lcmp(long1, long1), int0); assertEquals("lcmp failed when value1 < value2", zeTest.svmTestInlinabilityOfBytecode_lcmp(long0, long1), intn1); assertEquals("ldiv failed when dividing longeger by longeger", zeTest.svmTestInlinabilityOfBytecode_ldiv(long0, long1), long0); assertEquals("ldiv failed when dividing Long.MAX_VALUE by -1", zeTest.svmTestInlinabilityOfBytecode_ldiv(Long.MIN_VALUE, longn1), Long.MIN_VALUE); try { assertTrue(new Long(zeTest.svmTestInlinabilityOfBytecode_ldiv(long1, long0)) instanceof Long); fail("ldiv failed when dividing longeger by 0"); }catch(ArithmeticException e){} assertEquals("lmul failed", zeTest.svmTestInlinabilityOfBytecode_lmul(long1, longn1), longn1); assertEquals("lneg failed", zeTest.svmTestInlinabilityOfBytecode_lneg(long1), longn1); assertEquals("lor failed", zeTest.svmTestInlinabilityOfBytecode_lor(long1, longn1), longn1); assertEquals("lrem failed when remaining longeger by longeger", zeTest.svmTestInlinabilityOfBytecode_lrem(long1, long1), long0); try { assertTrue(new Long(zeTest.svmTestInlinabilityOfBytecode_lrem(long1, long0)) instanceof Long); fail("lrem failed when remaining longeger by 0"); }catch(ArithmeticException e){} assertEquals("lshl failed", zeTest.svmTestInlinabilityOfBytecode_lshl(long1, int1), 2); assertEquals("lshr failed", zeTest.svmTestInlinabilityOfBytecode_lshr(long1, int1), long0); assertEquals("lsub failed", zeTest.svmTestInlinabilityOfBytecode_lsub(long1, long1), long0); assertEquals("lushr failed", zeTest.svmTestInlinabilityOfBytecode_lushr(longn1, int1), Long.MAX_VALUE); assertEquals("lxor failed", zeTest.svmTestInlinabilityOfBytecode_lxor(long1, longn1), -2); } /** * @method : testWideLoad * @description : tests all the wide_load instructions individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testWideLoad() { // tests all the instructions of the wide_aload family assertEquals("wide_aload failed", zeTest.svmTestInlinabilityOfBytecode_wide_aload(anObject), anObject); assertEquals("wide_aload_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_aload_0(anObject), anObject); assertEquals("wide_aload_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_aload_1(anotherObject, anObject), anObject); assertEquals("wide_aload_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_aload_2(anotherObject, anotherObject, anObject), anObject); assertEquals("wide_aload_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_aload_3(anotherObject, anotherObject, anotherObject, anObject), anObject); // tests all the instructions of the wide_dload family assertEquals("wide_dload failed", zeTest.svmTestInlinabilityOfBytecode_wide_dload(double1), double1, double0); assertEquals("wide_dload_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dload_0(double1), double1, double0); assertEquals("wide_dload_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dload_1(int0, double1), double1, double0); assertEquals("wide_dload_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dload_2(double0, double1), double1, double0); assertEquals("wide_dload_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dload_3(int0, double0, double1), double1, double0); // tests all the instructions of the wide_fload family assertEquals("wide_fload failed", zeTest.svmTestInlinabilityOfBytecode_fload(float1), float1, float0); assertEquals("wide_fload_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fload_0(float1), float1, float0); assertEquals("wide_fload_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fload_1(float0, float1), float1, float0); assertEquals("wide_fload_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fload_2(float0, float0, float1), float1, float0); assertEquals("wide_fload_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fload_3(float0, float0, float0, float1), float1, float0); // tests all the instructions of the wide_iload family assertEquals("wide_iload failed", zeTest.svmTestInlinabilityOfBytecode_wide_iload(int1), int1); assertEquals("wide_iload_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_iload_0(int1), int1); assertEquals("wide_iload_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_iload_1(int0, int1), int1); assertEquals("wide_iload_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_iload_2(int0, int0, int1), int1); assertEquals("wide_iload_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_iload_3(int0, int0, int0, int1), int1); // tests all the instructions of the wide_lload family assertEquals("wide_lload failed", zeTest.svmTestInlinabilityOfBytecode_wide_lload(long1), long1); assertEquals("wide_lload_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lload_0(long1), long1); assertEquals("wide_lload_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lload_1(int0, long1), long1); assertEquals("wide_lload_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lload_2(long0, long1), long1); assertEquals("wide_lload_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lload_3(int0, long0, long1), long1); } /** * @method : testWideStore * @description : tests all the wide_store instructions individually. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testWideStore() { // tests all the instructions of the wide_astore family assertEquals("wide_astore failed", zeTest.svmTestInlinabilityOfBytecode_wide_astore(anObject), anObject); assertEquals("wide_astore_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_astore_0(anotherObject, anObject), anObject); assertEquals("wide_astore_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_astore_1(anObject), anObject); assertEquals("wide_astore_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_astore_2(anObject), anObject); assertEquals("wide_astore_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_astore_3(anObject), anObject); // tests all the instructions of the wide_dstore family assertEquals("wide_dstore failed", zeTest.svmTestInlinabilityOfBytecode_wide_dstore(double0, double1), double1, 0.0); assertEquals("wide_dstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dstore_0(double0, double1), double1, 0.0); assertEquals("wide_dstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dstore_1(0, double0, double1), double1, 0.0); assertEquals("wide_dstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dstore_2(double1), double1, 0.0); assertEquals("wide_dstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_dstore_3(double1), double1, 0.0); // tests all the instructions of the wide_fstore family assertEquals("wide_fstore failed", zeTest.svmTestInlinabilityOfBytecode_wide_fstore(float1), float1, 0.0f); assertEquals("wide_fstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fstore_0(float0, float1), float1, 0.0f); assertEquals("wide_fstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fstore_1(float1), float1, 0.0f); assertEquals("wide_fstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fstore_2(float1), float1, 0.0f); assertEquals("wide_fstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_fstore_3(float1), float1, 0.0f); // tests all the instructions of the wide_istore family assertEquals("wide_istore failed", zeTest.svmTestInlinabilityOfBytecode_wide_istore(int1), int1); assertEquals("wide_istore_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_istore_0(int0, int1), int1); assertEquals("wide_istore_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_istore_1(int1), int1); assertEquals("wide_istore_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_istore_2(int1), int1); assertEquals("wide_istore_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_istore_3(int1), int1); // tests all the instructions of the wide_lstore family assertEquals("wide_lstore failed", zeTest.svmTestInlinabilityOfBytecode_wide_lstore(long0, long1), long1); assertEquals("wide_lstore_0 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lstore_0(long0, long1), long1); assertEquals("wide_lstore_1 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lstore_1(0, long0, long1), long1); assertEquals("wide_lstore_2 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lstore_2(long1), long1); assertEquals("wide_lstore_3 failed", zeTest.svmTestInlinabilityOfBytecode_wide_lstore_3(long1), long1); // tests the wiinc instruction assertEquals("wide_iinc failed", zeTest.svmTestInlinabilityOfBytecode_wide_iinc(int0), int1); } /** * @method : testLock * @description : tests all the instructions monitorenter and monitorexit. It does not tests if the current * thread actually gains ownership of the monitor of the object but tests that the execution of the instructions * is coherent. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testLock() { // tests the monitorenter and monitorexit instructions assertTrue("monitorenter/exit failed", zeTest.svmTestInlinabilityOfBytecode_monitorenter(anObject) == anObject); } /** * @method : testArraylength * @description : tests the arraylength instruction. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testArraylength() { // tests the arraylength instruction assertEquals("arraylength failed", zeTest.svmTestInlinabilityOfBytecode_arraylength(anObjectArray), arrayLength); } /** * @method : testNop * @description : tests the nop instruction. * * @author : Christian Arcand * @version : 1.0 * @date : 2003 */ public void testNop() { // tests the nop instruction try { zeTest.svmTestInlinabilityOfBytecode_nop(); } catch (Exception e) { fail("nop failed"); } } }