Package edu.cmu.cs.fusion.constraint.predicates

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


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

    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

    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

    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

    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

    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

    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

TOP

Related Classes of edu.cmu.cs.fusion.constraint.predicates.InstanceOfPredicate

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.