public void testRealLiteralExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); RealLiteralExp exp1 = factory1.createRealLiteralExp("247.49", getClassifier("Real")); Assert.AreEqual("247.49", exp1.ToString()); Assert.AreEqual("Real", exp1.getType().getName()); }
public void testIfExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Boolean"), null); VariableExp condition = factory1.createVariableExp(variable); IntegerLiteralExp thenExp = factory1.createIntegerLiteralExp(100, getClassifier("Integer")); RealLiteralExp elseExp = factory1.createRealLiteralExp("247.49", getClassifier("Real")); IfExp exp = factory1.createIfExp(condition, thenExp, elseExp); Assert.AreEqual("if abc then 100 else 247.49 endif", exp.ToString()); Assert.AreEqual("Real", exp.getType().getName()); }
private void doTestReal(String expectedValueStr, double expectedValue) { CSTNode node = parseOK(expectedValueStr, this.getCurrentMethodName()); Assert.IsTrue(node is CSTRealLiteralExpCS); CSTRealLiteralExpCS literalExp = (CSTRealLiteralExpCS)node; Assert.IsNotNull(literalExp.getAst()); Assert.IsTrue(literalExp.getAst() is RealLiteralExp); RealLiteralExp ast = (RealLiteralExp)literalExp.getAst(); Assert.AreEqual(expectedValue, Double.Parse(ast.getRealSymbol(), CultureInfo.InvariantCulture)); CoreClassifier type = ast.getType(); Assert.IsNotNull(type); Assert.AreEqual("Real", type.getName()); }
public void testBody() { AstOclConstraintFactory factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage()); AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); RealLiteralExp exp1 = factory2.createRealLiteralExp("200.50", getClassifier("Real")); ExpressionInOcl expInOcl = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1); List <object> parms = new List <object>(); parms.Add(getClassifier("Integer")); CoreOperation oper = getClassifier("Film").lookupOperation("getRentalFee", parms); OclBodyConstraint constraint = (OclBodyConstraint)factory1.createBodyConstraint("test.ocl", oper, expInOcl, null); Assert.AreEqual("body: 200.50", constraint.ToString()); Assert.AreEqual(constraint, oper.getBodyDefinition()); Assert.AreEqual(expInOcl, oper.getBodyDefinition().getExpression()); oper.deleteAllConstraintsForSource("test.ocl"); Assert.IsNull(oper.getBodyDefinition()); }
public override OclExpression Visit(RealLiteralExp node) { return(new RealLiteralExp(node.Value, node.Type)); }
public virtual void Visit(RealLiteralExp node) { AssignIsPartOfIteratorBody(node); SubexpressionTranslations.AddTrivialTranslation(node, node.Value.ToString()); }
public override bool Visit(RealLiteralExp node) { return(true); }
public void Visit(RealLiteralExp node) { }
public void Visit(RealLiteralExp node) { sb.Append(node.Value); }
public void Visit(RealLiteralExp node) { throw new NotImplementedException(); }
public abstract TType Visit(RealLiteralExp node);
public void visitRealLiteralExp(RealLiteralExp exp) { // get real symbol and add to formula formula += exp.getRealSymbol(); }