Example usage for org.objectweb.asm Opcodes IF_ICMPGE

List of usage examples for org.objectweb.asm Opcodes IF_ICMPGE

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes IF_ICMPGE.

Prototype

int IF_ICMPGE

To view the source code for org.objectweb.asm Opcodes IF_ICMPGE.

Click Source Link

Usage

From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java

License:Open Source License

/**
 * <p>getInfectionDistance</p>
 *
 * @param opcodeOrig a int.//from ww w  .j av  a  2s . c  o  m
 * @param opcodeNew a int.
 * @return a {@link org.objectweb.asm.tree.InsnList} object.
 */
public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) {
    InsnList distance = new InsnList();
    switch (opcodeOrig) {
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance",
                "(IIII)D", false));
        break;

    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
        distance.add(new InsnNode(Opcodes.DUP));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance", "(III)D",
                false));
        break;

    default:
        distance.add(new LdcInsnNode(0.0));
    }

    return distance;
}

From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java

License:Open Source License

/**
 * <p>getInfectionDistance</p>
 *
 * @param left a int.//w  w  w. ja va2s. c  om
 * @param right a int.
 * @param opcodeOrig a int.
 * @param opcodeNew a int.
 * @return a double.
 */
public static double getInfectionDistance(int left, int right, int opcodeOrig, int opcodeNew) {
    long val = (long) left - (long) right;
    switch (opcodeOrig) {
    case Opcodes.IF_ICMPLT:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPLE:
            // Only differs for val == 0
            return Math.abs(val);
        case Opcodes.IF_ICMPEQ:
            // Only differs for val <= 0
            return val > 0 ? val : 0.0;
        case Opcodes.IF_ICMPGT:
            // Only same for val == 0
            return val == 0 ? 1.0 : 0.0;
        case Opcodes.IF_ICMPGE:
            // Always differs
            return 0.0;
        case Opcodes.IF_ICMPNE:
            // Only differs for val > 0
            return val <= 0 ? Math.abs(val) + 1.0 : 0.0;
        case TRUE:
            return val < 0 ? 1.0 : 0.0;
        case FALSE:
            return val < 0 ? 0.0 : 1.0;
        }
    case Opcodes.IF_ICMPLE:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPLT:
            // Only differs for val == 0
            return Math.abs(val);
        case Opcodes.IF_ICMPEQ:
            return val >= 0 ? val + 1.0 : 0.0;
        case Opcodes.IF_ICMPGE:
            // Only equals for val == 0
            return val == 0 ? 1.0 : 0.0;
        case Opcodes.IF_ICMPGT:
            // Always differs
            return 0.0;
        case Opcodes.IF_ICMPNE:
            // Only differs if val >= 0
            return val < 0 ? Math.abs(val) : 0.0;
        case TRUE:
            return val <= 0 ? 1.0 : 0.0;
        case FALSE:
            return val <= 0 ? 0.0 : 1.0;

        }
    case Opcodes.IF_ICMPGT:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPGE:
            // Only differs for val == 0
            return Math.abs(val);
        case Opcodes.IF_ICMPEQ:
            // Only differs for val >= 0
            return val < 0 ? Math.abs(val) : 0.0;
        case Opcodes.IF_ICMPLT:
            // Only same for val == 0
            return val == 0 ? 1.0 : 0.0;
        case Opcodes.IF_ICMPLE:
            // Always differs
            return 0.0;
        case Opcodes.IF_ICMPNE:
            // Only differs for val < 0
            return val >= 0 ? val + 1.0 : 0.0;
        case TRUE:
            return val > 0 ? 1.0 : 0.0;
        case FALSE:
            return val > 0 ? 0.0 : 1.0;
        }
    case Opcodes.IF_ICMPGE:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPGT:
            // Only differs for val == 0
            return Math.abs(val);
        case Opcodes.IF_ICMPEQ:
            return val <= 0 ? Math.abs(val) + 1.0 : 0.0;
        case Opcodes.IF_ICMPLE:
            // Only equals for val == 0
            return val == 0 ? 1.0 : 0.0;
        case Opcodes.IF_ICMPLT:
            // Always differs
            return 0.0;
        case Opcodes.IF_ICMPNE:
            // Only differs if val > 0
            return val > 0 ? val : 0.0;
        case TRUE:
            return val >= 0 ? 1.0 : 0.0;
        case FALSE:
            return val >= 0 ? 0.0 : 1.0;
        }
    case Opcodes.IF_ICMPEQ:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPLT:
            // Only differs if val <= 0
            return val > 0 ? val : 0.0;
        case Opcodes.IF_ICMPGT:
            // Only differs if val >= 0
            return val < 0 ? Math.abs(val) : 0.0;
        case Opcodes.IF_ICMPNE:
            // Always differs
            return 0.0;
        case Opcodes.IF_ICMPLE:
            return val >= 0 ? val + 1.0 : 0.0;
        case Opcodes.IF_ICMPGE:
            return val <= 0 ? Math.abs(val) + 1.0 : 0.0;
        case TRUE:
            return val == 0 ? 1.0 : 0.0;
        case FALSE:
            return val == 0 ? 0.0 : 1.0;
        }
    case Opcodes.IF_ICMPNE:
        switch (opcodeNew) {
        case Opcodes.IF_ICMPEQ:
            return 0.0;
        case Opcodes.IF_ICMPLT:
            // Only differs for val > 0
            return val <= 0 ? Math.abs(val) + 1.0 : 0.0;
        case Opcodes.IF_ICMPLE:
            // Only differs for val > 0
            return val < 0 ? Math.abs(val) : 0.0;
        case Opcodes.IF_ICMPGT:
            return val >= 0 ? val + 1.0 : 0.0;
        case Opcodes.IF_ICMPGE:
            return val > 0 ? val : 0.0;
        case TRUE:
            return val != 0 ? 1.0 : 0.0;
        case FALSE:
            return val != 0 ? 0.0 : 1.0;
        }
    }

    throw new RuntimeException("Unknown operator replacement: " + opcodeOrig + " -> " + opcodeNew);
}

