Example usage for org.objectweb.asm Opcodes IFEQ

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

Introduction

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

Prototype

int IFEQ

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

Click Source Link

Usage

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

License:Open Source License

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

    Set<Integer> replacement = new HashSet<Integer>();
    switch (opcode) {
    case Opcodes.IFEQ:
        replacement.add(Opcodes.IFGE);/* w  w w.  j  a v a2s . c  o  m*/
        replacement.add(Opcodes.IFLE);
        replacement.add(FALSE);
        // False
        break;
    case Opcodes.IFNE:
        replacement.add(Opcodes.IFLT);
        replacement.add(Opcodes.IFGT);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IFGT:
        replacement.add(Opcodes.IFGE);
        replacement.add(Opcodes.IFNE);
        // False
        replacement.add(FALSE);
        break;
    case Opcodes.IFLE:
        replacement.add(Opcodes.IFLT);
        replacement.add(Opcodes.IFEQ);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IFGE:
        replacement.add(Opcodes.IFGT);
        replacement.add(Opcodes.IFEQ);
        // True
        replacement.add(TRUE);
        break;
    case Opcodes.IFLT:
        replacement.add(Opcodes.IFLE);
        replacement.add(Opcodes.IFNE);
        // False
        replacement.add(FALSE);
        break;
    }
    return replacement;
}

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

License:Open Source License

@Test
public void testComparisonZeroEQ() {
    // x == 0 vs x != 0      
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFEQ, Opcodes.IFNE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFEQ, Opcodes.IFNE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFEQ, Opcodes.IFNE), 0.0);

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

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

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

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

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

License:Open Source License

@Test
public void testComparisonZeroNE() {
    // x != 0 vs x == 0      
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFEQ), 0.0);

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

    // x != 0 vs x <= 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFLE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFLE), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFLE), 0.0);

    // x != 0 vs x > 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFGT), 0.0);
    assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFGT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFGT), 0.0);

    // x != 0 vs x >= 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFNE, Opcodes.IFGE), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFNE, Opcodes.IFGE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFNE, Opcodes.IFGE), 0.0);
}

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

License:Open Source License

@Test
public void testComparisonZeroLT() {
    // x < 0 vs x == 0      
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFEQ), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFEQ), 0.0);

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

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

    // x < 0 vs x > 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFGT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFGT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFGT), 0.0);

    // x < 0 vs x >= 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLT, Opcodes.IFGE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLT, Opcodes.IFGE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLT, Opcodes.IFGE), 0.0);
}

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

License:Open Source License

@Test
public void testComparisonZeroLE() {
    // x <= 0 vs x == 0      
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFEQ), 0.0);
    assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFEQ), 0.0);

    // x <= 0 vs x != 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFNE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFNE), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFNE), 0.0);

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

    // x <= 0 vs x > 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFGT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFGT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFGT), 0.0);

    // x <= 0 vs x >= 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFLE, Opcodes.IFGE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFLE, Opcodes.IFGE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFLE, Opcodes.IFGE), 0.0);
}

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

License:Open Source License

@Test
public void testComparisonZeroGT() {
    // x > 0 vs x == 0      
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFEQ), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFEQ), 0.0);

    // x > 0 vs x != 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFNE), 0.0);
    assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFNE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFNE), 0.0);

    // x > 0 vs x <= 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFLE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFLE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFLE), 0.0);

    // x > 0 vs x < 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGT, Opcodes.IFLT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGT, Opcodes.IFLT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGT, Opcodes.IFLT), 0.0);

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

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

License:Open Source License

@Test
public void testComparisonZeroGE() {
    // x >= 0 vs x == 0      
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFEQ), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFEQ), 0.0);
    assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFEQ), 0.0);

    // x >= 0 vs x != 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFNE), 0.0);
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFNE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFNE), 0.0);

    // x >= 0 vs x <= 0
    assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFLE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFLE), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFLE), 0.0);

    // x >= 0 vs x < 0
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, Opcodes.IFGE, Opcodes.IFLT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, Opcodes.IFGE, Opcodes.IFLT), 0.0);
    assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, Opcodes.IFGE, Opcodes.IFLT), 0.0);

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

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

License:Open Source License

/**
 * <p>/*from  w  w  w. j a va 2  s.co  m*/
 * transformMethod
 * </p>
 * 
 * @param mn
 *            a {@link org.objectweb.asm.tree.MethodNode} object.
 * @return a boolean.
 */
