break Node out of GSS
[sbp.git] / src / edu / berkeley / sbp / misc / RegressionTests.java
index d870ae2..677f7dd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+
 package edu.berkeley.sbp.misc;
 import java.io.*;
 import java.util.*;
@@ -15,6 +17,10 @@ public class RegressionTests {
     public static boolean yes = false;
     public static boolean graph = false;
 
+    public static void main() throws Exception {
+      main(new String[] { "tests/meta.g", "tests/testcase.g", "tests/regression.tc" });
+    }
+
     public static void main(String[] s) throws Exception {
         try {
             boolean profile = false;
@@ -154,7 +160,10 @@ public class RegressionTests {
                 p.close();
                 System.out.println(parser);
             }
-            Collection<Tree<String>> results = res==null ? new HashSet<Tree<String>>() : res.expand(false);
+
+            HashSet<Tree<String>> results = new HashSet<Tree<String>>();
+            if (res != null) res.expand(results);
+
             System.out.print("\r");
             if (results == null || (results.size() == 0 && (output!=null && output.length > 0))) {
                 System.out.print("\033[31m");
@@ -199,13 +208,13 @@ public class RegressionTests {
                 else if ("input".equals(tree.head())) return string(tree.children());
                 else if ("testcase".equals(tree.head())) {
                     String input = string(tree.child(0));
-                    String[] output = tree.numChildren()>2 ? ((String[])walk(tree, 1)) : new String[0];
-                    Union grammar = Grammar.create(tree.child(tree.numChildren()-1), "s", new MetaGrammarBindings());
+                    String[] output = tree.size()>2 ? ((String[])walk(tree, 1)) : new String[0];
+                    Union grammar = Grammar.create(tree.child(tree.size()-1), "s", new MetaGrammarBindings());
                     TestCase tc = new TestCase(input, output, grammar, false, false);
                     return tc;
                 } else if ("ts".equals(tree.head())) return walk(tree, 0);
                 else if (tree.head() == null) {
-                    Object[] ret = new Object[tree.numChildren()];
+                    Object[] ret = new Object[tree.size()];
                     for(int i=0; i<ret.length; i++)
                         ret[i] = walk(tree.child(i));
                     return Reflection.lub(ret);