X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FRegressionTests.java;h=353866d3d6ae8c0f51b9064bc438a00afe305353;hb=6ae224025882c9929e2e4e9e8461decbf3b9cae4;hp=8af63a2651bc87838f2f4321d79832b78618dfbd;hpb=76038cc31d71c6e7c0e6352f9c21ebd320e5c0cc;p=sbp.git diff --git a/src/edu/berkeley/sbp/misc/RegressionTests.java b/src/edu/berkeley/sbp/misc/RegressionTests.java index 8af63a2..353866d 100644 --- a/src/edu/berkeley/sbp/misc/RegressionTests.java +++ b/src/edu/berkeley/sbp/misc/RegressionTests.java @@ -25,9 +25,11 @@ public class RegressionTests { //MetaGrammar mg0 = new MetaGrammar(); //mg0.walk(MetaGrammar.meta); //System.out.println(mg0); + System.err.println("parsing " + s[0]); Tree res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); //System.out.println(mg); Union meta = MetaGrammar.make(); + System.err.println("parsing " + s[1]); SequenceInputStream sis = new SequenceInputStream(new FileInputStream(s[0]), new FileInputStream(s[1])); res = new CharParser(meta).parse(sis).expand1(); Union testcasegrammar = MetaGrammar.make(res, "ts"); @@ -40,6 +42,7 @@ public class RegressionTests { } System.gc(); long now = System.currentTimeMillis(); + System.err.println("parsing " + s[2]); Forest r2 = parser.parse(new FileInputStream(s[2])); System.out.println(); System.out.println("elapsed = " + (System.currentTimeMillis()-now) + "ms"); @@ -48,7 +51,16 @@ public class RegressionTests { System.in.read(); System.exit(0); } - for(TestCase tc : (TestCase[])new TestCaseBuilder().walk(r2.expand1())) tc.execute(); + System.err.println("expanding..."); + GraphViz gv = new GraphViz(); + r2.toGraphViz(gv); + FileOutputStream fox = new FileOutputStream("out.dot"); + gv.dump(fox); + fox.close(); + + TestCase[] expanded = (TestCase[])new TestCaseBuilder().walk(r2.expand1()); + System.err.println("executing..."); + for(TestCase tc : expanded) tc.execute(); } catch (Throwable t) { System.err.println("\n\nexception thrown, class == " + t.getClass().getName()); @@ -102,7 +114,7 @@ public class RegressionTests { //ystem.out.println("res=="+res); Collection> results = res==null ? new HashSet>() : res.expand(false); System.out.print("\r"); - if (results.size() == 0 && output.length > 0) { + if (results == null || (results.size() == 0 && (output!=null && output.length > 0))) { System.out.print("\033[31m"); System.out.println("PARSE FAILED"); System.out.print("\033[0m"); @@ -142,15 +154,20 @@ public class RegressionTests { if ("grammar".equals(tree.head())) return MetaGrammar.make(tree, "s"); else if ("output".equals(tree.head())) return MetaGrammar.string(tree.children()); else if ("input".equals(tree.head())) return MetaGrammar.string(tree.children()); - else if ("javacase".equals(tree.head()) || "tibcase".equals(tree.head()) || "testcase".equals(tree.head())) { + else if ("testcase".equals(tree.head())) { String input = MetaGrammar.string(tree.child(0)); String[] output = tree.numChildren()>2 ? ((String[])walk(tree, 1)) : new String[0]; - boolean tib = "tibcase".equals(tree.head()); - boolean jav = "javacase".equals(tree.head()); Union grammar = MetaGrammar.make(tree.child(tree.numChildren()-1), "s"); - return new TestCase(input, output, grammar, tib, jav); + TestCase tc = new TestCase(input, output, grammar, false, false); + return tc; } else if ("ts".equals(tree.head())) return walk(tree, 0); - else return super.walk(tree); + else if (tree.head() == null) { + Object[] ret = new Object[tree.numChildren()]; + for(int i=0; i