]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/unit/TestNamespaceFilter.java
Fixed all line endings of the repository
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / unit / TestNamespaceFilter.java
index 3f9c9e4e90e9ff96e2bcd1f468f63e08fadcd42e..e1b5dcc5fd4eeaeec9f305a9b85111e0d499d64a 100644 (file)
@@ -1,89 +1,89 @@
-package org.simantics.scl.compiler.tests.unit;\r
-\r
-import java.util.Collection;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.simantics.scl.compiler.environment.filter.AcceptAllNamespaceFilter;\r
-import org.simantics.scl.compiler.environment.filter.NamespaceFilter;\r
-import org.simantics.scl.compiler.environment.filter.NamespaceFilters;\r
-import org.simantics.scl.compiler.environment.filter.NegativeNamespaceFilter;\r
-import org.simantics.scl.compiler.environment.filter.PositiveNamespaceFilter;\r
-\r
-import gnu.trove.set.hash.THashSet;\r
-\r
-public class TestNamespaceFilter {\r
-    \r
-    private void testBooleanOperations(Collection<String> all, NamespaceFilter a, NamespaceFilter b) {\r
-        {\r
-            NamespaceFilter c = NamespaceFilters.union(a, b);\r
-            //System.out.println("union(" + a + ", " + b + ") = " + c);\r
-            for(String name : all)\r
-                Assert.assertEquals(\r
-                        a.isValueIncluded(name) || b.isValueIncluded(name),\r
-                        c.isValueIncluded(name));\r
-        }\r
-        {\r
-            NamespaceFilter c = NamespaceFilters.intersection(a, b);\r
-            //System.out.println("intersection(" + a + ", " + b + ") = " + c);\r
-            for(String name : all)\r
-                Assert.assertEquals(\r
-                        a.isValueIncluded(name) && b.isValueIncluded(name),\r
-                        c.isValueIncluded(name));\r
-        }\r
-    }\r
-\r
-    private void testBooleanOperations(THashSet<String> a, THashSet<String> b) {\r
-        THashSet<String> all = new THashSet<String>();\r
-        all.addAll(a);\r
-        all.addAll(b);\r
-        all.add("dummy");\r
-        \r
-        PositiveNamespaceFilter pa = new PositiveNamespaceFilter(a);\r
-        NegativeNamespaceFilter na = new NegativeNamespaceFilter(a);\r
-        PositiveNamespaceFilter pb = new PositiveNamespaceFilter(b);\r
-        NegativeNamespaceFilter nb = new NegativeNamespaceFilter(b);\r
-        testBooleanOperations(all, pa, pb);\r
-        testBooleanOperations(all, na, pb);\r
-        testBooleanOperations(all, pa, nb);\r
-        testBooleanOperations(all, na, nb);\r
-    }\r
-    \r
-    private void testBooleanOperations(THashSet<String> a) {\r
-        THashSet<String> all = new THashSet<String>();\r
-        all.addAll(a);\r
-        all.add("dummy");\r
-        \r
-        PositiveNamespaceFilter pa = new PositiveNamespaceFilter(a);\r
-        NegativeNamespaceFilter na = new NegativeNamespaceFilter(a);\r
-        testBooleanOperations(all, pa, AcceptAllNamespaceFilter.INSTANCE);\r
-        testBooleanOperations(all, na, AcceptAllNamespaceFilter.INSTANCE);\r
-        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, pa);\r
-        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, na);\r
-        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, AcceptAllNamespaceFilter.INSTANCE);\r
-    }\r
-    \r
-    @Test\r
-    public void testBooleanOperations() {\r
-        for(int p=0;p<8;++p) {\r
-            THashSet<String> a = new THashSet<String>();\r
-            for(int i=0;i<3;++i)\r
-                if(((p >> i) & 1) == 1)\r
-                    a.add(String.valueOf(i));\r
-            testBooleanOperations(a);\r
-        }\r
-        \r
-        for(int p=0;p<64;++p) {\r
-            THashSet<String> a = new THashSet<String>();\r
-            THashSet<String> b = new THashSet<String>();\r
-            for(int i=0;i<3;++i) {\r
-                if(((p >> i) & 1) == 1)\r
-                    a.add(String.valueOf(i));\r
-                if(((p >> (i+3)) & 1) == 1)\r
-                    b.add(String.valueOf(i));\r
-            }\r
-            testBooleanOperations(a, b);\r
-        }\r
-    }\r
-    \r
-}\r
+package org.simantics.scl.compiler.tests.unit;
+
+import java.util.Collection;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.simantics.scl.compiler.environment.filter.AcceptAllNamespaceFilter;
+import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
+import org.simantics.scl.compiler.environment.filter.NamespaceFilters;
+import org.simantics.scl.compiler.environment.filter.NegativeNamespaceFilter;
+import org.simantics.scl.compiler.environment.filter.PositiveNamespaceFilter;
+
+import gnu.trove.set.hash.THashSet;
+
+public class TestNamespaceFilter {
+    
+    private void testBooleanOperations(Collection<String> all, NamespaceFilter a, NamespaceFilter b) {
+        {
+            NamespaceFilter c = NamespaceFilters.union(a, b);
+            //System.out.println("union(" + a + ", " + b + ") = " + c);
+            for(String name : all)
+                Assert.assertEquals(
+                        a.isValueIncluded(name) || b.isValueIncluded(name),
+                        c.isValueIncluded(name));
+        }
+        {
+            NamespaceFilter c = NamespaceFilters.intersection(a, b);
+            //System.out.println("intersection(" + a + ", " + b + ") = " + c);
+            for(String name : all)
+                Assert.assertEquals(
+                        a.isValueIncluded(name) && b.isValueIncluded(name),
+                        c.isValueIncluded(name));
+        }
+    }
+
+    private void testBooleanOperations(THashSet<String> a, THashSet<String> b) {
+        THashSet<String> all = new THashSet<String>();
+        all.addAll(a);
+        all.addAll(b);
+        all.add("dummy");
+        
+        PositiveNamespaceFilter pa = new PositiveNamespaceFilter(a);
+        NegativeNamespaceFilter na = new NegativeNamespaceFilter(a);
+        PositiveNamespaceFilter pb = new PositiveNamespaceFilter(b);
+        NegativeNamespaceFilter nb = new NegativeNamespaceFilter(b);
+        testBooleanOperations(all, pa, pb);
+        testBooleanOperations(all, na, pb);
+        testBooleanOperations(all, pa, nb);
+        testBooleanOperations(all, na, nb);
+    }
+    
+    private void testBooleanOperations(THashSet<String> a) {
+        THashSet<String> all = new THashSet<String>();
+        all.addAll(a);
+        all.add("dummy");
+        
+        PositiveNamespaceFilter pa = new PositiveNamespaceFilter(a);
+        NegativeNamespaceFilter na = new NegativeNamespaceFilter(a);
+        testBooleanOperations(all, pa, AcceptAllNamespaceFilter.INSTANCE);
+        testBooleanOperations(all, na, AcceptAllNamespaceFilter.INSTANCE);
+        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, pa);
+        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, na);
+        testBooleanOperations(all, AcceptAllNamespaceFilter.INSTANCE, AcceptAllNamespaceFilter.INSTANCE);
+    }
+    
+    @Test
+    public void testBooleanOperations() {
+        for(int p=0;p<8;++p) {
+            THashSet<String> a = new THashSet<String>();
+            for(int i=0;i<3;++i)
+                if(((p >> i) & 1) == 1)
+                    a.add(String.valueOf(i));
+            testBooleanOperations(a);
+        }
+        
+        for(int p=0;p<64;++p) {
+            THashSet<String> a = new THashSet<String>();
+            THashSet<String> b = new THashSet<String>();
+            for(int i=0;i<3;++i) {
+                if(((p >> i) & 1) == 1)
+                    a.add(String.valueOf(i));
+                if(((p >> (i+3)) & 1) == 1)
+                    b.add(String.valueOf(i));
+            }
+            testBooleanOperations(a, b);
+        }
+    }
+    
+}