Examples of InstanceOfPredicate


Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

  }
 
  @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

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

  }
 
  @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

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    assertEquals(1, fv.size());
  }

  @Test
  public void testTruthFalse() {
    InstanceOfPredicate pred = new InstanceOfPredicate(utils.getVar(0), "Foo");
    FusionEnvironment env = new TestEnvironment(utils.getContext(0), null);
   
    assertEquals(ThreeValue.FALSE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    assertEquals(ThreeValue.FALSE, pred.getTruth(env, utils.getSub(0)));
  }

  @Test
  public void testTruthTrue() {
    InstanceOfPredicate pred = new InstanceOfPredicate(utils.getVar(1), "Foo");
    FusionEnvironment env = new TestEnvironment(utils.getContext(0), null);
   
    assertEquals(ThreeValue.TRUE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    assertEquals(ThreeValue.TRUE, pred.getTruth(env, utils.getSub(0)));
  }

  @Test
  public void testTruthNotFalse() {
    InstanceOfPredicate pred = new InstanceOfPredicate(utils.getVar(0), "Foo");
    pred.setPositive(false);
    FusionEnvironment env = new TestEnvironment(utils.getContext(0), null);
   
    assertEquals(ThreeValue.TRUE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    assertEquals(ThreeValue.TRUE, pred.getTruth(env, utils.getSub(0)));
  }

  @Test
  public void testTruthNotTrue() {
    InstanceOfPredicate pred = new InstanceOfPredicate(utils.getVar(1), "Foo");
    pred.setPositive(false);
    FusionEnvironment env = new TestEnvironment(utils.getContext(0), null);
   
    assertEquals(ThreeValue.FALSE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    FPLParser parser = new FPLParser(string, null, new StubIType());
    Predicate pred = parser.expression();
   
    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

Examples of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

    FPLParser parser = new FPLParser(string, null, new StubIType());
    Predicate pred = parser.expression();
   
    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

Examples of org.apache.commons.collections.functors.InstanceofPredicate

    }

    @SuppressWarnings("unchecked")
    public <T> Collection<T> lookupObjects(Class<T> returntype)
    {
        return (Collection<T>) registryMap.select(new InstanceofPredicate(returntype));
    }
View Full Code Here

Examples of org.apache.commons.collections.functors.InstanceofPredicate

    if (conventions == null) conventions = new ArrayList<Convention>();
    return conventions;
  }
 
  public Collection<ModelConvention> getModelConventions() {
    Transformer transformer = new PredicateTransformer(new InstanceofPredicate(ModelConvention.class));
    return CollectionUtils.transformedCollection(getConventions(), transformer);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.