X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Funit%2FTestNamespaceFilter.java;fp=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Funit%2FTestNamespaceFilter.java;h=0000000000000000000000000000000000000000;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hp=fa3bd9f65988011ca71f8fa7f46fdeec2f7dd4cb;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/unit/TestNamespaceFilter.java b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/unit/TestNamespaceFilter.java deleted file mode 100644 index fa3bd9f65..000000000 --- a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/unit/TestNamespaceFilter.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.simantics.scl.compiler.tests.unit; - -import java.util.Collection; - -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; -import junit.framework.Assert; - -public class TestNamespaceFilter { - - private void testBooleanOperations(Collection 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 a, THashSet b) { - THashSet all = new THashSet(); - 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 a) { - THashSet all = new THashSet(); - 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 a = new THashSet(); - 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 a = new THashSet(); - THashSet b = new THashSet(); - 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); - } - } - -}