Instruction { public static Instruction failTwice() { return FAIL_TWICE; }  static void addAll(List<Instruction> list, Instruction[] array); static Instruction jump(int offset); static Instruction call(int offset, Matcher matcher); static Instruction ret(); static Instruction backtrack(); static Instruction end(); static Instruction choice(int offset); static Instruction predicateChoice(int offset); static Instruction commit(int offset); static Instruction commitVerify(int offset); static Instruction failTwice(); static Instruction backCommit(int offset); static Instruction ignoreErrors(); abstract void execute(Machine machine);  }
@Test public void failTwice() { Instruction instruction = Instruction.failTwice(); assertThat(instruction).isInstanceOf(FailTwiceInstruction.class); assertThat(instruction.toString()).isEqualTo("FailTwice"); assertThat(instruction).as("singleton").isSameAs(Instruction.failTwice()); MachineStack stack = mock(MachineStack.class); when(stack.index()).thenReturn(13); when(machine.peek()).thenReturn(stack); instruction.execute(machine); InOrder inOrder = Mockito.inOrder(machine); inOrder.verify(machine).peek(); inOrder.verify(machine).setIndex(13); inOrder.verify(machine).pop(); inOrder.verify(machine).backtrack(); verifyNoMoreInteractions(machine); }