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

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


    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a AndPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof AndPredicate);
   
    AndPredicate val = (AndPredicate)pred;
   
    Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
    Assert.assertTrue("Right side is a bool value", val.getRight() instanceof BooleanValue);
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain two free variables", 2, vars.size());

    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("a should have a boolean type", "boolean", vars.getType(new SpecVar("a")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("b should have a boolean type", "boolean", vars.getType(new SpecVar("b")));   
  }
View Full Code Here


    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a AndPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof AndPredicate);
   
    AndPredicate val = (AndPredicate)pred;
   
    Assert.assertTrue("Left side is a and pred", val.getLeft() instanceof AndPredicate);
    Assert.assertTrue("Right side is a bool value", val.getRight() instanceof BooleanValue);
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());

    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain two free variables", 2, vars.size());
    Assert.assertEquals("a should have a boolean type", "boolean", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a boolean type", "boolean", vars.getType(new SpecVar("b")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
  }
View Full Code Here

   
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a AndPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof AndPredicate);   
    AndPredicate val = (AndPredicate)pred;
   
    Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
    Assert.assertTrue("Right side is a and pred", val.getRight() instanceof AndPredicate);
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain 4 free variables", 4, vars.size());

    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("a should have a boolean type", "boolean", vars.getType(new SpecVar("a")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain 3 free variables", 3, vars.size());
   
    val = (AndPredicate)val.getRight();
    Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
    Assert.assertTrue("Right side is a and pred", val.getRight() instanceof AndPredicate);
   
    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("b should have a boolean type", "boolean", vars.getType(new SpecVar("b")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain 2 free variables", 2, vars.size());

    val = (AndPredicate)val.getRight();
    Assert.assertTrue("Left side is a bool value", val.getLeft() instanceof BooleanValue);
    Assert.assertTrue("Right side is a bool value", val.getRight() instanceof BooleanValue);

    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain one free variables", 1, vars.size());
    Assert.assertEquals("d should have a boolean type", "boolean", vars.getType(new SpecVar("d")));   

  }
View Full Code Here

    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a AndPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof AndPredicate);
   
    AndPredicate val = (AndPredicate)pred;
   
    Assert.assertTrue("Left side is a or pred", val.getLeft() instanceof OrPredicate);
    Assert.assertTrue("Right side is a bool value", val.getRight() instanceof BooleanValue);
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());

    vars = val.getLeft().getFreeVariables();
    Assert.assertEquals("Should only contain 2 free variables", 2, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
    Assert.assertEquals("b should have a boolean type", "boolean", vars.getType(new SpecVar("b")));   

    vars = val.getRight().getFreeVariables();
    Assert.assertEquals("Should only contain 1 free variables", 1, vars.size());
    Assert.assertEquals("a should have a boolean type", "boolean", vars.getType(new SpecVar("a")));   
  }
View Full Code Here

    FreeVars fv;
    String[] types = utils.getRelation(0).getFullyQualifiedTypes();
   
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(2)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    AndPredicate pred = new AndPredicate(lP, rP);
    fv = pred.getFreeVariables();
 
    assertEquals(types[0], fv.getType(utils.getVar(0)));
    assertEquals(types[1], fv.getType(utils.getVar(1)));
    assertEquals(types[1], fv.getType(utils.getVar(2)));
View Full Code Here

 
  @Test
  public void testTruthTrue() {
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(4), utils.getVar(3)});
    AndPredicate pred = new AndPredicate(lP, rP);

    FusionEnvironment env = new TestEnvironment(utils.getContext(0), Variant.SOUND_VARIANT);
   
    assertEquals(ThreeValue.TRUE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

  @Test
  public void testTruthFalse1() {
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(2)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(4), utils.getVar(3)});
    AndPredicate pred = new AndPredicate(lP, rP);

    FusionEnvironment env = new TestEnvironment(utils.getContext(0), Variant.SOUND_VARIANT);
   
    assertEquals(ThreeValue.FALSE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

  @Test
  public void testTruthFalse2() {
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(2), utils.getVar(3)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(2)});
    AndPredicate pred = new AndPredicate(lP, rP);

    FusionEnvironment env = new TestEnvironment(utils.getContext(0), Variant.SOUND_VARIANT);
   
    assertEquals(ThreeValue.FALSE, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

  @Test
  public void testTruthUnknown1() {
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(2), utils.getVar(3)});
    AndPredicate pred = new AndPredicate(lP, rP);

    FusionEnvironment env = new TestEnvironment(utils.getContext(0), Variant.SOUND_VARIANT);
   
    assertEquals(ThreeValue.UNKNOWN, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

  @Test
  public void testTruthUnknown2() {
    RelationshipPredicate lP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(2), utils.getVar(3)});
    RelationshipPredicate rP = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    AndPredicate pred = new AndPredicate(lP, rP);

    FusionEnvironment env = new TestEnvironment(utils.getContext(0), Variant.SOUND_VARIANT);
   
    assertEquals(ThreeValue.UNKNOWN, pred.getTruth(env, utils.getSub(0)));
  }
View Full Code Here

TOP

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

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.