From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java

License:Open Source License

private int getBooleanIntIntReplacement(int opcode) {
    logger.debug("Getting Boolean int int replacement");

    switch (opcode) {
    case Opcodes.IF_ICMPEQ:
        return Opcodes.IF_ICMPNE;
    case Opcodes.IF_ICMPNE:
        return Opcodes.IF_ICMPEQ;
    case Opcodes.IF_ICMPGT:
        return Opcodes.IF_ICMPEQ;
    case Opcodes.IF_ICMPLE:
        return Opcodes.IF_ICMPGT;
    // The rest should not occur except if our interpreter did something wrong
    case Opcodes.IF_ICMPGE:
        return Opcodes.IF_ICMPLT;
    case Opcodes.IF_ICMPLT:
        return Opcodes.IF_ICMPGE;
    }/* w  w  w  .  j a va  2s. c om*/
    throw new RuntimeException("Illegal opcode received: " + opcode);
}

From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java

License:Open Source License

private Set<Integer> getIntIntReplacement(int opcode) {
    logger.info("Getting int int replacement");

    Set<Integer> replacement = new HashSet<Integer>();
    switch (opcode) {
    case Opcodes.IF_ICMPEQ:
        replacement.add(Opcodes.IF_ICMPGE);
        replacement.add(Opcodes.IF_ICMPLE);
        // False/*from   ww  w . j  a v  a2  s  .c  om*/
        replacement.add(FALSE);
        break;
    case Opcodes.IF_ICMPNE:
        replacement.add(Opcodes.IF_ICMPLT);
        replacement.add(Opcodes.IF_ICMPGT);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IF_ICMPGT:
        replacement.add(Opcodes.IF_ICMPGE);
        replacement.add(Opcodes.IF_ICMPNE);
        // False
        replacement.add(FALSE);
        break;
    case Opcodes.IF_ICMPLE:
        replacement.add(Opcodes.IF_ICMPLT);
        replacement.add(Opcodes.IF_ICMPEQ);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IF_ICMPGE:
        replacement.add(Opcodes.IF_ICMPGT);
        replacement.add(Opcodes.IF_ICMPEQ);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IF_ICMPLT:
        replacement.add(Opcodes.IF_ICMPLE);
        replacement.add(Opcodes.IF_ICMPNE);
        // False
        replacement.add(FALSE);
        break;
    }
    return replacement;
}

From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java

License:Open Source License

