Package edu.cmu.cs.fusion.constraint

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


  @Test
  public void testFalseParses() throws ParseException {
    String string = "FALSE";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a FalsePredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof FalsePredicate);
   
  }
View Full Code Here


  @Test
  public void testBoolParses() throws ParseException {
    String string = "foo";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a BooleanValue, but is " + pred.getClass().getCanonicalName(), pred instanceof BooleanValue);
   
    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
View Full Code Here

  @Test
  public void testNegBoolParses() throws ParseException {
    String string = "!foo";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a BooleanValue, but is " + pred.getClass().getCanonicalName(), pred instanceof BooleanValue);
   
    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
View Full Code Here

    String string = "?Foo(a, b) : c";
    RelationsEnvironment env = new RelationsEnvironment();
    env.addRelation(new Relation("Foo", new String[] {"Bar", "Baz"}));
   
    FPLParser parser = new FPLParser(string, env, new StubIType());
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a TestPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof TestPredicate);
   
    TestPredicate val = (TestPredicate)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
    Assert.assertTrue("Parsed inner predicate should be positive", val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
View Full Code Here

    String string = "?Foo(a, b) : !c";
    RelationsEnvironment env = new RelationsEnvironment();
    env.addRelation(new Relation("Foo", new String[] {"Bar", "Baz"}));
   
    FPLParser parser = new FPLParser(string, env, new StubIType());
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a TestPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof TestPredicate);
   
    TestPredicate val = (TestPredicate)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
    Assert.assertTrue("Parsed inner predicate should be positive", val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
View Full Code Here

    String string = "?!Foo(a, b) : c";
    RelationsEnvironment env = new RelationsEnvironment();
    env.addRelation(new Relation("Foo", new String[] {"Bar", "Baz"}));
   
    FPLParser parser = new FPLParser(string, env, new StubIType());
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a TestPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof TestPredicate);
   
    TestPredicate val = (TestPredicate)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
    Assert.assertTrue("Parsed inner predicate should be negative", !val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
View Full Code Here

    String string = "?!Foo(a, b) : !c";
    RelationsEnvironment env = new RelationsEnvironment();
    env.addRelation(new Relation("Foo", new String[] {"Bar", "Baz"}));
   
    FPLParser parser = new FPLParser(string, env, new StubIType());
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a TestPredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof TestPredicate);
   
    TestPredicate val = (TestPredicate)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
    Assert.assertTrue("Parsed inner predicate should be negative", !val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
View Full Code Here

  @BeforeClass
  static public void setup() {
    utils = new TestUtils();
   
    Operation op;
    Predicate trigger;
    Predicate rst;
   
    op = new MethodInvocationOp("methodName", "Foo", new SpecVar[] {utils.getVar(0), utils.getVar(1)}, new String[] {"Foo", "Bar"}, "Bar", false);
    trigger = new RelationshipPredicate(utils.getRelation(0), new SpecVar[] {utils.getVar(0), utils.getVar(1)});
    rst = new RelationshipPredicate(utils.getRelation(1), new SpecVar[] {utils.getVar(1), utils.getVar(2)});
    cons = new Constraint("", op, trigger, rst, new TruePredicate(), new LinkedList<Effect>());
View Full Code Here

    assertEquals(partialSub, deltas.snd());
  }
 
  @Test
  public void testTrueNoSubs() throws FusionException {
    Predicate rst = new RelationshipPredicate(new Relation("D", new String[] {"Bar", "NewType"}), new SpecVar[] {utils.getVar(1), utils.getVar(2)});
    Constraint noSubCons = new Constraint("", cons.getOp(), cons.getTrigger(), rst, new TruePredicate(), new LinkedList<Effect>());
 
    RelationshipDelta startRels = new RelationshipDelta();
    startRels.setRelationship(new Relationship(utils.getRelation(0), new ObjectLabel[]{labels[0], labels[1]}), SevenPointLattice.TRU);
    RelationshipContext rels = new RelationshipContext(false).applyChangesFromDelta(startRels);
View Full Code Here

  }

  private void parseConstraint(IAnnotation constraint, IType contextType) throws JavaModelException {
    FPLParser parser = new FPLParser(rels, contextType);
    Operation op = null;
    Predicate trigger = null, requires = null, restrict = null;
    List<Effect> effects = new LinkedList<Effect>();
   
    try {
      for (IMemberValuePair pair : constraint.getMemberValuePairs()) {
        String name = pair.getMemberName();
View Full Code Here

TOP

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

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.