public boolean transformMethod(MethodNode mn) {
    boolean changed = transformStrings(mn);
    if (changed) {
        try {
            mn.maxStack++;
            Analyzer a = new Analyzer(new StringBooleanInterpreter());
            a.analyze(cn.name, mn);
            Frame[] frames = a.getFrames();
            AbstractInsnNode node = mn.instructions.getFirst();
            boolean done = false;
            while (!done) {
                if (node == mn.instructions.getLast())
                    done = true;
                AbstractInsnNode next = node.getNext();
                int index = mn.instructions.indexOf(node);
                if (index >= frames.length)
                    break;
                Frame current = frames[index];
                if (current == null)
                    break;
                int size = current.getStackSize();
                if (node.getOpcode() == Opcodes.IFNE) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFNE -> IFGT");
                        branch.setOpcode(Opcodes.IFGT);
                        // branch.setOpcode(Opcodes.IFGE);
                    }
                } else if (node.getOpcode() == Opcodes.IFEQ) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFEQ -> IFLE");
                        branch.setOpcode(Opcodes.IFLE);
                        // branch.setOpcode(Opcodes.IFNE);
                    }
                } else if (node.getOpcode() == Opcodes.IF_ICMPEQ) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious().getPrevious())) {
                        if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) {
                            branch.setOpcode(Opcodes.IFLE);
                            mn.instructions.remove(node.getPrevious());
                        } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) {
                            branch.setOpcode(Opcodes.IFGT);
                            mn.instructions.remove(node.getPrevious());
                        }
                    }
                } else if (node.getOpcode() == Opcodes.IF_ICMPNE) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious().getPrevious())) {
                        if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) {
                            branch.setOpcode(Opcodes.IFGT);
                            mn.instructions.remove(node.getPrevious());
                        } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) {
                            branch.setOpcode(Opcodes.IFLE);
                            mn.instructions.remove(node.getPrevious());
                        }
                    }
                } else if (node.getOpcode() == Opcodes.IRETURN) {
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFEQ -> IFLE");
                        MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
                                Type.getInternalName(BooleanHelper.class), "intToBoolean",
                                Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE }));

                        mn.instructions.insertBefore(node, n);
                    }
                }
                node = next;
            }
        } catch (Exception e) {
            logger.warn("EXCEPTION DURING STRING TRANSFORMATION: {}", e);
            e.printStackTrace();
            return changed;
        }
    }
    return changed;
}

From source file:org.evosuite.instrumentation.testability.StringTransformation.java

License:Open Source License

/**
 * <p>//from   w  ww .  jav  a  2 s. c o m
 * transformMethod
 * </p>
 * 
 * @param mn
 *            a {@link org.objectweb.asm.tree.MethodNode} object.
 * @return a boolean.
 */
public boolean transformMethod(MethodNode mn) {
    boolean changed = transformStrings(mn);
    if (changed) {
        try {
            mn.maxStack++;
            Analyzer a = new Analyzer(new StringBooleanInterpreter());
            a.analyze(cn.name, mn);
            Frame[] frames = a.getFrames();
            AbstractInsnNode node = mn.instructions.getFirst();
            boolean done = false;
            while (!done) {
                if (node == mn.instructions.getLast())
                    done = true;
                AbstractInsnNode next = node.getNext();
                int index = mn.instructions.indexOf(node);
                if (index >= frames.length)
                    break;
                Frame current = frames[index];
                if (current == null)
                    break;
                int size = current.getStackSize();
                if (node.getOpcode() == Opcodes.IFNE) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFNE -> IFGT");
                        branch.setOpcode(Opcodes.IFGT);
                    }
                } else if (node.getOpcode() == Opcodes.IFEQ) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFEQ -> IFLE");
                        branch.setOpcode(Opcodes.IFLE);
                    }
                } else if (node.getOpcode() == Opcodes.IF_ICMPEQ) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious().getPrevious())) {
                        if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) {
                            branch.setOpcode(Opcodes.IFLE);
                            mn.instructions.remove(node.getPrevious());
                        } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) {
                            branch.setOpcode(Opcodes.IFGT);
                            mn.instructions.remove(node.getPrevious());
                        }
                    }
                } else if (node.getOpcode() == Opcodes.IF_ICMPNE) {
                    JumpInsnNode branch = (JumpInsnNode) node;
                    if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious().getPrevious())) {
                        if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) {
                            branch.setOpcode(Opcodes.IFGT);
                            mn.instructions.remove(node.getPrevious());
                        } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) {
                            branch.setOpcode(Opcodes.IFLE);
                            mn.instructions.remove(node.getPrevious());
                        }
                    }
                } else if (node.getOpcode() == Opcodes.IRETURN) {
                    if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN
                            || isStringMethod(node.getPrevious())) {
                        logger.info("IFEQ -> IFLE");
                        MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
                                Type.getInternalName(BooleanHelper.class), "intToBoolean",
                                Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE }),
                                false);

                        mn.instructions.insertBefore(node, n);
                    }
                }
                node = next;
            }
        } catch (Exception e) {
            logger.warn("EXCEPTION DURING STRING TRANSFORMATION: " + e);
            return changed;
        }
    }
    return changed;
}

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;//w  w  w. j av  a 2s .  c  om
    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;
}