Package edu.cmu.cs.fusion

Examples of edu.cmu.cs.fusion.Relation


public class ParseTestPredicate
  @Test
  public void testTestPosPosPred() throws ParseException {
    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);
View Full Code Here


  @Test
  public void testTestNegPosPred() throws ParseException {
    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);
View Full Code Here

 
  @Test
  public void testTestPosNegPred() throws ParseException {
    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);
View Full Code Here

  @Test
  public void testTestNegNegPred() throws ParseException {
    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);
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

      Effect effect = Effect.valueOf(relElement.getAttribute("effect"));
      if (effect == null || effect == Effect.TEST)
        throw new FusionTypeCheckException(effect);
     
      relName = Utilities.resolveType(context, relName);
      Relation relType = relEnv.findRelation(relName);
      if (relType == null)
        throw new FusionTypeCheckException(relName);
     
      ObjectLabel[] labArr = getLabels(relElement, relType, types);
      Relationship rel = new Relationship(relType, labArr);
View Full Code Here

    List<Effect> effects = new LinkedList<Effect>();
   
    for (IAnnotation anno : method.getAnnotations()) {
      String qName = Utilities.resolveType(method.getDeclaringType(), anno.getElementName());
      Relation rel = rels.findRelation(qName);
     
      if (rel != null) {
        effects.add(parseEffect(anno, rel, method));
      }
      else {
View Full Code Here

  }

  private void parseCallback(IAnnotation callback, IMethod methodType) throws JavaModelException {
    IType declaringType = methodType.getDeclaringType();
    String relName = (String)callback.getMemberValuePairs()[0].getValue();
    Relation relation = rels.findRelation(Utilities.resolveType(declaringType, relName));
   
    if (relation == null) {
      ReportingUtility.reportParseError(callback.getResource(), callback.getNameRange(), "Unknown relation " + relName);
      return;
    }
   
    if (relation.getFullyQualifiedTypes().length != 1) {
      ReportingUtility.reportParseError(callback.getResource(), callback.getNameRange(), "Callback can only be used with one parameter");
      return;
    }
   
    String[] paramTypes = new String[methodType.getParameterTypes().length];
View Full Code Here

    aliases.addAlias(vars[3], labels[0]);
    aliases.addAlias(vars[4], labels[2]);
    aliases.addAlias(vars[4], labels[3]);

    relations = new Relation[2];
    relations[0] = new Relation("A", new String[] {"Foo", "Bar"});
    relations[1] = new Relation("B", new String[] {"Foo", "Foo"});
   
    ctx = new RelationshipContext(false);
    RelationshipDelta delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(relations[0], new ObjectLabel[] {labels[0], labels[1]}), SevenPointLattice.TRU);
    ctx = ctx.applyChangesFromDelta(delta);
View Full Code Here

TOP

Related Classes of edu.cmu.cs.fusion.Relation

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.