good patch
authoradam <adam@megacz.com>
Mon, 2 Jan 2006 01:59:22 +0000 (20:59 -0500)
committeradam <adam@megacz.com>
Mon, 2 Jan 2006 01:59:22 +0000 (20:59 -0500)
darcs-hash:20060102015922-5007d-8e200889e132bcf7ad9b3b6c19039e9afed8d691.gz

src/edu/berkeley/sbp/misc/RegressionTests.java
src/edu/berkeley/sbp/util/IntegerTopology.java
src/edu/berkeley/sbp/util/Range.java
src/edu/berkeley/sbp/util/Topology.java

index a88c8a4..1fd97f1 100644 (file)
@@ -82,7 +82,7 @@ public class RegressionTests {
                 System.out.println("PARSE FAILED");
                 System.out.print("\033[0m");
             } else {
                 System.out.println("PARSE FAILED");
                 System.out.print("\033[0m");
             } else {
-                System.out.println("\r                                                                                                              \r");
+                System.out.print("\r                                                                                                              \r");
             }
             HashSet<String> outs = new HashSet<String>();
             if (output != null) for(String s : output) outs.add(s.trim());
             }
             HashSet<String> outs = new HashSet<String>();
             if (output != null) for(String s : output) outs.add(s.trim());
@@ -90,20 +90,22 @@ public class RegressionTests {
             for (Tree<String> r : results) {
                 String s = r.toString().trim();
                 if (outs.contains(s)) { outs.remove(s); continue; }
             for (Tree<String> r : results) {
                 String s = r.toString().trim();
                 if (outs.contains(s)) { outs.remove(s); continue; }
+                if (!bad) System.out.println(input);
                 System.out.print("\033[33m");
                 System.out.println("     GOT: " + s);
                 bad = true;
             }
             for(String s : outs) {
                 System.out.print("\033[33m");
                 System.out.println("     GOT: " + s);
                 bad = true;
             }
             for(String s : outs) {
+                if (!bad) System.out.println(input);
                 System.out.print("\033[31m");
                 System.out.println("EXPECTED: " + s);
                 bad = true;
             }
             if (bad) {
                 System.out.print("\033[31m");
                 System.out.println("EXPECTED: " + s);
                 bad = true;
             }
             if (bad) {
-                System.out.print("\033[0m");
+                System.out.println("\033[0m");
                 return true;
             }             
                 return true;
             }             
-            System.out.println("\033[32mPASS\033[0m");
+            System.out.println("\r\033[32mPASS\033[0m                                                                              ");
             return false;
         }
     }
             return false;
         }
     }
index e9f01df..cac19e9 100644 (file)
@@ -9,8 +9,8 @@ import edu.berkeley.sbp.*;
 /** implementation of <tt>Topology</tt> for any class for which there is a mapping to the <tt>int</tt>s */
 public class IntegerTopology<V extends IntegerTopology.IntegerMappable> implements Topology<V> {
     private final Range.Set rs;
 /** implementation of <tt>Topology</tt> for any class for which there is a mapping to the <tt>int</tt>s */
 public class IntegerTopology<V extends IntegerTopology.IntegerMappable> implements Topology<V> {
     private final Range.Set rs;
-
-    public Range.Set getRanges() { return rs; /*FIXME: copy?*/ }
+    
+    public Range.Set getRanges()         { return new Range.Set(rs); }
 
     public IntegerTopology()             { this(new Range.Set()); }
     public IntegerTopology(V v)          { this(v.toInt()); }
 
     public IntegerTopology()             { this(new Range.Set()); }
     public IntegerTopology(V v)          { this(v.toInt()); }
index 399d2bb..714cd83 100644 (file)
@@ -298,6 +298,11 @@ public class Range {
             for(Range r : ranges) add(r);
         }
     
             for(Range r : ranges) add(r);
         }
     
+        public Set(Iterable<Range> it) {
+            this();
+            for(Range r : it) add(r);
+        }
+    
         /**
          * @param rs The set with which to union with this set.
          * @return A new set that represents the union of this and the passed set.
         /**
          * @param rs The set with which to union with this set.
          * @return A new set that represents the union of this and the passed set.
index 4f36f08..2756aae 100644 (file)
@@ -21,6 +21,7 @@ public interface Topology<V> {
     public Topology<V>       intersect(Topology<V> t);
     public Topology<V>       minus(Topology<V> t);
     public Topology<V>       union(Topology<V> t);
     public Topology<V>       intersect(Topology<V> t);
     public Topology<V>       minus(Topology<V> t);
     public Topology<V>       union(Topology<V> t);
+    public Topology<V>       complement();
     public boolean           disjoint(Topology<V> t);
     public boolean           containsAll(Topology<V> t);
 
     public boolean           disjoint(Topology<V> t);
     public boolean           containsAll(Topology<V> t);