@Test public void should_match() { when(machine.length()).thenReturn(3); when(machine.charAt(0)).thenReturn('f'); when(machine.charAt(1)).thenReturn('o'); when(machine.charAt(2)).thenReturn('o'); expression.execute(machine); InOrder inOrder = Mockito.inOrder(machine); inOrder.verify(machine).length(); inOrder.verify(machine).charAt(0); inOrder.verify(machine).charAt(1); inOrder.verify(machine).charAt(2); inOrder.verify(machine).createLeafNode(expression, 3); inOrder.verify(machine).jump(1); verifyNoMoreInteractions(machine); }
@Override public void execute(Machine machine) { if (machine.length() < string.length()) { machine.backtrack(); return; } for (int i = 0; i < string.length(); i++) { if (machine.charAt(i) != string.charAt(i)) { machine.backtrack(); return; } } machine.createLeafNode(this, string.length()); machine.jump(1); }
StringExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() < string.length()) { machine.backtrack(); return; } for (int i = 0; i < string.length(); i++) { if (machine.charAt(i) != string.charAt(i)) { machine.backtrack(); return; } } machine.createLeafNode(this, string.length()); machine.jump(1); } }
StringExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() < string.length()) { machine.backtrack(); return; } for (int i = 0; i < string.length(); i++) { if (machine.charAt(i) != string.charAt(i)) { machine.backtrack(); return; } } machine.createLeafNode(this, string.length()); machine.jump(1); } StringExpression(String string); }
StringExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() < string.length()) { machine.backtrack(); return; } for (int i = 0; i < string.length(); i++) { if (machine.charAt(i) != string.charAt(i)) { machine.backtrack(); return; } } machine.createLeafNode(this, string.length()); machine.jump(1); } StringExpression(String string); @Override void execute(Machine machine); @Override String toString(); }
StringExpression extends NativeExpression implements Matcher { @Override public void execute(Machine machine) { if (machine.length() < string.length()) { machine.backtrack(); return; } for (int i = 0; i < string.length(); i++) { if (machine.charAt(i) != string.charAt(i)) { machine.backtrack(); return; } } machine.createLeafNode(this, string.length()); machine.jump(1); } StringExpression(String string); @Override void execute(Machine machine); @Override String toString();  }