ReplaceBitwiseOperator implements MutationOperator { public static double getInfectionDistanceInt(int x, int y, int opcodeOrig, int opcodeNew) { if (opcodeOrig == Opcodes.ISHR && opcodeNew == Opcodes.IUSHR) { if (x < 0 && y != 0) { int origValue = calculate(x, y, opcodeOrig); int newValue = calculate(x, y, opcodeNew); assert (origValue != newValue); return 0.0; } else return y != 0 && x > 0 ? x + 1.0 : 1.0; } int origValue = calculate(x, y, opcodeOrig); int newValue = calculate(x, y, opcodeNew); return origValue == newValue ? 1.0 : 0.0; }  @Override List<Mutation> apply(MethodNode mn, String className, String methodName,
	        BytecodeInstruction instruction, Frame frame); InsnList getInfectionDistance(int opcodeOrig, int opcodeNew); static double getInfectionDistanceInt(int x, int y, int opcodeOrig,
	        int opcodeNew); static double getInfectionDistanceLong(long x, int y, int opcodeOrig,
	        int opcodeNew); static double getInfectionDistanceLong(long x, long y, int opcodeOrig,
	        int opcodeNew); static int calculate(int x, int y, int opcode); static long calculate(long x, long y, int opcode); @Override boolean isApplicable(BytecodeInstruction instruction); static final String NAME; }
@Test public void testGetInfectionDistanceInt() { assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.IAND, Opcodes.IOR), 0.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(0, 0, Opcodes.IAND, Opcodes.IOR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.IAND, Opcodes.IOR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 2, Opcodes.IAND, Opcodes.IOR), 0.0, 0.0); }
@Test public void testGetInfectionDistanceIntShift() { assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHL, Opcodes.ISHR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHL, Opcodes.ISHR), 0.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHL, Opcodes.IUSHR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHL, Opcodes.IUSHR), 0.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHR, Opcodes.IUSHR), 1.0, 0.0); assertEquals(2.0, ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHR, Opcodes.IUSHR), 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(-1, 1, Opcodes.ISHR, Opcodes.IUSHR), 0.0, 0.0); assertEquals(2.0, ReplaceBitwiseOperator.getInfectionDistanceInt(1, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(-1, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0, 0.0); assertEquals(0.0, ReplaceBitwiseOperator.getInfectionDistanceInt(-1449, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0); }