Package edu.cmu.cs.fusion.constraint

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


  }
 
  @Test
  public void testFindLabelsOneOption() {
    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"), "Narf");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
View Full Code Here


  }

  @Test
  public void testFindLabelsAliasesAllDefinite() {
    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"), "Foo");
   
    List<Substitution> subs = env.allValidSubs(existing, fv);
   
    Iterator<Substitution> itr = subs.iterator();
    assertTrue(itr.hasNext());
View Full Code Here

  }
 
  @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());
View Full Code Here

    Assert.assertTrue("Parsed predicate should be a InstanceOfPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof InstanceOfPredicate);
   
    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

    Assert.assertTrue("Parsed predicate should be a InstanceOfPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof InstanceOfPredicate);
   
    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

    utils = new TestUtils();
  }
 
  @Test
  public void testFreeVars() {
    FreeVars fv;
    InstanceOfPredicate pred;
   
    pred = new InstanceOfPredicate(utils.getVar(0), "Foo");
    fv = pred.getFreeVariables();
 
    assertEquals("Foo", fv.getType(utils.getVar(0)));
    assertEquals(1, fv.size());
  }
View Full Code Here

    Assert.assertTrue("Parsed predicate should be a RefEquality, but is " + pred.getClass().getCanonicalName(), pred instanceof ReferenceEqualityPredicate);
   
    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

    assertEquals(1, fv.size());
  }
 
  @Test
  public void testFreeVarsNeg() {
    FreeVars fv;
    InstanceOfPredicate pred;
   
    pred = new InstanceOfPredicate(utils.getVar(0), "Foo");
    pred.setPositive(false);
    fv = pred.getFreeVariables();
 
    assertEquals(FreeVars.OBJECT_TYPE, fv.getType(utils.getVar(0)));
    assertEquals(1, fv.size());
  }
View Full Code Here

    Assert.assertTrue("Parsed predicate should be a RefEquality, but is " + pred.getClass().getCanonicalName(), pred instanceof ReferenceEqualityPredicate);
   
    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

    utils = new TestUtils();
  }
 
  @Test
  public void testFreeVars() {
    FreeVars fv;
    RelationshipPredicate relPred = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    Predicate pred = new TestPredicate(relPred, utils.getVar(2));
   
    fv = pred.getFreeVariables();
    assertEquals(3, fv.size());

    String[] types = utils.getRelation(0).getFullyQualifiedTypes();
    assertEquals(FreeVars.BOOL_TYPE, fv.getType(utils.getVar(2)));   
    assertEquals(types[0], fv.getType(utils.getVar(0)));
    assertEquals(types[1], fv.getType(utils.getVar(1)));
  }
View Full Code Here

TOP

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

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.