コード例 #1
0
 @Test
 public void testGenerator() {
   LexerData lt = LexerGenerator.generate(LEXER_STATES, INPUT1, NO_PATTERNS, new TestStatus());
   for (TestRule tl : INPUT1) {
     for (String s : tl.getSamples()) {
       int res = nextToken(lt, s, INPUT1);
       assertEquals("For " + s + " Expected " + tl.getRegexp().toString() + ";", tl.index, res);
     }
   }
 }
コード例 #2
0
 @Test
 public void testLexGeneratorReporting() {
   TestStatus notifier =
       new TestStatus(
           "",
           "lexergentest,3: `empty' accepts empty text\n"
               + "lexergentest,1: two rules are identical: string and number\n");
   LexerGenerator.generate(LEXER_STATES, ERRINPUT, NO_PATTERNS, notifier);
   notifier.assertDone();
 }
コード例 #3
0
 private void checkMatch(String regex, String sample, boolean expected) {
   TestRule[] input = {new TestRule(0, 0, "test", LEXER_STATES[0], regex)};
   LexerData lt = LexerGenerator.generate(LEXER_STATES, input, NO_PATTERNS, new TestStatus());
   int token = nextToken(lt, sample, input);
   assertEquals(sample + " !~ /" + regex, expected, token == 0);
 }