Example #1
0
  @Test
  public void should_print_at_start() {
    Lexer lexer = new Lexer("(3x + y) * 3");
    // (

    assertEquals("[(]3x + y) * 3", lexer.printPosition());
  }
Example #2
0
 @Test
 public void should_print_at_last_letter() throws ValidationReaderException {
   Lexer lexer = new Lexer("(3x + y) * 3");
   while (lexer.hasLexeme()) {
     lexer.nextLexeme();
   }
   assertEquals("(3x + y) * 3[]", lexer.printPosition());
 }
Example #3
0
  @Test
  public void should_print_at_2nd_letter() throws ValidationReaderException {
    Lexer lexer = new Lexer("(3x + y) * 3");
    // (
    lexer.nextLexeme(); // 3

    assertEquals("([3]x + y) * 3", lexer.printPosition());
  }
Example #4
0
  @Test
  public void should_print_at_6th_letter() throws ValidationReaderException {
    Lexer lexer = new Lexer("(3x + y) * 3");
    // (
    lexer.nextLexeme(); // 3
    lexer.nextLexeme(); // x
    lexer.nextLexeme(); // +
    lexer.nextLexeme(); // y
    lexer.nextLexeme(); // )

    assertEquals("(3x + y[)] * 3", lexer.printPosition());
  }
Example #5
0
  @Test
  public void should_print_at_before_last_letter() throws ValidationReaderException {
    Lexer lexer = new Lexer("(3x + y) * 3");
    // (
    lexer.nextLexeme(); // 3
    lexer.nextLexeme(); // x
    lexer.nextLexeme(); // +
    lexer.nextLexeme(); // y
    lexer.nextLexeme(); // )
    lexer.nextLexeme(); // *
    lexer.nextLexeme(); // 3

    assertEquals("(3x + y) * [3]", lexer.printPosition());
  }
Example #6
0
  @Test
  public void should_print_at_start_on_single_letter() {
    Lexer lexer = new Lexer("3");

    assertEquals("[3]", lexer.printPosition());
  }