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 CSTExpressionInOclCS compileOclExpression(string expression, string sourceName, StreamWriter errWriter) { StringReader inR = new StringReader(expression); string inName = sourceName; cstNodes = this.compile(inR, inName, errWriter, typeof(CSTExpressionInOclCS), errors); if ((cstNodes != null) && (getErrorsCount() == 0)) { CSTExpressionInOclCS rootNode = (CSTExpressionInOclCS)cstNodes[0]; return(rootNode); } else { return(null); } }
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); } }
/* (non-Javadoc) * @see br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.CSTVisitor#visitExpressionInOclEnd(br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.context.CSTExpressionInOclCS) */ public override void visitExpressionInOclEnd(CSTExpressionInOclCS expression) { }
/* (non-Javadoc) * @see br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.CSTVisitor#visitExpressionInOclEnd(br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.context.CSTExpressionInOclCS) */ public void visitExpressionInOclEnd(CSTExpressionInOclCS expression) { }