### Question:
IfEq extends If0 { @Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!this.isSameField(thisIc, otherIc)) return false; if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) return true; if (otherIc.getInstruction() instanceof IfNe) { return true; } else if (otherIc.getInstruction() instanceof IfICmpEq || otherIc.getInstruction() instanceof IfICmpNe) { StackContext s1 = otherIc.getPops().get(0), s2 = otherIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) return true; } return false; } IfEq(Instructions instructions, InstructionType type);  IfEq(Instructions instructions, Label to); @Override boolean isSame(InstructionContext thisIc, InstructionContext otherIc); @Override void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other);  }### Answer:
@Test public void testIsSame() { Instructions ins = mock(Instructions.class); Frame originalIfEqFrame = mock(Frame.class); Stack stack = new Stack(42); Variables variables = new Variables(42); when(originalIfEqFrame.getStack()).thenReturn(stack); when(originalIfEqFrame.getVariables()).thenReturn(variables); variables.set(9, new VariableContext(INT)); Instruction i = new LDC(ins, 0); InstructionContext ctx = new InstructionContext(i, originalIfEqFrame); IfEq ifeq = new IfEq(ins, InstructionType.IFEQ); InstructionContext ifeqCtx = new InstructionContext(ifeq, originalIfEqFrame); ifeqCtx.pop(new StackContext(ctx, INT, new Value(1))); ins = mock(Instructions.class); Frame originalIfIcmpNeFrame = mock(Frame.class); stack = new Stack(42); variables = new Variables(42); when(originalIfIcmpNeFrame.getStack()).thenReturn(stack); when(originalIfIcmpNeFrame.getVariables()).thenReturn(variables); variables.set(5, new VariableContext(INT)); i = new LDC(ins, 1); InstructionContext ctx1 = new InstructionContext(i, originalIfIcmpNeFrame); i = new ILoad(ins, 5); InstructionContext ctx2 = new InstructionContext(i, originalIfIcmpNeFrame); IfICmpNe ificmpne = new IfICmpNe(ins, InstructionType.IF_ICMPNE); InstructionContext ificmpneCtx = new InstructionContext(ificmpne, originalIfIcmpNeFrame); ificmpneCtx.pop( new StackContext(ctx1, INT, new Value(1)), new StackContext(ctx2, INT, Value.UNKNOWN) ); assertEquals( ifeq.isSame(ifeqCtx, ificmpneCtx), ificmpne.isSame(ificmpneCtx, ifeqCtx) ); Frame ifeqBranchFrame = mock(Frame.class); ifeqCtx.branch(ifeqBranchFrame); Frame ificmpneBranchFrame = mock(Frame.class); ificmpneCtx.branch(ificmpneBranchFrame); when(originalIfEqFrame.getOther()).thenReturn(originalIfIcmpNeFrame); when(originalIfIcmpNeFrame.getOther()).thenReturn(originalIfEqFrame); ParallelExecutorMapping mapping = mock(ParallelExecutorMapping.class); ifeq.map(mapping, ifeqCtx, ificmpneCtx); ArgumentCaptor<Frame> frameCapture = ArgumentCaptor.forClass(Frame.class); verify(ifeqBranchFrame).setOther(frameCapture.capture()); assertEquals(ificmpneBranchFrame, frameCapture.getValue()); }