Package hampi.constraints

Examples of hampi.constraints.Regexp


public class BoundingTests extends TestCase{
  public void testMultiCharTerminals() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_multiCharTerminal.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "program", 3, false);
    System.out.println(boundedRegexp);
    assertTrue(!boundedRegexp.matches("AB__"));
    assertTrue(boundedRegexp.matches("AB_"));
  }
View Full Code Here


  }

  public void test1() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 2, false);
    assertTrue(boundedRegexp.matches("()"));
    assertTrue(!boundedRegexp.matches("(())"));
  }
View Full Code Here

  }

  public void test2() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 3, false);
    assertNull(boundedRegexp);
  }
View Full Code Here

  }

  public void test3() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 4, false);
    System.out.println(boundedRegexp);
    assertTrue(!boundedRegexp.matches("()"));
    assertTrue(boundedRegexp.matches("(())"));
    assertTrue(boundedRegexp.matches("()()"));
    assertTrue(!boundedRegexp.matches("(((("));

  }
View Full Code Here

  }

  public void test4() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 5, false);
    assertNull(boundedRegexp);
  }
View Full Code Here

  }

  public void test5() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 150, false);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

  public void test6() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_arithm.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 40;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

  }

  public void testSmallSQL() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "small_sql.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "Select", 20, true);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

  }

  public void testEcmascript() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "ecmascript.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "FunctionDeclaration", 27, true);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

  }

  public void testTinySQL() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "SelectStmt", 26, false);
    //"SELECT" is one terminal and 6 characters
    assertNotNull(boundedRegexp);
    //    System.out.println(boundedRegexp);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

TOP

Related Classes of hampi.constraints.Regexp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.