示例#1
0
public class EmptyStatementTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @Test
  public void test() {
    Assertions.assertThat(g.rule(FlexGrammar.EMPTY_STATEMENT)).matches(";");
  }
}
示例#2
0
public class ArgumentsTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @Test
  public void test() {
    Assertions.assertThat(g.rule(FlexGrammar.ARGUMENTS)).matches("( )").matches("(a, b, c)");
  }
}
public class HexadecimalTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @Test
  public void test() {
    Assertions.assertThat(g.rule(FlexGrammar.HEXADECIMAL)).matches("0x01aF");
  }
}
public class NonAttributeQualifierIdentifier {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @Test
  public void test() {
    Assertions.assertThat(g.rule(FlexGrammar.NON_ATTRIBUTE_QUALIFIED_IDENTIFIER))
        .matches("identifier")
        .matches("(null)::*");
  }
}
public class NonAssignmentExpressionTest {

  private LexerlessGrammar g = FlexGrammar.createGrammar();

  @Test
  public void test() {
    Assertions.assertThat(g.rule(FlexGrammar.NON_ASSIGNMENT_EXPR))
        .matches("a")
        .matches("a ? b : c");
  }
}
public class DefaultXmlNamespaceDirectiveTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @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 ;");
  }
}
示例#7
0
public class ClassDefinitionTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @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\";}");
  }
}
public class TryStatementTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @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 { }");
  }
}
public class FunctionDefinitionTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @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 ()");
  }
}
public class TypeExpressionTest {

  private final LexerlessGrammar g = FlexGrammar.createGrammar();

  @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.<*>");
  }
}