public void testSelect_08() { oclCompiler = new PSWOclCompiler(environment, tracker); CSTExpressionInOclCS rootNode = oclCompiler.compileOclExpression("Film::allInstances()->select(name.toInteger() > 10)", getCurrentMethodName(), new StreamWriter(Console.OpenStandardOutput())); source = getCurrentMethodName(); Assert.IsNotNull(rootNode); Assert.AreEqual("Set(Film)", rootNode.getAst().getBodyExpression().getType().getName()); }
protected OclExpression getConstraintExpression(List <object> constraints) { if (constraints.Count > 0) { CSTInvariantCS invariant = (CSTInvariantCS)constraints[0]; CSTExpressionInOclCS expression = invariant.getExpressionNodeCS(); return(((ExpressionInOclImpl)expression.getAst()).getBodyExpression()); } else { return(null); } }
public void testLetOK_03() { List <object> constraints = doTestContextOK("context Film inv: let x : Integer = 20, y : Real = 40.10 in x > 0 ", getCurrentMethodName()); foreach (CSTInvariantCS constraint in constraints) { CSTExpressionInOclCS expression = constraint.getExpressionNodeCS(); OclExpression oclExpression = ((ExpressionInOclImpl)expression.getAst()).getBodyExpression(); Assert.IsTrue(oclExpression is LetExp); LetExp exp = (LetExp)oclExpression; Assert.AreEqual("Boolean", exp.getType().getName()); } }
public void testIfOK() { List <object> constraints = doTestContextOK("context Film inv: if 20 > 10 then self.name = self.name else self.name.concat(\"Alex\") = self.name endif", getCurrentMethodName()); foreach (CSTInvariantCS constraint in constraints) { CSTExpressionInOclCS expression = constraint.getExpressionNodeCS(); OclExpression oclExpression = ((ExpressionInOclImpl)expression.getAst()).getBodyExpression(); Assert.IsTrue(oclExpression is IfExp); IfExp exp = (IfExp)oclExpression; Assert.AreEqual("Boolean", exp.getType().getName()); Assert.IsTrue(((OperationCallExp)exp.getThenExpression()).getSource() is AttributeCallExp); Assert.IsTrue(((OperationCallExp)exp.getElseExpression()).getSource() is OperationCallExp); } }