@Test
public void testComparisonTwoEQ() {
    // x == 0 vs x != 0      
    assertEquals(0.0,/*from  w w  w.jav a2s  . c o m*/
            ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);

    // x == 0 vs x < 0
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);

    // x == 0 vs x <= 0
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);
    assertEquals(2.0,
            ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);

    // x == 0 vs x > 0
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);

    // x == 0 vs x >= 0
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
    assertEquals(2.0,
            ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
}

From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java

License:Open Source License

@Test
public void testComparisonTwoEQ2() {
    // x == 0 vs x != 0      
    assertEquals(0.0,/*  ww w  .  ja  va 2s .co  m*/
            ReplaceComparisonOperator.getInfectionDistance(10, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0);

    // x == 0 vs x < 0
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(10, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0);

    // x == 0 vs x <= 0
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(10, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);
    assertEquals(2.0,
            ReplaceComparisonOperator.getInfectionDistance(11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(-11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0);

    // x == 0 vs x > 0
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(10, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);
    assertEquals(21.0,
            ReplaceComparisonOperator.getInfectionDistance(-11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0);

    // x == 0 vs x >= 0
    assertEquals(1.0,
            ReplaceComparisonOperator.getInfectionDistance(10, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
    assertEquals(0.0,
            ReplaceComparisonOperator.getInfectionDistance(11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
    assertEquals(22.0,
            ReplaceComparisonOperator.getInfectionDistance(-11, 10, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0);
}

From source file:org.evosuite.instrumentation.testability.transformer.BooleanDistanceTransformer.java

License:Open Source License

@Override
protected AbstractInsnNode transformJumpInsnNode(MethodNode mn, JumpInsnNode jumpNode) {

    switch (jumpNode.getOpcode()) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        TransformationStatistics.insertPush(jumpNode.getOpcode());
        this.booleanTestabilityTransformation.insertPush(jumpNode.getOpcode(), jumpNode, mn.instructions);
        break;//from w ww  .j  a  va  2  s  .c o  m
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
        TransformationStatistics.insertPush(jumpNode.getOpcode());
        this.booleanTestabilityTransformation.insertPush2(jumpNode.getOpcode(), jumpNode, mn.instructions);
        break;
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        TransformationStatistics.insertPush(jumpNode.getOpcode());
        this.booleanTestabilityTransformation.insertPushNull(jumpNode.getOpcode(), jumpNode, mn.instructions);
        break;
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        TransformationStatistics.insertPush(jumpNode.getOpcode());
        this.booleanTestabilityTransformation.insertPushEquals(jumpNode.getOpcode(), jumpNode, mn.instructions);
        break;
    default:
        // GOTO, JSR: Do nothing
    }
    return jumpNode;
}

From source file:org.evosuite.instrumentation.TransformationStatistics.java

License:Open Source License

/**
 * Insertion of pushDistance//from   w w  w  .ja  v  a  2s .c  o m
 *
 * @param opcode a int.
 */
public static void insertPush(int opcode) {
    switch (opcode) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        insertedPushInt0++;
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
        insertedPushInt1++;
        break;
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        insertedPushIntRef++;
        break;
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        insertedPushIntNull++;
        break;
    default:
        // GOTO, JSR: Do nothing
    }
}

From source file:org.evosuite.regression.bytecode.RegressionClassDiff.java

License:Open Source License

private static String getBranchFamily(int opcode) {
    // The default family is the opcode itself
    // Admittedly we could've use ints/enums for performance, but strings should be interned anyway
    String family = "" + opcode;
    switch (opcode) {
    // copmpare int with zero
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        family = "int_zero";
        break;/*from   w ww.  j  a v a  2  s.  co m*/
    // copmpare int with int
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
        family = "int_int";
        break;
    // copmpare reference with reference
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        family = "ref_ref";
        break;
    // compare reference with null
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        family = "ref_null";
        break;

    }
    return family;
}

From source file:org.evosuite.regression.RegressionClassDiff.java

License:Open Source License

public static String getBranchFamily(int opcode) {
    // The default family is the opcode itself
    // Admittedly we could've use ints/enums for performance, but strings should be interned anyway
    String family = "" + opcode;
    switch (opcode) {
    // copmpare int with zero
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        family = "int_zero";
        break;/*from   w w w.  j a va 2 s  .  c om*/
    // copmpare int with int
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
        family = "int_int";
        break;
    // copmpare reference with reference
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        family = "ref_ref";
        break;
    // compare reference with null
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        family = "ref_null";
        break;

    }
    return family;
}