@Test
  public void ok() {
    g.rule(JavaGrammar.TYPE).mock();
    g.rule(JavaGrammar.VARIABLE_DECLARATORS).mock();
    g.rule(JavaGrammar.ANNOTATION).mock();

    assertThat(g.rule(JavaGrammar.LOCAL_VARIABLE_DECLARATION_STATEMENT))
        .matches("final type variableDeclarators ;")
        .matches("annotation type variableDeclarators ;")
        .matches("type variableDeclarators ;");
  }
  /* antlr grammar
  equalityExpression
     : concatenationExpression
       ( ( equalityOperator5^ | equalityOperator3^ |  equalityOperator2^ | equalityOperator1^ ) concatenationExpression )*
     ;
   */
  @Test
  public void ok() {
    assertThat(g.rule(CFGrammar.EQUALITY_EXPRESSION))
        .matches("concatenationExpression")
        .matches("concatenationExpression is concatenationExpression")
        .matches("concatenationExpression < concatenationExpression")
        .matches("concatenationExpression lt concatenationExpression")
        .matches("concatenationExpression != concatenationExpression")
        .matches("concatenationExpression less than concatenationExpression")
        .matches("concatenationExpression does not contain concatenationExpression")
        .matches("concatenationExpression less than or equal toconcatenationExpression");

    assertThat(g.rule(CFGrammar.EQUALITY_EXPRESSION))
        .notMatches("concatenationExpression random words concatenationExpression");
  }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.DEFAULT_XML_NAMESPACE_DIRECTIVE))
       .matches("default xml namespace = ns ;")
       .notMatches("default \n xml namespace = ns ;")
       .notMatches("default xml \n namespace = ns ;");
 }
 @Test
 public void classWithStaticAtribute() {
   Assertions.assertThat(g.rule(FlexGrammar.CLASS_DEF))
       .matches("class a {}")
       .matches("class a extends b {}")
       .matches("class Base { public static var test:String = \"static\";}");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.TRY_STATEMENT))
       .matches("try { } catch (error) { }")
       .matches("try { } catch (error:ErrorType1) { } catch (error:ErrorType2) { }")
       .matches("try { } finally { }")
       .matches("try { } catch (error) { } finally { }");
 }
Example #6
0
 @Test
 public void realLife() {
   assertThat(g.rule(JavaTokenType.IDENTIFIER))
       .matches("foo")
       .matches("bar")
       .matches("enum")
       .notMatches("public")
       .notMatches("final")
       .notMatches("assert");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.FUNCTION_DEF))
       .matches("function name () {}")
       .matches("function name () ;")
       .matches("function get name ()")
       .notMatches("function get \n name ()")
       .matches("function set name ()")
       .notMatches("function set \n name ()");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.TYPE_EXPR))
       .matches("*")
       .matches("String")
       .matches("int")
       .matches("foo.bar")
       .matches("Vector.<String>")
       .matches("foo.bar.Vector.<String>")
       .matches("Vector.<*>");
 }
 @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 ");
 }
 @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);");
 }
Example #11
0
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.EMPTY_STATEMENT)).matches(";");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.HEXADECIMAL)).matches("0x01aF");
 }
Example #13
0
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.ARGUMENTS)).matches("( )").matches("(a, b, c)");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.NON_ATTRIBUTE_QUALIFIED_IDENTIFIER))
       .matches("identifier")
       .matches("(null)::*");
 }
 @Test
 public void test() {
   Assertions.assertThat(g.rule(FlexGrammar.NON_ASSIGNMENT_EXPR))
       .matches("a")
       .matches("a ? b : c");
 }