コード例 #1
0
public class DoWhileStatementTest {

  LexerlessGrammar g = EcmaScriptGrammar.createGrammar();

  @Test
  public void realLife() {
    assertThat(g.rule(EcmaScriptGrammar.DO_WHILE_STATEMENT))
        .as("inner statement must end by newline or semicolon")
        .notMatches("do something() while (condition);");
  }
}
コード例 #2
0
public class ContinueStatementTest {

  LexerlessGrammar g = EcmaScriptGrammar.createGrammar();

  @Test
  public void ok() {
    assertThat(g.rule(EcmaScriptGrammar.CONTINUE_STATEMENT))
        .as("EOS is line terminator")
        .matchesPrefix("continue \n", "another-statement ;")
        .matchesPrefix("continue label \n", "another-statement ;")
        .matchesPrefix("continue \n", ";")
        .as("EOS is semicolon")
        .matchesPrefix("continue ;", "another-statement")
        .matchesPrefix("continue label \n ;", "another-statement")
        .as("EOS is before right curly bracket")
        .matchesPrefix("continue ", "}")
        .matchesPrefix("continue label ", "}")
        .as("EOS is end of input")
        .matches("continue ")
        .matches("continue label ");
  }
}