Example #1
0
  public void testParsePipe() throws Exception {
    assertEquals(Operator.EDIT, Parser.parseOperator(Parser.tokenize("|")));
    assertEquals(Operator.TRANSLATE, Parser.parseOperator(Parser.tokenize(">")));

    assertParseOperatorFails("a", "Invalid operator \"Token[a], line 1\"");
    assertParseOperatorFails("-", "Invalid operator \"Token['-'], line 1\"");
  }
Example #2
0
 public void assertParseOperatorFails(String input, String errorMessage) {
   try {
     Parser.parseOperator(Parser.tokenize(input));
     fail();
   } catch (Parser.ParseError e) {
     assertEquals("Cannot parse: " + errorMessage, e.getMessage());
   }
 }
Example #3
0
 public void assertParseTermFails(String input, String errorMessage) {
   try {
     Term r = Parser.parseTerm(Parser.tokenize(input));
     fail(
         String.format(
             "Successfully parsed invalid string: %s into %s and %s",
             input, r.identifier, r.options.toString()));
   } catch (Parser.ParseError e) {
     assertEquals("Cannot parse: " + errorMessage, e.getMessage());
   }
 }
Example #4
0
 public void assertParseTerm(String input, String identifier, ImmutableMap<String, String> options)
     throws Parser.ParseError {
   Term r = Parser.parseTerm(Parser.tokenize(input));
   assertEquals(identifier, r.identifier);
   assertEquals(options, r.options);
 }