Package edu.cmu.cs.fusion.constraint

Examples of edu.cmu.cs.fusion.constraint.SpecVar


  }
 
  @Test
  public void testFindLabelsPossibleFromSuperTypes() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
    Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
   
    fv = fv.addVar(new SpecVar("c"), "Baz");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
    Substitution subA = itr.next();
    assertTrue(itr.hasNext());
    Substitution subB = itr.next();
    assertTrue(itr.hasNext());
    Substitution subC = itr.next();
    assertTrue(itr.hasNext());
    Substitution subD = itr.next();
    assertTrue(!itr.hasNext())
   
    assertEquals(3, subA.size());
    assertEquals(3, subB.size());
    assertEquals(3, subC.size());
    assertEquals(3, subD.size());
   
    List<ObjectLabel> possible = new LinkedList<ObjectLabel>();
    possible.add(subA.getSub(new SpecVar("c")));
    possible.add(subB.getSub(new SpecVar("c")));
    possible.add(subC.getSub(new SpecVar("c")));
    possible.add(subD.getSub(new SpecVar("c")));
   
    assertTrue(possible.contains(labels[1]));
    assertTrue(possible.contains(labels[2]));
    assertTrue(possible.contains(labels[5]));
    assertTrue(possible.contains(labels[6]));
View Full Code Here


    InstanceOfPredicate val = (InstanceOfPredicate)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain one free variable", 1, vars.size());
    Assert.assertEquals("Foo should have a Foo type", "Foo", vars.getType(new SpecVar("foo")));   
  }
View Full Code Here

    InstanceOfPredicate val = (InstanceOfPredicate)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain one free variable", 1, vars.size());
    Assert.assertEquals("Bar should have a Object type, has type " + vars.getType(new SpecVar("bar")), "java.lang.Object", vars.getType(new SpecVar("bar")));       
  }
View Full Code Here

    ReferenceEqualityPredicate val = (ReferenceEqualityPredicate)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain two free variable", 2, vars.size());
    Assert.assertEquals("Foo should have a Object type", "java.lang.Object", vars.getType(new SpecVar("foo")));   
    Assert.assertEquals("Bar should have a Object type", "java.lang.Object", vars.getType(new SpecVar("bar")));   
  }
View Full Code Here

    ReferenceEqualityPredicate val = (ReferenceEqualityPredicate)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain two free variable", 2, vars.size());
    Assert.assertEquals("Foo should have a Object type", "java.lang.Object", vars.getType(new SpecVar("foo")));   
    Assert.assertEquals("Bar should have a Object type", "java.lang.Object", vars.getType(new SpecVar("bar")));   
  }
View Full Code Here

    Assert.assertEquals("Effect type is wrong", RelEffect.EffectType.ADD, effect.getType());
    Assert.assertEquals("Effect relation is wrong", "Foo", effect.getRelation().getName());
   
    FreeVars vars = effect.getFreeVariables();
    Assert.assertEquals("Should only contain two free variables", 2, vars.size());
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertEquals("Effect type is wrong", RelEffect.EffectType.REMOVE, effect.getType());
    Assert.assertEquals("Effect relation is wrong", "Foo", effect.getRelation().getName());
   
    FreeVars vars = effect.getFreeVariables();
    Assert.assertEquals("Should only contain two free variables", 2, vars.size());
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertEquals("But actually has two!", 2, effect.getVars().length)
    Assert.assertEquals("one wildcard", 1, wcs.size());
    Assert.assertTrue("The first param should be a wildcard!", effect.getVars()[0].isWildCard());   
    Assert.assertEquals("wild card should have a Bar type", "Bar", wcs.getType(effect.getVars()[0]));   
    Assert.assertTrue("The second param should be normal", !effect.getVars()[1].isWildCard());
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertEquals("Effect type is wrong", RelEffect.EffectType.TEST, effect.getType());
    Assert.assertEquals("Effect relation is wrong", "Foo", effect.getRelation().getName());
   
    FreeVars vars = effect.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
  }
View Full Code Here

    Assert.assertEquals("Effect type is wrong", RelEffect.EffectType.NEG_TEST, effect.getType());
    Assert.assertEquals("Effect relation is wrong", "Foo", effect.getRelation().getName());
   
    FreeVars vars = effect.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
  }
View Full Code Here

TOP

Related Classes of edu.cmu.cs.fusion.constraint.SpecVar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.