@Test public void should_backtrack3() { when(machine.getIndex()).thenReturn(0); expression.execute(machine); InOrder inOrder = Mockito.inOrder(machine); inOrder.verify(machine).getIndex(); inOrder.verify(machine).backtrack(); verifyNoMoreInteractions(machine); }
@Override public void execute(Machine machine) { if (machine.getIndex() == 0) { machine.backtrack(); return; } Token previousToken = machine.tokenAt(-1); Token nextToken = machine.tokenAt(0); if (nextToken.getColumn() <= previousToken.getColumn() + previousToken.getValue().length() && nextToken.getLine() == previousToken.getLine()) { machine.jump(1); } else { machine.backtrack(); } }
AdjacentExpression extends NativeExpression { @Override public void execute(Machine machine) { if (machine.getIndex() == 0) { machine.backtrack(); return; } Token previousToken = machine.tokenAt(-1); Token nextToken = machine.tokenAt(0); if (nextToken.getColumn() <= previousToken.getColumn() + previousToken.getValue().length() && nextToken.getLine() == previousToken.getLine()) { machine.jump(1); } else { machine.backtrack(); } } }
AdjacentExpression extends NativeExpression { @Override public void execute(Machine machine) { if (machine.getIndex() == 0) { machine.backtrack(); return; } Token previousToken = machine.tokenAt(-1); Token nextToken = machine.tokenAt(0); if (nextToken.getColumn() <= previousToken.getColumn() + previousToken.getValue().length() && nextToken.getLine() == previousToken.getLine()) { machine.jump(1); } else { machine.backtrack(); } } private  AdjacentExpression(); }
AdjacentExpression extends NativeExpression { @Override public void execute(Machine machine) { if (machine.getIndex() == 0) { machine.backtrack(); return; } Token previousToken = machine.tokenAt(-1); Token nextToken = machine.tokenAt(0); if (nextToken.getColumn() <= previousToken.getColumn() + previousToken.getValue().length() && nextToken.getLine() == previousToken.getLine()) { machine.jump(1); } else { machine.backtrack(); } } private  AdjacentExpression(); @Override void execute(Machine machine); @Override String toString(); }
AdjacentExpression extends NativeExpression { @Override public void execute(Machine machine) { if (machine.getIndex() == 0) { machine.backtrack(); return; } Token previousToken = machine.tokenAt(-1); Token nextToken = machine.tokenAt(0); if (nextToken.getColumn() <= previousToken.getColumn() + previousToken.getValue().length() && nextToken.getLine() == previousToken.getLine()) { machine.jump(1); } else { machine.backtrack(); } } private  AdjacentExpression(); @Override void execute(Machine machine); @Override String toString(); static final AdjacentExpression INSTANCE; }