public void testPrePost() { AstOclConstraintFactory factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage()); AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); BooleanLiteralExp exp1 = factory2.createBooleanLiteralExp(true, getClassifier("Boolean")); ExpressionInOcl expInOcl1 = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1); BooleanLiteralExp exp2 = factory2.createBooleanLiteralExp(false, getClassifier("Boolean")); ExpressionInOcl expInOcl2 = factory1.createExpressionInOcl("name", getClassifier("Film"), exp2); List <object> parms = new List <object>(); parms.Add(getClassifier("Integer")); CoreOperation oper = getClassifier("Film").lookupOperation("getRentalFee", parms); OclPrePostConstraint constraint = (OclPrePostConstraint)factory1.createPrePostConstraint("test.ocl", oper); OclConstraint preConstraint = factory1.createPreConstraint(constraint, "test.ocl", "myPre", oper, expInOcl1); OclConstraint postConstraint = factory1.createPostConstraint(constraint, "test.ocl", "myPost", oper, expInOcl2); Assert.AreEqual("pre myPre: True", preConstraint.ToString()); Assert.AreEqual("post myPost: False", postConstraint.ToString()); Assert.IsTrue(oper.getSpecifications().Contains(constraint)); OclPrePostConstraint example = (OclPrePostConstraint)oper.getSpecifications()[0]; Assert.IsTrue(example.getPreConditions().Contains((OclPreConstraint)preConstraint)); Assert.IsTrue(example.getPostConditions().Contains((OclPostConstraint)postConstraint)); oper.deleteAllConstraintsForSource("test.ocl"); Assert.AreEqual(0, oper.getSpecifications().Count); }
private IExpression GetExpression(SelectContext context, BooleanLiteralExp booleanLiteral) { return(new EqualsToExpression { LeftExp = new LongValue { Value = 1 }, RightExp = new LongValue { Value = booleanLiteral.BooleanValue.GetValueOrDefault() ? 1 : 0 } }); }
public void testBooleanLiteralExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); BooleanLiteralExp exp1 = factory1.createBooleanLiteralExp(true, getClassifier("Boolean")); Assert.AreEqual("True", exp1.ToString()); Assert.AreEqual("Boolean", exp1.getType().getName()); AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); BooleanLiteralExp exp2 = factory2.createBooleanLiteralExp(true, getClassifier("Boolean")); Assert.AreEqual("True", exp2.ToString()); Assert.IsFalse(exp1 == exp2); Assert.IsTrue(factory1 == factory2); }
public void testInvariant() { AstOclConstraintFactory factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage()); AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); BooleanLiteralExp exp1 = factory2.createBooleanLiteralExp(true, getClassifier("Boolean")); ExpressionInOcl expInOcl = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1); OclInvariantConstraint constraint = (OclInvariantConstraint)factory1.createInvariantConstraint("test.ocl", "myInvariant", getClassifier("Film"), expInOcl); Assert.AreEqual("inv myInvariant: True", constraint.ToString()); Assert.IsTrue(getClassifier("Film").getAllInvariants().Contains(constraint)); getClassifier("Film").deleteAllConstraintsForSource("test.ocl"); Assert.IsFalse(getClassifier("Film").getAllInvariants().Contains(constraint)); }
private void doTestBoolean(bool expectedValue) { CSTNode node = parseOK(expectedValue.ToString().ToLower(), this.getCurrentMethodName()); Assert.IsTrue(node is CSTBooleanLiteralExpCS); CSTBooleanLiteralExpCS literalExp = (CSTBooleanLiteralExpCS)node; Assert.IsNotNull(literalExp.getAst()); Assert.IsTrue(literalExp.getAst() is BooleanLiteralExp); BooleanLiteralExp ast = (BooleanLiteralExp)literalExp.getAst(); Assert.AreEqual(expectedValue, ast.isBooleanSymbol()); CoreClassifier type = ast.getType(); Assert.IsNotNull(type); Assert.AreEqual("Boolean", type.getName()); }
public override OclExpression Visit(BooleanLiteralExp node) { return(new BooleanLiteralExp(node.Value, node.Type)); }
public virtual void Visit(BooleanLiteralExp node) { AssignIsPartOfIteratorBody(node); // instead boolean literals, functions are used SubexpressionTranslations.AddTrivialTranslation(node, node.Value ? "true()" : "false()"); }
public override bool Visit(BooleanLiteralExp node) { return(true); }
public void Visit(BooleanLiteralExp node) { }
public void Visit(BooleanLiteralExp node) { sb.AppendFormat("{0}", node.Value); }
public void Visit(BooleanLiteralExp node) { sb.AppendFormat("({0}:{1})", node.GetType().Name, node.Value); }
public abstract TType Visit(BooleanLiteralExp node);
public void visitBooleanLiteralExp(BooleanLiteralExp exp) { // get boolean symbol and add to formula formula += exp.isBooleanSymbol(); }