@Test public void should_backtrack3() { Token token = mock(Token.class); when(token.getValue()).thenReturn("h31"); when(machine.length()).thenReturn(1); when(machine.tokenAt(0)).thenReturn(token); expression.execute(machine); InOrder inOrder = Mockito.inOrder(machine); inOrder.verify(machine).length(); inOrder.verify(machine).tokenAt(0); inOrder.verify(machine).backtrack(); verifyNoMoreInteractions(machine); }
@Override public void execute(Machine machine) { if (machine.length() == 0) { machine.backtrack(); return; } Token token = machine.tokenAt(0); if (value.hashCode() == token.getValue().hashCode() && value.equals(token.getValue())) { machine.createLeafNode(this, 1); machine.jump(1); } else { machine.backtrack(); } }
TokenValueExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() == 0) { machine.backtrack(); return; } Token token = machine.tokenAt(0); if (value.hashCode() == token.getValue().hashCode() && value.equals(token.getValue())) { machine.createLeafNode(this, 1); machine.jump(1); } else { machine.backtrack(); } } }
TokenValueExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() == 0) { machine.backtrack(); return; } Token token = machine.tokenAt(0); if (value.hashCode() == token.getValue().hashCode() && value.equals(token.getValue())) { machine.createLeafNode(this, 1); machine.jump(1); } else { machine.backtrack(); } } TokenValueExpression(String value); }
TokenValueExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() == 0) { machine.backtrack(); return; } Token token = machine.tokenAt(0); if (value.hashCode() == token.getValue().hashCode() && value.equals(token.getValue())) { machine.createLeafNode(this, 1); machine.jump(1); } else { machine.backtrack(); } } TokenValueExpression(String value); @Override void execute(Machine machine); @Override String toString(); }
TokenValueExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() == 0) { machine.backtrack(); return; } Token token = machine.tokenAt(0); if (value.hashCode() == token.getValue().hashCode() && value.equals(token.getValue())) { machine.createLeafNode(this, 1); machine.jump(1); } else { machine.backtrack(); } } TokenValueExpression(String value); @Override void execute(Machine machine); @Override String toString();  }