public void testAttributeDerive() { AstOclConstraintFactory factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage()); AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); IntegerLiteralExp exp1 = factory2.createIntegerLiteralExp(100, getClassifier("Integer")); ExpressionInOcl expInOcl = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1); OclAttributeDeriveConstraint constraint = (OclAttributeDeriveConstraint)factory1.createAttributeDeriveConstraint("test.ocl", getClassifier("Film"), getClassifier("Film").lookupAttribute("rentalFee"), expInOcl); Assert.AreEqual("derive: 100", constraint.ToString()); OclConstraint c = getClassifier("Film").getDeriveConstraint("rentalFee"); Assert.AreEqual(constraint, c); CoreAttribute attrib = getClassifier("Film").lookupAttribute("rentalFee"); Assert.IsNotNull(attrib); Assert.AreEqual(expInOcl, attrib.getDerivedValueExpression()); Assert.IsTrue(attrib.isDerived()); getClassifier("Film").deleteAllConstraintsForSource("test.ocl"); Assert.IsNull(getClassifier("Film").getDeriveConstraint("rentalFee")); }
private IExpression GetExpression(SelectContext context, IntegerLiteralExp integerLiteral) { return(new LongValue { Value = integerLiteral.IntegerValue.GetValueOrDefault() }); }
public void testIntegerLiteralExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); IntegerLiteralExp exp1 = factory1.createIntegerLiteralExp(100, getClassifier("Integer")); Assert.AreEqual("100", exp1.ToString()); Assert.AreEqual("Integer", 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 doTestInteger(int expectedValue) { CSTNode node = parseOK(expectedValue.ToString(CultureInfo.InvariantCulture), this.getCurrentMethodName()); Assert.IsTrue(node is CSTIntegerLiteralExpCS); CSTIntegerLiteralExpCS literalExp = (CSTIntegerLiteralExpCS)node; Assert.IsNotNull(literalExp.getAst()); Assert.IsTrue(literalExp.getAst() is IntegerLiteralExp); IntegerLiteralExp ast = (IntegerLiteralExp)literalExp.getAst(); Assert.AreEqual(expectedValue, ast.getIntegerSymbol()); CoreClassifier type = ast.getType(); Assert.IsNotNull(type); Assert.AreEqual("Integer", type.getName()); }
public void testIterateExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Distributor"), null); VariableExp source = factory1.createVariableExp(variable); VariableDeclaration iter = factory1.createVariableDeclaration("iter", getClassifier("SpecialFilm"), null); VariableExp iterRef = factory1.createVariableExp(iter); CoreAttribute attr = getClassifier("SpecialFilm").lookupAttribute("lateReturnFee"); AttributeCallExp attCall = factory1.createAttributeCallExp(iterRef, attr, false); IntegerLiteralExp initExp = factory1.createIntegerLiteralExp(100, getClassifier("Integer")); VariableDeclaration result = factory1.createVariableDeclaration("result", getClassifier("Integer"), initExp); List <object> paramTypes = new List <object>(); paramTypes.Add(getClassifier("Integer")); CoreOperation oper = getClassifier("Integer").lookupOperation("+", paramTypes); VariableExp resultExp = factory1.createVariableExp(result); List <object> args = new List <object>(); args.Add(attCall); OclExpression body = factory1.createOperationCallExp(resultExp, oper, args, getClassifier("Integer"), false); List <object> iterators = new List <object>(); iterators.Add(iter); IterateExp exp = factory1.createIterateExp(getClassifier("Integer"), source, body, iterators, result); Assert.AreEqual("abc->iterate(iter : SpecialFilm ; result : Integer = 100 | result + iter.lateReturnFee)", exp.ToString()); Assert.AreEqual("Integer", exp.getType().getName()); }
public override OclExpression Visit(IntegerLiteralExp node) { return(new IntegerLiteralExp(node.Value, node.Type)); }
public virtual void Visit(IntegerLiteralExp node) { AssignIsPartOfIteratorBody(node); SubexpressionTranslations.AddTrivialTranslation(node, node.Value.ToString()); }
public override bool Visit(IntegerLiteralExp node) { return(true); }
public void Visit(IntegerLiteralExp node) { }
public void Visit(IntegerLiteralExp node) { sb.Append(node.Value); }
public void Visit(IntegerLiteralExp node) { sb.AppendFormat("({0}:{1})", node.GetType().Name, node.Value); }
public abstract TType Visit(IntegerLiteralExp node);
public void visitIntegerLiteralExp(IntegerLiteralExp exp) { // get integer symbol and add to formula formula += exp.getIntegerSymbol(); }