From 6368293c3f5c1163cd58532fb04dad970c8fbddd Mon Sep 17 00:00:00 2001 From: Senteran Date: Tue, 7 May 2024 11:12:16 +0200 Subject: [PATCH 001/236] Created interpreternew package and tests --- .../interpreternew/RosettaInterpreterNew.java | 7 ++++++ .../RosettaInterpreterNewTest.java | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java new file mode 100644 index 000000000..83106bca0 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -0,0 +1,7 @@ +package com.regnosys.rosetta.interpreternew; + +public class RosettaInterpreterNew { + public int Test() { + return 5; + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java new file mode 100644 index 000000000..d1d0f6238 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -0,0 +1,24 @@ +package com.regnosys.rosetta.interpreternew; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.tests.RosettaInjectorProvider; + +import static org.junit.jupiter.api.Assertions.*; +import javax.inject.Inject; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterNewTest { + + @Inject + RosettaInterpreterNew interpreter; + + @Test + public void TestTest() { + assertEquals(5, interpreter.Test()); + } +} From d590b3404fadfce4bd1d57240cf961161ec84509 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 7 May 2024 12:00:54 +0200 Subject: [PATCH 002/236] Added simple interpreter values and exception --- .../RosettaInterpreterIntegerValue.java | 12 ++++++++++++ .../RosettaInterpreterNewException.java | 8 ++++++++ .../interpreternew/RosettaInterpreterValue.java | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java new file mode 100644 index 000000000..d2f068850 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew; + +public class RosettaInterpreterIntegerValue extends RosettaInterpreterValue{ + private int value; + + public RosettaInterpreterIntegerValue(int value) { + super(); + this.value = value; + } + + public int getValue() { return value; } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java new file mode 100644 index 000000000..ff4ba9e31 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java @@ -0,0 +1,8 @@ +package com.regnosys.rosetta.interpreternew; + +public class RosettaInterpreterNewException extends RuntimeException{ + + public RosettaInterpreterNewException(String message) { + super(message); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java new file mode 100644 index 000000000..10e3c6bd1 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java @@ -0,0 +1,5 @@ +package com.regnosys.rosetta.interpreternew; + +public abstract class RosettaInterpreterValue { + +} From d4a4fe6c049036cba0b6be075884bbe1eb8b64ee Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 7 May 2024 12:01:16 +0200 Subject: [PATCH 003/236] Added simple example interpret function --- .../interpreternew/RosettaInterpreterNew.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index 83106bca0..b96607628 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -1,7 +1,24 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; + public class RosettaInterpreterNew { public int Test() { return 5; } + + /** + * Simple example interpret function to allow for better understanding of the development workflow + * @param expression + * @return value of RosettaIntLiteral otherwise exception + */ + public RosettaInterpreterValue interp(RosettaExpression expression) { + if (expression instanceof RosettaIntLiteral) { + RosettaIntLiteral expr = (RosettaIntLiteral)expression; + return new RosettaInterpreterIntegerValue(expr.getValue().intValue()); + } + else + throw new RosettaInterpreterNewException("Unimplemented operation: " + expression.toString()); + } } From 3258857f2c58a0e0a495367118393238605bc29e Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 7 May 2024 12:01:28 +0200 Subject: [PATCH 004/236] Added test for example interpret function --- rosetta-testing/pom.xml | 2 +- .../RosettaInterpreterNewTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/rosetta-testing/pom.xml b/rosetta-testing/pom.xml index b57e2229e..fd276145f 100644 --- a/rosetta-testing/pom.xml +++ b/rosetta-testing/pom.xml @@ -33,7 +33,7 @@ com.regnosys.rosetta com.regnosys.rosetta - ${project.version} + 0.0.0.main-SNAPSHOT diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index d1d0f6238..75aca8525 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -6,10 +6,17 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaIntLiteralImpl; import static org.junit.jupiter.api.Assertions.*; import javax.inject.Inject; +import java.math.BigInteger; + @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) public class RosettaInterpreterNewTest { @@ -21,4 +28,17 @@ public class RosettaInterpreterNewTest { public void TestTest() { assertEquals(5, interpreter.Test()); } + + @Test + public void ExampleInterpTest() { + final int testValue = 10; + + ExpressionFactory eFactory = ExpressionFactoryImpl.init(); + RosettaIntLiteral expr = eFactory.createRosettaIntLiteral(); + expr.setValue(BigInteger.valueOf(testValue)); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue intVal = (RosettaInterpreterIntegerValue)val; + assertEquals(testValue, intVal.getValue()); + } } From 2c930a38c9dd3c730139aa426b03fc359f0d1284 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 8 May 2024 13:06:22 +0200 Subject: [PATCH 005/236] Added initial visitor implementation --- rosetta-lang/model/RosettaExpression.xcore | 13 ++ .../interpreternew/RosettaInterpreterNew.java | 14 +- .../RosettaInterpreterValue.java | 5 - .../RosettaInterpreterVisitor.java | 29 ++++ .../RosettaInterpreterVisitorBase.java | 132 ++++++++++++++++++ .../values/RosettaInterpreterBaseValue.java | 132 ++++++++++++++++++ .../RosettaInterpreterBooleanValue.java | 17 +++ .../RosettaInterpreterIntegerValue.java | 4 +- ...reterRosettaBooleanLiteralInterpreter.java | 10 ++ rosetta-testing/pom.xml | 2 +- .../RosettaInterpreterNewTest.java | 25 +++- 11 files changed, 372 insertions(+), 11 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java rename rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/{ => values}/RosettaInterpreterIntegerValue.java (76%) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 891f0a9a7..f873c4aaa 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -17,10 +17,20 @@ import com.regnosys.rosetta.rosetta.RosettaTyped import com.regnosys.rosetta.rosetta.simple.Attribute import org.eclipse.emf.common.util.BasicEList +abstract class RosettaInterpreterValue { + +} + +interface InterpreterVisitor { + op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) + op RosettaInterpreterValue interp (RosettaStringLiteral exp) + op RosettaInterpreterValue interp (RosettaNumberLiteral exp) +} interface RosettaExpression { // Whether the expression was generated boolean generated + op RosettaInterpreterValue accept(InterpreterVisitor v) } /** @@ -53,6 +63,9 @@ class RosettaBooleanLiteral extends RosettaLiteral { op String stringValue() { return Boolean.toString(value) } + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaStringLiteral extends RosettaLiteral { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index b96607628..be2973200 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -1,9 +1,17 @@ package com.regnosys.rosetta.interpreternew; +import javax.inject.Inject; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; public class RosettaInterpreterNew { + + @Inject + private RosettaInterpreterVisitor visitor; + public int Test() { return 5; } @@ -14,11 +22,13 @@ public int Test() { * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { + + // OLD EXAMPLE CODE NOT CONFORMING TO THE VISITOR STYLE if (expression instanceof RosettaIntLiteral) { RosettaIntLiteral expr = (RosettaIntLiteral)expression; return new RosettaInterpreterIntegerValue(expr.getValue().intValue()); } - else - throw new RosettaInterpreterNewException("Unimplemented operation: " + expression.toString()); + else return expression.accept(visitor); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java deleted file mode 100644 index 10e3c6bd1..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterValue.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.regnosys.rosetta.interpreternew; - -public abstract class RosettaInterpreterValue { - -} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java new file mode 100644 index 000000000..908e4e247 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -0,0 +1,29 @@ +package com.regnosys.rosetta.interpreternew; + +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; + +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; + +public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ + + @Override + public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { + return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp); + } + + @Override + public RosettaInterpreterValue interp(RosettaStringLiteral exp) { + // TODO Auto-generated method stub + return null; + } + + @Override + public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java new file mode 100644 index 000000000..9638a334f --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java @@ -0,0 +1,132 @@ +package com.regnosys.rosetta.interpreternew; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; + +import com.regnosys.rosetta.rosetta.expression.InterpreterVisitor; + +public abstract class RosettaInterpreterVisitorBase implements InterpreterVisitor { + @Override + public EClass eClass() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource eResource() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EObject eContainer() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EStructuralFeature eContainingFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EReference eContainmentFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TreeIterator eAllContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eIsProxy() { + // TODO Auto-generated method stub + return false; + } + + @Override + public EList eCrossReferences() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature, boolean resolve) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void eSet(EStructuralFeature feature, Object newValue) { + // TODO Auto-generated method stub + + } + + @Override + public boolean eIsSet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eUnset(EStructuralFeature feature) { + // TODO Auto-generated method stub + + } + + @Override + public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eAdapters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eDeliver() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eSetDeliver(boolean deliver) { + // TODO Auto-generated method stub + + } + + @Override + public void eNotify(Notification notification) { + // TODO Auto-generated method stub + + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java new file mode 100644 index 000000000..8160433ba --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -0,0 +1,132 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; + +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; + +public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ + @Override + public EClass eClass() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource eResource() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EObject eContainer() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EStructuralFeature eContainingFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EReference eContainmentFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TreeIterator eAllContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eIsProxy() { + // TODO Auto-generated method stub + return false; + } + + @Override + public EList eCrossReferences() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature, boolean resolve) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void eSet(EStructuralFeature feature, Object newValue) { + // TODO Auto-generated method stub + + } + + @Override + public boolean eIsSet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eUnset(EStructuralFeature feature) { + // TODO Auto-generated method stub + + } + + @Override + public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eAdapters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eDeliver() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eSetDeliver(boolean deliver) { + // TODO Auto-generated method stub + + } + + @Override + public void eNotify(Notification notification) { + // TODO Auto-generated method stub + + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java new file mode 100644 index 000000000..f0342228f --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -0,0 +1,17 @@ +package com.regnosys.rosetta.interpreternew.values; + + +public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue{ + private boolean value; + + public RosettaInterpreterBooleanValue(boolean value) { + super(); + this.value = value; + } + + public boolean getValue() { return value; } + + + + +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java similarity index 76% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java rename to rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index d2f068850..ec327741c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -1,6 +1,6 @@ -package com.regnosys.rosetta.interpreternew; +package com.regnosys.rosetta.interpreternew.values; -public class RosettaInterpreterIntegerValue extends RosettaInterpreterValue{ +public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue{ private int value; public RosettaInterpreterIntegerValue(int value) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java new file mode 100644 index 000000000..86d8459b1 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java @@ -0,0 +1,10 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; + +public class RosettaInterpreterRosettaBooleanLiteralInterpreter { + public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr) { + return new RosettaInterpreterBooleanValue(expr.isValue()); + } +} diff --git a/rosetta-testing/pom.xml b/rosetta-testing/pom.xml index fd276145f..b57e2229e 100644 --- a/rosetta-testing/pom.xml +++ b/rosetta-testing/pom.xml @@ -33,7 +33,7 @@ com.regnosys.rosetta com.regnosys.rosetta - 0.0.0.main-SNAPSHOT + ${project.version} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 75aca8525..45712cac8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -2,13 +2,18 @@ import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.expression.impl.RosettaIntLiteralImpl; @@ -24,6 +29,13 @@ public class RosettaInterpreterNewTest { @Inject RosettaInterpreterNew interpreter; + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + } + @Test public void TestTest() { assertEquals(5, interpreter.Test()); @@ -33,7 +45,6 @@ public void TestTest() { public void ExampleInterpTest() { final int testValue = 10; - ExpressionFactory eFactory = ExpressionFactoryImpl.init(); RosettaIntLiteral expr = eFactory.createRosettaIntLiteral(); expr.setValue(BigInteger.valueOf(testValue)); RosettaInterpreterValue val = interpreter.interp(expr); @@ -41,4 +52,16 @@ public void ExampleInterpTest() { RosettaInterpreterIntegerValue intVal = (RosettaInterpreterIntegerValue)val; assertEquals(testValue, intVal.getValue()); } + + @Test + public void VisitorInitialTest() { + final boolean testValue = false; + + RosettaBooleanLiteral expr = eFactory.createRosettaBooleanLiteral(); + expr.setValue(testValue); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolVal = (RosettaInterpreterBooleanValue)val; + assertEquals(testValue, boolVal.getValue()); + } } From 0cfc9a5b84d566219c9044a21a51f727b7ad026c Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 8 May 2024 13:14:30 +0200 Subject: [PATCH 006/236] Added base concrete interpreter abstract class --- .../visitors/RosettaInterpreterConcreteInterpreter.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java new file mode 100644 index 000000000..ab1c65694 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java @@ -0,0 +1,5 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +public abstract class RosettaInterpreterConcreteInterpreter { + +} From 3028cbe3a3f0609d73693530b45f1a88e6f4cec7 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 8 May 2024 13:16:04 +0200 Subject: [PATCH 007/236] concrete interpreter improvements --- .../visitors/RosettaInterpreterConcreteInterpreter.java | 7 ++++++- ...RosettaInterpreterRosettaBooleanLiteralInterpreter.java | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java index ab1c65694..b79cd4369 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java @@ -1,5 +1,10 @@ package com.regnosys.rosetta.interpreternew.visitors; -public abstract class RosettaInterpreterConcreteInterpreter { +import javax.inject.Inject; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; +public abstract class RosettaInterpreterConcreteInterpreter { + @Inject + protected RosettaInterpreterVisitor visitor; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java index 86d8459b1..9c5fa8c31 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java @@ -3,7 +3,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; -public class RosettaInterpreterRosettaBooleanLiteralInterpreter { +public class RosettaInterpreterRosettaBooleanLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ + public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr) { return new RosettaInterpreterBooleanValue(expr.isValue()); } From 2fc68f084c801dbcbf41db2b7b54b666d485c7e1 Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 16:46:22 +0200 Subject: [PATCH 008/236] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..2c64df604 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +stages: + - build + - test + - checkstyle + +build: + image: maven:3.8-openjdk-17 + stage: build + script: + - mvn clean package + +test: + image: maven:3.8-openjdk-17 + stage: test + script: + - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false + +checkstyle: + image: maven:3.8-openjdk-17 + stage: checkstyle + script: + - mvn checkstyle:check -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* + From 09fb5cd8c81ee94ede78450ed05db310321c44e3 Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 17:04:46 +0200 Subject: [PATCH 009/236] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c64df604..4803f821f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,8 @@ build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package + - mvn clean package -pl com.regnosys.rosetta,com.regnosys.rosetta.tests,com.regnosys.rosetta.xcore + test: image: maven:3.8-openjdk-17 From 967fa71fbf158cdc1680946017452b7f5d60d568 Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 17:13:48 +0200 Subject: [PATCH 010/236] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4803f821f..bb25d30f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,20 +1,20 @@ stages: - build - - test + # - test - checkstyle build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl com.regnosys.rosetta,com.regnosys.rosetta.tests,com.regnosys.rosetta.xcore + - mvn clean package -pl rosetta-runtime,rosetta-testing,rosetta-xcore-plugin-dependencies -test: - image: maven:3.8-openjdk-17 - stage: test - script: - - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false +# test: +# image: maven:3.8-openjdk-17 +# stage: test +# script: +# - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false checkstyle: image: maven:3.8-openjdk-17 From cf859d1effcd6ac12a373fb68522baaf26a86a2b Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 18:03:14 +0200 Subject: [PATCH 011/236] Update .gitlab-ci.yml file to build certain modules --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb25d30f4..3903c26c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,13 @@ stages: - build # - test - - checkstyle + # - checkstyle build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl rosetta-runtime,rosetta-testing,rosetta-xcore-plugin-dependencies + - mvn clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing # test: @@ -16,9 +16,9 @@ build: # script: # - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false -checkstyle: - image: maven:3.8-openjdk-17 - stage: checkstyle - script: - - mvn checkstyle:check -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* +# checkstyle: +# image: maven:3.8-openjdk-17 +# stage: checkstyle +# script: +# - mvn checkstyle:check -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* From f55c07549d9ca3b4745ad4990e398bf596caca8a Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 18:18:04 +0200 Subject: [PATCH 012/236] Update .gitlab-ci.yml file to run checkstyle checks --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3903c26c4..368d1f80a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - build # - test - # - checkstyle + - checkstyle build: image: maven:3.8-openjdk-17 @@ -16,9 +16,9 @@ build: # script: # - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false -# checkstyle: -# image: maven:3.8-openjdk-17 -# stage: checkstyle -# script: -# - mvn checkstyle:check -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* +checkstyle: + image: maven:3.8-openjdk-17 + stage: checkstyle + script: + - mvn checkstyle:check -pl rosetta-lang,rosetta-testing -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* From 351c7d686728a4c110c4263f7e7ee539a47a9d1c Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Tue, 14 May 2024 18:50:17 +0200 Subject: [PATCH 013/236] Update .gitlab-ci.yml file checkstyle rules --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 368d1f80a..8d9466509 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,5 +20,5 @@ checkstyle: image: maven:3.8-openjdk-17 stage: checkstyle script: - - mvn checkstyle:check -pl rosetta-lang,rosetta-testing -Dcheckstyle.config.location=checkstyle-SP.xml -Dcheckstyle.includes=com/regnosys/rosetta/interpreternew/**/* + - mvn checkstyle:check -pl rosetta-lang,rosetta-testing -D"checkstyle.config.location"="checkstyle-SP.xml" From 56c3c7f45884a41819a2c302201e26a7c3ddf1e8 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 14 May 2024 21:48:52 +0200 Subject: [PATCH 014/236] Added pattern literal error throwing and int literal support --- rosetta-lang/model/RosettaExpression.xcore | 18 +++++++++++++++ .../interpreternew/RosettaInterpreterNew.java | 13 +---------- .../RosettaInterpreterNewException.java | 3 ++- .../RosettaInterpreterVisitor.java | 23 ++++++++++++++++++- .../values/RosettaInterpreterErrorValue.java | 12 ++++++++++ .../RosettaInterpreterIntegerValue.java | 8 ++++--- ...terpreterRosettaIntLiteralInterpreter.java | 11 +++++++++ .../RosettaInterpreterNewTest.java | 5 ---- 8 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index f873c4aaa..3546cef0c 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -25,6 +25,9 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) op RosettaInterpreterValue interp (RosettaStringLiteral exp) op RosettaInterpreterValue interp (RosettaNumberLiteral exp) + op RosettaInterpreterValue interp (RosettaIntLiteral exp) + op RosettaInterpreterValue interp (RosettaPatternLiteral exp) + op RosettaInterpreterValue interp (ListLiteral exp) } interface RosettaExpression { @@ -77,6 +80,9 @@ class RosettaStringLiteral extends RosettaLiteral { op String stringValue() { return '"' + value + '"' } + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaNumberLiteral extends RosettaLiteral { @@ -88,6 +94,9 @@ class RosettaNumberLiteral extends RosettaLiteral { op String stringValue() { return value.toPlainString } + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaIntLiteral extends RosettaLiteral { @@ -99,6 +108,9 @@ class RosettaIntLiteral extends RosettaLiteral { op String stringValue() { return value.toString } + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } // Not supported - see issue https://github.com/finos/rune-dsl/issues/524 @@ -112,6 +124,9 @@ class RosettaPatternLiteral extends RosettaLiteral { op String stringValue() { return '/' + value.toString() + '/' } + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } /* @@ -120,6 +135,9 @@ class RosettaPatternLiteral extends RosettaLiteral { class ListLiteral extends RosettaExpression { contains RosettaExpression[] elements + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } /* diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index be2973200..f306e58e5 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -12,23 +12,12 @@ public class RosettaInterpreterNew { @Inject private RosettaInterpreterVisitor visitor; - public int Test() { - return 5; - } - /** * Simple example interpret function to allow for better understanding of the development workflow * @param expression * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { - - // OLD EXAMPLE CODE NOT CONFORMING TO THE VISITOR STYLE - if (expression instanceof RosettaIntLiteral) { - RosettaIntLiteral expr = (RosettaIntLiteral)expression; - return new RosettaInterpreterIntegerValue(expr.getValue().intValue()); - } - else return expression.accept(visitor); - + return expression.accept(visitor); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java index ff4ba9e31..df7fb5820 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java @@ -1,7 +1,8 @@ package com.regnosys.rosetta.interpreternew; public class RosettaInterpreterNewException extends RuntimeException{ - + private static final long serialVersionUID = 1L; + public RosettaInterpreterNewException(String message) { super(message); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 908e4e247..5da353481 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,11 +1,15 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; - +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ @@ -26,4 +30,21 @@ public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { return null; } + @Override + public RosettaInterpreterValue interp(RosettaIntLiteral exp) { + // TODO Auto-generated method stub + return new RosettaInterpreterRosettaIntLiteralInterpreter().interp(exp); + } + + @Override + public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { + return new RosettaInterpreterErrorValue("Pattern literals are not supported"); + } + + @Override + public RosettaInterpreterValue interp(ListLiteral exp) { + // TODO Auto-generated method stub + return null; + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java new file mode 100644 index 000000000..97a251eee --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.values; + +public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue{ + private String value; + + public RosettaInterpreterErrorValue(String value) { + super(); + this.value = value; + } + + public String getError() { return value; } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index ec327741c..9acbb79ff 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -1,12 +1,14 @@ package com.regnosys.rosetta.interpreternew.values; +import java.math.BigInteger; + public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue{ - private int value; + private BigInteger value; - public RosettaInterpreterIntegerValue(int value) { + public RosettaInterpreterIntegerValue(BigInteger value) { super(); this.value = value; } - public int getValue() { return value; } + public BigInteger getValue() { return value; } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java new file mode 100644 index 000000000..bfcfc8693 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java @@ -0,0 +1,11 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; + +public class RosettaInterpreterRosettaIntLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ + + public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr) { + return new RosettaInterpreterIntegerValue(expr.getValue()); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 45712cac8..4b93b9b77 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -36,11 +36,6 @@ public void setup() { eFactory = ExpressionFactoryImpl.init(); } - @Test - public void TestTest() { - assertEquals(5, interpreter.Test()); - } - @Test public void ExampleInterpTest() { final int testValue = 10; From bd9da1d7a15149316428ea7d35688dc405b0df58 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 14 May 2024 21:51:07 +0200 Subject: [PATCH 015/236] shorten boolean value file --- .../interpreternew/values/RosettaInterpreterBooleanValue.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index f0342228f..f91064289 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -10,8 +10,4 @@ public RosettaInterpreterBooleanValue(boolean value) { } public boolean getValue() { return value; } - - - - } From ed50d02d3515a59a4aefb2dd61f18044ca0c4075 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Wed, 15 May 2024 10:42:48 +0200 Subject: [PATCH 016/236] add checkstyle rules --- checkstyle-SP.xml | 279 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 checkstyle-SP.xml diff --git a/checkstyle-SP.xml b/checkstyle-SP.xml new file mode 100644 index 000000000..29a362112 --- /dev/null +++ b/checkstyle-SP.xml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 06c0fc0febcae16cee2315545988d40630a9160a Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Wed, 15 May 2024 11:00:59 +0200 Subject: [PATCH 017/236] Check if pipeline fails when test fails --- .../rosetta/interpreternew/RosettaInterpreterNewTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 45712cac8..a8792aae2 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -38,7 +38,7 @@ public void setup() { @Test public void TestTest() { - assertEquals(5, interpreter.Test()); + assertEquals(6, interpreter.Test()); } @Test From 2f2a2655ee1860e73aa26ab369c22b775133191d Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Wed, 15 May 2024 11:11:58 +0200 Subject: [PATCH 018/236] Fix test --- .../rosetta/interpreternew/RosettaInterpreterNewTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index a8792aae2..45712cac8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -38,7 +38,7 @@ public void setup() { @Test public void TestTest() { - assertEquals(6, interpreter.Test()); + assertEquals(5, interpreter.Test()); } @Test From 2c5a4c88ea96070dab9f99bef477494607496edf Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 12:42:53 +0200 Subject: [PATCH 019/236] Added logical operation case in RosettaInterpreterVisitor --- rosetta-lang/model/RosettaExpression.xcore | 1 + .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index f873c4aaa..dc5bd331a 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -25,6 +25,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) op RosettaInterpreterValue interp (RosettaStringLiteral exp) op RosettaInterpreterValue interp (RosettaNumberLiteral exp) + op RosettaInterpreterValue interp (LogicalOperation exp) } interface RosettaExpression { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 908e4e247..06d8e8a52 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; @@ -25,5 +26,10 @@ public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { // TODO Auto-generated method stub return null; } + + @Override + public RosettaInterpreterValue interp(LogicalOperation exp) { + return null; + } } From 7bf87010eedc2d6e6baa636d12185ef5a4ce05f6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:01:22 +0200 Subject: [PATCH 020/236] Changed xcore file for logical operations --- rosetta-lang/model/RosettaExpression.xcore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index dc5bd331a..8be9c0147 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -214,6 +214,9 @@ class ArithmeticOperation extends RosettaBinaryOperation { } class LogicalOperation extends RosettaBinaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } enum CardinalityModifier { From 15681d344572d921faf32b136dcc66017e3fe3bc Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:04:34 +0200 Subject: [PATCH 021/236] Added interp case for logical operations --- .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 06d8e8a52..67aec177b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -5,13 +5,15 @@ import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ @Override - public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { + public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral exp) { return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp); } @@ -26,10 +28,10 @@ public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { // TODO Auto-generated method stub return null; } - + @Override public RosettaInterpreterValue interp(LogicalOperation exp) { - return null; + return new RosettaInterpreterLogicalOperationInterpreter().interp(exp); } } From f8bc58e3b3f2c49285ba8dd771783f0660793a7f Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:06:04 +0200 Subject: [PATCH 022/236] Actually instantiatied the visitor in the Concete Interpreter --- .../visitors/RosettaInterpreterConcreteInterpreter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java index b79cd4369..3a9c56f2c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java @@ -6,5 +6,5 @@ public abstract class RosettaInterpreterConcreteInterpreter { @Inject - protected RosettaInterpreterVisitor visitor; + protected RosettaInterpreterVisitor visitor = new RosettaInterpreterVisitor(); } From 195dce8050e032bc8bf12b886acc6e603756184f Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:06:50 +0200 Subject: [PATCH 023/236] Generated shanenigans --- .../interpreternew/values/RosettaInterpreterBaseValue.java | 1 + 1 file changed, 1 insertion(+) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 8160433ba..05a12c191 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -20,6 +20,7 @@ public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterV public EClass eClass() { // TODO Auto-generated method stub return null; + } @Override From e69d34bbc7741fc82af64776a47ba4722ff0185c Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:08:19 +0200 Subject: [PATCH 024/236] Implemented the actual interpreting of the logical operations, but without errors --- ...nterpreterLogicalOperationInterpreter.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java new file mode 100644 index 000000000..1c4e5a002 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -0,0 +1,37 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; + +public class RosettaInterpreterLogicalOperationInterpreter extends RosettaInterpreterConcreteInterpreter{ + + public RosettaInterpreterBooleanValue interp(LogicalOperation expr) { + boolean leftBoolean = false; + boolean rightBoolean = false; + + + RosettaExpression left = expr.getLeft(); + RosettaExpression right = expr.getRight(); + RosettaInterpreterValue leftInterpreted = left.accept(visitor); + RosettaInterpreterValue rightInterpreted = right.accept(visitor); + if(leftInterpreted instanceof RosettaInterpreterBooleanValue + && rightInterpreted instanceof RosettaInterpreterBooleanValue) { + leftBoolean = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); + rightBoolean = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); + } else { + // Idk?? error + } + + if(expr.getOperator().equals("and")) { + return new RosettaInterpreterBooleanValue(leftBoolean && rightBoolean); + } else if(expr.getOperator().equals("or")) { + return new RosettaInterpreterBooleanValue(leftBoolean || rightBoolean); + } else { + // Idk?? error + return null; + } + } +} From a2f6645551057233c38ac88f251a13fa4fe9ff26 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:09:12 +0200 Subject: [PATCH 025/236] Added test for 'AND' operation --- .../RosettaInterpreterNewTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 45712cac8..c93842c08 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -10,6 +10,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; @@ -64,4 +65,21 @@ public void VisitorInitialTest() { RosettaInterpreterBooleanValue boolVal = (RosettaInterpreterBooleanValue)val; assertEquals(testValue, boolVal.getValue()); } + + @Test + public void logicalAndInterpTest() { + boolean expected = false; + RosettaBooleanLiteral trueLiteral = eFactory.createRosettaBooleanLiteral(); + trueLiteral.setValue(true); + RosettaBooleanLiteral falseLiteral = eFactory.createRosettaBooleanLiteral(); + falseLiteral.setValue(false); + + LogicalOperation expr = eFactory.createLogicalOperation(); + expr.setOperator("and"); + expr.setLeft(trueLiteral); + expr.setRight(falseLiteral); + + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + } } From e249fc515740aa2920db17fc2d45898de2c29973 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 May 2024 16:17:24 +0200 Subject: [PATCH 026/236] Added tests for all simple cases --- .../RosettaInterpreterNewTest.java | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index c93842c08..774935fd2 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -67,7 +67,7 @@ public void VisitorInitialTest() { } @Test - public void logicalAndInterpTest() { + public void logicalAndInterpTestFalse() { boolean expected = false; RosettaBooleanLiteral trueLiteral = eFactory.createRosettaBooleanLiteral(); trueLiteral.setValue(true); @@ -79,7 +79,66 @@ public void logicalAndInterpTest() { expr.setLeft(trueLiteral); expr.setRight(falseLiteral); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; + assertEquals(expected, boolResult.getValue()); + } + + @Test + public void logicalAndInterpTestTrue() { + boolean expected = true; + RosettaBooleanLiteral trueLiteral1 = eFactory.createRosettaBooleanLiteral(); + trueLiteral1.setValue(true); + RosettaBooleanLiteral trueLiteral2 = eFactory.createRosettaBooleanLiteral(); + trueLiteral2.setValue(true); + + LogicalOperation expr = eFactory.createLogicalOperation(); + expr.setOperator("and"); + expr.setLeft(trueLiteral1); + expr.setRight(trueLiteral2); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; + assertEquals(expected, boolResult.getValue()); + } + + @Test + public void logicalOrInterpTestTrue() { + boolean expected = true; + RosettaBooleanLiteral trueLiteral = eFactory.createRosettaBooleanLiteral(); + trueLiteral.setValue(true); + RosettaBooleanLiteral falseLiteral = eFactory.createRosettaBooleanLiteral(); + falseLiteral.setValue(false); + + LogicalOperation expr = eFactory.createLogicalOperation(); + expr.setOperator("or"); + expr.setLeft(trueLiteral); + expr.setRight(falseLiteral); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; + assertEquals(expected, boolResult.getValue()); + } + + @Test + public void logicalOrInterpTestFalse() { + boolean expected = false; + RosettaBooleanLiteral falseLiteral1 = eFactory.createRosettaBooleanLiteral(); + falseLiteral1.setValue(false); + RosettaBooleanLiteral falseLiteral2 = eFactory.createRosettaBooleanLiteral(); + falseLiteral2.setValue(false); + + LogicalOperation expr = eFactory.createLogicalOperation(); + expr.setOperator("or"); + expr.setLeft(falseLiteral1); + expr.setRight(falseLiteral2); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; + assertEquals(expected, boolResult.getValue()); } } From e7faf84448b948a094ba27bd77f157e73fe2195f Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 15 May 2024 17:54:41 +0200 Subject: [PATCH 027/236] Added support for all literals (nonfunctional list) --- .../RosettaInterpreterVisitor.java | 13 ++- .../values/RosettaInterpreterListValue.java | 16 ++++ .../values/RosettaInterpreterNumberValue.java | 14 ++++ .../values/RosettaInterpreterStringValue.java | 12 +++ ...ettaInterpreterListLiteralInterpreter.java | 33 ++++++++ ...preterRosettaNumberLiteralInterpreter.java | 12 +++ ...preterRosettaStringLiteralInterpreter.java | 12 +++ .../RosettaInterpreterLiteralsTest.java | 84 +++++++++++++++++++ 8 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5da353481..a33b3784b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -8,8 +8,11 @@ import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ @@ -20,19 +23,16 @@ public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { @Override public RosettaInterpreterValue interp(RosettaStringLiteral exp) { - // TODO Auto-generated method stub - return null; + return new RosettaInterpreterRosettaStringLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { - // TODO Auto-generated method stub - return null; + return new RosettaInterpreterRosettaNumberLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaIntLiteral exp) { - // TODO Auto-generated method stub return new RosettaInterpreterRosettaIntLiteralInterpreter().interp(exp); } @@ -43,8 +43,7 @@ public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { @Override public RosettaInterpreterValue interp(ListLiteral exp) { - // TODO Auto-generated method stub - return null; + return new RosettaInterpreterListLiteralInterpreter().interp(exp); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java new file mode 100644 index 000000000..6bcf9b857 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -0,0 +1,16 @@ +package com.regnosys.rosetta.interpreternew.values; +import java.util.List; + +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; + +public class RosettaInterpreterListValue extends RosettaInterpreterBaseValue { + private List expressions; + + public RosettaInterpreterListValue(List expressions) { + super(); + this.expressions = expressions; + } + + public List getExpressions() { return expressions; } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java new file mode 100644 index 000000000..02bead455 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -0,0 +1,14 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.math.BigDecimal; + +public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue { + private BigDecimal value; + + public RosettaInterpreterNumberValue(BigDecimal value) { + super(); + this.value = value; + } + + public BigDecimal getValue() { return value; } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java new file mode 100644 index 000000000..0e5060f1c --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.values; + +public class RosettaInterpreterStringValue extends RosettaInterpreterBaseValue{ + private String value; + + public RosettaInterpreterStringValue(String value) { + super(); + this.value = value; + } + + public String getValue() { return value; } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java new file mode 100644 index 000000000..6a9b5d75e --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -0,0 +1,33 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import javax.inject.Inject; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.rosetta.expression.ListLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; + +public class RosettaInterpreterListLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { + @Inject + protected RosettaInterpreterVisitor visitor2; + public RosettaInterpreterListLiteralInterpreter() { + super(); + } + + public RosettaInterpreterListValue interp(ListLiteral exp) { + List expressions = exp.getElements(); + List interpretedExpressions = new ArrayList<>(); + + for(RosettaExpression e : expressions) { + interpretedExpressions.add(e.accept(visitor2)); + } + + return new RosettaInterpreterListValue(interpretedExpressions); + } + +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java new file mode 100644 index 000000000..5e732140a --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; + +public class RosettaInterpreterRosettaNumberLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterNumberValue interp(RosettaNumberLiteral exp) { + return new RosettaInterpreterNumberValue(exp.getValue()); + } + +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java new file mode 100644 index 000000000..823b9d0a2 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; + +public class RosettaInterpreterRosettaStringLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ + + public RosettaInterpreterStringValue interp(RosettaStringLiteral exp) { + return new RosettaInterpreterStringValue(exp.getValue()); + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java new file mode 100644 index 000000000..c15ea5d72 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -0,0 +1,84 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.*; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.ListLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterLiteralsTest { + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void BooleanTest() { + RosettaExpression expr = parser.parseExpression("True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(true, ((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void ListTest() { + RosettaExpression expr = parser.parseExpression("[1,2]"); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue expected = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)))); + assertEquals(expected, val); + + } + + @Test + public void IntTest() { + RosettaExpression expr = parser.parseExpression("5"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(BigInteger.valueOf(5), ((RosettaInterpreterIntegerValue)val).getValue()); + } + + @Test + public void NumberTest() { + RosettaExpression expr = parser.parseExpression("5.5"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(BigDecimal.valueOf(5.5), ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void StringTest() { + RosettaExpression expr = parser.parseExpression("\"hello\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("hello", ((RosettaInterpreterStringValue)val).getValue()); + } +} From 3aa2ef9ec16f6cca3699154622c175dad34048a6 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 15 May 2024 17:55:05 +0200 Subject: [PATCH 028/236] revert attempted fix --- .../visitors/RosettaInterpreterListLiteralInterpreter.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index 6a9b5d75e..723c1ba84 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.stream.Stream; -import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; @@ -13,8 +12,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; public class RosettaInterpreterListLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - @Inject - protected RosettaInterpreterVisitor visitor2; + public RosettaInterpreterListLiteralInterpreter() { super(); } @@ -24,7 +22,7 @@ public RosettaInterpreterListValue interp(ListLiteral exp) { List interpretedExpressions = new ArrayList<>(); for(RosettaExpression e : expressions) { - interpretedExpressions.add(e.accept(visitor2)); + interpretedExpressions.add(e.accept(visitor)); } return new RosettaInterpreterListValue(interpretedExpressions); From 0d61efe0909c059a86f329e1bc18a2c6efa2957f Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 15 May 2024 18:06:05 +0200 Subject: [PATCH 029/236] Added equals and hashcode for implemented values --- .../RosettaInterpreterBooleanValue.java | 20 +++++++++++++++++++ .../values/RosettaInterpreterErrorValue.java | 19 ++++++++++++++++++ .../RosettaInterpreterIntegerValue.java | 18 +++++++++++++++++ .../values/RosettaInterpreterListValue.java | 18 +++++++++++++++++ .../values/RosettaInterpreterNumberValue.java | 19 ++++++++++++++++++ .../values/RosettaInterpreterStringValue.java | 20 +++++++++++++++++++ ...RosettaInterpreterConcreteInterpreter.java | 4 +++- .../RosettaInterpreterLiteralsTest.java | 6 +++--- 8 files changed, 120 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index f91064289..db25e9ecb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue{ private boolean value; @@ -10,4 +11,23 @@ public RosettaInterpreterBooleanValue(boolean value) { } public boolean getValue() { return value; } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterBooleanValue other = (RosettaInterpreterBooleanValue) obj; + return value == other.value; + } + + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 97a251eee..5765c29f9 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -1,6 +1,25 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; + public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue{ + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterErrorValue other = (RosettaInterpreterErrorValue) obj; + return Objects.equals(value, other.value); + } + private String value; public RosettaInterpreterErrorValue(String value) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index 9acbb79ff..ff2dc436d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -1,8 +1,26 @@ package com.regnosys.rosetta.interpreternew.values; import java.math.BigInteger; +import java.util.Objects; public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue{ + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; + return Objects.equals(value, other.value); + } + private BigInteger value; public RosettaInterpreterIntegerValue(BigInteger value) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 6bcf9b857..bbd5a4f96 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; import java.util.List; +import java.util.Objects; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; @@ -12,5 +13,22 @@ public RosettaInterpreterListValue(List expressions) { this.expressions = expressions; } + @Override + public int hashCode() { + return Objects.hash(expressions); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterListValue other = (RosettaInterpreterListValue) obj; + return Objects.equals(expressions, other.expressions); + } + public List getExpressions() { return expressions; } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 02bead455..3b599ce8d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -1,6 +1,7 @@ package com.regnosys.rosetta.interpreternew.values; import java.math.BigDecimal; +import java.util.Objects; public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue { private BigDecimal value; @@ -11,4 +12,22 @@ public RosettaInterpreterNumberValue(BigDecimal value) { } public BigDecimal getValue() { return value; } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterNumberValue other = (RosettaInterpreterNumberValue) obj; + return Objects.equals(value, other.value); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index 0e5060f1c..1c1a4c285 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -1,5 +1,7 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; + public class RosettaInterpreterStringValue extends RosettaInterpreterBaseValue{ private String value; @@ -9,4 +11,22 @@ public RosettaInterpreterStringValue(String value) { } public String getValue() { return value; } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterStringValue other = (RosettaInterpreterStringValue) obj; + return Objects.equals(value, other.value); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java index b79cd4369..4a9c18d92 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java @@ -3,8 +3,10 @@ import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; +import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitorBase; + public abstract class RosettaInterpreterConcreteInterpreter { @Inject - protected RosettaInterpreterVisitor visitor; + protected RosettaInterpreterVisitor visitor = new RosettaInterpreterVisitor(); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index c15ea5d72..0dc284fb8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -55,9 +55,9 @@ public void ListTest() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)))); - assertEquals(expected, val); + new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)))); + assertTrue(expected.equals(val)); } From 374848ec6f73527208c75871847387cf9017eac1 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 15 May 2024 19:23:29 +0200 Subject: [PATCH 030/236] Remove example tests --- .../RosettaInterpreterNewTest.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 4b93b9b77..c5541aa4c 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -35,28 +35,5 @@ public class RosettaInterpreterNewTest { public void setup() { eFactory = ExpressionFactoryImpl.init(); } - - @Test - public void ExampleInterpTest() { - final int testValue = 10; - - RosettaIntLiteral expr = eFactory.createRosettaIntLiteral(); - expr.setValue(BigInteger.valueOf(testValue)); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue intVal = (RosettaInterpreterIntegerValue)val; - assertEquals(testValue, intVal.getValue()); - } - - @Test - public void VisitorInitialTest() { - final boolean testValue = false; - - RosettaBooleanLiteral expr = eFactory.createRosettaBooleanLiteral(); - expr.setValue(testValue); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue boolVal = (RosettaInterpreterBooleanValue)val; - assertEquals(testValue, boolVal.getValue()); - } + } From 91fb9b94a6c4179c1599bb558a8865436468d0f9 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 16 May 2024 09:19:43 +0200 Subject: [PATCH 031/236] Added rosettaInterpreter xcore file --- .gitignore | 4 ++++ rosetta-lang/.project | 11 ++++++++++ rosetta-lang/model/RosettaExpression.xcore | 11 ++-------- rosetta-lang/model/RosettaInterpreter.xcore | 21 +++++++++++++++++++ .../interpreternew/RosettaInterpreterNew.java | 2 +- .../RosettaInterpreterVisitor.java | 2 +- .../RosettaInterpreterVisitorBase.java | 2 +- .../values/RosettaInterpreterBaseValue.java | 2 +- .../RosettaInterpreterNewTest.java | 4 +--- 9 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 rosetta-lang/model/RosettaInterpreter.xcore diff --git a/.gitignore b/.gitignore index 31ef6ee72..816b156a5 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ com.regnosys.rosetta.web/ # CVE scan reports reports/ +rosetta-lang/META-INF/ +rosetta-lang/build.properties +rosetta-lang/plugin.properties +rosetta-lang/plugin.xml \ No newline at end of file diff --git a/rosetta-lang/.project b/rosetta-lang/.project index 56b2f7a46..f46323c08 100644 --- a/rosetta-lang/.project +++ b/rosetta-lang/.project @@ -25,12 +25,23 @@ + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + org.eclipse.jdt.core.javanature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.m2e.core.maven2Nature net.sf.eclipsecs.core.CheckstyleNature + org.eclipse.pde.PluginNature diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index f873c4aaa..6085494db 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -16,16 +16,9 @@ import com.regnosys.rosetta.rosetta.RosettaMapTestExpression import com.regnosys.rosetta.rosetta.RosettaTyped import com.regnosys.rosetta.rosetta.simple.Attribute import org.eclipse.emf.common.util.BasicEList +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor -abstract class RosettaInterpreterValue { - -} - -interface InterpreterVisitor { - op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) - op RosettaInterpreterValue interp (RosettaStringLiteral exp) - op RosettaInterpreterValue interp (RosettaNumberLiteral exp) -} interface RosettaExpression { // Whether the expression was generated diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore new file mode 100644 index 000000000..b250fe986 --- /dev/null +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -0,0 +1,21 @@ +@Ecore(nsURI="http://www.rosetta-model.com/RosettaInterpreter") +@GenModel(fileExtensions="rosetta", modelDirectory="/com.regnosys.rosetta/emf-gen/main/java", operationReflection="false", + copyrightText="Copyright (c) REGnosys 2017 (www.regnosys.com)", forceOverwrite="true", updateClasspath="false", + complianceLevel="8.0", bundleManifest="false", modelPluginID="") + +package com.regnosys.rosetta.rosetta.interpreter + +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral +import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral +import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral + + +abstract class RosettaInterpreterValue { + +} + +interface InterpreterVisitor { + op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) + op RosettaInterpreterValue interp (RosettaStringLiteral exp) + op RosettaInterpreterValue interp (RosettaNumberLiteral exp) +} \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index be2973200..fdaf2787d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -5,7 +5,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterNew { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 908e4e247..c55b09cca 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,7 +1,7 @@ package com.regnosys.rosetta.interpreternew; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java index 9638a334f..429f3b193 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java @@ -13,7 +13,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; -import com.regnosys.rosetta.rosetta.expression.InterpreterVisitor; +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor; public abstract class RosettaInterpreterVisitorBase implements InterpreterVisitor { @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 8160433ba..24207c0ad 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -13,7 +13,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; -import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ @Override diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 45712cac8..38d22f2d7 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -11,11 +11,9 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaIntLiteralImpl; import static org.junit.jupiter.api.Assertions.*; import javax.inject.Inject; From 17fcb384a23fe1c3f47e0b4233ead33866e272e0 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 16 May 2024 10:40:01 +0200 Subject: [PATCH 032/236] Added error list to baseInterpreterValue --- rosetta-lang/model/RosettaInterpreter.xcore | 7 + .../RosettaInterpreterVisitor.java | 6 +- .../values/RosettaInterpreterBaseValue.java | 38 +++- .../RosettaInterpreterBooleanValue.java | 7 + .../values/RosettaInterpreterError.java | 171 ++++++++++++++++++ .../values/RosettaInterpreterErrorValue.java | 31 ---- .../RosettaInterpreterErrorTest.java | 51 ++++++ 7 files changed, 277 insertions(+), 34 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index e0661e936..141406ec3 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -12,9 +12,16 @@ import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral import com.regnosys.rosetta.rosetta.expression.ListLiteral +class RosettaInterpreterBaseError{ + String message +} abstract class RosettaInterpreterValue { + refers RosettaInterpreterBaseError[] errors + op boolean addError(RosettaInterpreterBaseError error) + op boolean addAllErrors(RosettaInterpreterValue other) + op boolean addAllErrors(RosettaInterpreterBaseError[] errors) } interface InterpreterVisitor { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5a2ebe8a1..6d78dd6b6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -7,7 +7,8 @@ import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; @@ -38,7 +39,8 @@ public RosettaInterpreterValue interp(RosettaIntLiteral exp) { @Override public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { - return new RosettaInterpreterErrorValue("Pattern literals are not supported"); + return new RosettaInterpreterBaseValue( + new RosettaInterpreterError("Pattern literals are not supported")); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 24207c0ad..c7cd53a8e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -1,9 +1,12 @@ package com.regnosys.rosetta.interpreternew.values; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EClass; @@ -13,9 +16,42 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ +public class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ + List errors; + + @Override + public EList getErrors(){ + return new BasicEList(errors); + } + + @Override + public boolean addError(RosettaInterpreterBaseError error) { + return errors.add(error); + } + + @Override + public boolean addAllErrors(RosettaInterpreterValue other) { + return errors.addAll(other.getErrors()); + } + + @Override + public boolean addAllErrors(EList errors) { + return errors.addAll(errors); + } + + + public RosettaInterpreterBaseValue() { + this.errors = new ArrayList<>(); + } + + public RosettaInterpreterBaseValue(RosettaInterpreterError error) { + this.errors = new ArrayList<>(); + errors.add(error); + } + @Override public EClass eClass() { // TODO Auto-generated method stub diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index db25e9ecb..d01bd5495 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -2,6 +2,11 @@ import java.util.Objects; +import org.eclipse.emf.common.util.EList; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue{ private boolean value; @@ -28,6 +33,8 @@ public boolean equals(Object obj) { RosettaInterpreterBooleanValue other = (RosettaInterpreterBooleanValue) obj; return value == other.value; } + + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java new file mode 100644 index 000000000..8e5335fd0 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -0,0 +1,171 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.lang.reflect.InvocationTargetException; +import java.util.Objects; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; + +public class RosettaInterpreterError implements RosettaInterpreterBaseError{ + @Override + public int hashCode() { + return Objects.hash(errorMessage); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterError other = (RosettaInterpreterError) obj; + return Objects.equals(errorMessage, other.errorMessage); + } + + private String errorMessage; + + public RosettaInterpreterError(String value) { + super(); + this.errorMessage = errorMessage; + } + + public String getError() { return errorMessage; } + + @Override + public EClass eClass() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource eResource() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EObject eContainer() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EStructuralFeature eContainingFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EReference eContainmentFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TreeIterator eAllContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eIsProxy() { + // TODO Auto-generated method stub + return false; + } + + @Override + public EList eCrossReferences() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature, boolean resolve) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void eSet(EStructuralFeature feature, Object newValue) { + // TODO Auto-generated method stub + + } + + @Override + public boolean eIsSet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eUnset(EStructuralFeature feature) { + // TODO Auto-generated method stub + + } + + @Override + public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eAdapters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eDeliver() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eSetDeliver(boolean deliver) { + // TODO Auto-generated method stub + + } + + @Override + public void eNotify(Notification notification) { + // TODO Auto-generated method stub + + } + + @Override + public String getMessage() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMessage(String value) { + // TODO Auto-generated method stub + + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java deleted file mode 100644 index 5765c29f9..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.regnosys.rosetta.interpreternew.values; - -import java.util.Objects; - -public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue{ - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RosettaInterpreterErrorValue other = (RosettaInterpreterErrorValue) obj; - return Objects.equals(value, other.value); - } - - private String value; - - public RosettaInterpreterErrorValue(String value) { - super(); - this.value = value; - } - - public String getError() { return value; } -} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java new file mode 100644 index 000000000..876b2246f --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java @@ -0,0 +1,51 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.*; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.ListLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterErrorTest { + + @Test + public void SimpleErrorTest() { + RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); + RosettaInterpreterError e2 = new RosettaInterpreterError("e2"); + List el = List.of(e1, e2); + + RosettaInterpreterStringValue val1 = new RosettaInterpreterStringValue("a"); + RosettaInterpreterStringValue val2 = new RosettaInterpreterStringValue("b"); + + val1.addError(e1); + val2.addError(e2); + + val1.addAllErrors(val2); + + assertEquals(el, val1.getErrors()); + } +} From 5c5e02670d323ad04e13efe4eb009d358bcef3bd Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 16 May 2024 14:20:56 +0200 Subject: [PATCH 033/236] Added support for list flattening --- .../values/RosettaInterpreterListValue.java | 5 +++ ...ettaInterpreterListLiteralInterpreter.java | 8 +++- .../RosettaInterpreterLiteralsTest.java | 37 ++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 062d96be4..1783fd0b5 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -18,6 +18,11 @@ public int hashCode() { return Objects.hash(expressions); } + @Override + public String toString() { + return "RosettaInterpreterListValue [expressions=" + expressions + "]"; + } + @Override public boolean equals(Object obj) { if (this == obj) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index f9641e334..c3ad64886 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -22,9 +22,15 @@ public RosettaInterpreterListValue interp(ListLiteral exp) { List interpretedExpressions = new ArrayList<>(); for(RosettaExpression e : expressions) { - interpretedExpressions.add(e.accept(visitor)); + RosettaInterpreterValue val = e.accept(visitor); + + if (val instanceof RosettaInterpreterListValue) { + interpretedExpressions.addAll(((RosettaInterpreterListValue)val).getExpressions()); + } + else interpretedExpressions.add(e.accept(visitor)); } + return new RosettaInterpreterListValue(interpretedExpressions); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index d00f20e8c..835676f54 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -20,12 +20,12 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; -import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ExpressionValidationHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -34,6 +34,8 @@ public class RosettaInterpreterLiteralsTest { private ExpressionParser parser; @Inject RosettaInterpreterNew interpreter; + @Inject + private ExpressionValidationHelper validation; private ExpressionFactory eFactory; @@ -52,12 +54,43 @@ public void BooleanTest() { @Test public void ListTest() { RosettaExpression expr = parser.parseExpression("[1,2]"); + validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)))); - assertTrue(expected.equals(val)); + assertEquals(expected, val); + + } + + @Test + public void NestedListTest() { + RosettaExpression expr = parser.parseExpression("[1,[2,3]]"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue expected = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)))); + assertEquals(expected, val); + + } + + @Test + public void VeryNestedListTest() { + RosettaExpression expr = parser.parseExpression("[1,[2,[3, [4, [5]]]]]"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue expected = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(4)), + new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)))); + assertEquals(expected, val); } From 520901deb305da7c505318573060b432e753d3d6 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 16 May 2024 14:31:02 +0200 Subject: [PATCH 034/236] Changed error handling to be value based --- rosetta-lang/model/RosettaInterpreter.xcore | 5 --- .../RosettaInterpreterVisitor.java | 3 +- .../values/RosettaInterpreterBaseValue.java | 34 +------------- .../values/RosettaInterpreterErrorValue.java | 44 +++++++++++++++++++ .../RosettaInterpreterErrorTest.java | 5 ++- 5 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 141406ec3..8574ac5c0 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -17,11 +17,6 @@ class RosettaInterpreterBaseError{ } abstract class RosettaInterpreterValue { - refers RosettaInterpreterBaseError[] errors - - op boolean addError(RosettaInterpreterBaseError error) - op boolean addAllErrors(RosettaInterpreterValue other) - op boolean addAllErrors(RosettaInterpreterBaseError[] errors) } interface InterpreterVisitor { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 6d78dd6b6..efe62ad3d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -8,6 +8,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; @@ -39,7 +40,7 @@ public RosettaInterpreterValue interp(RosettaIntLiteral exp) { @Override public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { - return new RosettaInterpreterBaseValue( + return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Pattern literals are not supported")); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index c7cd53a8e..95416070b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -19,39 +19,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ - List errors; - - @Override - public EList getErrors(){ - return new BasicEList(errors); - } - - @Override - public boolean addError(RosettaInterpreterBaseError error) { - return errors.add(error); - } - - @Override - public boolean addAllErrors(RosettaInterpreterValue other) { - return errors.addAll(other.getErrors()); - } - - @Override - public boolean addAllErrors(EList errors) { - return errors.addAll(errors); - } - - - public RosettaInterpreterBaseValue() { - this.errors = new ArrayList<>(); - } - - public RosettaInterpreterBaseValue(RosettaInterpreterError error) { - this.errors = new ArrayList<>(); - errors.add(error); - } - +public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ @Override public EClass eClass() { // TODO Auto-generated method stub diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java new file mode 100644 index 000000000..2eb5a1854 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -0,0 +1,44 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue{ + List errors; + + public RosettaInterpreterErrorValue() { + this.errors = new ArrayList<>(); + } + + public RosettaInterpreterErrorValue(RosettaInterpreterBaseError error) { + this.errors = new ArrayList<>(); + errors.add(error); + } + + public RosettaInterpreterErrorValue(List errors) { + this.errors = new ArrayList<>(); + errors.addAll(errors); + } + + public EList getErrors(){ + return new BasicEList(errors); + } + + public boolean addError(RosettaInterpreterBaseError error) { + return errors.add(error); + } + + public boolean addAllErrors(RosettaInterpreterErrorValue other) { + return errors.addAll(other.getErrors()); + } + + public boolean addAllErrors(EList errors) { + return errors.addAll(errors); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java index 876b2246f..87fdde138 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; @@ -38,8 +39,8 @@ public void SimpleErrorTest() { RosettaInterpreterError e2 = new RosettaInterpreterError("e2"); List el = List.of(e1, e2); - RosettaInterpreterStringValue val1 = new RosettaInterpreterStringValue("a"); - RosettaInterpreterStringValue val2 = new RosettaInterpreterStringValue("b"); + RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(); + RosettaInterpreterErrorValue val2 = new RosettaInterpreterErrorValue(); val1.addError(e1); val2.addError(e2); From 8691ee883ce31bc14be7d187c3f09c121481e825 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 16 May 2024 18:09:15 +0200 Subject: [PATCH 035/236] Generated needed methods to support equality/comparison --- rosetta-lang/model/RosettaExpression.xcore | 6 ++++++ rosetta-lang/model/RosettaInterpreter.xcore | 4 ++++ .../interpreternew/RosettaInterpreterVisitor.java | 14 ++++++++++++++ .../values/RosettaInterpreterBaseValue.java | 8 +++++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index b038b3b24..0472bd12a 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -234,9 +234,15 @@ interface ModifiableBinaryOperation extends RosettaBinaryOperation { } class EqualityOperation extends ModifiableBinaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class ComparisonOperation extends ModifiableBinaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaContainsExpression extends RosettaBinaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 141406ec3..c9db111e2 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -11,6 +11,8 @@ import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral import com.regnosys.rosetta.rosetta.expression.ListLiteral +import com.regnosys.rosetta.rosetta.expression.EqualityOperation +import com.regnosys.rosetta.rosetta.expression.ComparisonOperation class RosettaInterpreterBaseError{ String message @@ -31,4 +33,6 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaIntLiteral exp) op RosettaInterpreterValue interp (RosettaPatternLiteral exp) op RosettaInterpreterValue interp (ListLiteral exp) + op RosettaInterpreterValue interp (EqualityOperation exp) + op RosettaInterpreterValue interp (ComparisonOperation exp) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 6d78dd6b6..820dee4e5 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,5 +1,7 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; +import com.regnosys.rosetta.rosetta.expression.EqualityOperation; import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; @@ -9,6 +11,8 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEqualityOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; @@ -48,4 +52,14 @@ public RosettaInterpreterValue interp(ListLiteral exp) { return new RosettaInterpreterListLiteralInterpreter().interp(exp); } + @Override + public RosettaInterpreterValue interp(EqualityOperation exp) { + return new RosettaInterpreterEqualityOperationInterpreter().interp(exp); + } + + @Override + public RosettaInterpreterValue interp(ComparisonOperation exp) { + return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index c7cd53a8e..8c0de5c70 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -19,11 +19,12 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ +public class RosettaInterpreterBaseValue implements RosettaInterpreterValue { List errors; + //private List items; @Override - public EList getErrors(){ + public EList getErrors() { return new BasicEList(errors); } @@ -137,7 +138,8 @@ public void eUnset(EStructuralFeature feature) { } @Override - public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + public Object eInvoke(EOperation operation, EList arguments) + throws InvocationTargetException { // TODO Auto-generated method stub return null; } From 79b03588d8606676c51fc3b19c76d42328a82d2e Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 16 May 2024 20:30:19 +0200 Subject: [PATCH 036/236] Making value classes comparable --- .../values/RosettaInterpreterBooleanValue.java | 8 +++++++- .../values/RosettaInterpreterIntegerValue.java | 8 +++++++- .../values/RosettaInterpreterNumberValue.java | 8 +++++++- .../values/RosettaInterpreterStringValue.java | 17 ++++++++++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index d01bd5495..60f63e60d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -7,7 +7,8 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue{ +public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue + implements Comparable{ private boolean value; public RosettaInterpreterBooleanValue(boolean value) { @@ -34,6 +35,11 @@ public boolean equals(Object obj) { return value == other.value; } + @Override + public int compareTo(RosettaInterpreterBooleanValue o) { + return Boolean.compare(this.value, o.value); + } + diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index ff2dc436d..b7b37058e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -3,7 +3,8 @@ import java.math.BigInteger; import java.util.Objects; -public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue{ +public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue + implements Comparable { @Override public int hashCode() { return Objects.hash(value); @@ -29,4 +30,9 @@ public RosettaInterpreterIntegerValue(BigInteger value) { } public BigInteger getValue() { return value; } + + @Override + public int compareTo(RosettaInterpreterIntegerValue o) { + return this.value.compareTo(o.value); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 3b599ce8d..45c9ddbf2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -3,7 +3,8 @@ import java.math.BigDecimal; import java.util.Objects; -public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue { +public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue + implements Comparable{ private BigDecimal value; public RosettaInterpreterNumberValue(BigDecimal value) { @@ -29,5 +30,10 @@ public boolean equals(Object obj) { RosettaInterpreterNumberValue other = (RosettaInterpreterNumberValue) obj; return Objects.equals(value, other.value); } + + @Override + public int compareTo(RosettaInterpreterNumberValue o) { + return this.value.compareTo(o.value); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index 1c1a4c285..5c90e037f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -2,7 +2,8 @@ import java.util.Objects; -public class RosettaInterpreterStringValue extends RosettaInterpreterBaseValue{ +public class RosettaInterpreterStringValue extends RosettaInterpreterBaseValue + implements Comparable { private String value; public RosettaInterpreterStringValue(String value) { @@ -28,5 +29,19 @@ public boolean equals(Object obj) { RosettaInterpreterStringValue other = (RosettaInterpreterStringValue) obj; return Objects.equals(value, other.value); } + + @Override + public int compareTo(RosettaInterpreterStringValue o) { + int compareValue = this.value.compareTo(o.value); + if (compareValue < 0) { + return -1; + } + else if (compareValue > 0) { + return 1; + } + else { + return 0; + } + } } From 213017fad5bfa7c6a349fe9f221e4881aa979469 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 16 May 2024 20:34:00 +0200 Subject: [PATCH 037/236] Implementation + Testing equality --- ...terpreterEqualityOperationInterpreter.java | 194 ++++++++++++++++++ .../RosettaInterpreterEqualityTest.java | 93 +++++++++ 2 files changed, 287 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java new file mode 100644 index 000000000..540700cd8 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java @@ -0,0 +1,194 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.rosetta.expression.EqualityOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterEqualityOperationInterpreter extends + RosettaInterpreterConcreteInterpreter { + + /** + * Interprets an equality operation by evaluating both sides of the expression and + * determining if they are equal. + * + * @param expr equality operation expression to interpret + * @return A RosettaInterpreterBooleanValue representing the result of the equality + * comparison. + * It will be true if both evaluated expressions are equal, otherwise false. + */ + public RosettaInterpreterBooleanValue interp(EqualityOperation expr) { + RosettaExpression left = expr.getLeft(); + RosettaExpression right = expr.getRight(); + + RosettaInterpreterValue leftValue = left.accept(visitor); + RosettaInterpreterValue rightValue = right.accept(visitor); + + boolean comparisonResult = leftValue.equals(rightValue); + + switch (expr.getCardMod()) { + case NONE: + //normally compare left and right side. + boolean result = compareComparableValues(comparisonResult, + expr.getOperator()); + return new RosettaInterpreterBooleanValue(result); + + case ANY: + boolean resultAny = compareAny(leftValue, rightValue, expr.getOperator()); + return new RosettaInterpreterBooleanValue(resultAny); + + case ALL: + boolean resultAll = compareAll(leftValue, rightValue, expr.getOperator()); + return new RosettaInterpreterBooleanValue(resultAll); + + default: + return new RosettaInterpreterBooleanValue(false); + //TODO: throw exception, not a supported case + + } + +// boolean comparisonResult = leftValue.equals(rightValue); +// +// boolean result = compareComparableValues(comparisonResult, +// expr.getOperator()); +// return new RosettaInterpreterBooleanValue(result); + + } + + private boolean compareAny(RosettaInterpreterValue leftValue, + RosettaInterpreterValue rightValue, + String operator) { + //list vs list case: + if (leftValue instanceof RosettaInterpreterListValue + && rightValue instanceof RosettaInterpreterListValue) { + + //only way this is allowed is if rightValue has a length of 1 + // and left has length more than 1 + RosettaInterpreterListValue rgtList = + (RosettaInterpreterListValue) rightValue; + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + if (rgtList.getExpressions().size() == 1 + && lfList.getExpressions().size() > 1) { + + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean anyTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + boolean comparisonResult = + e.equals(rgtList.getExpressions().get(0)); + anyTrue |= compareComparableValues(comparisonResult, + operator); + } + return anyTrue; + } + else { + return false; + //TODO: throw exception, cannot compare two lists. + } + } + + //list vs element case: + else if (leftValue instanceof RosettaInterpreterListValue) { + + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + + //only way this is allowed is if left side has a length of + // more than 1 + if (lfList.getExpressions().size() > 1) { + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean anyTrue = false; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + boolean comparisonResult = e.equals(rightValue); + anyTrue |= compareComparableValues(comparisonResult, + operator); + } + return anyTrue; + } + } + else { + //TODO: throw exception, cannot compare 2 elements + return false; + } + return false; + } + + private boolean compareAll(RosettaInterpreterValue leftValue, + RosettaInterpreterValue rightValue, + String operator) { + //list vs list case: + if (leftValue instanceof RosettaInterpreterListValue + && rightValue instanceof RosettaInterpreterListValue) { + + //only way this is allowed is if rightValue has a length of 1 + // and left has length more than 1 + RosettaInterpreterListValue rgtList = + (RosettaInterpreterListValue) rightValue; + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + if (rgtList.getExpressions().size() == 1 + && lfList.getExpressions().size() > 1) { + + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean allTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + boolean comparisonResult = + e.equals(rgtList.getExpressions().get(0)); + allTrue &= compareComparableValues(comparisonResult, + operator); + } + return allTrue; + } + else { + return false; + //TODO: throw exception, cannot compare two lists. + } + } + + //list vs element case: + else if (leftValue instanceof RosettaInterpreterListValue) { + + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + + //only way this is allowed is if left side has a length of + // more than 1 + if (lfList.getExpressions().size() > 1) { + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean allTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + boolean comparisonResult = e.equals(rightValue); + allTrue &= compareComparableValues(comparisonResult, + operator); + } + return allTrue; + } + } + else { + //TODO: throw exception, cannot compare 2 elements + return false; + } + return false; + } + + private boolean compareComparableValues(boolean comparisonResult, String operator) { + switch (operator) { + case "=": + return comparisonResult; + case "<>": + return !comparisonResult ; + default: + return false; //TODO: should throw exception + } + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java new file mode 100644 index 000000000..86c53bf45 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -0,0 +1,93 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.*; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterEqualityTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void equalityTrueTest() { + RosettaExpression expr = parser.parseExpression("1 = 1"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityFalseTest() { + RosettaExpression expr = parser.parseExpression("1 = 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void inequalityTrueTest() { + RosettaExpression expr = parser.parseExpression("1 <> 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityDifferentTypesTest() { + RosettaExpression expr = parser.parseExpression("1 = True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityAllTrueTest() { + RosettaExpression expr = parser.parseExpression("[1,1,1] all = 1"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityAllFalseTest() { + RosettaExpression expr = parser.parseExpression("[1,2,1] all = 1"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityAnyFalseTest() { + RosettaExpression expr = parser.parseExpression("[2,2,2] any <> 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void equalityAnyTrueTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] any = 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + +} From 264270ed55e16be5d5a3d8aff2d9dc006c54333b Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 16 May 2024 20:34:34 +0200 Subject: [PATCH 038/236] Implementation + Testing comparison --- ...rpreterComparisonOperationInterpreter.java | 253 ++++++++++++++++++ .../RosettaInterpreterComparisonTest.java | 79 ++++++ 2 files changed, 332 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java new file mode 100644 index 000000000..1b5bc30a5 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -0,0 +1,253 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterComparisonOperationInterpreter extends + RosettaInterpreterConcreteInterpreter { + + /** + * Interprets a comparison operation, evaluating the comparison between two operands. + * + * @param expr The ComparisonOperation expression to interpret + * @return A RosettaInterpreterBooleanValue representing the result + * of the comparison operation. + */ + public RosettaInterpreterValue interp(ComparisonOperation expr) { + RosettaExpression left = expr.getLeft(); + RosettaExpression right = expr.getRight(); + + RosettaInterpreterValue leftValue = left.accept(visitor); + RosettaInterpreterValue rightValue = right.accept(visitor); + + //check cardinality operation + switch (expr.getCardMod()) { + case NONE: + //normally compare left and right side. + boolean result = checkComparableTypes(leftValue, + rightValue, + expr.getOperator()); + return new RosettaInterpreterBooleanValue(result); + + case ANY: + boolean resultAny = compareAny(leftValue, rightValue, expr.getOperator()); + return new RosettaInterpreterBooleanValue(resultAny); + + case ALL: + boolean resultAll = compareAll(leftValue, rightValue, expr.getOperator()); + return new RosettaInterpreterBooleanValue(resultAll); + + default: + return new RosettaInterpreterBooleanValue(false); + //TODO: throw exception, not a supported case + + } + + //check if these types are actually comparable +// boolean result = checkComparableTypes(leftValue, rightValue, expr.getOperator()); +// +// return new RosettaInterpreterBooleanValue(result); + } + + private boolean compareAny(RosettaInterpreterValue leftValue, + RosettaInterpreterValue rightValue, + String operator) { + //list vs list case: + if (leftValue instanceof RosettaInterpreterListValue + && rightValue instanceof RosettaInterpreterListValue) { + + //only way this is allowed is if rightValue has a length of 1 + // and left has length more than 1 + RosettaInterpreterListValue rgtList = + (RosettaInterpreterListValue) rightValue; + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + if (rgtList.getExpressions().size() == 1 + && lfList.getExpressions().size() > 1) { + + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean anyTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + anyTrue |= checkComparableTypes(e, + rgtList.getExpressions().get(0), + operator); + } + return anyTrue; + } + else { + return false; + //TODO: throw exception, cannot compare two lists. + } + } + + //list vs element case: + else if (leftValue instanceof RosettaInterpreterListValue) { + + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + + //only way this is allowed is if left side has a length of + // more than 1 + if (lfList.getExpressions().size() > 1) { + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean anyTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + anyTrue |= checkComparableTypes(e, + rightValue, + operator); + } + return anyTrue; + } + } + else { + //TODO: throw exception, cannot compare 2 elements + return false; + } + return false; + } + + private boolean compareAll(RosettaInterpreterValue leftValue, + RosettaInterpreterValue rightValue, + String operator) { + //list vs list case: + if (leftValue instanceof RosettaInterpreterListValue + && rightValue instanceof RosettaInterpreterListValue) { + + //only way this is allowed is if rightValue has a length of 1 + // and left has length more than 1 + RosettaInterpreterListValue rgtList = + (RosettaInterpreterListValue) rightValue; + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + if (rgtList.getExpressions().size() == 1 + && lfList.getExpressions().size() > 1) { + + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean allTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + allTrue &= checkComparableTypes(e, + rgtList.getExpressions().get(0), + operator); + } + return allTrue; + } + else { + return false; + //TODO: throw exception, cannot compare two lists. + } + } + + //list vs element case: + else if (leftValue instanceof RosettaInterpreterListValue) { + + RosettaInterpreterListValue lfList = + (RosettaInterpreterListValue) leftValue; + + //only way this is allowed is if left side has a length of + // more than 1 + if (lfList.getExpressions().size() > 1) { + + //for all elements in left list, check if the comparison + // between them and right-hand side is true + boolean allTrue = true; + for (RosettaInterpreterValue e : lfList.getExpressions()) { + allTrue &= checkComparableTypes(e, + rightValue, + operator); + } + return allTrue; + } + } + else { + //TODO: throw exception, cannot compare 2 elements + return false; + } + return false; + } + + private boolean checkComparableTypes(RosettaInterpreterValue leftValue, + RosettaInterpreterValue rightValue, + String operator) { + int comparisonResult = 2; + + //compare integers + if (leftValue instanceof RosettaInterpreterIntegerValue + && rightValue instanceof RosettaInterpreterIntegerValue) { + RosettaInterpreterIntegerValue leftInt = + (RosettaInterpreterIntegerValue) leftValue; + RosettaInterpreterIntegerValue rightInt = + (RosettaInterpreterIntegerValue) rightValue; + + comparisonResult = leftInt.compareTo(rightInt); + } + + //compare booleans + else if (leftValue instanceof RosettaInterpreterBooleanValue + && rightValue instanceof RosettaInterpreterBooleanValue) { + RosettaInterpreterBooleanValue leftBool = + (RosettaInterpreterBooleanValue) leftValue; + RosettaInterpreterBooleanValue rightBool = + (RosettaInterpreterBooleanValue) rightValue; + + comparisonResult = leftBool.compareTo(rightBool); + } + + //compare strings + else if (leftValue instanceof RosettaInterpreterStringValue + && rightValue instanceof RosettaInterpreterStringValue) { + RosettaInterpreterStringValue leftString = + (RosettaInterpreterStringValue) leftValue; + RosettaInterpreterStringValue rightString = + (RosettaInterpreterStringValue) rightValue; + + comparisonResult = leftString.compareTo(rightString); + } + + //compare numbers + else if (leftValue instanceof RosettaInterpreterNumberValue + && rightValue instanceof RosettaInterpreterNumberValue) { + RosettaInterpreterNumberValue leftNumber = + (RosettaInterpreterNumberValue) leftValue; + RosettaInterpreterNumberValue rightNumber = + (RosettaInterpreterNumberValue) rightValue; + + comparisonResult = leftNumber.compareTo(rightNumber); + } + + + return compareComparableValues(comparisonResult, + operator); + } + + private boolean compareComparableValues(int comparisonResult, String operator) { + if (comparisonResult == 2) { + //should not happen, means classes are not comparable + return false; //TODO: should throw exception + } + switch (operator) { + case "<": + return comparisonResult == -1; + case "<=": + return comparisonResult == -1 || comparisonResult == 0; + case ">": + return comparisonResult == 1; + case ">=": + return comparisonResult == 1 || comparisonResult == 0; + default: + return false; //TODO: should throw exception + } + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java new file mode 100644 index 000000000..589026085 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -0,0 +1,79 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterComparisonTest { + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void intSmallerTest() { + RosettaExpression expr = parser.parseExpression("1 < 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void stringBiggerTest() { + RosettaExpression expr = parser.parseExpression("\"bro\" > \"dude\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void booleanLessEqualTest() { + RosettaExpression expr = parser.parseExpression("False <= False"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void cardinalityAllListsTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] all > [0]"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void cardinalityAllSimpleTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] all < 4"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void cardinalityAnySimpleTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] any > 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + +} From 9417eac48fc27e418110f575b9d9819453d69542 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 17 May 2024 08:52:54 +0200 Subject: [PATCH 039/236] Made separate file for logical operation tests, and rewrote the tests to look cleaner --- ...settaInterpreterLogicalOperationsTest.java | 113 ++++++++++++++++++ .../RosettaInterpreterNewTest.java | 76 ------------ 2 files changed, 113 insertions(+), 76 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java new file mode 100644 index 000000000..4353fb70d --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -0,0 +1,113 @@ +package com.regnosys.rosetta.interpreternew; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; + +import static org.junit.jupiter.api.Assertions.*; +import javax.inject.Inject; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterLogicalOperationsTest { + + @Inject + RosettaInterpreterNew interpreter; + + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + + } + + // ------------- Helper Methods ------------- + private RosettaBooleanLiteral createBooleanLiteral(boolean value) { + RosettaBooleanLiteral literal = eFactory.createRosettaBooleanLiteral(); + literal.setValue(value); + return literal; + } + + private LogicalOperation createLogicalOperation(String operator, RosettaExpression left, RosettaExpression right) { + LogicalOperation operation = eFactory.createLogicalOperation(); + operation.setOperator(operator); + operation.setLeft(left); + operation.setRight(right); + return operation; + } + + private void assertBooleanResult(RosettaInterpreterValue result, boolean expected) { + assertTrue(result instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; + assertEquals(expected, boolResult.getValue()); + } + + + // ------------- Actual Tests ------------- + @Test + public void logicalAndInterpTestFalse() { + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); + LogicalOperation expr = createLogicalOperation("and", trueLiteral, falseLiteral); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertBooleanResult(result, false); + } + + @Test + public void logicalAndInterpTestTrue() { + RosettaBooleanLiteral trueLiteral1 = createBooleanLiteral(true); + RosettaBooleanLiteral trueLiteral2 = createBooleanLiteral(true); + LogicalOperation expr = createLogicalOperation("and", trueLiteral1, trueLiteral2); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertBooleanResult(result, true); + } + + @Test + public void logicalOrInterpTestTrue() { + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); + LogicalOperation expr = createLogicalOperation("or", trueLiteral, falseLiteral); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertBooleanResult(result, true); + } + + @Test + public void logicalOrInterpTestFalse() { + RosettaBooleanLiteral falseLiteral1 = createBooleanLiteral(false); + RosettaBooleanLiteral falseLiteral2 = createBooleanLiteral(false); + LogicalOperation expr = createLogicalOperation("or", falseLiteral1, falseLiteral2); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertBooleanResult(result, false); + } + + @Test + public void nestedBooleansLogicalTest() { + RosettaBooleanLiteral falseLiteral1 = createBooleanLiteral(false); + RosettaBooleanLiteral falseLiteral2 = createBooleanLiteral(false); + RosettaBooleanLiteral trueLiteral1 = createBooleanLiteral(true); + RosettaBooleanLiteral trueLiteral2 = createBooleanLiteral(true); + + LogicalOperation expr1 = createLogicalOperation("and", falseLiteral1, trueLiteral1); + LogicalOperation expr2 = createLogicalOperation("and", falseLiteral2, trueLiteral2); + LogicalOperation nestedExpr = createLogicalOperation("or", expr1, expr2); + + RosettaInterpreterValue result = interpreter.interp(nestedExpr); + assertBooleanResult(result, false); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index 774935fd2..19b771aaf 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -65,80 +65,4 @@ public void VisitorInitialTest() { RosettaInterpreterBooleanValue boolVal = (RosettaInterpreterBooleanValue)val; assertEquals(testValue, boolVal.getValue()); } - - @Test - public void logicalAndInterpTestFalse() { - boolean expected = false; - RosettaBooleanLiteral trueLiteral = eFactory.createRosettaBooleanLiteral(); - trueLiteral.setValue(true); - RosettaBooleanLiteral falseLiteral = eFactory.createRosettaBooleanLiteral(); - falseLiteral.setValue(false); - - LogicalOperation expr = eFactory.createLogicalOperation(); - expr.setOperator("and"); - expr.setLeft(trueLiteral); - expr.setRight(falseLiteral); - - RosettaInterpreterValue result = interpreter.interp(expr); - assertTrue(result instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; - assertEquals(expected, boolResult.getValue()); - } - - @Test - public void logicalAndInterpTestTrue() { - boolean expected = true; - RosettaBooleanLiteral trueLiteral1 = eFactory.createRosettaBooleanLiteral(); - trueLiteral1.setValue(true); - RosettaBooleanLiteral trueLiteral2 = eFactory.createRosettaBooleanLiteral(); - trueLiteral2.setValue(true); - - LogicalOperation expr = eFactory.createLogicalOperation(); - expr.setOperator("and"); - expr.setLeft(trueLiteral1); - expr.setRight(trueLiteral2); - - RosettaInterpreterValue result = interpreter.interp(expr); - assertTrue(result instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; - assertEquals(expected, boolResult.getValue()); - } - - @Test - public void logicalOrInterpTestTrue() { - boolean expected = true; - RosettaBooleanLiteral trueLiteral = eFactory.createRosettaBooleanLiteral(); - trueLiteral.setValue(true); - RosettaBooleanLiteral falseLiteral = eFactory.createRosettaBooleanLiteral(); - falseLiteral.setValue(false); - - LogicalOperation expr = eFactory.createLogicalOperation(); - expr.setOperator("or"); - expr.setLeft(trueLiteral); - expr.setRight(falseLiteral); - - RosettaInterpreterValue result = interpreter.interp(expr); - assertTrue(result instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; - assertEquals(expected, boolResult.getValue()); - } - - @Test - public void logicalOrInterpTestFalse() { - boolean expected = false; - RosettaBooleanLiteral falseLiteral1 = eFactory.createRosettaBooleanLiteral(); - falseLiteral1.setValue(false); - RosettaBooleanLiteral falseLiteral2 = eFactory.createRosettaBooleanLiteral(); - falseLiteral2.setValue(false); - - LogicalOperation expr = eFactory.createLogicalOperation(); - expr.setOperator("or"); - expr.setLeft(falseLiteral1); - expr.setRight(falseLiteral2); - - RosettaInterpreterValue result = interpreter.interp(expr); - assertTrue(result instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue boolResult = (RosettaInterpreterBooleanValue) result; - assertEquals(expected, boolResult.getValue()); - } } From 1962476706fadb1468dd3d7e1ff841d4bea9cea5 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 17 May 2024 13:26:05 +0200 Subject: [PATCH 040/236] Fix conflicts again --- .../values/RosettaInterpreterBaseValue.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index cde0fb7db..1a5806da3 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -19,44 +19,8 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -<<<<<<< HEAD -public class RosettaInterpreterBaseValue implements RosettaInterpreterValue { - List errors; - //private List items; - - @Override - public EList getErrors() { - return new BasicEList(errors); - } - - @Override - public boolean addError(RosettaInterpreterBaseError error) { - return errors.add(error); - } - @Override - public boolean addAllErrors(RosettaInterpreterValue other) { - return errors.addAll(other.getErrors()); - } - - @Override - public boolean addAllErrors(EList errors) { - return errors.addAll(errors); - } - - - public RosettaInterpreterBaseValue() { - this.errors = new ArrayList<>(); - } - - public RosettaInterpreterBaseValue(RosettaInterpreterError error) { - this.errors = new ArrayList<>(); - errors.add(error); - } - -======= public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ ->>>>>>> dev @Override public EClass eClass() { // TODO Auto-generated method stub From d0388f41af44177c77b572f087fd3b519d1a4285 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 17 May 2024 14:07:03 +0200 Subject: [PATCH 041/236] Implemented error support for equality + tests --- ...terpreterEqualityOperationInterpreter.java | 82 +++++++++++-------- .../RosettaInterpreterEqualityTest.java | 24 ++++++ 2 files changed, 71 insertions(+), 35 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java index 540700cd8..80ad2a7fa 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java @@ -1,6 +1,12 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.Arrays; +import java.util.List; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.rosetta.expression.EqualityOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -9,6 +15,8 @@ public class RosettaInterpreterEqualityOperationInterpreter extends RosettaInterpreterConcreteInterpreter { + private static List equalityOperators = Arrays.asList("=", "<>"); + /** * Interprets an equality operation by evaluating both sides of the expression and * determining if they are equal. @@ -18,7 +26,12 @@ public class RosettaInterpreterEqualityOperationInterpreter extends * comparison. * It will be true if both evaluated expressions are equal, otherwise false. */ - public RosettaInterpreterBooleanValue interp(EqualityOperation expr) { + public RosettaInterpreterBaseValue interp(EqualityOperation expr) { + if (!equalityOperators.contains(expr.getOperator())) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "operator not suppported")); + } RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); @@ -35,28 +48,21 @@ public RosettaInterpreterBooleanValue interp(EqualityOperation expr) { return new RosettaInterpreterBooleanValue(result); case ANY: - boolean resultAny = compareAny(leftValue, rightValue, expr.getOperator()); - return new RosettaInterpreterBooleanValue(resultAny); + return compareAny(leftValue, rightValue, expr.getOperator()); case ALL: - boolean resultAll = compareAll(leftValue, rightValue, expr.getOperator()); - return new RosettaInterpreterBooleanValue(resultAll); + return compareAll(leftValue, rightValue, expr.getOperator()); default: - return new RosettaInterpreterBooleanValue(false); - //TODO: throw exception, not a supported case + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cardinality modifier " + expr.getCardMod() + + " not supported")); - } - -// boolean comparisonResult = leftValue.equals(rightValue); -// -// boolean result = compareComparableValues(comparisonResult, -// expr.getOperator()); -// return new RosettaInterpreterBooleanValue(result); - + } } - private boolean compareAny(RosettaInterpreterValue leftValue, + private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, String operator) { //list vs list case: @@ -82,11 +88,12 @@ private boolean compareAny(RosettaInterpreterValue leftValue, anyTrue |= compareComparableValues(comparisonResult, operator); } - return anyTrue; + return new RosettaInterpreterBooleanValue(anyTrue); } else { - return false; - //TODO: throw exception, cannot compare two lists. + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } } @@ -108,17 +115,19 @@ else if (leftValue instanceof RosettaInterpreterListValue) { anyTrue |= compareComparableValues(comparisonResult, operator); } - return anyTrue; + return new RosettaInterpreterBooleanValue(anyTrue); } } else { - //TODO: throw exception, cannot compare 2 elements - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ANY\" keyword " + + "to compare two elements")); } - return false; + return new RosettaInterpreterBooleanValue(false); } - private boolean compareAll(RosettaInterpreterValue leftValue, + private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, String operator) { //list vs list case: @@ -144,11 +153,13 @@ private boolean compareAll(RosettaInterpreterValue leftValue, allTrue &= compareComparableValues(comparisonResult, operator); } - return allTrue; + return new RosettaInterpreterBooleanValue(allTrue); } else { - return false; //TODO: throw exception, cannot compare two lists. + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } } @@ -170,24 +181,25 @@ else if (leftValue instanceof RosettaInterpreterListValue) { allTrue &= compareComparableValues(comparisonResult, operator); } - return allTrue; + return new RosettaInterpreterBooleanValue(allTrue); } } else { - //TODO: throw exception, cannot compare 2 elements - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + + "to compare two elements")); + } - return false; + return new RosettaInterpreterBooleanValue(false); } private boolean compareComparableValues(boolean comparisonResult, String operator) { - switch (operator) { - case "=": + if (operator.equals("=")) { return comparisonResult; - case "<>": + } + else { return !comparisonResult ; - default: - return false; //TODO: should throw exception } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index 86c53bf45..10709bd69 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -11,6 +11,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; @@ -89,5 +91,27 @@ public void equalityAnyTrueTest() { RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } + + @Test + public void errorThrownListTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); + RosettaExpression expr = parser.parseExpression("[1,2,3] any = [1,2]"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(expectedError.getErrors(), + ((RosettaInterpreterErrorValue)val).getErrors()); + } + + @Test + public void errorThrownAllElementsTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); + RosettaExpression expr = parser.parseExpression("1 all = 3"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(expectedError.getErrors(), + ((RosettaInterpreterErrorValue)val).getErrors()); + } } From b2d221ee51fd44b6f4f6001e3e6a0c221b2c0ad5 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 17 May 2024 14:35:32 +0200 Subject: [PATCH 042/236] error support for comparison + tests + javadoc --- ...rpreterComparisonOperationInterpreter.java | 82 ++++++++++++------- ...terpreterEqualityOperationInterpreter.java | 5 +- .../RosettaInterpreterComparisonTest.java | 33 ++++++++ .../RosettaInterpreterEqualityTest.java | 3 +- 4 files changed, 91 insertions(+), 32 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 1b5bc30a5..e71769516 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -1,6 +1,12 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.Arrays; +import java.util.List; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; @@ -12,14 +18,24 @@ public class RosettaInterpreterComparisonOperationInterpreter extends RosettaInterpreterConcreteInterpreter { + private static List comparisonOperators = + Arrays.asList("<", "<=", ">", ">="); + /** * Interprets a comparison operation, evaluating the comparison between two operands. * * @param expr The ComparisonOperation expression to interpret - * @return A RosettaInterpreterBooleanValue representing the result - * of the comparison operation. + * @return If no errors are encountered, a RosettaInterpreterBooleanValue representing + * the result of the comparison operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. */ - public RosettaInterpreterValue interp(ComparisonOperation expr) { + public RosettaInterpreterBaseValue interp(ComparisonOperation expr) { + if (!comparisonOperators.contains(expr.getOperator())) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "operator not suppported")); + } RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); @@ -36,16 +52,16 @@ public RosettaInterpreterValue interp(ComparisonOperation expr) { return new RosettaInterpreterBooleanValue(result); case ANY: - boolean resultAny = compareAny(leftValue, rightValue, expr.getOperator()); - return new RosettaInterpreterBooleanValue(resultAny); + return compareAny(leftValue, rightValue, expr.getOperator()); case ALL: - boolean resultAll = compareAll(leftValue, rightValue, expr.getOperator()); - return new RosettaInterpreterBooleanValue(resultAll); + return compareAll(leftValue, rightValue, expr.getOperator()); default: - return new RosettaInterpreterBooleanValue(false); - //TODO: throw exception, not a supported case + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cardinality modifier " + expr.getCardMod() + + " not supported")); } @@ -55,7 +71,7 @@ public RosettaInterpreterValue interp(ComparisonOperation expr) { // return new RosettaInterpreterBooleanValue(result); } - private boolean compareAny(RosettaInterpreterValue leftValue, + private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, String operator) { //list vs list case: @@ -80,11 +96,12 @@ private boolean compareAny(RosettaInterpreterValue leftValue, rgtList.getExpressions().get(0), operator); } - return anyTrue; + return new RosettaInterpreterBooleanValue(anyTrue); } else { - return false; - //TODO: throw exception, cannot compare two lists. + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } } @@ -106,17 +123,19 @@ else if (leftValue instanceof RosettaInterpreterListValue) { rightValue, operator); } - return anyTrue; + return new RosettaInterpreterBooleanValue(anyTrue); } } else { - //TODO: throw exception, cannot compare 2 elements - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ANY\" keyword " + + "to compare two elements")); } - return false; + return new RosettaInterpreterBooleanValue(false); } - private boolean compareAll(RosettaInterpreterValue leftValue, + private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, String operator) { //list vs list case: @@ -141,11 +160,12 @@ private boolean compareAll(RosettaInterpreterValue leftValue, rgtList.getExpressions().get(0), operator); } - return allTrue; + return new RosettaInterpreterBooleanValue(allTrue); } else { - return false; - //TODO: throw exception, cannot compare two lists. + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } } @@ -167,14 +187,16 @@ else if (leftValue instanceof RosettaInterpreterListValue) { rightValue, operator); } - return allTrue; + return new RosettaInterpreterBooleanValue(allTrue); } } else { - //TODO: throw exception, cannot compare 2 elements - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + + "to compare two elements")); } - return false; + return new RosettaInterpreterBooleanValue(false); } private boolean checkComparableTypes(RosettaInterpreterValue leftValue, @@ -232,10 +254,10 @@ else if (leftValue instanceof RosettaInterpreterNumberValue } private boolean compareComparableValues(int comparisonResult, String operator) { - if (comparisonResult == 2) { - //should not happen, means classes are not comparable - return false; //TODO: should throw exception - } +// if (comparisonResult == 2) { +// //should not happen, means classes are not comparable +// return false; //TODO: should throw exception +// } switch (operator) { case "<": return comparisonResult == -1; @@ -246,7 +268,7 @@ private boolean compareComparableValues(int comparisonResult, String operator) { case ">=": return comparisonResult == 1 || comparisonResult == 0; default: - return false; //TODO: should throw exception + return false; //should never happen } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java index 80ad2a7fa..e3c4dfc35 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java @@ -22,9 +22,12 @@ public class RosettaInterpreterEqualityOperationInterpreter extends * determining if they are equal. * * @param expr equality operation expression to interpret - * @return A RosettaInterpreterBooleanValue representing the result of the equality + * @return If no errors are encountered, a RosettaInterpreterBooleanValue representing + * the result of the equality * comparison. * It will be true if both evaluated expressions are equal, otherwise false. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. */ public RosettaInterpreterBaseValue interp(EqualityOperation expr) { if (!equalityOperators.contains(expr.getOperator())) { diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 589026085..76800b90c 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -12,6 +13,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; @@ -76,4 +79,34 @@ public void cardinalityAnySimpleTest() { assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test + public void errorThrownListTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); + RosettaExpression expr = parser.parseExpression("[1,2,3] any <= [1,2]"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(expectedError.getErrors(), + ((RosettaInterpreterErrorValue)val).getErrors()); + assertEquals(expectedError.getErrors().get(0).getMessage(), + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void errorThrownAllElementsTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + + "to compare two elements")); + RosettaExpression expr = parser.parseExpression("1 all > 3"); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; + assertEquals(expectedError.getErrors(), + (errorVal.getErrors())); + + assertEquals(expectedError.getErrors().get(0).getMessage(), + (errorVal.getErrors().get(0).getMessage())); + } + } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index 10709bd69..a2110e51e 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -107,7 +107,8 @@ public void errorThrownListTest() { public void errorThrownAllElementsTest() { RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); + "cannot use \"ALL\" keyword " + + "to compare two elements")); RosettaExpression expr = parser.parseExpression("1 all = 3"); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors(), From 0d8734188ed71c877faf61b6ac23c8a1e7d383b9 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 17 May 2024 15:14:27 +0200 Subject: [PATCH 043/236] Added error handling and some testing + checkstyle --- ...nterpreterLogicalOperationInterpreter.java | 53 ++++++++++++-- ...settaInterpreterLogicalOperationsTest.java | 70 +++++++++++++++++++ 2 files changed, 119 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index efc226e4b..fbec2952a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -1,13 +1,22 @@ package com.regnosys.rosetta.interpreternew.visitors; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterLogicalOperationInterpreter extends RosettaInterpreterConcreteInterpreter{ - public RosettaInterpreterBooleanValue interp(LogicalOperation expr) { + /** + * Interpreter method for Logical Operations. + * + * @param expr LogicalOperaation to be interpreted + * @return The interpreted value + */ + public RosettaInterpreterBaseValue interp(LogicalOperation expr) { boolean leftBoolean = false; boolean rightBoolean = false; @@ -16,12 +25,25 @@ public RosettaInterpreterBooleanValue interp(LogicalOperation expr) { RosettaExpression right = expr.getRight(); RosettaInterpreterValue leftInterpreted = left.accept(visitor); RosettaInterpreterValue rightInterpreted = right.accept(visitor); + if(leftInterpreted instanceof RosettaInterpreterBooleanValue && rightInterpreted instanceof RosettaInterpreterBooleanValue) { leftBoolean = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); rightBoolean = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); } else { - // Idk?? error + // Check for errors in the left or right side of the binary operation + RosettaInterpreterErrorValue leftSideCheck = checkForErrors(leftInterpreted, "Leftside"); + RosettaInterpreterErrorValue rightSideCheck = checkForErrors(rightInterpreted, "Rightside"); + + // Null means there were no errors on that side + if(leftSideCheck == null) return rightSideCheck; + else if(rightSideCheck == null) return leftSideCheck; + else { + // There were errors on both sides => Combine the error messages + RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(leftSideCheck.getErrors()); + newErrorValue.addAllErrors(rightSideCheck.getErrors()); + return newErrorValue; + } } if(expr.getOperator().equals("and")) { @@ -29,8 +51,31 @@ public RosettaInterpreterBooleanValue interp(LogicalOperation expr) { } else if(expr.getOperator().equals("or")) { return new RosettaInterpreterBooleanValue(leftBoolean || rightBoolean); } else { - // Idk?? error - return null; + // Wrong logical operator -> only "and" / "or" supported + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: Wrong operator - try 'and' / 'or'")); + } + } + + /** + * Helper method that takes an interpretedValue and a string, and returns the correct error which + * that interpretedValue causes, if any. + * + * @param interpretedValue The interpreted value which we check for errors + * @param side String containing either "Leftside" or "Rightside", purely for clearer error messages + * @return The correct RosettaInterpreterErrorValue, or "null" if the interpretedValue does not cause an error + */ + private RosettaInterpreterErrorValue checkForErrors(RosettaInterpreterValue interpretedValue, String side) { + if(interpretedValue instanceof RosettaInterpreterErrorValue) { + // The interpreted value was an error (so we need to add a new error message to the existing ones) + RosettaInterpreterErrorValue oldErrorValue = (RosettaInterpreterErrorValue) interpretedValue; + RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is an error value")); + newErrorValue.addAllErrors(oldErrorValue.getErrors()); + return newErrorValue; + } else if (!(interpretedValue instanceof RosettaInterpreterBooleanValue)) { + // The interpreted value was not an error, but something other than a boolean + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is not of type Boolean")); } + + return null; } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index c87f69cd7..fde7004ee 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; +import org.eclipse.emf.common.util.EList; import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.junit.jupiter.api.BeforeEach; @@ -8,14 +9,23 @@ import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import static org.junit.jupiter.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + import javax.inject.Inject; @ExtendWith(InjectionExtension.class) @@ -54,6 +64,14 @@ private void assertBooleanResult(RosettaInterpreterValue result, boolean expecte assertEquals(expected, boolResult.getValue()); } + private void compareErrors(List expected, EList errors) { + assertEquals(expected.size(), errors.size()); + for(int i = 0; i < expected.size(); i++) { + RosettaInterpreterError newError = (RosettaInterpreterError) errors.get(i); + System.out.println(newError.getError()); + assertEquals(expected.get(i).getError(), newError.getError()); + } + } // ------------- Actual Tests ------------- @Test @@ -110,4 +128,56 @@ public void nestedBooleansLogicalTest() { RosettaInterpreterValue result = interpreter.interp(nestedExpr); assertBooleanResult(result, false); } + + @Test + public void wrongOperatorTest() { + List expected = new ArrayList(); + expected.add(new RosettaInterpreterError("Logical Operation: Wrong operator - try 'and' / 'or'")); + + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); + LogicalOperation expr = createLogicalOperation("xor", trueLiteral, falseLiteral); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; + compareErrors(expected, castedResult.getErrors()); + } + + @Test + public void notBooleanValueTest() { + List expected = new ArrayList(); + expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); + + RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); + RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); + LogicalOperation expr = createLogicalOperation("and", stringLiteral, falseLiteral); + + RosettaInterpreterValue result = interpreter.interp(expr); + assertTrue(result instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; + compareErrors(expected, castedResult.getErrors()); + } + + @Test + public void errorsOnBothSidesTest() { + List expected = new ArrayList(); + // The order of these might be wrong, I am not sure if they which order they get added in, + // but I assume they get added from the inside, as they get propagated to the out-most expression + expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); + expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); + expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); + + RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); + + RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); + LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); + + RosettaInterpreterValue result = interpreter.interp(nestedExpr); + assertTrue(result instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; + compareErrors(expected, castedResult.getErrors()); + } } From 771fd75937986ff710e59efa76c7cfd30aef329d Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 17 May 2024 15:17:04 +0200 Subject: [PATCH 044/236] Added nested test --- .../RosettaInterpreterComparisonTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 76800b90c..7c1128741 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -37,6 +37,13 @@ public void setup() { eFactory = ExpressionFactoryImpl.init(); } + @Test + public void nestedTest() { + RosettaExpression expr = parser.parseExpression("True = (1 < 3)"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + @Test public void intSmallerTest() { RosettaExpression expr = parser.parseExpression("1 < 2"); @@ -105,8 +112,8 @@ public void errorThrownAllElementsTest() { assertEquals(expectedError.getErrors(), (errorVal.getErrors())); - assertEquals(expectedError.getErrors().get(0).getMessage(), - (errorVal.getErrors().get(0).getMessage())); + assertEquals(((RosettaInterpreterError) expectedError.getErrors().get(0)).getError(), + (((RosettaInterpreterError) (errorVal.getErrors().get(0))).getError())); } } From 9cff1eb5af1006aff890b942e9f2bda3430f0f68 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 17 May 2024 15:24:32 +0200 Subject: [PATCH 045/236] Changed some of the tests to use the parser --- ...settaInterpreterLogicalOperationsTest.java | 87 ++++++++----------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index fde7004ee..0913d5c20 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -32,6 +33,9 @@ @InjectWith(RosettaInjectorProvider.class) public class RosettaInterpreterLogicalOperationsTest { + @Inject + private ExpressionParser parser; + @Inject RosettaInterpreterNew interpreter; @@ -76,56 +80,40 @@ private void compareErrors(List expected, EList expected = new ArrayList(); expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); - RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); - RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); - LogicalOperation expr = createLogicalOperation("and", stringLiteral, falseLiteral); - + RosettaExpression expr = parser.parseExpression("1 and False"); RosettaInterpreterValue result = interpreter.interp(expr); assertTrue(result instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; compareErrors(expected, castedResult.getErrors()); } - @Test - public void errorsOnBothSidesTest() { - List expected = new ArrayList(); - // The order of these might be wrong, I am not sure if they which order they get added in, - // but I assume they get added from the inside, as they get propagated to the out-most expression - expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); - expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); - expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); - - RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); - RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); - LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); - - RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); - LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); - - RosettaInterpreterValue result = interpreter.interp(nestedExpr); - assertTrue(result instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; - compareErrors(expected, castedResult.getErrors()); - } +// @Test +// public void errorsOnBothSidesTest() { +// List expected = new ArrayList(); +// // The order of these might be wrong, I am not sure if they which order they get added in, +// // but I assume they get added from the inside, as they get propagated to the out-most expression +// expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); +// expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); +// expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); +// +// RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); +// RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); +// LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); +// +// RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); +// LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); +// +// RosettaInterpreterValue result = interpreter.interp(nestedExpr); +// assertTrue(result instanceof RosettaInterpreterErrorValue); +// RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; +// compareErrors(expected, castedResult.getErrors()); +// } } From 363ce925d244778c040ddd3e49545047cfdb86de Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 17 May 2024 15:46:21 +0200 Subject: [PATCH 046/236] Fix error messages being null --- .../interpreternew/values/RosettaInterpreterError.java | 10 +++++++--- .../interpreternew/RosettaInterpreterErrorTest.java | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index 8e5335fd0..888d0c28d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -36,12 +36,17 @@ public boolean equals(Object obj) { private String errorMessage; - public RosettaInterpreterError(String value) { + public RosettaInterpreterError(String errorMessage) { super(); this.errorMessage = errorMessage; } public String getError() { return errorMessage; } + + @Override + public String toString() { + return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; + } @Override public EClass eClass() { @@ -159,8 +164,7 @@ public void eNotify(Notification notification) { @Override public String getMessage() { - // TODO Auto-generated method stub - return null; + return errorMessage; } @Override diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java index 87fdde138..7aed49d30 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java @@ -49,4 +49,11 @@ public void SimpleErrorTest() { assertEquals(el, val1.getErrors()); } + + @Test + public void ErrorMessageExists() { + RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); + RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(e1); + assertEquals("e1", val1.getErrors().get(0).getMessage()); + } } From bc918c1228b5b4126a0e3ab4c08bb7e6e7ed69bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 17 May 2024 20:54:12 +0300 Subject: [PATCH 047/236] Base methods for conditionals support --- rosetta-lang/model/RosettaInterpreter.xcore | 2 ++ .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 8574ac5c0..de77b48c9 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -11,6 +11,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral import com.regnosys.rosetta.rosetta.expression.ListLiteral +import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression class RosettaInterpreterBaseError{ String message @@ -26,4 +27,5 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaIntLiteral exp) op RosettaInterpreterValue interp (RosettaPatternLiteral exp) op RosettaInterpreterValue interp (ListLiteral exp) + op RosettaInterpreterValue interp (RosettaConditionalExpression exp) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index efe62ad3d..56da79e70 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -2,6 +2,7 @@ import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; @@ -48,5 +49,10 @@ public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { public RosettaInterpreterValue interp(ListLiteral exp) { return new RosettaInterpreterListLiteralInterpreter().interp(exp); } + + @Override + public RosettaInterpreterValue interp(RosettaConditionalExpression exp) { + return null; + } } From 2aee9c6db230f30477ae88b895b5b367c6e5ce13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 17 May 2024 21:44:57 +0300 Subject: [PATCH 048/236] Start of the implementation of conditional operations --- rosetta-lang/model/RosettaExpression.xcore | 4 +++ ...settaConditionalExpressionInterpreter.java | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index b038b3b24..f0ac5300e 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -174,6 +174,10 @@ class RosettaConditionalExpression extends RosettaExpression { contains RosettaExpression elsethen boolean full // whether the conditional expression has an explicit `else` branch. + + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaConstructorExpression extends RosettaExpression, RosettaTyped { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java new file mode 100644 index 000000000..43f13e138 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -0,0 +1,34 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterRosettaConditionalExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { + boolean ifResult = false; + + RosettaExpression if_ = expr.getIf(); + RosettaExpression ifThen = expr.getIfthen(); + RosettaExpression elseThen = expr.getElsethen(); + + RosettaInterpreterValue ifValue = if_.accept(visitor); + RosettaInterpreterValue ifThenValue = ifThen.accept(visitor); + RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); + + if (ifValue instanceof RosettaInterpreterBooleanValue) { + ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); + } else { + // error + } + + if (ifResult == true) { + + } + + return null; + } +} From 64b37e72fc4730324790fe8e1a646b2042c209f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Sun, 19 May 2024 21:51:38 +0300 Subject: [PATCH 049/236] Added implementation for conditionals support --- ...settaConditionalExpressionInterpreter.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 43f13e138..46d63efc1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -2,6 +2,10 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -13,11 +17,9 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { RosettaExpression if_ = expr.getIf(); RosettaExpression ifThen = expr.getIfthen(); - RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue ifValue = if_.accept(visitor); RosettaInterpreterValue ifThenValue = ifThen.accept(visitor); - RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); if (ifValue instanceof RosettaInterpreterBooleanValue) { ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); @@ -26,9 +28,34 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { } if (ifResult == true) { + return checkInstance(ifThenValue); + } else if (expr.isFull()) { + RosettaExpression elseThen = expr.getElsethen(); + RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); + return checkInstance(elseThenValue); } return null; } + + private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr) { + RosettaInterpreterBaseValue result = null; + + if (expr instanceof RosettaInterpreterBooleanValue) { + result = new RosettaInterpreterBooleanValue(((RosettaInterpreterBooleanValue) expr).getValue()); + } else if (expr instanceof RosettaInterpreterIntegerValue) { + result = new RosettaInterpreterIntegerValue(((RosettaInterpreterIntegerValue) expr).getValue()); + } else if (expr instanceof RosettaInterpreterNumberValue) { + result = new RosettaInterpreterNumberValue(((RosettaInterpreterNumberValue) expr).getValue()); + } else if (expr instanceof RosettaInterpreterStringValue) { + result = new RosettaInterpreterStringValue(((RosettaInterpreterStringValue) expr).getValue()); + } else if (expr instanceof RosettaInterpreterListValue) { + result = new RosettaInterpreterListValue(((RosettaInterpreterListValue) expr).getExpressions()); + } else { + // error + } + + return result; + } } From 82755cde0f565476e3bd0a79941db9b0ac5676ab Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sun, 19 May 2024 21:34:19 +0200 Subject: [PATCH 050/236] Merge equality+comparison and fix reviewed code --- .../RosettaInterpreterVisitor.java | 4 +- ...rpreterComparisonOperationInterpreter.java | 18 +- ...terpreterEqualityOperationInterpreter.java | 209 ------------------ .../RosettaInterpreterComparisonTest.java | 2 +- .../RosettaInterpreterEqualityTest.java | 26 +++ 5 files changed, 37 insertions(+), 222 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index a67906328..0ba78e8ac 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -11,9 +11,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; -import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEqualityOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; @@ -55,7 +53,7 @@ public RosettaInterpreterValue interp(ListLiteral exp) { @Override public RosettaInterpreterValue interp(EqualityOperation exp) { - return new RosettaInterpreterEqualityOperationInterpreter().interp(exp); + return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index e71769516..7c6bc8f9f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -11,7 +11,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; +import com.regnosys.rosetta.rosetta.expression.ModifiableBinaryOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -19,7 +19,7 @@ public class RosettaInterpreterComparisonOperationInterpreter extends RosettaInterpreterConcreteInterpreter { private static List comparisonOperators = - Arrays.asList("<", "<=", ">", ">="); + Arrays.asList("<", "<=", ">", ">=", "=", "<>"); /** * Interprets a comparison operation, evaluating the comparison between two operands. @@ -30,7 +30,7 @@ public class RosettaInterpreterComparisonOperationInterpreter extends * If errors are encountered, a RosettaInterpreterErrorValue representing * the error. */ - public RosettaInterpreterBaseValue interp(ComparisonOperation expr) { + public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { if (!comparisonOperators.contains(expr.getOperator())) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( @@ -90,7 +90,7 @@ private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue //for all elements in left list, check if the comparison // between them and right-hand side is true - boolean anyTrue = true; + boolean anyTrue = false; for (RosettaInterpreterValue e : lfList.getExpressions()) { anyTrue |= checkComparableTypes(e, rgtList.getExpressions().get(0), @@ -117,7 +117,7 @@ else if (leftValue instanceof RosettaInterpreterListValue) { //for all elements in left list, check if the comparison // between them and right-hand side is true - boolean anyTrue = true; + boolean anyTrue = false; for (RosettaInterpreterValue e : lfList.getExpressions()) { anyTrue |= checkComparableTypes(e, rightValue, @@ -254,11 +254,11 @@ else if (leftValue instanceof RosettaInterpreterNumberValue } private boolean compareComparableValues(int comparisonResult, String operator) { -// if (comparisonResult == 2) { -// //should not happen, means classes are not comparable -// return false; //TODO: should throw exception -// } switch (operator) { + case "=": + return comparisonResult == 0; + case "<>": + return comparisonResult != 0; case "<": return comparisonResult == -1; case "<=": diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java deleted file mode 100644 index e3c4dfc35..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEqualityOperationInterpreter.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.regnosys.rosetta.interpreternew.visitors; - -import java.util.Arrays; -import java.util.List; - -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.rosetta.expression.EqualityOperation; -import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -public class RosettaInterpreterEqualityOperationInterpreter extends - RosettaInterpreterConcreteInterpreter { - - private static List equalityOperators = Arrays.asList("=", "<>"); - - /** - * Interprets an equality operation by evaluating both sides of the expression and - * determining if they are equal. - * - * @param expr equality operation expression to interpret - * @return If no errors are encountered, a RosettaInterpreterBooleanValue representing - * the result of the equality - * comparison. - * It will be true if both evaluated expressions are equal, otherwise false. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterBaseValue interp(EqualityOperation expr) { - if (!equalityOperators.contains(expr.getOperator())) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "operator not suppported")); - } - RosettaExpression left = expr.getLeft(); - RosettaExpression right = expr.getRight(); - - RosettaInterpreterValue leftValue = left.accept(visitor); - RosettaInterpreterValue rightValue = right.accept(visitor); - - boolean comparisonResult = leftValue.equals(rightValue); - - switch (expr.getCardMod()) { - case NONE: - //normally compare left and right side. - boolean result = compareComparableValues(comparisonResult, - expr.getOperator()); - return new RosettaInterpreterBooleanValue(result); - - case ANY: - return compareAny(leftValue, rightValue, expr.getOperator()); - - case ALL: - return compareAll(leftValue, rightValue, expr.getOperator()); - - default: - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cardinality modifier " + expr.getCardMod() - + " not supported")); - - } - } - - private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, - RosettaInterpreterValue rightValue, - String operator) { - //list vs list case: - if (leftValue instanceof RosettaInterpreterListValue - && rightValue instanceof RosettaInterpreterListValue) { - - //only way this is allowed is if rightValue has a length of 1 - // and left has length more than 1 - RosettaInterpreterListValue rgtList = - (RosettaInterpreterListValue) rightValue; - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - if (rgtList.getExpressions().size() == 1 - && lfList.getExpressions().size() > 1) { - - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean anyTrue = true; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - boolean comparisonResult = - e.equals(rgtList.getExpressions().get(0)); - anyTrue |= compareComparableValues(comparisonResult, - operator); - } - return new RosettaInterpreterBooleanValue(anyTrue); - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot compare two lists")); - } - } - - //list vs element case: - else if (leftValue instanceof RosettaInterpreterListValue) { - - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - - //only way this is allowed is if left side has a length of - // more than 1 - if (lfList.getExpressions().size() > 1) { - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean anyTrue = false; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - boolean comparisonResult = e.equals(rightValue); - anyTrue |= compareComparableValues(comparisonResult, - operator); - } - return new RosettaInterpreterBooleanValue(anyTrue); - } - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot use \"ANY\" keyword " - + "to compare two elements")); - } - return new RosettaInterpreterBooleanValue(false); - } - - private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, - RosettaInterpreterValue rightValue, - String operator) { - //list vs list case: - if (leftValue instanceof RosettaInterpreterListValue - && rightValue instanceof RosettaInterpreterListValue) { - - //only way this is allowed is if rightValue has a length of 1 - // and left has length more than 1 - RosettaInterpreterListValue rgtList = - (RosettaInterpreterListValue) rightValue; - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - if (rgtList.getExpressions().size() == 1 - && lfList.getExpressions().size() > 1) { - - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean allTrue = true; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - boolean comparisonResult = - e.equals(rgtList.getExpressions().get(0)); - allTrue &= compareComparableValues(comparisonResult, - operator); - } - return new RosettaInterpreterBooleanValue(allTrue); - } - else { - //TODO: throw exception, cannot compare two lists. - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot compare two lists")); - } - } - - //list vs element case: - else if (leftValue instanceof RosettaInterpreterListValue) { - - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - - //only way this is allowed is if left side has a length of - // more than 1 - if (lfList.getExpressions().size() > 1) { - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean allTrue = true; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - boolean comparisonResult = e.equals(rightValue); - allTrue &= compareComparableValues(comparisonResult, - operator); - } - return new RosettaInterpreterBooleanValue(allTrue); - } - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot use \"ALL\" keyword " - + "to compare two elements")); - - } - return new RosettaInterpreterBooleanValue(false); - } - - private boolean compareComparableValues(boolean comparisonResult, String operator) { - if (operator.equals("=")) { - return comparisonResult; - } - else { - return !comparisonResult ; - } - } - -} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 7c1128741..3ff78e7d3 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -67,7 +67,7 @@ public void booleanLessEqualTest() { @Test public void cardinalityAllListsTest() { - RosettaExpression expr = parser.parseExpression("[1,2,3] all > [0]"); + RosettaExpression expr = parser.parseExpression("[1,2,3] all >= [0]"); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index a2110e51e..ce8b5e89b 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -2,6 +2,8 @@ import static org.junit.jupiter.api.Assertions.*; +import java.math.BigInteger; + import javax.inject.Inject; import org.eclipse.xtext.testing.InjectWith; @@ -14,7 +16,10 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.ListLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; @@ -85,6 +90,13 @@ public void equalityAnyFalseTest() { assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test + public void equalityAnyTwoListsTest() { + RosettaExpression expr = parser.parseExpression("[1,2,2] any = [1]"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + @Test public void equalityAnyTrueTest() { RosettaExpression expr = parser.parseExpression("[1,2,3] any = 2"); @@ -92,6 +104,19 @@ public void equalityAnyTrueTest() { assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test + public void equalityAnyErrorTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ANY\" keyword " + + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("2 any = 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(expectedError.getErrors(), + ((RosettaInterpreterErrorValue)val).getErrors()); + } + @Test public void errorThrownListTest() { RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( @@ -114,5 +139,6 @@ public void errorThrownAllElementsTest() { assertEquals(expectedError.getErrors(), ((RosettaInterpreterErrorValue)val).getErrors()); } + } From 3d6aecf09a19ee9ccfe6d8616e7bb458c7955f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Sun, 19 May 2024 22:37:24 +0300 Subject: [PATCH 051/236] Added simple tests --- .../RosettaInterpreterVisitor.java | 3 +- ...aInterpreterConditionalExpressionTest.java | 92 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 56da79e70..3dd4b6c58 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -13,6 +13,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; @@ -52,7 +53,7 @@ public RosettaInterpreterValue interp(ListLiteral exp) { @Override public RosettaInterpreterValue interp(RosettaConditionalExpression exp) { - return null; + return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java new file mode 100644 index 000000000..900e21169 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -0,0 +1,92 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaConditionalExpressionImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterConditionalExpressionTest { + + @Inject + private ExpressionParser parser; + + @Inject + RosettaInterpreterNew interpreter; + + private ExpressionFactory eFactory; + + @BeforeEach + public void setup() { + eFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void simpleTestInt() { + RosettaExpression expr = parser.parseExpression("if True then 1"); + RosettaInterpreterValue result = interpreter.interp(expr); + + BigInteger number = BigInteger.valueOf(1); + + assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); + } + + @Test + public void elseTest1Int() { + RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + BigInteger number = BigInteger.valueOf(2); + + assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); + } + + @Test + public void elseTest2Int() { + RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + BigInteger number = BigInteger.valueOf(1); + + assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); + } + + @Test + public void simpleTestString() { + RosettaExpression expr = parser.parseExpression("if True then \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals("abc", ((RosettaInterpreterStringValue) result).getValue()); + } + + @Test + public void simpleTestNumber() { + RosettaExpression expr = parser.parseExpression("if True then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + BigDecimal number = BigDecimal.valueOf(1.2); + + assertEquals(number, ((RosettaInterpreterNumberValue) result).getValue()); + } +} From 7172d15991758789877a7539fce9db97f72aea44 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 20 May 2024 09:37:23 +0200 Subject: [PATCH 052/236] Update RosettaInterpreterListLiteralInterpreter.java --- .../visitors/RosettaInterpreterListLiteralInterpreter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index c3ad64886..ace56deb2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -27,7 +27,7 @@ public RosettaInterpreterListValue interp(ListLiteral exp) { if (val instanceof RosettaInterpreterListValue) { interpretedExpressions.addAll(((RosettaInterpreterListValue)val).getExpressions()); } - else interpretedExpressions.add(e.accept(visitor)); + else interpretedExpressions.add(val); } From a711f41971f3ae1b3a79ddcda73b8c62e9ec80dd Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 20 May 2024 11:12:04 +0200 Subject: [PATCH 053/236] Changed implementation to allow for errors on both sides of logical operations --- ...nterpreterLogicalOperationInterpreter.java | 24 ++++-- ...settaInterpreterLogicalOperationsTest.java | 76 ++++++++++--------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index fbec2952a..d6b3e2130 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -1,5 +1,9 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -40,8 +44,11 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { else if(rightSideCheck == null) return leftSideCheck; else { // There were errors on both sides => Combine the error messages - RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(leftSideCheck.getErrors()); - newErrorValue.addAllErrors(rightSideCheck.getErrors()); + // ???????????? HERE, SHOULD I JUST CHECK THE LEFTSIDE? If we have the expression ("string" or (true and 0)), + // do we even check the rightside, or do we just say there was an error on the left? + RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(); + newErrorValue.addAllErrors(leftSideCheck); + newErrorValue.addAllErrors(rightSideCheck); return newErrorValue; } } @@ -52,7 +59,7 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { return new RosettaInterpreterBooleanValue(leftBoolean || rightBoolean); } else { // Wrong logical operator -> only "and" / "or" supported - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: Wrong operator - try 'and' / 'or'")); + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: Wrong operator - only 'and' / 'or' supported")); } } @@ -65,17 +72,18 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { * @return The correct RosettaInterpreterErrorValue, or "null" if the interpretedValue does not cause an error */ private RosettaInterpreterErrorValue checkForErrors(RosettaInterpreterValue interpretedValue, String side) { - if(interpretedValue instanceof RosettaInterpreterErrorValue) { + if(interpretedValue instanceof RosettaInterpreterBooleanValue) { + // No errors found + return null; + } else if(interpretedValue instanceof RosettaInterpreterErrorValue) { // The interpreted value was an error (so we need to add a new error message to the existing ones) RosettaInterpreterErrorValue oldErrorValue = (RosettaInterpreterErrorValue) interpretedValue; RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is an error value")); - newErrorValue.addAllErrors(oldErrorValue.getErrors()); + newErrorValue.addAllErrors(oldErrorValue); return newErrorValue; - } else if (!(interpretedValue instanceof RosettaInterpreterBooleanValue)) { + } else { // The interpreted value was not an error, but something other than a boolean return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is not of type Boolean")); } - - return null; } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index 0913d5c20..b83bf8ec7 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -1,5 +1,14 @@ package com.regnosys.rosetta.interpreternew; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + import org.eclipse.emf.common.util.EList; import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.extensions.InjectionExtension; @@ -7,11 +16,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import com.regnosys.rosetta.tests.RosettaInjectorProvider; -import com.regnosys.rosetta.tests.util.ExpressionParser; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; @@ -21,13 +28,8 @@ import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -import static org.junit.jupiter.api.Assertions.*; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -72,7 +74,6 @@ private void compareErrors(List expected, EList expected, EList expected = new ArrayList(); - expected.add(new RosettaInterpreterError("Logical Operation: Wrong operator - try 'and' / 'or'")); + expected.add(new RosettaInterpreterError("Logical Operation: Wrong operator - only 'and' / 'or' supported")); RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); @@ -144,25 +141,30 @@ public void notBooleanValueTest() { compareErrors(expected, castedResult.getErrors()); } -// @Test -// public void errorsOnBothSidesTest() { -// List expected = new ArrayList(); -// // The order of these might be wrong, I am not sure if they which order they get added in, -// // but I assume they get added from the inside, as they get propagated to the out-most expression -// expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); -// expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); -// expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); -// -// RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); -// RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); -// LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); -// -// RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); -// LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); -// -// RosettaInterpreterValue result = interpreter.interp(nestedExpr); -// assertTrue(result instanceof RosettaInterpreterErrorValue); -// RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; -// compareErrors(expected, castedResult.getErrors()); -// } + @Test + public void errorsOnBothSidesTest() { + List expected = new ArrayList(); + // The order of these might be wrong, I am not sure if they which order they get added in + // The way I did it now, it technically gets more specific the further you go, + // so for the example below, it will first say (True or 1) is an error value, and then say that 1 is not a boolean + + // This is the case: ("string" and (True or 1)) + expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); + expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); + expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); + + RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); + intLiteral.setValue(BigInteger.valueOf(1)); + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); + + RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); + stringLiteral.setValue("string"); + LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); + + RosettaInterpreterValue result = interpreter.interp(nestedExpr); + assertTrue(result instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; + compareErrors(expected, castedResult.getErrors()); + } } From 518d2ad8b499e80112c12c7ae394bca6e12411db Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 20 May 2024 11:12:46 +0200 Subject: [PATCH 054/236] Forgot to click save for the last commit --- .../RosettaInterpreterLogicalOperationInterpreter.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index d6b3e2130..2aa331a93 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -1,9 +1,5 @@ package com.regnosys.rosetta.interpreternew.visitors; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; From 680786d980b4730b527039ea62dd190d0d7bd429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 20 May 2024 13:02:23 +0300 Subject: [PATCH 055/236] Added error handling and instance check --- ...settaConditionalExpressionInterpreter.java | 49 ++++++++++++++++--- ...aInterpreterConditionalExpressionTest.java | 15 ++++++ 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 46d63efc1..62f508a2e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -2,6 +2,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; @@ -23,24 +25,51 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { if (ifValue instanceof RosettaInterpreterBooleanValue) { ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); + } else if (ifValue instanceof RosettaInterpreterErrorValue) { + return createErrors(ifValue, "Conditional expression: condition is an error value."); } else { - // error + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is not a boolean value.")); } if (ifResult == true) { - return checkInstance(ifThenValue); + RosettaInterpreterBaseValue result = checkInstance(ifThenValue, false); + + if (expr.isFull()) { + RosettaExpression elseThen = expr.getElsethen(); + RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); + + RosettaInterpreterBaseValue elseInstance = checkInstance(elseThenValue, true); + + if (!result.getClass().equals(elseInstance.getClass())) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + } + } + return result; } else if (expr.isFull()) { RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); - return checkInstance(elseThenValue); + RosettaInterpreterBaseValue result = checkInstance(elseThenValue, true); + RosettaInterpreterBaseValue ifInstance = checkInstance(ifThenValue, true); + + if (!result.getClass().equals(ifInstance.getClass())) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + } + return result; } return null; } - private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr) { + private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr, boolean branch) { RosettaInterpreterBaseValue result = null; + String message = null; + + if (branch == false) { + message = "consequent"; + } else { + message = "alternative"; + } if (expr instanceof RosettaInterpreterBooleanValue) { result = new RosettaInterpreterBooleanValue(((RosettaInterpreterBooleanValue) expr).getValue()); @@ -52,10 +81,18 @@ private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr) result = new RosettaInterpreterStringValue(((RosettaInterpreterStringValue) expr).getValue()); } else if (expr instanceof RosettaInterpreterListValue) { result = new RosettaInterpreterListValue(((RosettaInterpreterListValue) expr).getExpressions()); - } else { - // error + } else if (expr instanceof RosettaInterpreterErrorValue) { + result = createErrors(expr, "Conditional expression: " + message + " is an error value"); } return result; } + + private RosettaInterpreterBaseValue createErrors(RosettaInterpreterValue exp, String message) { + RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) exp; + RosettaInterpreterErrorValue newExpError = new RosettaInterpreterErrorValue(new RosettaInterpreterError(message)); + + newExpError.addAllErrors(expError); + return newExpError; + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 900e21169..415593c0d 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; @@ -89,4 +91,17 @@ public void simpleTestNumber() { assertEquals(number, ((RosettaInterpreterNumberValue) result).getValue()); } + + @Test + public void notSameType() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + + RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + + } } From 252e057eca086719353b49c24015f4c40e936b31 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 20 May 2024 12:18:49 +0200 Subject: [PATCH 056/236] Added error utils for dealing with error propagation --- .../values/RosettaInterpreterErrorValue.java | 87 ++++++++++++- rosetta-testing/pom.xml | 6 + .../RosettaInterpreterErrorValueTest.java | 121 ++++++++++++++++++ 3 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 2eb5a1854..6e7d398ed 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; @@ -37,8 +38,90 @@ public boolean addError(RosettaInterpreterBaseError error) { public boolean addAllErrors(RosettaInterpreterErrorValue other) { return errors.addAll(other.getErrors()); } + public boolean addAllErrors(RosettaInterpreterValue other) { + if (!(other instanceof RosettaInterpreterErrorValue)) return false; + return errors.addAll(((RosettaInterpreterErrorValue)other).getErrors()); + } - public boolean addAllErrors(EList errors) { - return errors.addAll(errors); + public boolean addAllErrors(List errors) { + return this.errors.addAll(errors); + } + + /** + * Checks if there is at least one error within the supplied values + * @param val1 + * @param val2 + * @return + */ + public static boolean errorsExist(RosettaInterpreterValue val1, RosettaInterpreterValue val2) { + return val1 instanceof RosettaInterpreterErrorValue + || val2 instanceof RosettaInterpreterErrorValue; + } + + /** + * Checks if the supplied value is an error + * @param val1 + * @return + */ + public static boolean errorsExist(RosettaInterpreterValue val1) { + return val1 instanceof RosettaInterpreterErrorValue; } + + /** + * Checks if there is at least one error within the supplied values + * @param vals + * @return + */ + public static boolean errorsExist(List vals) { + for(RosettaInterpreterValue v : vals) { + if (v instanceof RosettaInterpreterErrorValue) return true; + } + return false; + } + + /** + * Merges all errors existing within a list into one error value + * @param vals - list of values with at least one error value + * @return error value with all error messages + */ + public static RosettaInterpreterErrorValue merge(List vals) { + if (!errorsExist(vals)) throw new IllegalArgumentException("None of the values are errors"); + RosettaInterpreterErrorValue baseVal = new RosettaInterpreterErrorValue(); + + for(RosettaInterpreterValue val : vals) { + baseVal.addAllErrors(val); + } + + return baseVal; + } + + public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val) { + return merge(List.of(val)); + } + public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val1, RosettaInterpreterValue val2) { + return merge(List.of(val1, val2)); + } + + @Override + public String toString() { + return "RosettaInterpreterErrorValue [errors=" + errors + "]"; + } + + @Override + public int hashCode() { + return Objects.hash(errors); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RosettaInterpreterErrorValue other = (RosettaInterpreterErrorValue) obj; + return Objects.equals(errors, other.errors); + } + } diff --git a/rosetta-testing/pom.xml b/rosetta-testing/pom.xml index b57e2229e..aba724373 100644 --- a/rosetta-testing/pom.xml +++ b/rosetta-testing/pom.xml @@ -53,6 +53,12 @@ org.mdkt.compiler InMemoryJavaCompiler + + org.assertj + assertj-core + 3.24.2 + + diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java new file mode 100644 index 000000000..1c950ebde --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -0,0 +1,121 @@ +package com.regnosys.rosetta.interpreternew.value; + + +import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; + + + +class RosettaInterpreterErrorValueTest { + + RosettaInterpreterError e1; + RosettaInterpreterError e2; + RosettaInterpreterError e3; + RosettaInterpreterError e4; + RosettaInterpreterErrorValue v1; + RosettaInterpreterErrorValue v2; + RosettaInterpreterErrorValue v3; + RosettaInterpreterBooleanValue vb2; + RosettaInterpreterBooleanValue vb1; + List vals; + + @BeforeEach + void setup() { + e1 = new RosettaInterpreterError("e1"); + e2 = new RosettaInterpreterError("e2"); + e3 = new RosettaInterpreterError("e3"); + e4 = new RosettaInterpreterError("e4"); + v1 = new RosettaInterpreterErrorValue(e1); + v2 = new RosettaInterpreterErrorValue(e2); + v3 = new RosettaInterpreterErrorValue(e3); + vb1 = new RosettaInterpreterBooleanValue(true); + vb2 = new RosettaInterpreterBooleanValue(false); + vals = new ArrayList<>(List.of(v1,v2,v3,vb1,vb2)); + } + + @Test + void testGetErrors() { + assertEquals(List.of(e1), v1.getErrors()); + } + + @Test + void testAddError() { + v1.addError(e2); + assertEquals(List.of(e1,e2), v1.getErrors()); + } + + @Test + void testAddAllErrorsRosettaInterpreterErrorValue() { + v1.addError(e2); + v3.addAllErrors(v1); + assertThat(v3.getErrors()).containsExactlyInAnyOrderElementsOf(List.of(e1,e2,e3)); + } + + @Test + void testAddAllErrorsRosettaInterpreterValue() { + v1.addError(e2); + v3.addAllErrors(((RosettaInterpreterValue)v1)); + assertThat(v3.getErrors()).containsExactlyInAnyOrderElementsOf(List.of(e1,e2,e3)); + } + + @Test + void testAddAllErrorsEListOfRosettaInterpreterBaseError() { + v3.addAllErrors(List.of(e1,e2)); + assertThat(v3.getErrors()).containsExactlyInAnyOrderElementsOf(List.of(e1,e2,e3)); + } + + @Test + void testErrorsExistRosettaInterpreterValueRosettaInterpreterValue() { + assertTrue(RosettaInterpreterErrorValue.errorsExist(v2, vb2)); + assertFalse(RosettaInterpreterErrorValue.errorsExist(vb1, vb2)); + } + + @Test + void testErrorsExistRosettaInterpreterValue() { + assertTrue(RosettaInterpreterErrorValue.errorsExist(v2)); + assertFalse(RosettaInterpreterErrorValue.errorsExist(vb1)); + } + + @Test + void testErrorsExistListOfRosettaInterpreterValue() { + assertTrue(RosettaInterpreterErrorValue.errorsExist(vals)); + vals.remove(v1); + vals.remove(v2); + vals.remove(v3); + assertFalse(RosettaInterpreterErrorValue.errorsExist(vals)); + } + + @Test + void testMergeListOfRosettaInterpreterValue() { + RosettaInterpreterErrorValue val = new RosettaInterpreterErrorValue(); + val.addAllErrors(List.of(e1,e2,e3)); + + assertEquals(val, RosettaInterpreterErrorValue.merge(vals)); + } + + @Test + void testMergeRosettaInterpreterValue() { + RosettaInterpreterErrorValue val = new RosettaInterpreterErrorValue(e2); + assertEquals(val, RosettaInterpreterErrorValue.merge(v2)); + } + + @Test + void testMergeRosettaInterpreterValueRosettaInterpreterValue() { + RosettaInterpreterErrorValue val = new RosettaInterpreterErrorValue(); + val.addAllErrors(List.of(e2, e3)); + + assertEquals(val, RosettaInterpreterErrorValue.merge(v2, v3)); + } + +} From 15a3b9af8402be60f0add3c8f86caddec7f8e963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 20 May 2024 13:44:27 +0300 Subject: [PATCH 057/236] Added more tests for 100% branch coverage --- ...settaConditionalExpressionInterpreter.java | 6 +- ...aInterpreterConditionalExpressionTest.java | 108 ++++++++++++++++-- 2 files changed, 104 insertions(+), 10 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 62f508a2e..4b4a09ca8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -40,7 +40,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { RosettaInterpreterBaseValue elseInstance = checkInstance(elseThenValue, true); - if (!result.getClass().equals(elseInstance.getClass())) { + if (!result.getClass().equals(elseInstance.getClass()) && !(result instanceof RosettaInterpreterErrorValue) && !(elseInstance instanceof RosettaInterpreterErrorValue)) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); } } @@ -52,7 +52,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { RosettaInterpreterBaseValue result = checkInstance(elseThenValue, true); RosettaInterpreterBaseValue ifInstance = checkInstance(ifThenValue, true); - if (!result.getClass().equals(ifInstance.getClass())) { + if (!result.getClass().equals(ifInstance.getClass()) && !(result instanceof RosettaInterpreterErrorValue) && !(ifInstance instanceof RosettaInterpreterErrorValue)) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); } return result; @@ -82,7 +82,7 @@ private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr, } else if (expr instanceof RosettaInterpreterListValue) { result = new RosettaInterpreterListValue(((RosettaInterpreterListValue) expr).getExpressions()); } else if (expr instanceof RosettaInterpreterErrorValue) { - result = createErrors(expr, "Conditional expression: " + message + " is an error value"); + result = createErrors(expr, "Conditional expression: " + message + " is an error value."); } return result; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 415593c0d..5ef407926 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -5,6 +5,7 @@ import java.math.BigDecimal; import java.math.BigInteger; +import java.util.List; import javax.inject.Inject; @@ -14,15 +15,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaConditionalExpressionImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; @@ -45,7 +47,7 @@ public void setup() { } @Test - public void simpleTestInt() { + public void integerTest() { RosettaExpression expr = parser.parseExpression("if True then 1"); RosettaInterpreterValue result = interpreter.interp(expr); @@ -55,7 +57,7 @@ public void simpleTestInt() { } @Test - public void elseTest1Int() { + public void integerElseTest() { RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); RosettaInterpreterValue result = interpreter.interp(expr); @@ -65,7 +67,7 @@ public void elseTest1Int() { } @Test - public void elseTest2Int() { + public void integerThenTest() { RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); RosettaInterpreterValue result = interpreter.interp(expr); @@ -75,7 +77,15 @@ public void elseTest2Int() { } @Test - public void simpleTestString() { + public void booleanTest() { + RosettaExpression expr = parser.parseExpression("if True then False"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(false, ((RosettaInterpreterBooleanValue) result).getValue()); + } + + @Test + public void stringTest() { RosettaExpression expr = parser.parseExpression("if True then \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); @@ -83,7 +93,7 @@ public void simpleTestString() { } @Test - public void simpleTestNumber() { + public void numberTest() { RosettaExpression expr = parser.parseExpression("if True then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); @@ -93,7 +103,46 @@ public void simpleTestNumber() { } @Test - public void notSameType() { + public void listTest() { + RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); + RosettaInterpreterValue result = interpreter.interp(expr); + + RosettaInterpreterIntegerValue one = new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)); + RosettaInterpreterIntegerValue two = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)); + + List list = List.of(one, two); + + assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); + } + + @Test + public void errorThenTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent is an error value.")); + expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void errorElseTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: alternative is an error value.")); + expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void notSameTypeThenTest() { RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); @@ -102,6 +151,51 @@ public void notSameType() { assertEquals(expected.getErrors(), errorResult.getErrors()); assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void notSameTypeElseTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + + RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void conditionNotBooleanTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is not a boolean value.")); + + RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); } + + @Test + public void conditionErrorTypeTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is an error value.")); + expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void noElseTest() { + RosettaExpression expr = parser.parseExpression("if False then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(null, result); + } + } From 1652a47136f56ff915cdaed4bd487d699237c339 Mon Sep 17 00:00:00 2001 From: Antonio Lupu Date: Mon, 20 May 2024 13:45:16 +0200 Subject: [PATCH 058/236] Update RosettaInterpreterVisitor.java --- .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index eb98f1c50..3f980feea 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -24,7 +24,7 @@ public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ @Override - public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral exp) { + public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp); } From 1355ed83f70b3bdff2f71a616ae6622bc1187748 Mon Sep 17 00:00:00 2001 From: Antonio Lupu Date: Mon, 20 May 2024 13:45:38 +0200 Subject: [PATCH 059/236] Update RosettaInterpreterNewTest.java --- .../rosetta/interpreternew/RosettaInterpreterNewTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java index b41829413..2780dc7a2 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; -import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From eb46f38e47c1e61a65ca47b6d35a84e67c5eb0b6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 20 May 2024 13:52:43 +0200 Subject: [PATCH 060/236] Changed some things according to code reviews + Changed propagation to not add useless errors --- .../RosettaInterpreterLogicalOperationInterpreter.java | 7 +------ .../RosettaInterpreterLogicalOperationsTest.java | 5 ----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index 2aa331a93..daba23bec 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -40,8 +40,6 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { else if(rightSideCheck == null) return leftSideCheck; else { // There were errors on both sides => Combine the error messages - // ???????????? HERE, SHOULD I JUST CHECK THE LEFTSIDE? If we have the expression ("string" or (true and 0)), - // do we even check the rightside, or do we just say there was an error on the left? RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(); newErrorValue.addAllErrors(leftSideCheck); newErrorValue.addAllErrors(rightSideCheck); @@ -73,10 +71,7 @@ private RosettaInterpreterErrorValue checkForErrors(RosettaInterpreterValue inte return null; } else if(interpretedValue instanceof RosettaInterpreterErrorValue) { // The interpreted value was an error (so we need to add a new error message to the existing ones) - RosettaInterpreterErrorValue oldErrorValue = (RosettaInterpreterErrorValue) interpretedValue; - RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is an error value")); - newErrorValue.addAllErrors(oldErrorValue); - return newErrorValue; + return (RosettaInterpreterErrorValue) interpretedValue; } else { // The interpreted value was not an error, but something other than a boolean return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is not of type Boolean")); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index b83bf8ec7..9ebd0262a 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -144,13 +144,8 @@ public void notBooleanValueTest() { @Test public void errorsOnBothSidesTest() { List expected = new ArrayList(); - // The order of these might be wrong, I am not sure if they which order they get added in - // The way I did it now, it technically gets more specific the further you go, - // so for the example below, it will first say (True or 1) is an error value, and then say that 1 is not a boolean - // This is the case: ("string" and (True or 1)) expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); - expected.add(new RosettaInterpreterError("Logical Operation: Rightside is an error value")); expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); From a117a1fe39cbafb6c8baede476715a58844172d6 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 20 May 2024 16:08:35 +0200 Subject: [PATCH 061/236] Added stream conversion for each value class --- rosetta-lang/model/RosettaExpression.xcore | 24 ++++++ rosetta-lang/model/RosettaInterpreter.xcore | 17 ++++ .../RosettaInterpreterVisitor.java | 56 +++++++++++++ .../values/RosettaInterpreterBaseValue.java | 55 ++++++++++-- .../RosettaInterpreterBooleanValue.java | 25 ++++-- .../values/RosettaInterpreterError.java | 14 ++-- .../values/RosettaInterpreterErrorValue.java | 83 ++++++++++++++----- .../RosettaInterpreterIntegerValue.java | 27 ++++-- .../values/RosettaInterpreterListValue.java | 22 ++++- .../values/RosettaInterpreterNumberValue.java | 25 +++++- .../values/RosettaInterpreterStringValue.java | 23 ++++- 11 files changed, 315 insertions(+), 56 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 0472bd12a..b4f7a4db4 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -246,13 +246,22 @@ class ComparisonOperation extends ModifiableBinaryOperation { } class RosettaContainsExpression extends RosettaBinaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaDisjointExpression extends RosettaBinaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class JoinOperation extends RosettaBinaryOperation { boolean explicitSeparator + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } /** @@ -306,15 +315,24 @@ enum ExistsModifier { class RosettaExistsExpression extends RosettaUnaryOperation { ExistsModifier modifier + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaAbsentExpression extends RosettaUnaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class RosettaOnlyElement extends ListOperation { } class RosettaCountOperation extends RosettaUnaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class FlattenOperation extends ListOperation, CanHandleListOfLists { @@ -327,9 +345,15 @@ class ReverseOperation extends ListOperation { } class FirstOperation extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class LastOperation extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class SumOperation extends ListOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 74d08276f..6c4452a37 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -13,12 +13,21 @@ import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral import com.regnosys.rosetta.rosetta.expression.ListLiteral import com.regnosys.rosetta.rosetta.expression.EqualityOperation import com.regnosys.rosetta.rosetta.expression.ComparisonOperation +import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression +import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression +import com.regnosys.rosetta.rosetta.expression.JoinOperation +import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression +import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression +import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation +import com.regnosys.rosetta.rosetta.expression.FirstOperation +import com.regnosys.rosetta.rosetta.expression.LastOperation class RosettaInterpreterBaseError{ String message } abstract class RosettaInterpreterValue { + } interface InterpreterVisitor { @@ -30,4 +39,12 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (ListLiteral exp) op RosettaInterpreterValue interp (EqualityOperation exp) op RosettaInterpreterValue interp (ComparisonOperation exp) + op RosettaInterpreterValue interp (RosettaContainsExpression exp) + op RosettaInterpreterValue interp (RosettaDisjointExpression exp) + op RosettaInterpreterValue interp (JoinOperation exp) + op RosettaInterpreterValue interp (RosettaExistsExpression exp) + op RosettaInterpreterValue interp (RosettaAbsentExpression exp) + op RosettaInterpreterValue interp (RosettaCountOperation exp) + op RosettaInterpreterValue interp (FirstOperation exp) + op RosettaInterpreterValue interp (LastOperation exp) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 0ba78e8ac..f521c8a26 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -2,8 +2,16 @@ import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.EqualityOperation; +import com.regnosys.rosetta.rosetta.expression.FirstOperation; +import com.regnosys.rosetta.rosetta.expression.JoinOperation; +import com.regnosys.rosetta.rosetta.expression.LastOperation; import com.regnosys.rosetta.rosetta.expression.ListLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; @@ -61,4 +69,52 @@ public RosettaInterpreterValue interp(ComparisonOperation exp) { return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } + @Override + public RosettaInterpreterValue interp(RosettaContainsExpression exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(JoinOperation exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaExistsExpression exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaCountOperation exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(FirstOperation exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(LastOperation exp) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 1a5806da3..020695cf2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -1,12 +1,10 @@ package com.regnosys.rosetta.interpreternew.values; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; +import java.util.stream.Stream; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EClass; @@ -16,11 +14,58 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ +public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue { + + /** + * Converts a Value to a Stream of the elements it contains. + * This is done this way and not defined inside of RosettaInterpreterValue + * because xcore does not seem to have a notion of streams + * + * @return stream of elements of this value + */ + public abstract Stream toElementStream(); + + /** + * Converts a Value to a Stream of itself or the values it contains. + * This is done this way and not defined inside of RosettaInterpreterValue + * because xcore does not seem to have a notion of streams + * + * @return stream of this value or values it contains + */ + public abstract Stream toValueStream(); + + /** + * Converts a value to a stream of its elements. + * + * @param val - value to extract stream out of + * @return a stream of elements iff val is a RosettaInterpreterBaseValue + */ + public static Stream elementStream(RosettaInterpreterValue val) { + if (!(val instanceof RosettaInterpreterBaseValue)) { + throw new RosettaInterpreterNewException("Cannot take element stream" + + "of RosettaInterpreterValue"); + } + return ((RosettaInterpreterBaseValue)val).toElementStream(); + } + + /** + * Converts a value to a stream of itself or its contained values. + * + * @param val - value to convert + * @return stream of value or its contained values + */ + public static Stream valueStream(RosettaInterpreterValue val){ + if (!(val instanceof RosettaInterpreterBaseValue)) { + throw new RosettaInterpreterNewException("Cannot take value stream" + + "of RosettaInterpreterValue"); + } + return ((RosettaInterpreterBaseValue)val).toValueStream(); + } + @Override public EClass eClass() { // TODO Auto-generated method stub diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index 60f63e60d..0f97b35fc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -1,14 +1,12 @@ package com.regnosys.rosetta.interpreternew.values; import java.util.Objects; +import java.util.stream.Stream; -import org.eclipse.emf.common.util.EList; - -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterBooleanValue extends RosettaInterpreterBaseValue - implements Comparable{ + implements Comparable { private boolean value; public RosettaInterpreterBooleanValue(boolean value) { @@ -25,12 +23,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterBooleanValue other = (RosettaInterpreterBooleanValue) obj; return value == other.value; } @@ -40,6 +41,16 @@ public int compareTo(RosettaInterpreterBooleanValue o) { return Boolean.compare(this.value, o.value); } + @Override + public Stream toElementStream() { + return Stream.of(value); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } + diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index 888d0c28d..f4e82f92c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -16,7 +16,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; -public class RosettaInterpreterError implements RosettaInterpreterBaseError{ +public class RosettaInterpreterError implements RosettaInterpreterBaseError { @Override public int hashCode() { return Objects.hash(errorMessage); @@ -24,12 +24,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterError other = (RosettaInterpreterError) obj; return Objects.equals(errorMessage, other.errorMessage); } @@ -133,7 +136,8 @@ public void eUnset(EStructuralFeature feature) { } @Override - public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + public Object eInvoke(EOperation operation, EList arguments) + throws InvocationTargetException { // TODO Auto-generated method stub return null; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 6e7d398ed..7c531fa89 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -3,14 +3,16 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Stream; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue{ +public class RosettaInterpreterErrorValue extends RosettaInterpreterBaseValue { List errors; public RosettaInterpreterErrorValue() { @@ -27,7 +29,7 @@ public RosettaInterpreterErrorValue(List errors) { errors.addAll(errors); } - public EList getErrors(){ + public EList getErrors() { return new BasicEList(errors); } @@ -38,8 +40,17 @@ public boolean addError(RosettaInterpreterBaseError error) { public boolean addAllErrors(RosettaInterpreterErrorValue other) { return errors.addAll(other.getErrors()); } + + /** + * Adds all errors from another value if its an error. + * + * @param other - value to add errors from + * @return true iff other is an error and errors were added successfully + */ public boolean addAllErrors(RosettaInterpreterValue other) { - if (!(other instanceof RosettaInterpreterErrorValue)) return false; + if (!(other instanceof RosettaInterpreterErrorValue)) { + return false; + } return errors.addAll(((RosettaInterpreterErrorValue)other).getErrors()); } @@ -48,47 +59,56 @@ public boolean addAllErrors(List errors) { } /** - * Checks if there is at least one error within the supplied values - * @param val1 - * @param val2 - * @return + * Checks if there is at least one error within the supplied values. + * + * @param val1 - first value to check + * @param val2 - second value to check + * @return true iff at least one of the values is an error value */ - public static boolean errorsExist(RosettaInterpreterValue val1, RosettaInterpreterValue val2) { + public static boolean errorsExist(RosettaInterpreterValue val1, + RosettaInterpreterValue val2) { return val1 instanceof RosettaInterpreterErrorValue || val2 instanceof RosettaInterpreterErrorValue; } /** - * Checks if the supplied value is an error - * @param val1 - * @return + * Checks if the supplied value is an error. + * + * @param val1 - value to check + * @return true iff value is an error value */ public static boolean errorsExist(RosettaInterpreterValue val1) { return val1 instanceof RosettaInterpreterErrorValue; } /** - * Checks if there is at least one error within the supplied values - * @param vals - * @return + * Checks if there is at least one error within the supplied values. + * + * @param vals - list of values to check + * @return true iff at least one of the values is an error */ public static boolean errorsExist(List vals) { - for(RosettaInterpreterValue v : vals) { - if (v instanceof RosettaInterpreterErrorValue) return true; + for (RosettaInterpreterValue v : vals) { + if (v instanceof RosettaInterpreterErrorValue) { + return true; + } } return false; } /** - * Merges all errors existing within a list into one error value + * Merges all errors existing within a list into one error value. + * * @param vals - list of values with at least one error value * @return error value with all error messages */ public static RosettaInterpreterErrorValue merge(List vals) { - if (!errorsExist(vals)) throw new IllegalArgumentException("None of the values are errors"); + if (!errorsExist(vals)) { + throw new IllegalArgumentException("None of the values are errors"); + } RosettaInterpreterErrorValue baseVal = new RosettaInterpreterErrorValue(); - for(RosettaInterpreterValue val : vals) { + for (RosettaInterpreterValue val : vals) { baseVal.addAllErrors(val); } @@ -98,7 +118,9 @@ public static RosettaInterpreterErrorValue merge(List v public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val) { return merge(List.of(val)); } - public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val1, RosettaInterpreterValue val2) { + + public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val1, + RosettaInterpreterValue val2) { return merge(List.of(val1, val2)); } @@ -114,14 +136,29 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterErrorValue other = (RosettaInterpreterErrorValue) obj; return Objects.equals(errors, other.errors); } + + @Override + public Stream toElementStream() { + throw new RosettaInterpreterNewException("You should not be trying to take" + + " a stream of element of an error value"); + } + + @Override + public Stream toValueStream() { + throw new RosettaInterpreterNewException("You should not be trying to take" + + " a stream of an error value"); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index b7b37058e..fbf0b29df 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -2,9 +2,15 @@ import java.math.BigInteger; import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue implements Comparable { + + private BigInteger value; + @Override public int hashCode() { return Objects.hash(value); @@ -12,18 +18,19 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; return Objects.equals(value, other.value); } - private BigInteger value; - public RosettaInterpreterIntegerValue(BigInteger value) { super(); this.value = value; @@ -35,4 +42,14 @@ public RosettaInterpreterIntegerValue(BigInteger value) { public int compareTo(RosettaInterpreterIntegerValue o) { return this.value.compareTo(o.value); } + + @Override + public Stream toElementStream() { + return Stream.of(value); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 1783fd0b5..704df4774 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -1,8 +1,9 @@ package com.regnosys.rosetta.interpreternew.values; + import java.util.List; import java.util.Objects; +import java.util.stream.Stream; -import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterListValue extends RosettaInterpreterBaseValue { @@ -25,15 +26,28 @@ public String toString() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterListValue other = (RosettaInterpreterListValue) obj; return Objects.equals(expressions, other.expressions); } public List getExpressions() { return expressions; } + + @Override + public Stream toElementStream() { + return Stream.of(expressions.toArray()); + } + + @Override + public Stream toValueStream() { + return expressions.stream(); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 45c9ddbf2..a0a2e7166 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -2,9 +2,13 @@ import java.math.BigDecimal; import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue - implements Comparable{ + implements Comparable { + private BigDecimal value; public RosettaInterpreterNumberValue(BigDecimal value) { @@ -21,12 +25,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterNumberValue other = (RosettaInterpreterNumberValue) obj; return Objects.equals(value, other.value); } @@ -35,5 +42,15 @@ public boolean equals(Object obj) { public int compareTo(RosettaInterpreterNumberValue o) { return this.value.compareTo(o.value); } + + @Override + public Stream toElementStream() { + return Stream.of(value); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index 5c90e037f..0bc0e075a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -1,9 +1,13 @@ package com.regnosys.rosetta.interpreternew.values; import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterStringValue extends RosettaInterpreterBaseValue implements Comparable { + private String value; public RosettaInterpreterStringValue(String value) { @@ -20,12 +24,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterStringValue other = (RosettaInterpreterStringValue) obj; return Objects.equals(value, other.value); } @@ -43,5 +50,15 @@ else if (compareValue > 0) { return 0; } } + + @Override + public Stream toElementStream() { + return Stream.of(value); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } } From 8a43fa119b44c81b2e33996d9a8d4cd5ba47263e Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 20 May 2024 17:12:40 +0200 Subject: [PATCH 062/236] Added contains operation support --- .../RosettaInterpreterVisitor.java | 4 +- .../RosettaInterpreterBooleanValue.java | 7 +- ...aInterpreterListOperationsInterpreter.java | 51 ++++++++++++ ...erpreterListOperationsInterpreterTest.java | 80 +++++++++++++++++++ 4 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index f521c8a26..3d45e5660 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -21,6 +21,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; @@ -71,8 +72,7 @@ public RosettaInterpreterValue interp(ComparisonOperation exp) { @Override public RosettaInterpreterValue interp(RosettaContainsExpression exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index 0f97b35fc..7db729c43 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -51,7 +51,8 @@ public Stream toValueStream() { return Stream.of(this); } - - - + @Override + public String toString() { + return "RosettaInterpreterBooleanValue [value=" + value + "]"; + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java new file mode 100644 index 000000000..58c226e42 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -0,0 +1,51 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.HashSet; +import java.util.stream.Collectors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterListOperationsInterpreter + extends RosettaInterpreterConcreteInterpreter { + + + /** + * Interprets a rosetta contains expression. + * Checks if the right element, which may be a single element or a list, + * is contained within the left list + * + * @param exp - expression to evaluate + * @return value of contains expression + */ + public RosettaInterpreterValue interp(RosettaContainsExpression exp) { + RosettaExpression leftExp = exp.getLeft(); + RosettaExpression rightExp = exp.getRight(); + + RosettaInterpreterValue leftVal = leftExp.accept(visitor); + RosettaInterpreterValue rightVal = rightExp.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(leftVal, rightVal)) { + return RosettaInterpreterErrorValue.merge(leftVal, rightVal); + } + + if (RosettaInterpreterBaseValue.valueStream(rightVal).count() < 1L || + RosettaInterpreterBaseValue.valueStream(leftVal).count() < 1L) { + return new RosettaInterpreterBooleanValue(false); + } + + HashSet leftValueSet = new HashSet<>( + RosettaInterpreterBaseValue.valueStream(leftVal) + .collect(Collectors.toList())); + + boolean contains = RosettaInterpreterBaseValue.valueStream(rightVal) + .allMatch(x -> leftValueSet.contains(x)); + + return new RosettaInterpreterBooleanValue(contains); + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java new file mode 100644 index 000000000..a3871af45 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -0,0 +1,80 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ExpressionValidationHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +class RosettaInterpreterListOperationsInterpreterTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + @Inject + private ExpressionValidationHelper validation; + + private ExpressionFactory expFactory; + + @BeforeEach + public void setup() { + expFactory = ExpressionFactoryImpl.init(); + } + + private void testHelper(RosettaInterpreterValue expected, String[] expressions) { + List expressionsParsed = Stream.of(expressions) + .map(x -> parser.parseExpression(x)) + .collect(Collectors.toList()); + expressionsParsed.stream().forEach(x -> validation.assertNoIssues(x)); + expressionsParsed.stream().forEach(x -> { + assertEquals(expected, + interpreter.interp(x)); + }); + } + + @Test + void testInterpContains() { + String[] expressionsTrue = new String[] { + "[1,2,3] contains [1,2]", + "[1] contains 1", + "[2, [3]] contains [2, 3]", + "[2] contains [2, 2]", + "False contains False" + }; + testHelper(new RosettaInterpreterBooleanValue(true), expressionsTrue); + + String[] expressionsFalse = new String[] { + "[1,2,3] contains [1,2,3,4]", + "[] contains 1", + "[2] contains [2, 3]", + "[2] contains [2, 2, 3]", + "[1,2] contains []", + "[] contains []", + "[] contains 1", + "2 contains 1" + }; + testHelper(new RosettaInterpreterBooleanValue(false), expressionsFalse); + } + +} From 968a33f0af1236236040346306e47373c4455f12 Mon Sep 17 00:00:00 2001 From: MARIA Cristescu Date: Mon, 20 May 2024 17:19:56 +0200 Subject: [PATCH 063/236] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: MARIA Cristescu --- .../interpreternew/values/RosettaInterpreterErrorValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 6e7d398ed..41faef7db 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -74,7 +74,7 @@ public static boolean errorsExist(RosettaInterpreterValue val1) { */ public static boolean errorsExist(List vals) { for(RosettaInterpreterValue v : vals) { - if (v instanceof RosettaInterpreterErrorValue) return true; + if (errorsExist(v)) return true; } return false; } From 233e0566c58db2af414d8d84afc19f7a8f10accb Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 20 May 2024 17:22:00 +0200 Subject: [PATCH 064/236] Update RosettaInterpreterErrorValue.java --- .../values/RosettaInterpreterErrorValue.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 41faef7db..f4ff74841 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -54,8 +54,7 @@ public boolean addAllErrors(List errors) { * @return */ public static boolean errorsExist(RosettaInterpreterValue val1, RosettaInterpreterValue val2) { - return val1 instanceof RosettaInterpreterErrorValue - || val2 instanceof RosettaInterpreterErrorValue; + return errorsExist(List.of(val1, val2)); } /** @@ -64,7 +63,7 @@ public static boolean errorsExist(RosettaInterpreterValue val1, RosettaInterpret * @return */ public static boolean errorsExist(RosettaInterpreterValue val1) { - return val1 instanceof RosettaInterpreterErrorValue; + return errorsExist(List.of(val1)); } /** @@ -74,7 +73,9 @@ public static boolean errorsExist(RosettaInterpreterValue val1) { */ public static boolean errorsExist(List vals) { for(RosettaInterpreterValue v : vals) { - if (errorsExist(v)) return true; + if (v instanceof RosettaInterpreterErrorValue) { + return true; + } } return false; } From fd40b462f3478325a616bfdee23cf646fdde4c44 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Mon, 20 May 2024 17:54:23 +0200 Subject: [PATCH 065/236] Improved code maintainability in Comparison class --- ...rpreterComparisonOperationInterpreter.java | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 7c6bc8f9f..c0a7d409d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; @@ -21,6 +22,17 @@ public class RosettaInterpreterComparisonOperationInterpreter extends private static List comparisonOperators = Arrays.asList("<", "<=", ">", ">=", "=", "<>"); + private static List comparableClasses = + Arrays.asList( + "com.regnosys.rosetta.interpreternew.values." + + "RosettaInterpreterBooleanValue", + "com.regnosys.rosetta.interpreternew.values." + + "RosettaInterpreterIntegerValue", + "com.regnosys.rosetta.interpreternew.values." + + "RosettaInterpreterNumberValue", + "com.regnosys.rosetta.interpreternew.values." + + "RosettaInterpreterStringValue"); + /** * Interprets a comparison operation, evaluating the comparison between two operands. * @@ -204,56 +216,50 @@ private boolean checkComparableTypes(RosettaInterpreterValue leftValue, String operator) { int comparisonResult = 2; - //compare integers - if (leftValue instanceof RosettaInterpreterIntegerValue - && rightValue instanceof RosettaInterpreterIntegerValue) { - RosettaInterpreterIntegerValue leftInt = - (RosettaInterpreterIntegerValue) leftValue; - RosettaInterpreterIntegerValue rightInt = - (RosettaInterpreterIntegerValue) rightValue; - - comparisonResult = leftInt.compareTo(rightInt); - } - //compare booleans - else if (leftValue instanceof RosettaInterpreterBooleanValue - && rightValue instanceof RosettaInterpreterBooleanValue) { - RosettaInterpreterBooleanValue leftBool = - (RosettaInterpreterBooleanValue) leftValue; - RosettaInterpreterBooleanValue rightBool = - (RosettaInterpreterBooleanValue) rightValue; - - comparisonResult = leftBool.compareTo(rightBool); - } + boolean isComparable = false; - //compare strings - else if (leftValue instanceof RosettaInterpreterStringValue - && rightValue instanceof RosettaInterpreterStringValue) { - RosettaInterpreterStringValue leftString = - (RosettaInterpreterStringValue) leftValue; - RosettaInterpreterStringValue rightString = - (RosettaInterpreterStringValue) rightValue; - - comparisonResult = leftString.compareTo(rightString); - } + //left and right will be of type comparableClazz + Class comparableClazz = null; - //compare numbers - else if (leftValue instanceof RosettaInterpreterNumberValue - && rightValue instanceof RosettaInterpreterNumberValue) { - RosettaInterpreterNumberValue leftNumber = - (RosettaInterpreterNumberValue) leftValue; - RosettaInterpreterNumberValue rightNumber = - (RosettaInterpreterNumberValue) rightValue; - - comparisonResult = leftNumber.compareTo(rightNumber); + try { + for (String clazzString : comparableClasses) { + Class clazz = Class.forName(clazzString); + + //check that both expressions are of the same type + boolean isInstance = (clazz.isInstance(leftValue) + && clazz.isInstance(rightValue)); + if (isInstance) { + comparableClazz = clazz; + } + isComparable |= isInstance; + } + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + System.out.println("Not a class"); + e.printStackTrace(); } - + if (isComparable) { + try { + //compare the two expressions + comparisonResult = (int) comparableClazz + .getDeclaredMethod("compareTo",comparableClazz) + .invoke(leftValue, rightValue); + } catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException + | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return compareComparableValues(comparisonResult, operator); } private boolean compareComparableValues(int comparisonResult, String operator) { + if(comparisonResult == 2) return false; switch (operator) { case "=": return comparisonResult == 0; From 0c9e422c21f21d65fbe8c3316e291d69fb06eab9 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Mon, 20 May 2024 17:56:49 +0200 Subject: [PATCH 066/236] Checkstyle fix --- .../RosettaInterpreterComparisonOperationInterpreter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index c0a7d409d..ef147161f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -8,10 +8,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ModifiableBinaryOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -259,7 +256,9 @@ private boolean checkComparableTypes(RosettaInterpreterValue leftValue, } private boolean compareComparableValues(int comparisonResult, String operator) { - if(comparisonResult == 2) return false; + if (comparisonResult == 2) { + return false; + } switch (operator) { case "=": return comparisonResult == 0; From 1c797d2eddcd0db32f350326da241b2182f84daa Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 21 May 2024 10:38:48 +0200 Subject: [PATCH 067/236] Added join support --- .../RosettaInterpreterVisitor.java | 6 +- ...aInterpreterListOperationsInterpreter.java | 94 ++++++++++++++++++- ...erpreterListOperationsInterpreterTest.java | 30 ++++++ 3 files changed, 124 insertions(+), 6 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 3d45e5660..221f281c4 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -77,14 +77,12 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { @Override public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(JoinOperation exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 58c226e42..e119bfff9 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -5,8 +5,12 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -33,8 +37,8 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { return RosettaInterpreterErrorValue.merge(leftVal, rightVal); } - if (RosettaInterpreterBaseValue.valueStream(rightVal).count() < 1L || - RosettaInterpreterBaseValue.valueStream(leftVal).count() < 1L) { + if (RosettaInterpreterBaseValue.valueStream(rightVal).count() < 1L + || RosettaInterpreterBaseValue.valueStream(leftVal).count() < 1L) { return new RosettaInterpreterBooleanValue(false); } @@ -47,5 +51,91 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { return new RosettaInterpreterBooleanValue(contains); } + + /** + * Interprets a rosetta disjoint expression. + * Checks if the right element, which may be a single element or a list, + * is not contained within the left list + * + * @param exp - expression to evaluate + * @return value of contains expression + */ + public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { + RosettaExpression leftExp = exp.getLeft(); + RosettaExpression rightExp = exp.getRight(); + + RosettaInterpreterValue leftVal = leftExp.accept(visitor); + RosettaInterpreterValue rightVal = rightExp.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(leftVal, rightVal)) { + return RosettaInterpreterErrorValue.merge(leftVal, rightVal); + } + + if (RosettaInterpreterBaseValue.valueStream(rightVal).count() < 1L + || RosettaInterpreterBaseValue.valueStream(leftVal).count() < 1L) { + return new RosettaInterpreterBooleanValue(true); + } + + HashSet rightValueSet = new HashSet<>( + RosettaInterpreterBaseValue.valueStream(rightVal) + .collect(Collectors.toList())); + + boolean notContains = RosettaInterpreterBaseValue.valueStream(leftVal) + .allMatch(x -> !rightValueSet.contains(x)); + + return new RosettaInterpreterBooleanValue(notContains); + } + + /** + * Interprets a join operation. + * Join takes as input a list of strings and a delimiter + * Then returns a single string of the strings concatenated with the join operator + * + * @param exp - join operation to interpret + * @return concatenated string + */ + public RosettaInterpreterValue interp(JoinOperation exp) { + RosettaExpression stringsExp = exp.getLeft(); + RosettaExpression delimExp = exp.getRight(); + + RosettaInterpreterValue stringsVal = stringsExp.accept(visitor); + RosettaInterpreterValue delimVal = delimExp.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(stringsVal, delimVal)) { + return RosettaInterpreterErrorValue.merge(stringsVal, delimVal); + } + + boolean allStrings = RosettaInterpreterBaseValue.valueStream(stringsVal) + .allMatch(x -> x instanceof RosettaInterpreterStringValue); + + if (!allStrings) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The list of values for a join " + + "operation must be a list of strings")); + } + if (!(delimVal instanceof RosettaInterpreterStringValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The delimiter for a join" + + " operation must be a string")); + } + String delimString = ((RosettaInterpreterStringValue)delimVal).getValue(); + + RosettaInterpreterStringValue result = + RosettaInterpreterBaseValue.valueStream(stringsVal) + .map(x -> (RosettaInterpreterStringValue)x) + .reduce(new RosettaInterpreterStringValue("dummy please ignore"), + (x,y) -> { + if (x.getValue().equals("dummy" + + " please ignore")) { + return new RosettaInterpreterStringValue(y.getValue()); + } + return new RosettaInterpreterStringValue( + x.getValue() + + delimString + + y.getValue()); + }); + + return result; + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index a3871af45..d8779cf73 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; @@ -76,5 +77,34 @@ void testInterpContains() { }; testHelper(new RosettaInterpreterBooleanValue(false), expressionsFalse); } + + @Test + void testInterpDisjoint() { + String[] expressionsTrue = new String[] { + "[1,2,3] disjoint [4]", + "[1,2,[3]] disjoint []", + "[] disjoint [1]", + "[1,2,3,4] disjoint [0,5,6,7,8]" + }; + testHelper(new RosettaInterpreterBooleanValue(true), expressionsTrue); + + String[] expressionsFalse = new String[] { + "[1] disjoint [1]", + "[1,2,3,4] disjoint [4]", + "[2] disjoint [1,2,3,4,5,6,7]", + "[1,2,3,4,5,6,7] disjoint [1,2,3,4,5,6,7]" + }; + testHelper(new RosettaInterpreterBooleanValue(false), expressionsFalse); + } + + @Test + void testInterpJoin() { + String msg = "[\"abc\", \"cde\"] join \", \""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterStringValue val = + (RosettaInterpreterStringValue)interpreter.interp(msgExp); + assertEquals("abc, cde", val.getValue()); + } } From 56db1ea5c879092bec59e922ca5571aa8e0ac1d1 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 21 May 2024 11:04:14 +0200 Subject: [PATCH 068/236] Checkstyle fixed --- .../interpreternew/RosettaInterpreterNew.java | 8 +-- .../RosettaInterpreterNewException.java | 2 +- .../RosettaInterpreterVisitor.java | 2 +- .../RosettaInterpreterVisitorBase.java | 3 +- ...RosettaInterpreterConcreteInterpreter.java | 1 - ...ettaInterpreterListLiteralInterpreter.java | 21 ++++--- ...reterRosettaBooleanLiteralInterpreter.java | 3 +- ...terpreterRosettaIntLiteralInterpreter.java | 3 +- ...preterRosettaNumberLiteralInterpreter.java | 3 +- ...preterRosettaStringLiteralInterpreter.java | 3 +- .../RosettaInterpreterComparisonTest.java | 10 ++-- .../RosettaInterpreterEqualityTest.java | 10 +--- .../RosettaInterpreterErrorTest.java | 22 +------- .../RosettaInterpreterLiteralsTest.java | 55 ++++++++++++------- .../RosettaInterpreterNewTest.java | 37 ------------- .../RosettaInterpreterErrorValueTest.java | 2 +- 16 files changed, 77 insertions(+), 108 deletions(-) delete mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index 87a957b12..b648dce0a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -2,9 +2,7 @@ import javax.inject.Inject; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterNew { @@ -13,8 +11,10 @@ public class RosettaInterpreterNew { private RosettaInterpreterVisitor visitor; /** - * Simple example interpret function to allow for better understanding of the development workflow - * @param expression + * Simple example interpret function to allow for better understanding + * of the development workflow. + * + * @param expression the expression to be interpreted * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java index df7fb5820..f1847f83a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java @@ -1,6 +1,6 @@ package com.regnosys.rosetta.interpreternew; -public class RosettaInterpreterNewException extends RuntimeException{ +public class RosettaInterpreterNewException extends RuntimeException { private static final long serialVersionUID = 1L; public RosettaInterpreterNewException(String message) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 0ba78e8ac..6c1a5eeb4 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -18,7 +18,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; -public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase{ +public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase { @Override public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java index 429f3b193..82ca1aa5d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java @@ -101,7 +101,8 @@ public void eUnset(EStructuralFeature feature) { } @Override - public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + public Object eInvoke(EOperation operation, EList arguments) + throws InvocationTargetException { // TODO Auto-generated method stub return null; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java index 4a9c18d92..d8f0b0896 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java @@ -3,7 +3,6 @@ import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitorBase; public abstract class RosettaInterpreterConcreteInterpreter { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index ace56deb2..422717588 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -2,32 +2,39 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Stream; - -import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterListLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { +public class RosettaInterpreterListLiteralInterpreter + extends RosettaInterpreterConcreteInterpreter { public RosettaInterpreterListLiteralInterpreter() { super(); } + /** + * Interprets a list literal, evaluating it to a list value. + * + * @param exp the expression to be interpreted + * @return the list value it represents + */ public RosettaInterpreterListValue interp(ListLiteral exp) { List expressions = exp.getElements(); List interpretedExpressions = new ArrayList<>(); - for(RosettaExpression e : expressions) { + for (RosettaExpression e : expressions) { RosettaInterpreterValue val = e.accept(visitor); if (val instanceof RosettaInterpreterListValue) { - interpretedExpressions.addAll(((RosettaInterpreterListValue)val).getExpressions()); + interpretedExpressions.addAll( + ((RosettaInterpreterListValue)val) + .getExpressions()); + } else { + interpretedExpressions.add(val); } - else interpretedExpressions.add(val); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java index 9c5fa8c31..aa6b30340 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java @@ -3,7 +3,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; -public class RosettaInterpreterRosettaBooleanLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ +public class RosettaInterpreterRosettaBooleanLiteralInterpreter + extends RosettaInterpreterConcreteInterpreter { public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr) { return new RosettaInterpreterBooleanValue(expr.isValue()); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java index bfcfc8693..a317a36d0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java @@ -3,7 +3,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; -public class RosettaInterpreterRosettaIntLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ +public class RosettaInterpreterRosettaIntLiteralInterpreter + extends RosettaInterpreterConcreteInterpreter { public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr) { return new RosettaInterpreterIntegerValue(expr.getValue()); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java index 5e732140a..150f0b689 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java @@ -3,7 +3,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; -public class RosettaInterpreterRosettaNumberLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { +public class RosettaInterpreterRosettaNumberLiteralInterpreter + extends RosettaInterpreterConcreteInterpreter { public RosettaInterpreterNumberValue interp(RosettaNumberLiteral exp) { return new RosettaInterpreterNumberValue(exp.getValue()); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java index 823b9d0a2..0799bef9d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java @@ -3,7 +3,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; -public class RosettaInterpreterRosettaStringLiteralInterpreter extends RosettaInterpreterConcreteInterpreter{ +public class RosettaInterpreterRosettaStringLiteralInterpreter + extends RosettaInterpreterConcreteInterpreter { public RosettaInterpreterStringValue interp(RosettaStringLiteral exp) { return new RosettaInterpreterStringValue(exp.getValue()); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 3ff78e7d3..9f22a578f 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -30,11 +30,12 @@ public class RosettaInterpreterComparisonTest { @Inject RosettaInterpreterNew interpreter; - private ExpressionFactory eFactory; + @SuppressWarnings("unused") + private ExpressionFactory exFactory; @BeforeEach public void setup() { - eFactory = ExpressionFactoryImpl.init(); + exFactory = ExpressionFactoryImpl.init(); } @Test @@ -112,8 +113,9 @@ public void errorThrownAllElementsTest() { assertEquals(expectedError.getErrors(), (errorVal.getErrors())); - assertEquals(((RosettaInterpreterError) expectedError.getErrors().get(0)).getError(), - (((RosettaInterpreterError) (errorVal.getErrors().get(0))).getError())); + assertEquals(((RosettaInterpreterError)expectedError.getErrors().get(0)).getError(), + (((RosettaInterpreterError)(errorVal.getErrors().get(0))) + .getError())); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index ce8b5e89b..16a79f2e6 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -2,8 +2,6 @@ import static org.junit.jupiter.api.Assertions.*; -import java.math.BigInteger; - import javax.inject.Inject; import org.eclipse.xtext.testing.InjectWith; @@ -16,10 +14,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; -import com.regnosys.rosetta.rosetta.expression.ListLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; @@ -34,11 +29,12 @@ public class RosettaInterpreterEqualityTest { @Inject RosettaInterpreterNew interpreter; - private ExpressionFactory eFactory; + @SuppressWarnings("unused") + private ExpressionFactory exFactory; @BeforeEach public void setup() { - eFactory = ExpressionFactoryImpl.init(); + exFactory = ExpressionFactoryImpl.init(); } @Test diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java index 7aed49d30..b534bef0c 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java @@ -2,42 +2,25 @@ import static org.junit.jupiter.api.Assertions.*; -import java.math.BigDecimal; -import java.math.BigInteger; import java.util.List; -import javax.inject.Inject; - import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.extensions.InjectionExtension; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; -import com.regnosys.rosetta.rosetta.expression.ListLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; -import com.regnosys.rosetta.tests.util.ExpressionParser; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) public class RosettaInterpreterErrorTest { @Test - public void SimpleErrorTest() { + public void simpleErrorTest() { RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); RosettaInterpreterError e2 = new RosettaInterpreterError("e2"); - List el = List.of(e1, e2); RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(); RosettaInterpreterErrorValue val2 = new RosettaInterpreterErrorValue(); @@ -47,11 +30,12 @@ public void SimpleErrorTest() { val1.addAllErrors(val2); + List el = List.of(e1, e2); assertEquals(el, val1.getErrors()); } @Test - public void ErrorMessageExists() { + public void errorMessageExists() { RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(e1); assertEquals("e1", val1.getErrors().get(0).getMessage()); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 835676f54..4383fddcb 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -37,79 +37,92 @@ public class RosettaInterpreterLiteralsTest { @Inject private ExpressionValidationHelper validation; - private ExpressionFactory eFactory; + @SuppressWarnings("unused") + private ExpressionFactory exFactory; @BeforeEach public void setup() { - eFactory = ExpressionFactoryImpl.init(); + exFactory = ExpressionFactoryImpl.init(); } @Test - public void BooleanTest() { + public void booleanTest() { RosettaExpression expr = parser.parseExpression("True"); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(true, ((RosettaInterpreterBooleanValue)val).getValue()); } @Test - public void ListTest() { + public void listTest() { RosettaExpression expr = parser.parseExpression("[1,2]"); validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)))); + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(2)))); assertEquals(expected, val); } @Test - public void NestedListTest() { + public void nestedListTest() { RosettaExpression expr = parser.parseExpression("[1,[2,3]]"); validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)))); + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(2)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(3)))); assertEquals(expected, val); } @Test - public void VeryNestedListTest() { + public void veryNestedListTest() { RosettaExpression expr = parser.parseExpression("[1,[2,[3, [4, [5]]]]]"); validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(4)), - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)))); + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(1)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(2)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(3)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(4)), + new RosettaInterpreterIntegerValue( + BigInteger.valueOf(5)))); assertEquals(expected, val); } @Test - public void IntTest() { + public void intTest() { RosettaExpression expr = parser.parseExpression("5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(BigInteger.valueOf(5), ((RosettaInterpreterIntegerValue)val).getValue()); + assertEquals(BigInteger.valueOf(5), + ((RosettaInterpreterIntegerValue)val).getValue()); } @Test - public void NumberTest() { + public void numberTest() { RosettaExpression expr = parser.parseExpression("5.5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(BigDecimal.valueOf(5.5), ((RosettaInterpreterNumberValue)val).getValue()); + assertEquals(BigDecimal.valueOf(5.5), + ((RosettaInterpreterNumberValue)val).getValue()); } @Test - public void StringTest() { + public void stringTest() { RosettaExpression expr = parser.parseExpression("\"hello\""); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals("hello", ((RosettaInterpreterStringValue)val).getValue()); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java deleted file mode 100644 index 2780dc7a2..000000000 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.regnosys.rosetta.interpreternew; - -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.extensions.InjectionExtension; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import com.regnosys.rosetta.tests.RosettaInjectorProvider; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; -import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; -import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; -import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; - -import static org.junit.jupiter.api.Assertions.*; -import javax.inject.Inject; - -import java.math.BigInteger; - -@ExtendWith(InjectionExtension.class) -@InjectWith(RosettaInjectorProvider.class) -public class RosettaInterpreterNewTest { - - @Inject - RosettaInterpreterNew interpreter; - - private ExpressionFactory eFactory; - - @BeforeEach - public void setup() { - eFactory = ExpressionFactoryImpl.init(); - } - -} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index 1c950ebde..b58452b26 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -70,7 +70,7 @@ void testAddAllErrorsRosettaInterpreterValue() { } @Test - void testAddAllErrorsEListOfRosettaInterpreterBaseError() { + void testAddAllErrorsElistOfRosettaInterpreterBaseError() { v3.addAllErrors(List.of(e1,e2)); assertThat(v3.getErrors()).containsExactlyInAnyOrderElementsOf(List.of(e1,e2,e3)); } From 69be2a78320f67ebb63d1ffed1f3b10cf525f6e4 Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 21 May 2024 11:05:49 +0200 Subject: [PATCH 069/236] Refactored method to use error utils --- ...nterpreterLogicalOperationInterpreter.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index daba23bec..638880a3f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -1,5 +1,7 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.List; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -7,6 +9,7 @@ import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; public class RosettaInterpreterLogicalOperationInterpreter extends RosettaInterpreterConcreteInterpreter{ @@ -26,27 +29,26 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { RosettaInterpreterValue leftInterpreted = left.accept(visitor); RosettaInterpreterValue rightInterpreted = right.accept(visitor); + Boolean errorLeftSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); + Boolean errorRightSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); + if(leftInterpreted instanceof RosettaInterpreterBooleanValue && rightInterpreted instanceof RosettaInterpreterBooleanValue) { leftBoolean = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); rightBoolean = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); - } else { + } else if(errorLeftSide || errorRightSide) { // Check for errors in the left or right side of the binary operation - RosettaInterpreterErrorValue leftSideCheck = checkForErrors(leftInterpreted, "Leftside"); - RosettaInterpreterErrorValue rightSideCheck = checkForErrors(rightInterpreted, "Rightside"); - // Null means there were no errors on that side - if(leftSideCheck == null) return rightSideCheck; - else if(rightSideCheck == null) return leftSideCheck; - else { + if(errorLeftSide == false) return (RosettaInterpreterErrorValue) rightInterpreted; + else if(errorRightSide == false) return (RosettaInterpreterErrorValue) leftInterpreted; + else { // There were errors on both sides => Combine the error messages - RosettaInterpreterErrorValue newErrorValue = new RosettaInterpreterErrorValue(); - newErrorValue.addAllErrors(leftSideCheck); - newErrorValue.addAllErrors(rightSideCheck); - return newErrorValue; + return RosettaInterpreterErrorValue.merge(List.of(leftInterpreted, rightInterpreted)); } + } else { // The interpreted value was not an error, but something other than a boolean + return makeNewError(leftInterpreted, rightInterpreted); } - + if(expr.getOperator().equals("and")) { return new RosettaInterpreterBooleanValue(leftBoolean && rightBoolean); } else if(expr.getOperator().equals("or")) { @@ -65,16 +67,15 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { * @param side String containing either "Leftside" or "Rightside", purely for clearer error messages * @return The correct RosettaInterpreterErrorValue, or "null" if the interpretedValue does not cause an error */ - private RosettaInterpreterErrorValue checkForErrors(RosettaInterpreterValue interpretedValue, String side) { - if(interpretedValue instanceof RosettaInterpreterBooleanValue) { - // No errors found - return null; - } else if(interpretedValue instanceof RosettaInterpreterErrorValue) { - // The interpreted value was an error (so we need to add a new error message to the existing ones) - return (RosettaInterpreterErrorValue) interpretedValue; - } else { - // The interpreted value was not an error, but something other than a boolean - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: " + side + " is not of type Boolean")); + private RosettaInterpreterErrorValue makeNewError(RosettaInterpreterValue left, RosettaInterpreterValue right) { + RosettaInterpreterErrorValue newError = new RosettaInterpreterErrorValue(); + if(!(left instanceof RosettaInterpreterBooleanValue)) { + newError.addError(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); } + if(!(right instanceof RosettaInterpreterBooleanValue)) { + newError.addError(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); + } + + return newError; } } From e26f0666c328e4377f8b8ed11e9234669ed6c5a6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 21 May 2024 11:13:49 +0200 Subject: [PATCH 070/236] Fixed checkstyle --- ...nterpreterLogicalOperationInterpreter.java | 69 +++++++++++-------- ...settaInterpreterLogicalOperationsTest.java | 33 +++++---- 2 files changed, 61 insertions(+), 41 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index 638880a3f..9479e4a56 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -9,19 +9,19 @@ import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -public class RosettaInterpreterLogicalOperationInterpreter extends RosettaInterpreterConcreteInterpreter{ +public class RosettaInterpreterLogicalOperationInterpreter + extends RosettaInterpreterConcreteInterpreter { /** * Interpreter method for Logical Operations. - * + * * @param expr LogicalOperaation to be interpreted * @return The interpreted value */ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { - boolean leftBoolean = false; - boolean rightBoolean = false; + boolean leftBool = false; + boolean rightBool = false; RosettaExpression left = expr.getLeft(); @@ -32,48 +32,61 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { Boolean errorLeftSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); Boolean errorRightSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); - if(leftInterpreted instanceof RosettaInterpreterBooleanValue + if (leftInterpreted instanceof RosettaInterpreterBooleanValue && rightInterpreted instanceof RosettaInterpreterBooleanValue) { - leftBoolean = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); - rightBoolean = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); - } else if(errorLeftSide || errorRightSide) { + leftBool = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); + rightBool = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); + } else if (errorLeftSide || errorRightSide) { // Check for errors in the left or right side of the binary operation - if(errorLeftSide == false) return (RosettaInterpreterErrorValue) rightInterpreted; - else if(errorRightSide == false) return (RosettaInterpreterErrorValue) leftInterpreted; + if (errorLeftSide == false) { + return (RosettaInterpreterErrorValue) rightInterpreted; + } + else if (errorRightSide == false) { + return (RosettaInterpreterErrorValue) leftInterpreted; + } else { // There were errors on both sides => Combine the error messages - return RosettaInterpreterErrorValue.merge(List.of(leftInterpreted, rightInterpreted)); + return RosettaInterpreterErrorValue + .merge(List.of(leftInterpreted, rightInterpreted)); } - } else { // The interpreted value was not an error, but something other than a boolean + } else { // The interpreted value was not error, but something other than a boolean return makeNewError(leftInterpreted, rightInterpreted); } - if(expr.getOperator().equals("and")) { - return new RosettaInterpreterBooleanValue(leftBoolean && rightBoolean); - } else if(expr.getOperator().equals("or")) { - return new RosettaInterpreterBooleanValue(leftBoolean || rightBoolean); + if (expr.getOperator().equals("and")) { + return new RosettaInterpreterBooleanValue(leftBool && rightBool); + } else if (expr.getOperator().equals("or")) { + return new RosettaInterpreterBooleanValue(leftBool || rightBool); } else { // Wrong logical operator -> only "and" / "or" supported - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Logical Operation: Wrong operator - only 'and' / 'or' supported")); + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Logical Operation: Wrong operator " + + "- only 'and' / 'or' supported")); } } /** - * Helper method that takes an interpretedValue and a string, and returns the correct error which - * that interpretedValue causes, if any. - * + * Helper method that takes an interpretedValue and a string, + * and returns the correct error which that interpretedValue causes, if any. + * * @param interpretedValue The interpreted value which we check for errors - * @param side String containing either "Leftside" or "Rightside", purely for clearer error messages - * @return The correct RosettaInterpreterErrorValue, or "null" if the interpretedValue does not cause an error + * @param side String containing either "Leftside" or "Rightside", + * purely for clearer error messages + * @return The correct RosettaInterpreterErrorValue, + * or "null" if the interpretedValue does not cause an error */ - private RosettaInterpreterErrorValue makeNewError(RosettaInterpreterValue left, RosettaInterpreterValue right) { + private RosettaInterpreterErrorValue makeNewError( + RosettaInterpreterValue left, RosettaInterpreterValue right) { RosettaInterpreterErrorValue newError = new RosettaInterpreterErrorValue(); - if(!(left instanceof RosettaInterpreterBooleanValue)) { - newError.addError(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); + if (!(left instanceof RosettaInterpreterBooleanValue)) { + newError.addError(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); } - if(!(right instanceof RosettaInterpreterBooleanValue)) { - newError.addError(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); + if (!(right instanceof RosettaInterpreterBooleanValue)) { + newError.addError(new RosettaInterpreterError( + "Logical Operation: Rightside is not of type Boolean")); } return newError; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index 9ebd0262a..4340923c5 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -41,23 +41,24 @@ public class RosettaInterpreterLogicalOperationsTest { @Inject RosettaInterpreterNew interpreter; - private ExpressionFactory eFactory; + private ExpressionFactory exFactory; @BeforeEach public void setup() { - eFactory = ExpressionFactoryImpl.init(); + exFactory = ExpressionFactoryImpl.init(); } // ------------- Helper Methods ------------- private RosettaBooleanLiteral createBooleanLiteral(boolean value) { - RosettaBooleanLiteral literal = eFactory.createRosettaBooleanLiteral(); + RosettaBooleanLiteral literal = exFactory.createRosettaBooleanLiteral(); literal.setValue(value); return literal; } - private LogicalOperation createLogicalOperation(String operator, RosettaExpression left, RosettaExpression right) { - LogicalOperation operation = eFactory.createLogicalOperation(); + private LogicalOperation createLogicalOperation( + String operator, RosettaExpression left, RosettaExpression right) { + LogicalOperation operation = exFactory.createLogicalOperation(); operation.setOperator(operator); operation.setLeft(left); operation.setRight(right); @@ -70,9 +71,11 @@ private void assertBooleanResult(RosettaInterpreterValue result, boolean expecte assertEquals(expected, boolResult.getValue()); } - private void compareErrors(List expected, EList errors) { + private void compareErrors( + List expected, + EList errors) { assertEquals(expected.size(), errors.size()); - for(int i = 0; i < expected.size(); i++) { + for (int i = 0; i < expected.size(); i++) { RosettaInterpreterError newError = (RosettaInterpreterError) errors.get(i); assertEquals(expected.get(i).getError(), newError.getError()); } @@ -117,7 +120,8 @@ public void nestedBooleansLogicalTest() { @Test public void wrongOperatorTest() { List expected = new ArrayList(); - expected.add(new RosettaInterpreterError("Logical Operation: Wrong operator - only 'and' / 'or' supported")); + expected.add(new RosettaInterpreterError( + "Logical Operation: Wrong operator - only 'and' / 'or' supported")); RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); @@ -132,7 +136,8 @@ public void wrongOperatorTest() { @Test public void notBooleanValueTest() { List expected = new ArrayList(); - expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); + expected.add(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); RosettaExpression expr = parser.parseExpression("1 and False"); RosettaInterpreterValue result = interpreter.interp(expr); @@ -145,15 +150,17 @@ public void notBooleanValueTest() { public void errorsOnBothSidesTest() { List expected = new ArrayList(); // This is the case: ("string" and (True or 1)) - expected.add(new RosettaInterpreterError("Logical Operation: Leftside is not of type Boolean")); - expected.add(new RosettaInterpreterError("Logical Operation: Rightside is not of type Boolean")); + expected.add(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); + expected.add(new RosettaInterpreterError( + "Logical Operation: Rightside is not of type Boolean")); - RosettaIntLiteral intLiteral = eFactory.createRosettaIntLiteral(); + RosettaIntLiteral intLiteral = exFactory.createRosettaIntLiteral(); intLiteral.setValue(BigInteger.valueOf(1)); RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); - RosettaStringLiteral stringLiteral = eFactory.createRosettaStringLiteral(); + RosettaStringLiteral stringLiteral = exFactory.createRosettaStringLiteral(); stringLiteral.setValue("string"); LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); From 40666746fa9849ceb4df7412f5632cc1735f2912 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 21 May 2024 11:59:31 +0200 Subject: [PATCH 071/236] Fixed list comparison functionality + tests --- ...rpreterComparisonOperationInterpreter.java | 58 ++----------------- .../RosettaInterpreterComparisonTest.java | 7 ++- .../RosettaInterpreterEqualityTest.java | 7 ++- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index ef147161f..b635fd539 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -86,32 +86,9 @@ private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { - - //only way this is allowed is if rightValue has a length of 1 - // and left has length more than 1 - RosettaInterpreterListValue rgtList = - (RosettaInterpreterListValue) rightValue; - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - if (rgtList.getExpressions().size() == 1 - && lfList.getExpressions().size() > 1) { - - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean anyTrue = false; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - anyTrue |= checkComparableTypes(e, - rgtList.getExpressions().get(0), - operator); - } - return new RosettaInterpreterBooleanValue(anyTrue); - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot compare two lists")); - } + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } //list vs element case: @@ -150,32 +127,9 @@ private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { - - //only way this is allowed is if rightValue has a length of 1 - // and left has length more than 1 - RosettaInterpreterListValue rgtList = - (RosettaInterpreterListValue) rightValue; - RosettaInterpreterListValue lfList = - (RosettaInterpreterListValue) leftValue; - if (rgtList.getExpressions().size() == 1 - && lfList.getExpressions().size() > 1) { - - - //for all elements in left list, check if the comparison - // between them and right-hand side is true - boolean allTrue = true; - for (RosettaInterpreterValue e : lfList.getExpressions()) { - allTrue &= checkComparableTypes(e, - rgtList.getExpressions().get(0), - operator); - } - return new RosettaInterpreterBooleanValue(allTrue); - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot compare two lists")); - } + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); } //list vs element case: diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 3ff78e7d3..316fa4e83 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -67,9 +67,14 @@ public void booleanLessEqualTest() { @Test public void cardinalityAllListsTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); RosettaExpression expr = parser.parseExpression("[1,2,3] all >= [0]"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + assertEquals(expectedError.getErrors().get(0).getMessage(), + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); } @Test diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index ce8b5e89b..f9ee4d346 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -92,9 +92,14 @@ public void equalityAnyFalseTest() { @Test public void equalityAnyTwoListsTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot compare two lists")); RosettaExpression expr = parser.parseExpression("[1,2,2] any = [1]"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + assertEquals(expectedError.getErrors().get(0).getMessage(), + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); } @Test From a301db55d1f41ad1bddab057b10c530bd12b9d73 Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 21 May 2024 12:02:49 +0200 Subject: [PATCH 072/236] Fixed faulty implementation --- ...nterpreterLogicalOperationInterpreter.java | 64 +++++++++---------- ...settaInterpreterLogicalOperationsTest.java | 21 ++++++ 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index 9479e4a56..f5bc60e8a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -23,35 +23,23 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { boolean leftBool = false; boolean rightBool = false; - RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); RosettaInterpreterValue leftInterpreted = left.accept(visitor); RosettaInterpreterValue rightInterpreted = right.accept(visitor); - Boolean errorLeftSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); - Boolean errorRightSide = RosettaInterpreterErrorValue.errorsExist(leftInterpreted); - if (leftInterpreted instanceof RosettaInterpreterBooleanValue && rightInterpreted instanceof RosettaInterpreterBooleanValue) { leftBool = ((RosettaInterpreterBooleanValue) leftInterpreted).getValue(); rightBool = ((RosettaInterpreterBooleanValue) rightInterpreted).getValue(); - } else if (errorLeftSide || errorRightSide) { + } else { // Check for errors in the left or right side of the binary operation + RosettaInterpreterErrorValue leftErrors = + checkForErrors(leftInterpreted, "Leftside"); + RosettaInterpreterErrorValue rightErrors = + checkForErrors(rightInterpreted, "Rightside"); - if (errorLeftSide == false) { - return (RosettaInterpreterErrorValue) rightInterpreted; - } - else if (errorRightSide == false) { - return (RosettaInterpreterErrorValue) leftInterpreted; - } - else { - // There were errors on both sides => Combine the error messages - return RosettaInterpreterErrorValue - .merge(List.of(leftInterpreted, rightInterpreted)); - } - } else { // The interpreted value was not error, but something other than a boolean - return makeNewError(leftInterpreted, rightInterpreted); + return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); } if (expr.getOperator().equals("and")) { @@ -68,27 +56,33 @@ else if (errorRightSide == false) { } /** - * Helper method that takes an interpretedValue and a string, - * and returns the correct error which that interpretedValue causes, if any. + * Helper method that takes an interpretedValue and a string + * , and returns the correct error which + * that interpretedValue causes, if any. * * @param interpretedValue The interpreted value which we check for errors * @param side String containing either "Leftside" or "Rightside", - * purely for clearer error messages - * @return The correct RosettaInterpreterErrorValue, - * or "null" if the interpretedValue does not cause an error + * purely for clearer error messages + * @return The correct RosettaInterpreterErrorValue, or "null" + * if the interpretedValue does not cause an error */ - private RosettaInterpreterErrorValue makeNewError( - RosettaInterpreterValue left, RosettaInterpreterValue right) { - RosettaInterpreterErrorValue newError = new RosettaInterpreterErrorValue(); - if (!(left instanceof RosettaInterpreterBooleanValue)) { - newError.addError(new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); - } - if (!(right instanceof RosettaInterpreterBooleanValue)) { - newError.addError(new RosettaInterpreterError( - "Logical Operation: Rightside is not of type Boolean")); + private RosettaInterpreterErrorValue checkForErrors( + RosettaInterpreterValue interpretedValue, String side) { + if (interpretedValue instanceof RosettaInterpreterBooleanValue) { + // No errors found. + // I return an error value without any errors in its list, + // So that I can still use the merge method with 2 elements + return new RosettaInterpreterErrorValue(); + } else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { + // The interpreted value was an error so we propagate it + return (RosettaInterpreterErrorValue) interpretedValue; + } else { + // The interpreted value was not an error, + // but something other than a boolean + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Logical Operation: " + side + + " is not of type Boolean")); } - - return newError; } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index 4340923c5..5685f7919 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -146,6 +146,27 @@ public void notBooleanValueTest() { compareErrors(expected, castedResult.getErrors()); } + @Test + public void errorOnRightSideTest() { + List expected = new ArrayList(); + // This is the case: (False and (True or 1)) + expected.add(new RosettaInterpreterError( + "Logical Operation: Rightside is not of type Boolean")); + + RosettaIntLiteral intLiteral = exFactory.createRosettaIntLiteral(); + intLiteral.setValue(BigInteger.valueOf(1)); + RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); + LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); + + RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); + LogicalOperation nestedExpr = createLogicalOperation("and", falseLiteral, expr); + + RosettaInterpreterValue result = interpreter.interp(nestedExpr); + assertTrue(result instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; + compareErrors(expected, castedResult.getErrors()); + } + @Test public void errorsOnBothSidesTest() { List expected = new ArrayList(); From a28b425232b8d5185731d98ead0693bf691fb9c2 Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 21 May 2024 12:10:42 +0200 Subject: [PATCH 073/236] Fixed branch coverage --- .../RosettaInterpreterLogicalOperationsTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index 5685f7919..2d5ee49d8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -95,20 +95,27 @@ public void logicalAndInterpTestTrue() { RosettaInterpreterValue result = interpreter.interp(expr); assertBooleanResult(result, true); } - + @Test public void logicalOrInterpTestTrue() { RosettaExpression expr = parser.parseExpression("True or False"); RosettaInterpreterValue result = interpreter.interp(expr); assertBooleanResult(result, true); } + + @Test + public void logicalOrInterpTestTrue2() { + RosettaExpression expr = parser.parseExpression("False or True"); + RosettaInterpreterValue result = interpreter.interp(expr); + assertBooleanResult(result, true); + } @Test public void logicalOrInterpTestFalse() { RosettaExpression expr = parser.parseExpression("False or False"); RosettaInterpreterValue result = interpreter.interp(expr); assertBooleanResult(result, false); - } + } @Test public void nestedBooleansLogicalTest() { From 4a787646afa5bc500b5f2b6f3b4a23985bfa44af Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 21 May 2024 12:29:28 +0200 Subject: [PATCH 074/236] Fixed javadoc text --- .../RosettaInterpreterLogicalOperationInterpreter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index f5bc60e8a..d1c1f7646 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -56,9 +56,9 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr) { } /** - * Helper method that takes an interpretedValue and a string - * , and returns the correct error which - * that interpretedValue causes, if any. + * Helper method that takes an interpretedValue and a string, + * and returns the correct error which + * interpretedValue causes, if any. * * @param interpretedValue The interpreted value which we check for errors * @param side String containing either "Leftside" or "Rightside", From b85aab46adbe36a7b4f5e736f9ed88dddf6ee015 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 21 May 2024 12:46:54 +0200 Subject: [PATCH 075/236] Tested join operation --- ...aInterpreterListOperationsInterpreter.java | 6 ++ ...erpreterListOperationsInterpreterTest.java | 62 ++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index e119bfff9..6a31c135c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -118,6 +118,12 @@ public RosettaInterpreterValue interp(JoinOperation exp) { new RosettaInterpreterError("The delimiter for a join" + " operation must be a string")); } + + if (RosettaInterpreterBaseValue.valueStream(stringsVal) + .count() < 1L) { + return new RosettaInterpreterStringValue(""); + } + String delimString = ((RosettaInterpreterStringValue)delimVal).getValue(); RosettaInterpreterStringValue result = diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index d8779cf73..d439021af 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -98,7 +99,7 @@ void testInterpDisjoint() { } @Test - void testInterpJoin() { + void testInterpJoinSimple() { String msg = "[\"abc\", \"cde\"] join \", \""; RosettaExpression msgExp = parser.parseExpression(msg); validation.assertNoIssues(msgExp); @@ -106,5 +107,64 @@ void testInterpJoin() { (RosettaInterpreterStringValue)interpreter.interp(msgExp); assertEquals("abc, cde", val.getValue()); } + + @Test + void testInterpJoinEmpty() { + String msg = "[] join \", \""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterStringValue val = + (RosettaInterpreterStringValue)interpreter.interp(msgExp); + assertEquals("", val.getValue()); + } + + @Test + void testInterpJoinOneElement() { + String msg = "[\"a\"] join \", \""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterStringValue val = + (RosettaInterpreterStringValue)interpreter.interp(msgExp); + assertEquals("a", val.getValue()); + } + + @Test + void testInterpJoinNoDelimiter() { + String msg = "[\"a\", \"b\"] join \"\""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterStringValue val = + (RosettaInterpreterStringValue)interpreter.interp(msgExp); + assertEquals("ab", val.getValue()); + } + + @Test + void testInterpJoinLonger() { + String msg = "[\"abc\", \"cde\", \"cde\", \"cde\"] join \", \""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterStringValue val = + (RosettaInterpreterStringValue)interpreter.interp(msgExp); + assertEquals("abc, cde, cde, cde", val.getValue()); + } + + @Test + void testInterpJoinNotAllString() { + String msg = "[\"abc\", \"cde\", 5, \"cde\"] join \", \""; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterValue val = interpreter.interp(msgExp); + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + + @Test + void testInterpJoinDelimiterNotString() { + String msg = "[\"abc\", \"cde\", \"cde\"] join 5"; + RosettaExpression msgExp = parser.parseExpression(msg); + validation.assertNoIssues(msgExp); + RosettaInterpreterValue val = interpreter.interp(msgExp); + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + } From 10ca9dbebd2eccb322192590a95f62ffff34d5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 22 May 2024 20:07:30 +0300 Subject: [PATCH 076/236] Fix small issues and checkstyle --- ...settaConditionalExpressionInterpreter.java | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 4b4a09ca8..c1dbef640 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -12,36 +12,55 @@ import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public class RosettaInterpreterRosettaConditionalExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { +public class RosettaInterpreterRosettaConditionalExpressionInterpreter +extends RosettaInterpreterConcreteInterpreter { + /** + * Interpreter method for Conditional Expressions. + * + * @param expr RosettaConditionalExpression to be interpreted + * @return The interpreted value + */ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { boolean ifResult = false; - RosettaExpression if_ = expr.getIf(); + RosettaExpression ifExression = expr.getIf(); RosettaExpression ifThen = expr.getIfthen(); - RosettaInterpreterValue ifValue = if_.accept(visitor); + RosettaInterpreterValue ifValue = ifExression.accept(visitor); RosettaInterpreterValue ifThenValue = ifThen.accept(visitor); if (ifValue instanceof RosettaInterpreterBooleanValue) { ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); - } else if (ifValue instanceof RosettaInterpreterErrorValue) { - return createErrors(ifValue, "Conditional expression: condition is an error value."); + } else if (RosettaInterpreterErrorValue.errorsExist(ifValue)) { + return createErrors(ifValue, + "Conditional expression: condition is an error value."); } else { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is not a boolean value.")); + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Conditional expression: condition " + + "is not a boolean value.")); } - if (ifResult == true) { + if (ifResult) { RosettaInterpreterBaseValue result = checkInstance(ifThenValue, false); if (expr.isFull()) { RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); - RosettaInterpreterBaseValue elseInstance = checkInstance(elseThenValue, true); + RosettaInterpreterBaseValue elseInstance = + checkInstance(elseThenValue, true); - if (!result.getClass().equals(elseInstance.getClass()) && !(result instanceof RosettaInterpreterErrorValue) && !(elseInstance instanceof RosettaInterpreterErrorValue)) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + if (!result.getClass().equals(elseInstance.getClass()) + && !(result + instanceof RosettaInterpreterErrorValue) + && !(elseInstance + instanceof RosettaInterpreterErrorValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: " + + "consequent and alternative " + + "need to have the same type.")); } } return result; @@ -52,8 +71,14 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { RosettaInterpreterBaseValue result = checkInstance(elseThenValue, true); RosettaInterpreterBaseValue ifInstance = checkInstance(ifThenValue, true); - if (!result.getClass().equals(ifInstance.getClass()) && !(result instanceof RosettaInterpreterErrorValue) && !(ifInstance instanceof RosettaInterpreterErrorValue)) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + if (!result.getClass().equals(ifInstance.getClass()) + && !(result instanceof RosettaInterpreterErrorValue) + && !(ifInstance instanceof RosettaInterpreterErrorValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: " + + "consequent and alternative " + + "need to have the same type.")); } return result; } @@ -61,7 +86,8 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { return null; } - private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr, boolean branch) { + private RosettaInterpreterBaseValue + checkInstance(RosettaInterpreterValue expr, boolean branch) { RosettaInterpreterBaseValue result = null; String message = null; @@ -72,25 +98,35 @@ private RosettaInterpreterBaseValue checkInstance(RosettaInterpreterValue expr, } if (expr instanceof RosettaInterpreterBooleanValue) { - result = new RosettaInterpreterBooleanValue(((RosettaInterpreterBooleanValue) expr).getValue()); + result = new RosettaInterpreterBooleanValue((( + RosettaInterpreterBooleanValue) expr).getValue()); } else if (expr instanceof RosettaInterpreterIntegerValue) { - result = new RosettaInterpreterIntegerValue(((RosettaInterpreterIntegerValue) expr).getValue()); + result = new RosettaInterpreterIntegerValue((( + RosettaInterpreterIntegerValue) expr).getValue()); } else if (expr instanceof RosettaInterpreterNumberValue) { - result = new RosettaInterpreterNumberValue(((RosettaInterpreterNumberValue) expr).getValue()); + result = new RosettaInterpreterNumberValue((( + RosettaInterpreterNumberValue) expr).getValue()); } else if (expr instanceof RosettaInterpreterStringValue) { - result = new RosettaInterpreterStringValue(((RosettaInterpreterStringValue) expr).getValue()); + result = new RosettaInterpreterStringValue((( + RosettaInterpreterStringValue) expr).getValue()); } else if (expr instanceof RosettaInterpreterListValue) { - result = new RosettaInterpreterListValue(((RosettaInterpreterListValue) expr).getExpressions()); + result = new RosettaInterpreterListValue((( + RosettaInterpreterListValue) expr).getExpressions()); } else if (expr instanceof RosettaInterpreterErrorValue) { - result = createErrors(expr, "Conditional expression: " + message + " is an error value."); + result = createErrors(expr, + "Conditional expression: " + + "" + message + " is an error value."); } return result; } - private RosettaInterpreterBaseValue createErrors(RosettaInterpreterValue exp, String message) { + private RosettaInterpreterBaseValue + createErrors(RosettaInterpreterValue exp, String message) { RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) exp; - RosettaInterpreterErrorValue newExpError = new RosettaInterpreterErrorValue(new RosettaInterpreterError(message)); + RosettaInterpreterErrorValue newExpError = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError(message)); newExpError.addAllErrors(expError); return newExpError; From 63626ff1a9b2378aecf21476f6a161de3f7ab56f Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Wed, 22 May 2024 19:56:05 +0200 Subject: [PATCH 077/236] Improved join implementation and testing --- rosetta-lang/model/RosettaInterpreter.xcore | 1 - ...aInterpreterListOperationsInterpreter.java | 23 ++++-------- ...erpreterListOperationsInterpreterTest.java | 36 +++++++++++++++++-- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 60c4c0ac7..3638e6112 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -28,7 +28,6 @@ class RosettaInterpreterBaseError{ } abstract class RosettaInterpreterValue { - } interface InterpreterVisitor { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 6a31c135c..4d7adb3bc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -1,6 +1,7 @@ package com.regnosys.rosetta.interpreternew.visitors; import java.util.HashSet; +import java.util.List; import java.util.stream.Collectors; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; @@ -125,23 +126,13 @@ public RosettaInterpreterValue interp(JoinOperation exp) { } String delimString = ((RosettaInterpreterStringValue)delimVal).getValue(); + List texts = RosettaInterpreterBaseValue.valueStream(stringsVal) + .map(x -> ((RosettaInterpreterStringValue)x).getValue()) + .collect(Collectors.toList()); - RosettaInterpreterStringValue result = - RosettaInterpreterBaseValue.valueStream(stringsVal) - .map(x -> (RosettaInterpreterStringValue)x) - .reduce(new RosettaInterpreterStringValue("dummy please ignore"), - (x,y) -> { - if (x.getValue().equals("dummy" - + " please ignore")) { - return new RosettaInterpreterStringValue(y.getValue()); - } - return new RosettaInterpreterStringValue( - x.getValue() - + delimString - + y.getValue()); - }); - - return result; + String result = String.join(delimString, texts); + + return new RosettaInterpreterStringValue(result); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index 8c17154ad..0974e7e42 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; @@ -80,6 +81,17 @@ void testInterpContains() { testHelper(new RosettaInterpreterBooleanValue(false), expressionsFalse); } + @Test + void testInterpContainsError() { + RosettaExpression expr = parser.parseExpression("[1,2,3] contains (1 and False)"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); + assertEquals(err, val); + } + @Test void testInterpDisjoint() { String[] expressionsTrue = new String[] { @@ -99,6 +111,17 @@ void testInterpDisjoint() { testHelper(new RosettaInterpreterBooleanValue(false), expressionsFalse); } + @Test + void testInterpDisjointError() { + RosettaExpression expr = parser.parseExpression("[1,2,3] disjoint (1 and False)"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); + assertEquals(err, val); + } + @Test void testInterpJoinSimple() { String msg = "[\"abc\", \"cde\"] join \", \""; @@ -166,6 +189,15 @@ void testInterpJoinDelimiterNotString() { RosettaInterpreterValue val = interpreter.interp(msgExp); assertTrue(val instanceof RosettaInterpreterErrorValue); } - - + + @Test + void testInterpJoinError() { + RosettaExpression expr = parser.parseExpression("[1,2,3] join (1 and False)"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); + assertEquals(err, val); + } } From 6493c1eb6e3ec189bd084c44fd9c12ff46bac20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 22 May 2024 22:05:00 +0300 Subject: [PATCH 078/236] Changed how the result of an if is returned --- .../values/RosettaInterpreterBaseValue.java | 4 +- .../RosettaInterpreterBooleanValue.java | 5 +- .../values/RosettaInterpreterErrorValue.java | 5 ++ .../RosettaInterpreterIntegerValue.java | 5 ++ .../values/RosettaInterpreterListValue.java | 5 ++ .../values/RosettaInterpreterNumberValue.java | 5 ++ .../values/RosettaInterpreterStringValue.java | 5 ++ ...settaConditionalExpressionInterpreter.java | 65 +++++++------------ ...aInterpreterConditionalExpressionTest.java | 8 +-- 9 files changed, 58 insertions(+), 49 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 5dff9bba3..a80892d0a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -16,7 +16,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue{ +public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue { @Override public EClass eClass() { // TODO Auto-generated method stub @@ -131,4 +131,6 @@ public void eNotify(Notification notification) { // TODO Auto-generated method stub } + + public abstract RosettaInterpreterBaseValue createInstance(); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index 60f63e60d..4311b2a83 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -41,6 +41,9 @@ public int compareTo(RosettaInterpreterBooleanValue o) { } - + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterBooleanValue(this.value); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index f4ff74841..7b29809c7 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -125,4 +125,9 @@ public boolean equals(Object obj) { return Objects.equals(errors, other.errors); } + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterErrorValue(this.errors); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index b7b37058e..377d477e8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -35,4 +35,9 @@ public RosettaInterpreterIntegerValue(BigInteger value) { public int compareTo(RosettaInterpreterIntegerValue o) { return this.value.compareTo(o.value); } + + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterIntegerValue(this.value); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 1783fd0b5..9d9e0346d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -36,4 +36,9 @@ public boolean equals(Object obj) { } public List getExpressions() { return expressions; } + + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterListValue(this.expressions); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 45c9ddbf2..33fab6ec3 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -36,4 +36,9 @@ public int compareTo(RosettaInterpreterNumberValue o) { return this.value.compareTo(o.value); } + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterNumberValue(this.value); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index 5c90e037f..f8901835b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -44,4 +44,9 @@ else if (compareValue > 0) { } } + @Override + public RosettaInterpreterBaseValue createInstance() { + return new RosettaInterpreterStringValue(this.value); + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index c1dbef640..03a1f52f1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -1,5 +1,7 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.List; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -42,14 +44,19 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { } if (ifResult) { - RosettaInterpreterBaseValue result = checkInstance(ifThenValue, false); + if (RosettaInterpreterErrorValue.errorsExist(ifThenValue)) { + return createErrors(ifThenValue, + "Conditional expression: then is an error value."); + } + RosettaInterpreterBaseValue result = ((RosettaInterpreterBaseValue) + ifThenValue).createInstance(); if (expr.isFull()) { RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); RosettaInterpreterBaseValue elseInstance = - checkInstance(elseThenValue, true); + ((RosettaInterpreterBaseValue) elseThenValue).createInstance(); if (!result.getClass().equals(elseInstance.getClass()) && !(result @@ -59,17 +66,25 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Conditional expression: " - + "consequent and alternative " + + "then and else " + "need to have the same type.")); } } return result; + } else if (expr.isFull()) { RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); - RosettaInterpreterBaseValue result = checkInstance(elseThenValue, true); - RosettaInterpreterBaseValue ifInstance = checkInstance(ifThenValue, true); + if (RosettaInterpreterErrorValue.errorsExist(elseThenValue)) { + return createErrors(elseThenValue, + "Conditional expression: else is an error value."); + } + + RosettaInterpreterBaseValue result = ((RosettaInterpreterBaseValue) + elseThenValue).createInstance(); + RosettaInterpreterBaseValue ifInstance = ((RosettaInterpreterBaseValue) + ifThenValue).createInstance(); if (!result.getClass().equals(ifInstance.getClass()) && !(result instanceof RosettaInterpreterErrorValue) @@ -77,7 +92,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Conditional expression: " - + "consequent and alternative " + + "then and else " + "need to have the same type.")); } return result; @@ -86,41 +101,6 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { return null; } - private RosettaInterpreterBaseValue - checkInstance(RosettaInterpreterValue expr, boolean branch) { - RosettaInterpreterBaseValue result = null; - String message = null; - - if (branch == false) { - message = "consequent"; - } else { - message = "alternative"; - } - - if (expr instanceof RosettaInterpreterBooleanValue) { - result = new RosettaInterpreterBooleanValue((( - RosettaInterpreterBooleanValue) expr).getValue()); - } else if (expr instanceof RosettaInterpreterIntegerValue) { - result = new RosettaInterpreterIntegerValue((( - RosettaInterpreterIntegerValue) expr).getValue()); - } else if (expr instanceof RosettaInterpreterNumberValue) { - result = new RosettaInterpreterNumberValue((( - RosettaInterpreterNumberValue) expr).getValue()); - } else if (expr instanceof RosettaInterpreterStringValue) { - result = new RosettaInterpreterStringValue((( - RosettaInterpreterStringValue) expr).getValue()); - } else if (expr instanceof RosettaInterpreterListValue) { - result = new RosettaInterpreterListValue((( - RosettaInterpreterListValue) expr).getExpressions()); - } else if (expr instanceof RosettaInterpreterErrorValue) { - result = createErrors(expr, - "Conditional expression: " - + "" + message + " is an error value."); - } - - return result; - } - private RosettaInterpreterBaseValue createErrors(RosettaInterpreterValue exp, String message) { RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) exp; @@ -128,7 +108,6 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { new RosettaInterpreterErrorValue( new RosettaInterpreterError(message)); - newExpError.addAllErrors(expError); - return newExpError; + return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 5ef407926..054518130 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -117,7 +117,7 @@ public void listTest() { @Test public void errorThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent is an error value.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then is an error value.")); expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); @@ -130,7 +130,7 @@ public void errorThenTest() { @Test public void errorElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: alternative is an error value.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: else is an error value.")); expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); @@ -143,7 +143,7 @@ public void errorElseTest() { @Test public void notSameTypeThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then and else need to have the same type.")); RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); @@ -155,7 +155,7 @@ public void notSameTypeThenTest() { @Test public void notSameTypeElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: consequent and alternative need to have the same type.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then and else need to have the same type.")); RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); From 502c890422bc2733136c4f23a413cb8e5d7173d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 22 May 2024 22:09:58 +0300 Subject: [PATCH 079/236] Added complex test --- .../RosettaInterpreterConditionalExpressionTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 054518130..939b456c7 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -115,6 +115,16 @@ public void listTest() { assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); } + @Test + public void complexTest() { + RosettaExpression expr = parser.parseExpression("if 3 > 2 then 1 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + BigInteger number = BigInteger.valueOf(1); + + assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); + } + @Test public void errorThenTest() { RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then is an error value.")); From df8e4d132de7d9c28856a855421344e99e1c97d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 23 May 2024 02:52:35 +0300 Subject: [PATCH 080/236] Removed unused imports --- ...ttaInterpreterRosettaConditionalExpressionInterpreter.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 03a1f52f1..5fbd9f7dc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -6,10 +6,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From 092e69bfdfbe76e30b15f24e52ecedc98140e129 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 23 May 2024 09:49:34 +0200 Subject: [PATCH 081/236] Setting up an environment --- .../values/RosettaInterpreterEnvironment.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java new file mode 100644 index 000000000..2d7d94f74 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java @@ -0,0 +1,64 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.HashMap; +import java.util.Map; + +public class RosettaInterpreterEnvironment { + private Map environment; + + public RosettaInterpreterEnvironment() { + this.setEnvironment(new HashMap<>()); + } + + public RosettaInterpreterEnvironment(Map el) { + this.setEnvironment(el); + } + + public Map getEnvironment() { + return environment; + } + + public void setEnvironment(Map env) { + this.environment = env; + } + + /** + * Find a value, by name, in the environment. + * + * @param name - name of the variable you search for + * @return - the value iff variable exists in environment + * error otherwise + */ + public RosettaInterpreterBaseValue findValue(String name) { + if (environment.containsKey(name)) { + return environment.get(name); + } + else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "no such variable in the environment")); + } + + } + + /** + * Add a variable and its value to the environment. + * + * @param name - name of the variable + * @param val - value of the variable + */ + public void addValue(String name, + RosettaInterpreterBaseValue val) { + + if (environment.containsKey(name)) { + //update env + environment.replace(name, val); + } + else { + environment.put(name, val); + } + + } + + +} From ac9ac3bfd7c872ab1ac63718f874404237f5c19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 23 May 2024 13:26:14 +0300 Subject: [PATCH 082/236] Fixed conditional implementation and checkstyle issues --- .../values/RosettaInterpreterBaseValue.java | 1 - .../RosettaInterpreterBooleanValue.java | 6 -- .../values/RosettaInterpreterErrorValue.java | 5 -- .../RosettaInterpreterIntegerValue.java | 4 -- .../values/RosettaInterpreterListValue.java | 4 -- .../values/RosettaInterpreterNumberValue.java | 5 -- .../values/RosettaInterpreterStringValue.java | 5 -- ...settaConditionalExpressionInterpreter.java | 72 ++++++++----------- ...aInterpreterConditionalExpressionTest.java | 64 ++++++++++------- 9 files changed, 70 insertions(+), 96 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index a80892d0a..5aadb9bc6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -132,5 +132,4 @@ public void eNotify(Notification notification) { } - public abstract RosettaInterpreterBaseValue createInstance(); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java index 4311b2a83..9b65e949d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java @@ -39,11 +39,5 @@ public boolean equals(Object obj) { public int compareTo(RosettaInterpreterBooleanValue o) { return Boolean.compare(this.value, o.value); } - - - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterBooleanValue(this.value); - } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 7b29809c7..f4ff74841 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -125,9 +125,4 @@ public boolean equals(Object obj) { return Objects.equals(errors, other.errors); } - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterErrorValue(this.errors); - } - } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index 377d477e8..ba7b0f454 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -36,8 +36,4 @@ public int compareTo(RosettaInterpreterIntegerValue o) { return this.value.compareTo(o.value); } - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterIntegerValue(this.value); - } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 9d9e0346d..782ed9b7c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -37,8 +37,4 @@ public boolean equals(Object obj) { public List getExpressions() { return expressions; } - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterListValue(this.expressions); - } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 33fab6ec3..45c9ddbf2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -36,9 +36,4 @@ public int compareTo(RosettaInterpreterNumberValue o) { return this.value.compareTo(o.value); } - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterNumberValue(this.value); - } - } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index f8901835b..5c90e037f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -44,9 +44,4 @@ else if (compareValue > 0) { } } - @Override - public RosettaInterpreterBaseValue createInstance() { - return new RosettaInterpreterStringValue(this.value); - } - } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 5fbd9f7dc..a50f9793a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -22,12 +22,15 @@ public class RosettaInterpreterRosettaConditionalExpressionInterpreter public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { boolean ifResult = false; - RosettaExpression ifExression = expr.getIf(); + RosettaExpression ifExpression = expr.getIf(); RosettaExpression ifThen = expr.getIfthen(); - RosettaInterpreterValue ifValue = ifExression.accept(visitor); + RosettaInterpreterValue ifValue = ifExpression.accept(visitor); RosettaInterpreterValue ifThenValue = ifThen.accept(visitor); + RosettaExpression elseThen = null; + RosettaInterpreterValue elseThenValue = null; + if (ifValue instanceof RosettaInterpreterBooleanValue) { ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); } else if (RosettaInterpreterErrorValue.errorsExist(ifValue)) { @@ -39,59 +42,44 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { + "is not a boolean value.")); } + if (expr.isFull()) { + elseThen = expr.getElsethen(); + elseThenValue = elseThen.accept(visitor); + + RosettaInterpreterBaseValue ifInstance = + ((RosettaInterpreterBaseValue) ifThenValue); + + RosettaInterpreterBaseValue elseInstance = + ((RosettaInterpreterBaseValue) elseThenValue); + + if (!ifInstance.getClass().equals(elseInstance.getClass()) + && !(ifInstance + instanceof RosettaInterpreterErrorValue) + && !(elseInstance + instanceof RosettaInterpreterErrorValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: " + + "then and else " + + "need to have the same type.")); + } + } + if (ifResult) { if (RosettaInterpreterErrorValue.errorsExist(ifThenValue)) { return createErrors(ifThenValue, "Conditional expression: then is an error value."); } - RosettaInterpreterBaseValue result = ((RosettaInterpreterBaseValue) - ifThenValue).createInstance(); - if (expr.isFull()) { - RosettaExpression elseThen = expr.getElsethen(); - RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); - - RosettaInterpreterBaseValue elseInstance = - ((RosettaInterpreterBaseValue) elseThenValue).createInstance(); - - if (!result.getClass().equals(elseInstance.getClass()) - && !(result - instanceof RosettaInterpreterErrorValue) - && !(elseInstance - instanceof RosettaInterpreterErrorValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Conditional expression: " - + "then and else " - + "need to have the same type.")); - } - } - return result; + return ((RosettaInterpreterBaseValue) ifThenValue); } else if (expr.isFull()) { - RosettaExpression elseThen = expr.getElsethen(); - RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); - if (RosettaInterpreterErrorValue.errorsExist(elseThenValue)) { return createErrors(elseThenValue, "Conditional expression: else is an error value."); } - RosettaInterpreterBaseValue result = ((RosettaInterpreterBaseValue) - elseThenValue).createInstance(); - RosettaInterpreterBaseValue ifInstance = ((RosettaInterpreterBaseValue) - ifThenValue).createInstance(); - - if (!result.getClass().equals(ifInstance.getClass()) - && !(result instanceof RosettaInterpreterErrorValue) - && !(ifInstance instanceof RosettaInterpreterErrorValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Conditional expression: " - + "then and else " - + "need to have the same type.")); - } - return result; + return ((RosettaInterpreterBaseValue) elseThenValue); } return null; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 939b456c7..a15a1e0d1 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -38,13 +38,6 @@ public class RosettaInterpreterConditionalExpressionTest { @Inject RosettaInterpreterNew interpreter; - - private ExpressionFactory eFactory; - - @BeforeEach - public void setup() { - eFactory = ExpressionFactoryImpl.init(); - } @Test public void integerTest() { @@ -107,8 +100,10 @@ public void listTest() { RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterIntegerValue one = new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)); - RosettaInterpreterIntegerValue two = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)); + RosettaInterpreterIntegerValue one = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)); + RosettaInterpreterIntegerValue two = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)); List list = List.of(one, two); @@ -127,77 +122,98 @@ public void complexTest() { @Test public void errorThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then is an error value.")); - expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: then is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test public void errorElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: else is an error value.")); - expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: else is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test public void notSameTypeThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then and else need to have the same type.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "then and else need to have the same type.")); RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test public void notSameTypeElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: then and else need to have the same type.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "then and else need to have the same type.")); RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test public void conditionNotBooleanTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is not a boolean value.")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "condition is not a boolean value.")); RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test public void conditionErrorTypeTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError("Conditional expression: condition is an error value.")); - expected.addError(new RosettaInterpreterError("cannot use \"ALL\" keyword " + "to compare two elements")); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "condition is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), errorResult.getErrors().get(0).getMessage()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); } @Test From 7b99646654c0d5a865045d19a99de10b2c68881f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 23 May 2024 14:00:11 +0300 Subject: [PATCH 083/236] Removed unused imports --- .../RosettaInterpreterConditionalExpressionTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index a15a1e0d1..9fe62a0fb 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -1,7 +1,6 @@ package com.regnosys.rosetta.interpreternew; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; import java.math.BigInteger; @@ -11,7 +10,6 @@ import org.eclipse.xtext.testing.InjectWith; import org.eclipse.xtext.testing.extensions.InjectionExtension; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -22,9 +20,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; From 0af3c74176f7aa1e11e7aa1a127c5cfb7bc7ad0d Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 24 May 2024 11:15:11 +0200 Subject: [PATCH 084/236] Extended max file length to 120 --- checkstyle-SP.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle-SP.xml b/checkstyle-SP.xml index 29a362112..3f8c27c07 100644 --- a/checkstyle-SP.xml +++ b/checkstyle-SP.xml @@ -274,6 +274,6 @@ - + From ef3b2963e6ae9ce9c961f3cc0f09dfa4b627f677 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 11:40:40 +0200 Subject: [PATCH 085/236] Required setup for environment --- rosetta-lang/model/Rosetta.xcore | 3 + rosetta-lang/model/RosettaExpression.xcore | 39 +++++++++- rosetta-lang/model/RosettaInterpreter.xcore | 20 +++++ .../interpreternew/RosettaInterpreterNew.java | 8 +- .../RosettaInterpreterVisitor.java | 74 ++++++++++++++++++- 5 files changed, 139 insertions(+), 5 deletions(-) diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index fca67db2f..3cbc5fd21 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -90,6 +90,9 @@ class TypeCallArgument { contains RosettaExpression value } +abstract class RosettaInterpreterBaseEnvironment { +} + /********************************************************************** * Built-in diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 9238f71e3..4701103b1 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -19,11 +19,14 @@ import org.eclipse.emf.common.util.BasicEList import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment + interface RosettaExpression { // Whether the expression was generated boolean generated op RosettaInterpreterValue accept(InterpreterVisitor v) + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment env) } /** @@ -59,6 +62,9 @@ class RosettaBooleanLiteral extends RosettaLiteral { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaStringLiteral extends RosettaLiteral { @@ -73,6 +79,9 @@ class RosettaStringLiteral extends RosettaLiteral { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaNumberLiteral extends RosettaLiteral { @@ -87,6 +96,9 @@ class RosettaNumberLiteral extends RosettaLiteral { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaIntLiteral extends RosettaLiteral { @@ -101,6 +113,9 @@ class RosettaIntLiteral extends RosettaLiteral { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } // Not supported - see issue https://github.com/finos/rune-dsl/issues/524 @@ -128,6 +143,9 @@ class ListLiteral extends RosettaExpression { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } /* @@ -135,6 +153,12 @@ class ListLiteral extends RosettaExpression { */ abstract class RosettaReference extends RosettaExpression { +// op RosettaInterpreterValue accept(InterpreterVisitor v) { +// v.interp(this) +// } +// op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { +// v.interp(this,nv) +// } } class RosettaSymbolReference extends RosettaReference { @@ -158,6 +182,10 @@ class RosettaSymbolReference extends RosettaReference { } return rawArgs } + + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this, nv) + } } class RosettaImplicitVariable extends RosettaReference, RosettaNamed { @@ -224,6 +252,9 @@ class LogicalOperation extends RosettaBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } enum CardinalityModifier { @@ -240,12 +271,16 @@ class EqualityOperation extends ModifiableBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ComparisonOperation extends ModifiableBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) } + } class RosettaContainsExpression extends RosettaBinaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index d553422fe..0a92bf73a 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -14,6 +14,9 @@ import com.regnosys.rosetta.rosetta.expression.ListLiteral import com.regnosys.rosetta.rosetta.expression.LogicalOperation import com.regnosys.rosetta.rosetta.expression.EqualityOperation import com.regnosys.rosetta.rosetta.expression.ComparisonOperation +import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference +import com.regnosys.rosetta.rosetta.expression.RosettaReference +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment class RosettaInterpreterBaseError{ String message @@ -32,4 +35,21 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (LogicalOperation exp) op RosettaInterpreterValue interp (EqualityOperation exp) op RosettaInterpreterValue interp (ComparisonOperation exp) + //op RosettaInterpreterValue interp (RosettaImplicitVariable exp) + op RosettaInterpreterValue interp (RosettaSymbolReference exp) + //op RosettaInterpreterValue interp (RosettaReference exp) + + + op RosettaInterpreterValue interp (RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaIntLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaPatternLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ListLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (LogicalOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (EqualityOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ComparisonOperation exp, RosettaInterpreterBaseEnvironment env) + //op RosettaInterpreterValue interp (RosettaImplicitVariable exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaSymbolReference exp, RosettaInterpreterBaseEnvironment env) + //op RosettaInterpreterValue interp (RosettaReference exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index b648dce0a..a898996c0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -2,6 +2,7 @@ import javax.inject.Inject; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -18,6 +19,11 @@ public class RosettaInterpreterNew { * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { - return expression.accept(visitor); + return expression.accept(visitor, new RosettaInterpreterEnvironment()); + } + + public RosettaInterpreterValue interp(RosettaExpression expression, + RosettaInterpreterEnvironment env) { + return expression.accept(visitor, env); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index b2c69322e..4a6a17b0b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,6 +1,7 @@ package com.regnosys.rosetta.interpreternew; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.EqualityOperation; import com.regnosys.rosetta.rosetta.expression.ListLiteral; @@ -10,7 +11,8 @@ import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; @@ -20,52 +22,120 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterVariableInterpreter; public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase { @Override public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaBooleanLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaStringLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaStringLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaStringLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaNumberLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaNumberLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaIntLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaIntLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaIntLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaPatternLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Pattern literals are not supported")); } @Override public RosettaInterpreterValue interp(ListLiteral exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(ListLiteral exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterListLiteralInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(LogicalOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(LogicalOperation exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterLogicalOperationInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(EqualityOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(EqualityOperation exp, + RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(ComparisonOperation exp) { - return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); + return interp(exp, new RosettaInterpreterEnvironment()); + //return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } + + @Override + public RosettaInterpreterValue interp(ComparisonOperation exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(RosettaSymbolReference exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaSymbolReference exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterVariableInterpreter().interp(exp, env); + } } From a7fa5f135a55ae95cf86efb5fe7a842d48e285df Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 11:43:36 +0200 Subject: [PATCH 086/236] Change interpreter methods in all classes to accomodate environments --- ...rpreterComparisonOperationInterpreter.java | 66 ++++++++++++++----- ...ettaInterpreterListLiteralInterpreter.java | 11 +++- ...nterpreterLogicalOperationInterpreter.java | 16 +++-- ...reterRosettaBooleanLiteralInterpreter.java | 9 ++- ...terpreterRosettaIntLiteralInterpreter.java | 9 ++- ...preterRosettaNumberLiteralInterpreter.java | 9 ++- ...preterRosettaStringLiteralInterpreter.java | 9 ++- 7 files changed, 101 insertions(+), 28 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index b635fd539..85cb26f09 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -6,9 +6,11 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ModifiableBinaryOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -39,7 +41,24 @@ public class RosettaInterpreterComparisonOperationInterpreter extends * If errors are encountered, a RosettaInterpreterErrorValue representing * the error. */ - public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { + public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } + + + /** + * Interprets a comparison operation, evaluating the comparison between two operands. + * + * @param expr The ComparisonOperation expression to interpret + * @param env RosettaInterpreterBaseEnvironment that keeps track + * of the current state of the program + * @return If no errors are encountered, a RosettaInterpreterBooleanValue representing + * the result of the comparison operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr, + RosettaInterpreterBaseEnvironment env) { if (!comparisonOperators.contains(expr.getOperator())) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( @@ -48,8 +67,21 @@ public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); - RosettaInterpreterValue leftValue = left.accept(visitor); - RosettaInterpreterValue rightValue = right.accept(visitor); + RosettaInterpreterValue leftValue = left.accept(visitor, env); + RosettaInterpreterValue rightValue = right.accept(visitor, env); + + if (RosettaInterpreterErrorValue.errorsExist(leftValue) + && RosettaInterpreterErrorValue.errorsExist(rightValue)) { + return RosettaInterpreterErrorValue + .merge((RosettaInterpreterErrorValue)leftValue, + (RosettaInterpreterErrorValue)rightValue); + } + else if (RosettaInterpreterErrorValue.errorsExist(leftValue)) { + return (RosettaInterpreterErrorValue)leftValue; + } + else if (RosettaInterpreterErrorValue.errorsExist(rightValue)) { + return (RosettaInterpreterErrorValue)rightValue; + } //check cardinality operation switch (expr.getCardMod()) { @@ -112,13 +144,13 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterBooleanValue(anyTrue); } } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot use \"ANY\" keyword " - + "to compare two elements")); - } - return new RosettaInterpreterBooleanValue(false); + + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ANY\" keyword " + + "to compare two elements")); + + //return new RosettaInterpreterBooleanValue(false); } private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, @@ -153,13 +185,13 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterBooleanValue(allTrue); } } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cannot use \"ALL\" keyword " - + "to compare two elements")); - } - return new RosettaInterpreterBooleanValue(false); + + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + + "to compare two elements")); + + //return new RosettaInterpreterBooleanValue(false); } private boolean checkComparableTypes(RosettaInterpreterValue leftValue, diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index 422717588..22db70b08 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.rosetta.expression.ListLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -15,18 +17,23 @@ public RosettaInterpreterListLiteralInterpreter() { super(); } + public RosettaInterpreterBaseValue interp(ListLiteral expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } + /** * Interprets a list literal, evaluating it to a list value. * * @param exp the expression to be interpreted * @return the list value it represents */ - public RosettaInterpreterListValue interp(ListLiteral exp) { + public RosettaInterpreterListValue interp(ListLiteral exp, + RosettaInterpreterEnvironment env) { List expressions = exp.getElements(); List interpretedExpressions = new ArrayList<>(); for (RosettaExpression e : expressions) { - RosettaInterpreterValue val = e.accept(visitor); + RosettaInterpreterValue val = e.accept(visitor, env); if (val instanceof RosettaInterpreterListValue) { interpretedExpressions.addAll( diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index d1c1f7646..dff13447a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -4,6 +4,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; @@ -12,6 +13,10 @@ public class RosettaInterpreterLogicalOperationInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(LogicalOperation expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } /** * Interpreter method for Logical Operations. @@ -19,14 +24,15 @@ public class RosettaInterpreterLogicalOperationInterpreter * @param expr LogicalOperaation to be interpreted * @return The interpreted value */ - public RosettaInterpreterBaseValue interp(LogicalOperation expr) { + public RosettaInterpreterBaseValue interp(LogicalOperation expr, + RosettaInterpreterEnvironment env) { boolean leftBool = false; boolean rightBool = false; RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); - RosettaInterpreterValue leftInterpreted = left.accept(visitor); - RosettaInterpreterValue rightInterpreted = right.accept(visitor); + RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); + RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); if (leftInterpreted instanceof RosettaInterpreterBooleanValue && rightInterpreted instanceof RosettaInterpreterBooleanValue) { @@ -81,8 +87,8 @@ private RosettaInterpreterErrorValue checkForErrors( // but something other than a boolean return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Logical Operation: " + side + - " is not of type Boolean")); + "Logical Operation: " + side + + " is not of type Boolean")); } } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java index aa6b30340..be0780f36 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java @@ -1,12 +1,19 @@ package com.regnosys.rosetta.interpreternew.visitors; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; public class RosettaInterpreterRosettaBooleanLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaBooleanLiteral expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } - public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr) { + public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr, + RosettaInterpreterEnvironment env) { return new RosettaInterpreterBooleanValue(expr.isValue()); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java index a317a36d0..2ecf6cdfa 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java @@ -1,12 +1,19 @@ package com.regnosys.rosetta.interpreternew.visitors; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; public class RosettaInterpreterRosettaIntLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr) { + public RosettaInterpreterBaseValue interp(RosettaIntLiteral expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } + + public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr, + RosettaInterpreterEnvironment env) { return new RosettaInterpreterIntegerValue(expr.getValue()); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java index 150f0b689..0b687bd12 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java @@ -1,12 +1,19 @@ package com.regnosys.rosetta.interpreternew.visitors; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; public class RosettaInterpreterRosettaNumberLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaNumberLiteral expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } - public RosettaInterpreterNumberValue interp(RosettaNumberLiteral exp) { + public RosettaInterpreterNumberValue interp(RosettaNumberLiteral exp, + RosettaInterpreterEnvironment env) { return new RosettaInterpreterNumberValue(exp.getValue()); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java index 0799bef9d..33e9acea6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java @@ -1,12 +1,19 @@ package com.regnosys.rosetta.interpreternew.visitors; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; public class RosettaInterpreterRosettaStringLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaStringLiteral expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } - public RosettaInterpreterStringValue interp(RosettaStringLiteral exp) { + public RosettaInterpreterStringValue interp(RosettaStringLiteral exp, + RosettaInterpreterEnvironment env) { return new RosettaInterpreterStringValue(exp.getValue()); } From 7ef79e54d47df2d1647e96abb2a831e4c1fed633 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 11:44:12 +0200 Subject: [PATCH 087/236] Implemented interp method for Exists operations + Tests) --- .../RosettaInterpreterVisitor.java | 3 +- ...aInterpreterListOperationsInterpreter.java | 35 +++++++++ ...erpreterListOperationsInterpreterTest.java | 74 +++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 051d54e52..ef5d87a2e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -101,8 +101,7 @@ public RosettaInterpreterValue interp(JoinOperation exp) { @Override public RosettaInterpreterValue interp(RosettaExistsExpression exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 4d7adb3bc..da2d991ba 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -12,6 +12,7 @@ import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -134,5 +135,39 @@ public RosettaInterpreterValue interp(JoinOperation exp) { return new RosettaInterpreterStringValue(result); } + + /** + * Interprets an exists operation. + * If the argument of the expression is an error, it returns it. + * Otherwise, it checks to see if the interpreted argument + * is of single or multiple cardinality. + * + * @param exp Exists operation to interpret + * @return Boolean indicating if the argument exists or not + */ + public RosettaInterpreterValue interp(RosettaExistsExpression exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + + boolean exists; + switch (exp.getModifier()) { + case SINGLE: + exists = count == 1; + break; + case MULTIPLE: + exists = count > 1; + break; + default: + exists = count > 0; + } + + return new RosettaInterpreterBooleanValue(exists); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index 0974e7e42..de13fe65e 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -200,4 +200,78 @@ void testInterpJoinError() { "Logical Operation: Leftside is not of type Boolean")); assertEquals(err, val); } + + + @Test + void testExistsTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("(True and False) exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[] exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsSingleTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[1] single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsSingleFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[1,2] single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsMultipleTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[1,2,3] multiple exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsMultipleFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[True] multiple exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } } From dc27cfd7b7c36c24dc257cbb230d37ceb8aa50f1 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 11:48:38 +0200 Subject: [PATCH 088/236] Variable support + tests --- .../values/RosettaInterpreterEnvironment.java | 7 +- ...RosettaInterpreterVariableInterpreter.java | 32 ++++ .../RosettaInterpreterVariableTest.java | 137 ++++++++++++++++++ 3 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java index 2d7d94f74..59baf9cdb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java @@ -3,7 +3,9 @@ import java.util.HashMap; import java.util.Map; -public class RosettaInterpreterEnvironment { +import com.regnosys.rosetta.rosetta.impl.RosettaInterpreterBaseEnvironmentImpl; + +public class RosettaInterpreterEnvironment extends RosettaInterpreterBaseEnvironmentImpl { private Map environment; public RosettaInterpreterEnvironment() { @@ -36,7 +38,8 @@ public RosettaInterpreterBaseValue findValue(String name) { else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "no such variable in the environment")); + name + + " does not exist in the environment")); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java new file mode 100644 index 000000000..93cc624cf --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -0,0 +1,32 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterVariableInterpreter { + + /** + * Interprets a variable, returns the value of it. + * + * @param exp The RosettaSymbolReference expression to interpret + * @param environment RosettaInterpreterBaseEnvironment that keeps track + * of the current state of the program + * @return If no errors are encountered, a RosettaInterpreterValue representing + * the value of the variable. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(RosettaSymbolReference exp, + RosettaInterpreterBaseEnvironment environment) { + RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) environment; + + //Search for variable in environment + RosettaInterpreterBaseValue varValue = env.findValue(exp.getSymbol().getName()); + + return varValue; + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java new file mode 100644 index 000000000..36f807d45 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java @@ -0,0 +1,137 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterVariableTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + @SuppressWarnings("unused") + private ExpressionFactory exFactory; + + @BeforeEach + public void setup() { + exFactory = ExpressionFactoryImpl.init(); + } + + + @Test + public void variableGoodComparisonTest() { + //create the environment and add variable 'a' to it + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaInterpreterIntegerValue intValue = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + env.addValue("a", intValue); + + //give the same environment to the parser + RosettaExpression expr = parser.parseExpression("a >= 2", + List.of("a" + " " + "int (1..1)")); + + RosettaInterpreterValue val = interpreter.interp(expr,env); + + assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void variableLeftErrorComparisonTest() { + //create the environment and add variable 'a' to it + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaInterpreterIntegerValue intValue = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + env.addValue("a", intValue); + + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "b does not exist in the environment")); + + //give a different environment to the parser + RosettaExpression expr = parser.parseExpression("b >= 2", + List.of("b" + " " + "int (1..1)")); + + RosettaInterpreterValue val = interpreter.interp(expr,env); + + assertEquals(expectedError.getErrors().get(0).getMessage(), + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void variableRightErrorComparisonTest() { + //create empty environment + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "b does not exist in the environment")); + + //give a different environment to the parser + RosettaExpression expr = parser.parseExpression("1 = b", + List.of("b" + " " + "int (1..1)")); + + RosettaInterpreterValue val = interpreter.interp(expr,env); + + assertEquals(expectedError.getErrors().get(0).getMessage(), + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void variableBothErrorTest() { + //create empty environment + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + + List expected = new ArrayList(); + expected.add(new RosettaInterpreterError( + "a does not exist in the environment")); + expected.add(new RosettaInterpreterError( + "b does not exist in the environment")); + + //give a different environment to the parser + RosettaExpression expr = parser.parseExpression("a <= b", + List.of("a" + " " + "int (1..1)", "b" + " " + "int (1..1)")); + + RosettaInterpreterValue val = interpreter.interp(expr,env); + + EList errors = + ((RosettaInterpreterErrorValue) val).getErrors(); + + assertEquals(expected.size(), errors.size()); + for (int i = 0; i < expected.size(); i++) { + RosettaInterpreterError newError = (RosettaInterpreterError) errors.get(i); + assertEquals(expected.get(i).getError(), newError.getError()); + } + } +} From 75221baa8a640b84c9537dd81047f0e17f33edc1 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 12:07:37 +0200 Subject: [PATCH 089/236] Implemented interp method for 'is absent' operation + Tests --- .../RosettaInterpreterVisitor.java | 3 +- ...aInterpreterListOperationsInterpreter.java | 24 ++++++++++++++ ...erpreterListOperationsInterpreterTest.java | 33 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index ef5d87a2e..78347cccb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -106,8 +106,7 @@ public RosettaInterpreterValue interp(RosettaExistsExpression exp) { @Override public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index da2d991ba..74e964816 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,6 +10,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.JoinOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; @@ -169,5 +170,28 @@ public RosettaInterpreterValue interp(RosettaExistsExpression exp) { return new RosettaInterpreterBooleanValue(exists); } + + + /** + * Interprets an "is absent" expression. + * If the argument of the expression is of size 0, so: + * - either it is optional, (0..*), and it was not instantiated + * - or it is a list with 0 elements [] + * + * @param exp "Is absent" expression to intepret + * @return Boolean indicating if the interpreted argument is absent + */ + public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + boolean isAbsent = count == 0; + return new RosettaInterpreterBooleanValue(isAbsent); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index de13fe65e..3cef03d6e 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -274,4 +274,37 @@ void testExistsError() { RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; assertEquals(expected, castedVal); } + + @Test + void testIsAbsentTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[] is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testIsAbsentFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[True] is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testIsAbsentError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } } From 5f92ed1eedaafc724d3a2f72eb10f2a4b304e545 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 12:19:24 +0200 Subject: [PATCH 090/236] Implemented count operation + Tests --- .../RosettaInterpreterVisitor.java | 3 +- ...aInterpreterListOperationsInterpreter.java | 22 +++++++++++ ...erpreterListOperationsInterpreterTest.java | 37 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 78347cccb..7a0add222 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -111,8 +111,7 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { @Override public RosettaInterpreterValue interp(RosettaCountOperation exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 74e964816..6f7966800 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.math.BigInteger; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -8,10 +9,12 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -193,5 +196,24 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { boolean isAbsent = count == 0; return new RosettaInterpreterBooleanValue(isAbsent); } + + /** + * Interprets a count operation. + * Return the number of elements in a list + * + * @param exp Expression to perform 'count' on + * @return Integer indicating how many elements there are in the list + */ + public RosettaInterpreterValue interp(RosettaCountOperation exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + return new RosettaInterpreterIntegerValue(BigInteger.valueOf(count)); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index 3cef03d6e..dbd56f693 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.*; +import java.math.BigInteger; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -18,6 +19,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -307,4 +309,39 @@ void testIsAbsentError() { RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; assertEquals(expected, castedVal); } + + @Test + void testCountEmptyList() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(0)); + RosettaExpression expr = parser.parseExpression("[] count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testCount() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaExpression expr = parser.parseExpression("[1, 2, 3] count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testCountError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } } From d8d1dce311e75f7da45879b59a3242a328508cb6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 12:34:19 +0200 Subject: [PATCH 091/236] Implemented First operation + Tests --- .../RosettaInterpreterVisitor.java | 3 +- ...aInterpreterListOperationsInterpreter.java | 32 ++++++++++++++++- ...erpreterListOperationsInterpreterTest.java | 36 +++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 7a0add222..87ffa7a5d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -116,8 +116,7 @@ public RosettaInterpreterValue interp(RosettaCountOperation exp) { @Override public RosettaInterpreterValue interp(FirstOperation exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperationsInterpreter().interp(exp); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 6f7966800..3efeccacc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; @@ -11,6 +12,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; @@ -200,7 +202,7 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { /** * Interprets a count operation. * Return the number of elements in a list - * + * * @param exp Expression to perform 'count' on * @return Integer indicating how many elements there are in the list */ @@ -215,5 +217,33 @@ public RosettaInterpreterValue interp(RosettaCountOperation exp) { long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); return new RosettaInterpreterIntegerValue(BigInteger.valueOf(count)); } + + /** + * Interprets a first operation. + * If a list is not empty, it returns the first element. + * Otherwise, it returns an error. + * + * @param exp Expression on which to perform 'first' operation + * @return First element of the list + */ + public RosettaInterpreterValue interp(FirstOperation exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + if (count == 0L) { + // List is empty + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + } else { + // List has at least one element + return RosettaInterpreterBaseValue.valueStream(interpretedArgument) + .collect(Collectors.toList()).get(0); + } + } + } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index dbd56f693..27c29978f 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -344,4 +344,40 @@ void testCountError() { RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; assertEquals(expected, castedVal); } + + @Test + void testFirstEmptyList() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + RosettaExpression expr = parser.parseExpression("[] first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testFirst() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaExpression expr = parser.parseExpression("[3, 4, 5] first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testFirstError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } } From 1d0632766368030f040d0a932004da26936811e1 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 12:39:43 +0200 Subject: [PATCH 092/236] Fixed merge conflicts --- rosetta-lang/model/RosettaExpression.xcore | 27 ++++++++++ rosetta-lang/model/RosettaInterpreter.xcore | 1 + .../RosettaInterpreterVisitor.java | 49 +++++++++++++++++-- ...aInterpreterListOperationsInterpreter.java | 34 +++++++++---- ...settaConditionalExpressionInterpreter.java | 14 ++++-- 5 files changed, 109 insertions(+), 16 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 1d70536de..327dd60ed 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -206,6 +206,9 @@ class RosettaConditionalExpression extends RosettaExpression { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaConstructorExpression extends RosettaExpression, RosettaTyped { @@ -291,12 +294,18 @@ class RosettaContainsExpression extends RosettaBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaDisjointExpression extends RosettaBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class JoinOperation extends RosettaBinaryOperation { @@ -304,6 +313,9 @@ class JoinOperation extends RosettaBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } /** @@ -360,12 +372,18 @@ class RosettaExistsExpression extends RosettaUnaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaAbsentExpression extends RosettaUnaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaOnlyElement extends ListOperation { @@ -375,6 +393,9 @@ class RosettaCountOperation extends RosettaUnaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class FlattenOperation extends ListOperation, CanHandleListOfLists { @@ -390,12 +411,18 @@ class FirstOperation extends ListOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class LastOperation extends ListOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class SumOperation extends ListOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 86baf4f24..a2efe350e 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -64,6 +64,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaIntLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaPatternLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ListLiteral exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaConditionalExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (LogicalOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (EqualityOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ComparisonOperation exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index b589b87ec..08e12a30f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -109,6 +109,12 @@ public RosettaInterpreterValue interp(ListLiteral exp, public RosettaInterpreterValue interp(RosettaConditionalExpression exp) { return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp); } + + @Override + public RosettaInterpreterValue interp(RosettaConditionalExpression exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp, env); + } @Override public RosettaInterpreterValue interp(LogicalOperation exp) { @@ -192,30 +198,65 @@ public RosettaInterpreterValue interp(JoinOperation exp, @Override public RosettaInterpreterValue interp(RosettaExistsExpression exp) { // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(RosettaCountOperation exp) { // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(FirstOperation exp) { // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(LastOperation exp) { // TODO Auto-generated method stub + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaExistsExpression exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaAbsentExpression exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(RosettaCountOperation exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(FirstOperation exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + @Override + public RosettaInterpreterValue interp(LastOperation exp, + RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub throw new UnsupportedOperationException(); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 4d7adb3bc..1540063ff 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -6,9 +6,11 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; @@ -18,6 +20,9 @@ public class RosettaInterpreterListOperationsInterpreter extends RosettaInterpreterConcreteInterpreter { + public RosettaInterpreterValue interp(RosettaContainsExpression exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } /** * Interprets a rosetta contains expression. @@ -27,12 +32,13 @@ public class RosettaInterpreterListOperationsInterpreter * @param exp - expression to evaluate * @return value of contains expression */ - public RosettaInterpreterValue interp(RosettaContainsExpression exp) { + public RosettaInterpreterValue interp(RosettaContainsExpression exp, + RosettaInterpreterBaseEnvironment env) { RosettaExpression leftExp = exp.getLeft(); RosettaExpression rightExp = exp.getRight(); - RosettaInterpreterValue leftVal = leftExp.accept(visitor); - RosettaInterpreterValue rightVal = rightExp.accept(visitor); + RosettaInterpreterValue leftVal = leftExp.accept(visitor, env); + RosettaInterpreterValue rightVal = rightExp.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(leftVal, rightVal)) { return RosettaInterpreterErrorValue.merge(leftVal, rightVal); @@ -53,6 +59,10 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { return new RosettaInterpreterBooleanValue(contains); } + public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + /** * Interprets a rosetta disjoint expression. * Checks if the right element, which may be a single element or a list, @@ -61,12 +71,13 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { * @param exp - expression to evaluate * @return value of contains expression */ - public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { + public RosettaInterpreterValue interp(RosettaDisjointExpression exp, + RosettaInterpreterBaseEnvironment env) { RosettaExpression leftExp = exp.getLeft(); RosettaExpression rightExp = exp.getRight(); - RosettaInterpreterValue leftVal = leftExp.accept(visitor); - RosettaInterpreterValue rightVal = rightExp.accept(visitor); + RosettaInterpreterValue leftVal = leftExp.accept(visitor, env); + RosettaInterpreterValue rightVal = rightExp.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(leftVal, rightVal)) { return RosettaInterpreterErrorValue.merge(leftVal, rightVal); @@ -86,6 +97,10 @@ public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { return new RosettaInterpreterBooleanValue(notContains); } + + public RosettaInterpreterValue interp(JoinOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } /** * Interprets a join operation. @@ -95,12 +110,13 @@ public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { * @param exp - join operation to interpret * @return concatenated string */ - public RosettaInterpreterValue interp(JoinOperation exp) { + public RosettaInterpreterValue interp(JoinOperation exp, + RosettaInterpreterBaseEnvironment env) { RosettaExpression stringsExp = exp.getLeft(); RosettaExpression delimExp = exp.getRight(); - RosettaInterpreterValue stringsVal = stringsExp.accept(visitor); - RosettaInterpreterValue delimVal = delimExp.accept(visitor); + RosettaInterpreterValue stringsVal = stringsExp.accept(visitor, env); + RosettaInterpreterValue delimVal = delimExp.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(stringsVal, delimVal)) { return RosettaInterpreterErrorValue.merge(stringsVal, delimVal); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index a50f9793a..ee78fd37e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -4,8 +4,10 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -13,20 +15,26 @@ public class RosettaInterpreterRosettaConditionalExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } + /** * Interpreter method for Conditional Expressions. * * @param expr RosettaConditionalExpression to be interpreted * @return The interpreted value */ - public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { + public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, + RosettaInterpreterBaseEnvironment env) { boolean ifResult = false; RosettaExpression ifExpression = expr.getIf(); RosettaExpression ifThen = expr.getIfthen(); - RosettaInterpreterValue ifValue = ifExpression.accept(visitor); - RosettaInterpreterValue ifThenValue = ifThen.accept(visitor); + RosettaInterpreterValue ifValue = ifExpression.accept(visitor, env); + RosettaInterpreterValue ifThenValue = ifThen.accept(visitor, env); RosettaExpression elseThen = null; RosettaInterpreterValue elseThenValue = null; From 89c70915975ca6a632d7a3a46c75db2166ed8d41 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 13:07:02 +0200 Subject: [PATCH 093/236] Restored old files --- ...aInterpreterListOperationsInterpreter.java | 111 ----------- ...erpreterListOperationsInterpreterTest.java | 180 ------------------ 2 files changed, 291 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 3efeccacc..4d7adb3bc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -1,24 +1,17 @@ package com.regnosys.rosetta.interpreternew.visitors; -import java.math.BigInteger; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.JoinOperation; -import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; -import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; -import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -141,109 +134,5 @@ public RosettaInterpreterValue interp(JoinOperation exp) { return new RosettaInterpreterStringValue(result); } - - /** - * Interprets an exists operation. - * If the argument of the expression is an error, it returns it. - * Otherwise, it checks to see if the interpreted argument - * is of single or multiple cardinality. - * - * @param exp Exists operation to interpret - * @return Boolean indicating if the argument exists or not - */ - public RosettaInterpreterValue interp(RosettaExistsExpression exp) { - RosettaExpression argument = exp.getArgument(); - RosettaInterpreterValue interpretedArgument = argument.accept(visitor); - - if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { - return interpretedArgument; - } - - long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); - - boolean exists; - switch (exp.getModifier()) { - case SINGLE: - exists = count == 1; - break; - case MULTIPLE: - exists = count > 1; - break; - default: - exists = count > 0; - } - return new RosettaInterpreterBooleanValue(exists); - } - - - /** - * Interprets an "is absent" expression. - * If the argument of the expression is of size 0, so: - * - either it is optional, (0..*), and it was not instantiated - * - or it is a list with 0 elements [] - * - * @param exp "Is absent" expression to intepret - * @return Boolean indicating if the interpreted argument is absent - */ - public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { - RosettaExpression argument = exp.getArgument(); - RosettaInterpreterValue interpretedArgument = argument.accept(visitor); - - if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { - return interpretedArgument; - } - - long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); - boolean isAbsent = count == 0; - return new RosettaInterpreterBooleanValue(isAbsent); - } - - /** - * Interprets a count operation. - * Return the number of elements in a list - * - * @param exp Expression to perform 'count' on - * @return Integer indicating how many elements there are in the list - */ - public RosettaInterpreterValue interp(RosettaCountOperation exp) { - RosettaExpression argument = exp.getArgument(); - RosettaInterpreterValue interpretedArgument = argument.accept(visitor); - - if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { - return interpretedArgument; - } - - long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); - return new RosettaInterpreterIntegerValue(BigInteger.valueOf(count)); - } - - /** - * Interprets a first operation. - * If a list is not empty, it returns the first element. - * Otherwise, it returns an error. - * - * @param exp Expression on which to perform 'first' operation - * @return First element of the list - */ - public RosettaInterpreterValue interp(FirstOperation exp) { - RosettaExpression argument = exp.getArgument(); - RosettaInterpreterValue interpretedArgument = argument.accept(visitor); - - if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { - return interpretedArgument; - } - - long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); - if (count == 0L) { - // List is empty - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); - } else { - // List has at least one element - return RosettaInterpreterBaseValue.valueStream(interpretedArgument) - .collect(Collectors.toList()).get(0); - } - } - } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index 27c29978f..0974e7e42 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.*; -import java.math.BigInteger; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -19,7 +18,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -202,182 +200,4 @@ void testInterpJoinError() { "Logical Operation: Leftside is not of type Boolean")); assertEquals(err, val); } - - - @Test - void testExistsTrue() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); - RosettaExpression expr = parser.parseExpression("(True and False) exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsFalse() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); - RosettaExpression expr = parser.parseExpression("[] exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsSingleTrue() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); - RosettaExpression expr = parser.parseExpression("[1] single exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsSingleFalse() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); - RosettaExpression expr = parser.parseExpression("[1,2] single exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsMultipleTrue() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); - RosettaExpression expr = parser.parseExpression("[1,2,3] multiple exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsMultipleFalse() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); - RosettaExpression expr = parser.parseExpression("[True] multiple exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testExistsError() { - RosettaInterpreterErrorValue expected = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) single exists"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testIsAbsentTrue() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); - RosettaExpression expr = parser.parseExpression("[] is absent"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testIsAbsentFalse() { - RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); - RosettaExpression expr = parser.parseExpression("[True] is absent"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterBooleanValue); - RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testIsAbsentError() { - RosettaInterpreterErrorValue expected = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) is absent"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testCountEmptyList() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(0)); - RosettaExpression expr = parser.parseExpression("[] count"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testCount() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); - RosettaExpression expr = parser.parseExpression("[1, 2, 3] count"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testCountError() { - RosettaInterpreterErrorValue expected = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) count"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testFirstEmptyList() { - RosettaInterpreterErrorValue expected = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); - RosettaExpression expr = parser.parseExpression("[] first"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testFirst() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); - RosettaExpression expr = parser.parseExpression("[3, 4, 5] first"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; - assertEquals(expected, castedVal); - } - - @Test - void testFirstError() { - RosettaInterpreterErrorValue expected = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) first"); - RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterErrorValue); - RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; - assertEquals(expected, castedVal); - } } From e4d1ee815a505a1b3d2abe3dec165d3b33843ae4 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 24 May 2024 13:16:05 +0200 Subject: [PATCH 094/236] Changed the file in which methods were made and tested --- .../RosettaInterpreterVisitor.java | 12 +- ...ttaInterpreterListOperatorInterpreter.java | 155 +++++++++++ ...nterpreterListOperatorInterpreterTest.java | 257 ++++++++++++++++++ 3 files changed, 418 insertions(+), 6 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 87ffa7a5d..df5400a96 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -25,6 +25,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperatorInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; @@ -101,27 +102,26 @@ public RosettaInterpreterValue interp(JoinOperation exp) { @Override public RosettaInterpreterValue interp(RosettaExistsExpression exp) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp); + return new RosettaInterpreterListOperatorInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp); + return new RosettaInterpreterListOperatorInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(RosettaCountOperation exp) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp); + return new RosettaInterpreterListOperatorInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(FirstOperation exp) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp); + return new RosettaInterpreterListOperatorInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(LastOperation exp) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); + return new RosettaInterpreterListOperatorInterpreter().interp(exp); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java new file mode 100644 index 000000000..2aac6bb86 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -0,0 +1,155 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.math.BigInteger; +import java.util.stream.Collectors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.rosetta.expression.FirstOperation; +import com.regnosys.rosetta.rosetta.expression.LastOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterListOperatorInterpreter + extends RosettaInterpreterConcreteInterpreter { + + /** + * Interprets an exists operation. + * If the argument of the expression is an error, it returns it. + * Otherwise, it checks to see if the interpreted argument + * is of single or multiple cardinality. + * + * @param exp Exists operation to interpret + * @return Boolean indicating if the argument exists or not + */ + public RosettaInterpreterValue interp(RosettaExistsExpression exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + + boolean exists; + switch (exp.getModifier()) { + case SINGLE: + exists = count == 1; + break; + case MULTIPLE: + exists = count > 1; + break; + default: + exists = count > 0; + } + + return new RosettaInterpreterBooleanValue(exists); + } + + + /** + * Interprets an "is absent" expression. + * If the argument of the expression is of size 0, so: + * - either it is optional, (0..*), and it was not instantiated + * - or it is a list with 0 elements [] + * + * @param exp "Is absent" expression to intepret + * @return Boolean indicating if the interpreted argument is absent + */ + public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + boolean isAbsent = count == 0; + return new RosettaInterpreterBooleanValue(isAbsent); + } + + /** + * Interprets a count operation. + * Return the number of elements in a list + * + * @param exp Expression to perform 'count' on + * @return Integer indicating how many elements there are in the list + */ + public RosettaInterpreterValue interp(RosettaCountOperation exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + return new RosettaInterpreterIntegerValue(BigInteger.valueOf(count)); + } + + /** + * Interprets a first operation. + * If a list is not empty, it returns the first element. + * Otherwise, it returns an error. + * + * @param exp Expression on which to perform 'first' operation + * @return First element of the list + */ + public RosettaInterpreterValue interp(FirstOperation exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + if (count == 0L) { + // List is empty + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + } else { + // List has at least one element + return RosettaInterpreterBaseValue.valueStream(interpretedArgument) + .collect(Collectors.toList()).get(0); + } + } + + + /** + * Interprets a last operation. + * If a list is not empty, it returns the last element. + * Otherwise, it returns an error. + * + * @param exp Expression on which to perform 'last' operation + * @return Last element of the list + */ + public RosettaInterpreterValue interp(LastOperation exp) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + if (count == 0L) { + // List is empty + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + } else { + // List has at least one element + return RosettaInterpreterBaseValue.valueStream(interpretedArgument) + .collect(Collectors.toList()).get((int)count - 1); + } + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java new file mode 100644 index 000000000..7eb0af06c --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -0,0 +1,257 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import static org.junit.jupiter.api.Assertions.*; + +import java.math.BigInteger; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +class RosettaInterpreterListOperatorInterpreterTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + @SuppressWarnings("unused") + private ExpressionFactory expFactory; + + @BeforeEach + public void setup() { + expFactory = ExpressionFactoryImpl.init(); + } + + @Test + void testExistsTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("(True and False) exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[] exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsSingleTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[1] single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsSingleFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[1,2] single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsMultipleTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[1,2,3] multiple exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsMultipleFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[True] multiple exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testExistsError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) single exists"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testIsAbsentTrue() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); + RosettaExpression expr = parser.parseExpression("[] is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testIsAbsentFalse() { + RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(false); + RosettaExpression expr = parser.parseExpression("[True] is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testIsAbsentError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) is absent"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testCountEmptyList() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(0)); + RosettaExpression expr = parser.parseExpression("[] count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testCount() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaExpression expr = parser.parseExpression("[1, 2, 3] count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testCountError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) count"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testFirstEmptyList() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + RosettaExpression expr = parser.parseExpression("[] first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testFirst() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaExpression expr = parser.parseExpression("[3, 4, 5] first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testFirstError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) first"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testLastEmptyList() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + RosettaExpression expr = parser.parseExpression("[] last"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testLast() { + RosettaInterpreterIntegerValue expected = + new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaExpression expr = parser.parseExpression("[3, 4, 5] last"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterIntegerValue); + RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertEquals(expected, castedVal); + } + + @Test + void testLastError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) last"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); + } + +} From cc4424d610019b6a2154602f94a8c6cdc6cae56d Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 24 May 2024 13:33:57 +0200 Subject: [PATCH 095/236] Arithmetics operations implementation with error handling and tests --- rosetta-lang/model/RosettaExpression.xcore | 4 + rosetta-lang/model/RosettaInterpreter.xcore | 2 + .../RosettaInterpreterVisitor.java | 7 + .../values/RosettaInterpreterNumberValue.java | 15 +- ...osettaArithmeticOperationsInterpreter.java | 149 ++++++++++++++ ...taInterpreterArithmeticOperationsTest.java | 192 ++++++++++++++++++ ...aInterpreterConditionalExpressionTest.java | 3 +- .../RosettaInterpreterLiteralsTest.java | 4 +- 8 files changed, 369 insertions(+), 7 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index a3b923729..6b6123653 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -222,6 +222,10 @@ interface RosettaBinaryOperation extends RosettaOperation, HasGeneratedInput { } class ArithmeticOperation extends RosettaBinaryOperation { + + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class LogicalOperation extends RosettaBinaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 42dd112f0..1ec3297ba 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -15,6 +15,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression import com.regnosys.rosetta.rosetta.expression.LogicalOperation import com.regnosys.rosetta.rosetta.expression.EqualityOperation import com.regnosys.rosetta.rosetta.expression.ComparisonOperation +import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression import com.regnosys.rosetta.rosetta.expression.JoinOperation @@ -42,6 +43,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (LogicalOperation exp) op RosettaInterpreterValue interp (EqualityOperation exp) op RosettaInterpreterValue interp (ComparisonOperation exp) + op RosettaInterpreterValue interp (ArithmeticOperation exp) op RosettaInterpreterValue interp (RosettaContainsExpression exp) op RosettaInterpreterValue interp (RosettaDisjointExpression exp) op RosettaInterpreterValue interp (JoinOperation exp) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 051d54e52..d079ed662 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.EqualityOperation; @@ -24,6 +25,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; @@ -83,6 +85,11 @@ public RosettaInterpreterValue interp(EqualityOperation exp) { public RosettaInterpreterValue interp(ComparisonOperation exp) { return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } + + @Override + public RosettaInterpreterValue interp(ArithmeticOperation exp) { + return new RosettaInterpreterRosettaArithmeticOperationsInterpreter().interp(exp); + } @Override public RosettaInterpreterValue interp(RosettaContainsExpression exp) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index a0a2e7166..ae21f68cb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -6,17 +6,24 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.rosetta.model.lib.RosettaNumber; + public class RosettaInterpreterNumberValue extends RosettaInterpreterBaseValue - implements Comparable { - - private BigDecimal value; + implements Comparable { + private RosettaNumber value; + public RosettaInterpreterNumberValue(BigDecimal value) { + super(); + this.value = RosettaNumber.valueOf(value); + } + + public RosettaInterpreterNumberValue(RosettaNumber value) { super(); this.value = value; } - public BigDecimal getValue() { return value; } + public RosettaNumber getValue() { return value; } @Override public int hashCode() { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java new file mode 100644 index 000000000..4e6b89ddd --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -0,0 +1,149 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.List; + + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.rosetta.model.lib.RosettaNumber; + +public class RosettaInterpreterRosettaArithmeticOperationsInterpreter + extends RosettaInterpreterConcreteInterpreter { + /** + * Interprets an arithmetic operation, evaluating the operation between the two terms. + * + * @param expr The ArithmeticOperation expression to interpret + * @return If no errors are encountered, a RosettaInterpreterNumberValue or + * RosettaInterpreterStringValue representing + * the result of the arithmetic/concatenation operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(ArithmeticOperation expr) { + + String leftString = null; + String rightString = null; + + RosettaExpression left = expr.getLeft(); + RosettaExpression right = expr.getRight(); + RosettaInterpreterValue leftInterpreted = left.accept(visitor); + RosettaInterpreterValue rightInterpreted = right.accept(visitor); + + if (!(leftInterpreted instanceof RosettaInterpreterNumberValue + || leftInterpreted instanceof RosettaInterpreterStringValue + || leftInterpreted instanceof RosettaInterpreterIntegerValue) + || !(rightInterpreted instanceof RosettaInterpreterNumberValue + || rightInterpreted instanceof RosettaInterpreterStringValue + || rightInterpreted instanceof RosettaInterpreterIntegerValue)) { + + // Check for errors in the left or right side of the binary operation + RosettaInterpreterErrorValue leftErrors = + checkForErrors(leftInterpreted, "Leftside"); + RosettaInterpreterErrorValue rightErrors = + checkForErrors(rightInterpreted, "Rightside"); + return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); + } + + boolean sameType = + (leftInterpreted instanceof RosettaInterpreterStringValue + && rightInterpreted instanceof RosettaInterpreterStringValue) + || (!(leftInterpreted instanceof RosettaInterpreterStringValue) + && !(rightInterpreted instanceof RosettaInterpreterStringValue)); + if (!sameType) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "The terms of the operation " + + "are neither both strings nor both numbers")); + } + + if (leftInterpreted instanceof RosettaInterpreterStringValue) { + leftString = ((RosettaInterpreterStringValue) leftInterpreted) + .getValue(); + rightString = ((RosettaInterpreterStringValue) rightInterpreted) + .getValue(); + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterStringValue(leftString + rightString); + } + else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "The terms are strings but the operation " + + "is not concatenation: not implemented")); + } + } + + RosettaNumber leftNumber; + RosettaNumber rightNumber; + + if (leftInterpreted instanceof RosettaInterpreterNumberValue) { + leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); + } + else { + leftNumber = RosettaNumber + .valueOf(((RosettaInterpreterIntegerValue) leftInterpreted) + .getValue()); + } + if (rightInterpreted instanceof RosettaInterpreterNumberValue) { + rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); + } else { + rightNumber = RosettaNumber + .valueOf(((RosettaInterpreterIntegerValue) rightInterpreted) + .getValue()); + } + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterNumberValue((leftNumber + .add(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("-")) { + return new RosettaInterpreterNumberValue((leftNumber + .subtract(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("*")) { + return new RosettaInterpreterNumberValue((leftNumber + .multiply(rightNumber)).bigDecimalValue()); + } else { + return new RosettaInterpreterNumberValue((leftNumber + .divide(rightNumber)).bigDecimalValue()); + } + } + + + /** + * Helper method that takes an interpretedValue and a string, + * and returns the correct error which + * interpretedValue causes, if any. + * + * @param interpretedValue The interpreted value which we check for errors + * @param side String containing either "Leftside" or "Rightside", + * purely for clearer error messages + * @return The correct RosettaInterpreterErrorValue, or "null" + * if the interpretedValue does not cause an error + */ + private RosettaInterpreterErrorValue checkForErrors( + RosettaInterpreterValue interpretedValue, String side) { + if (interpretedValue instanceof RosettaInterpreterNumberValue + || interpretedValue instanceof RosettaInterpreterStringValue + || interpretedValue instanceof RosettaInterpreterIntegerValue) { + // If the value satisfies the type conditions, we return an empty + // error value so that the merger has two error values to merge + return new RosettaInterpreterErrorValue(); + } + + else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { + // The interpreted value was an error so we propagate it + return (RosettaInterpreterErrorValue) interpretedValue; + } else { + // The interpreted value was not an error, + // but something other than a string or number + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Arithmetic Operation: " + side + + " is not of type Number/String")); + } + } +} + diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java new file mode 100644 index 000000000..2d99230f6 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java @@ -0,0 +1,192 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.rosetta.model.lib.RosettaNumber; +import java.math.BigDecimal; +import java.util.List; + +import javax.inject.Inject; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterArithmeticOperationsTest { + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + @SuppressWarnings("unused") + private ExpressionFactory exFactory; + + @BeforeEach + public void setup() { + exFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void plusTest() { + RosettaExpression expr = parser.parseExpression("1+2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(3)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void compositePlusTest() { + RosettaExpression expr = parser.parseExpression("1+2+3"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(6)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void decimalPlusTest() { + RosettaExpression expr = parser.parseExpression("1.2 + 2.7"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(3.9)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void minusTest() { + RosettaExpression expr = parser.parseExpression("1-2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(-1)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void multiplyTest() { + RosettaExpression expr = parser.parseExpression("5*2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(10)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void divideTest() { + RosettaExpression expr = parser.parseExpression("6/2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(3)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void stringConcatenationTest() { + RosettaExpression expr = parser.parseExpression("\"Hello \" + \"World\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Hello World", ((RosettaInterpreterStringValue)val).getValue()); + } + + @Test + public void correctTypesMixedTest() { + RosettaExpression expr = parser.parseExpression("\"Hello \" + 5"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms of the operation " + + "are neither both strings nor both numbers", + ((RosettaInterpreterErrorValue)val).getErrors() + .get(0).getMessage()); + } + + @Test + public void correctTypesMixedTestTheOtherWay() { + RosettaExpression expr = parser.parseExpression("5 + \"Hello\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms of the operation " + + "are neither both strings nor both numbers", + ((RosettaInterpreterErrorValue)val).getErrors() + .get(0).getMessage()); + } + + @Test + public void stringConcatenationErrorTest() { + RosettaExpression expr = parser.parseExpression("\"Hello \" - \"World\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms are strings but the operation " + + "is not concatenation: not implemented", + ((RosettaInterpreterErrorValue)val).getErrors() + .get(0).getMessage()); + } + + @Test + public void wrongTypeLeftTest() { + RosettaExpression expr = parser.parseExpression("True - \"World\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Arithmetic Operation: Leftside is not of type Number/String", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void wrongTypeRightTestString() { + RosettaExpression expr = parser.parseExpression("\"Hello \" + True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void wrongTypeRightTestInteger() { + RosettaExpression expr = parser.parseExpression("2 + True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void wrongTypeRightTestNumber() { + RosettaExpression expr = parser.parseExpression("2.5 + True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void leftsideErrorTest() { + RosettaExpression expr = parser + .parseExpression("\"Hello \" - \"World\" + \"World\""); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms are strings but the " + + "operation is not concatenation: not implemented", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void complexTest() { + RosettaExpression expr = parser + .parseExpression("(\"Hello \" - \"World\") + (2 + ([1, 2] any > 0))"); + RosettaInterpreterValue val = interpreter.interp(expr); + List expected = List.of( + new RosettaInterpreterError( + "The terms are strings but the operation " + + "is not concatenation: not implemented"), + new RosettaInterpreterError( + "Arithmetic Operation: Rightside " + + "is not of type Number/String") + ); + assertEquals(expected, + ((RosettaInterpreterErrorValue)val) + .getErrors()); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 9fe62a0fb..c3db7c203 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -24,6 +24,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.rosetta.model.lib.RosettaNumber; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -86,7 +87,7 @@ public void numberTest() { RosettaExpression expr = parser.parseExpression("if True then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); - BigDecimal number = BigDecimal.valueOf(1.2); + RosettaNumber number = RosettaNumber.valueOf(BigDecimal.valueOf(1.2)); assertEquals(number, ((RosettaInterpreterNumberValue) result).getValue()); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 4383fddcb..9684e7afd 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -25,6 +25,7 @@ import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.rosetta.model.lib.RosettaNumber; import com.regnosys.rosetta.tests.util.ExpressionValidationHelper; @ExtendWith(InjectionExtension.class) @@ -117,8 +118,7 @@ public void intTest() { public void numberTest() { RosettaExpression expr = parser.parseExpression("5.5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(BigDecimal.valueOf(5.5), - ((RosettaInterpreterNumberValue)val).getValue()); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), ((RosettaInterpreterNumberValue)val).getValue()); } @Test From 2ca9c909ea5b59576040053824557d0e689d67a7 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 14:09:47 +0200 Subject: [PATCH 096/236] Fixed conflicts with dev (arithmetics) --- rosetta-lang/model/RosettaExpression.xcore | 3 +++ rosetta-lang/model/RosettaInterpreter.xcore | 1 - .../RosettaInterpreterVisitor.java | 17 ++++++++++++----- ...rRosettaArithmeticOperationsInterpreter.java | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 2b3511739..71d675e55 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -257,6 +257,9 @@ class ArithmeticOperation extends RosettaBinaryOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class LogicalOperation extends RosettaBinaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index e35b2677d..4fab8b9f5 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -17,7 +17,6 @@ import com.regnosys.rosetta.rosetta.expression.EqualityOperation import com.regnosys.rosetta.rosetta.expression.ComparisonOperation import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference -import com.regnosys.rosetta.rosetta.expression.RosettaReference import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 08765a884..4e4dd86b2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -146,17 +146,22 @@ public RosettaInterpreterValue interp(ComparisonOperation exp) { //return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } - @Override - public RosettaInterpreterValue interp(ArithmeticOperation exp) { - return new RosettaInterpreterRosettaArithmeticOperationsInterpreter().interp(exp); - } - @Override public RosettaInterpreterValue interp(ComparisonOperation exp, RosettaInterpreterBaseEnvironment env) { // TODO Auto-generated method stub return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(ArithmeticOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(ArithmeticOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterRosettaArithmeticOperationsInterpreter().interp(exp, env); + } @Override public RosettaInterpreterValue interp(RosettaSymbolReference exp) { @@ -266,4 +271,6 @@ public RosettaInterpreterValue interp(LastOperation exp, // TODO Auto-generated method stub throw new UnsupportedOperationException(); } + + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 4e6b89ddd..ffc17b61a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -2,12 +2,13 @@ import java.util.List; - +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -15,6 +16,12 @@ public class RosettaInterpreterRosettaArithmeticOperationsInterpreter extends RosettaInterpreterConcreteInterpreter { + + + public RosettaInterpreterValue interp(ArithmeticOperation expr) { + return interp(expr, new RosettaInterpreterEnvironment()); + } + /** * Interprets an arithmetic operation, evaluating the operation between the two terms. * @@ -25,15 +32,16 @@ public class RosettaInterpreterRosettaArithmeticOperationsInterpreter * If errors are encountered, a RosettaInterpreterErrorValue representing * the error. */ - public RosettaInterpreterValue interp(ArithmeticOperation expr) { + public RosettaInterpreterValue interp(ArithmeticOperation expr, + RosettaInterpreterBaseEnvironment env) { String leftString = null; String rightString = null; RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); - RosettaInterpreterValue leftInterpreted = left.accept(visitor); - RosettaInterpreterValue rightInterpreted = right.accept(visitor); + RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); + RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); if (!(leftInterpreted instanceof RosettaInterpreterNumberValue || leftInterpreted instanceof RosettaInterpreterStringValue From 78ead24d497d2dc487b7efdbe44ca1acc9169cac Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 14:16:28 +0200 Subject: [PATCH 097/236] Deleted comment/fixed test string --- rosetta-lang/model/RosettaExpression.xcore | 6 ------ .../interpreternew/RosettaInterpreterVariableTest.java | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 71d675e55..a45e41c55 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -153,12 +153,6 @@ class ListLiteral extends RosettaExpression { */ abstract class RosettaReference extends RosettaExpression { -// op RosettaInterpreterValue accept(InterpreterVisitor v) { -// v.interp(this) -// } -// op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { -// v.interp(this,nv) -// } } class RosettaSymbolReference extends RosettaReference { diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java index 36f807d45..951553836 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java @@ -58,7 +58,7 @@ public void variableGoodComparisonTest() { //give the same environment to the parser RosettaExpression expr = parser.parseExpression("a >= 2", - List.of("a" + " " + "int (1..1)")); + List.of("a int (1..1)")); RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -79,7 +79,7 @@ public void variableLeftErrorComparisonTest() { //give a different environment to the parser RosettaExpression expr = parser.parseExpression("b >= 2", - List.of("b" + " " + "int (1..1)")); + List.of("b int (1..1)")); RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -99,7 +99,7 @@ public void variableRightErrorComparisonTest() { //give a different environment to the parser RosettaExpression expr = parser.parseExpression("1 = b", - List.of("b" + " " + "int (1..1)")); + List.of("b int (1..1)")); RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -121,7 +121,7 @@ public void variableBothErrorTest() { //give a different environment to the parser RosettaExpression expr = parser.parseExpression("a <= b", - List.of("a" + " " + "int (1..1)", "b" + " " + "int (1..1)")); + List.of("a int (1..1)", "b int (1..1)")); RosettaInterpreterValue val = interpreter.interp(expr,env); From b1ea203e70b2031455b2b2cd7e006b74e7963bf7 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 24 May 2024 20:39:03 +0200 Subject: [PATCH 098/236] Remove comments --- .../interpreternew/RosettaInterpreterVisitor.java | 7 ------- ...RosettaInterpreterComparisonOperationInterpreter.java | 9 --------- 2 files changed, 16 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 4e4dd86b2..67516c51b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -143,13 +143,11 @@ public RosettaInterpreterValue interp(EqualityOperation exp, @Override public RosettaInterpreterValue interp(ComparisonOperation exp) { return interp(exp, new RosettaInterpreterEnvironment()); - //return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); } @Override public RosettaInterpreterValue interp(ComparisonOperation exp, RosettaInterpreterBaseEnvironment env) { - // TODO Auto-generated method stub return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, env); } @@ -209,31 +207,26 @@ public RosettaInterpreterValue interp(JoinOperation exp, @Override public RosettaInterpreterValue interp(RosettaExistsExpression exp) { - // TODO Auto-generated method stub return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { - // TODO Auto-generated method stub return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(RosettaCountOperation exp) { - // TODO Auto-generated method stub return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(FirstOperation exp) { - // TODO Auto-generated method stub return interp(exp, new RosettaInterpreterEnvironment()); } @Override public RosettaInterpreterValue interp(LastOperation exp) { - // TODO Auto-generated method stub return interp(exp, new RosettaInterpreterEnvironment()); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 85cb26f09..477e3f8db 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -105,11 +105,6 @@ else if (RosettaInterpreterErrorValue.errorsExist(rightValue)) { + " not supported")); } - - //check if these types are actually comparable -// boolean result = checkComparableTypes(leftValue, rightValue, expr.getOperator()); -// -// return new RosettaInterpreterBooleanValue(result); } private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, @@ -149,8 +144,6 @@ else if (leftValue instanceof RosettaInterpreterListValue) { new RosettaInterpreterError( "cannot use \"ANY\" keyword " + "to compare two elements")); - - //return new RosettaInterpreterBooleanValue(false); } private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, @@ -190,8 +183,6 @@ else if (leftValue instanceof RosettaInterpreterListValue) { new RosettaInterpreterError( "cannot use \"ALL\" keyword " + "to compare two elements")); - - //return new RosettaInterpreterBooleanValue(false); } private boolean checkComparableTypes(RosettaInterpreterValue leftValue, From 98e0f3aea848e13ebb35907ae87194a13c97dbf7 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Sun, 26 May 2024 11:08:32 +0200 Subject: [PATCH 099/236] Distinct, reverse, sum operations --- rosetta-lang/model/RosettaExpression.xcore | 9 + rosetta-lang/model/RosettaInterpreter.xcore | 8 +- .../RosettaInterpreterVisitor.java | 19 ++ .../values/RosettaInterpreterBaseValue.java | 17 +- .../values/RosettaInterpreterErrorValue.java | 13 +- .../RosettaInterpreterIntegerValue.java | 5 + ...ttaInterpreterListOperatorInterpreter.java | 122 +++++++++ ...nterpreterListOperatorInterpreterTest.java | 248 ++++++++++++++++++ 8 files changed, 432 insertions(+), 9 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index a3b923729..d4bf37647 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -346,9 +346,15 @@ class FlattenOperation extends ListOperation, CanHandleListOfLists { } class DistinctOperation extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class ReverseOperation extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class FirstOperation extends ListOperation { @@ -364,6 +370,9 @@ class LastOperation extends ListOperation { } class SumOperation extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } } class AsKeyOperation extends RosettaUnaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 42dd112f0..a31e4b222 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -23,6 +23,9 @@ import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation import com.regnosys.rosetta.rosetta.expression.FirstOperation import com.regnosys.rosetta.rosetta.expression.LastOperation +import com.regnosys.rosetta.rosetta.expression.DistinctOperation +import com.regnosys.rosetta.rosetta.expression.ReverseOperation +import com.regnosys.rosetta.rosetta.expression.SumOperation class RosettaInterpreterBaseError{ String message @@ -49,5 +52,8 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaAbsentExpression exp) op RosettaInterpreterValue interp (RosettaCountOperation exp) op RosettaInterpreterValue interp (FirstOperation exp) - op RosettaInterpreterValue interp (LastOperation exp) + op RosettaInterpreterValue interp (LastOperation exp) + op RosettaInterpreterValue interp (DistinctOperation exp) + op RosettaInterpreterValue interp (ReverseOperation exp) + op RosettaInterpreterValue interp (SumOperation exp) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 051d54e52..49d9d8095 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,7 +1,9 @@ package com.regnosys.rosetta.interpreternew; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; +import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.EqualityOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.JoinOperation; @@ -19,12 +21,14 @@ import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; +import com.regnosys.rosetta.rosetta.expression.SumOperation; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperatorInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; @@ -128,4 +132,19 @@ public RosettaInterpreterValue interp(LastOperation exp) { // TODO Auto-generated method stub throw new UnsupportedOperationException(); } + + @Override + public RosettaInterpreterValue interp(DistinctOperation exp) { + return new RosettaInterpreterListOperatorInterpreter().interp(exp); + } + + @Override + public RosettaInterpreterValue interp(ReverseOperation exp) { + return new RosettaInterpreterListOperatorInterpreter().interp(exp); + } + + @Override + public RosettaInterpreterValue interp(SumOperation exp) { + return new RosettaInterpreterListOperatorInterpreter().interp(exp); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index 16fe4c5e7..c806f758d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -1,7 +1,8 @@ package com.regnosys.rosetta.interpreternew.values; import java.lang.reflect.InvocationTargetException; - +import java.util.List; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.eclipse.emf.common.notify.Adapter; @@ -65,6 +66,20 @@ public static Stream valueStream(RosettaInterpreterValu return ((RosettaInterpreterBaseValue)val).toValueStream(); } + /** + * Converts a rosetta value to a list of itself or values it contains. + * + * @param val - value to convert + * @return - list of value or its contained values + */ + public static List toValueList(RosettaInterpreterValue val){ + if (!(val instanceof RosettaInterpreterBaseValue)) { + throw new RosettaInterpreterNewException("Cannot take value stream" + + "of RosettaInterpreterValue"); + } + return valueStream(val).collect(Collectors.toList()); + } + @Override public EClass eClass() { // TODO Auto-generated method stub diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 112bb7849..d8848f2c8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -71,13 +71,14 @@ public static boolean errorsExist(RosettaInterpreterValue val1, } /** - * Checks if the supplied value is an error. + * Checks if the supplied value is an error + * or if the contained list contains an error. * * @param val1 - value to check * @return true iff value is an error value */ public static boolean errorsExist(RosettaInterpreterValue val1) { - return errorsExist(List.of(val1)); + return errorsExist(RosettaInterpreterBaseValue.toValueList(val1)); } /** @@ -115,7 +116,7 @@ public static RosettaInterpreterErrorValue merge(List v } public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val) { - return merge(List.of(val)); + return merge(RosettaInterpreterBaseValue.toValueList(val)); } public static RosettaInterpreterErrorValue merge(RosettaInterpreterValue val1, @@ -150,14 +151,12 @@ public boolean equals(Object obj) { @Override public Stream toElementStream() { - throw new RosettaInterpreterNewException("You should not be trying to take" - + " a stream of element of an error value"); + return Stream.of(errors); } @Override public Stream toValueStream() { - throw new RosettaInterpreterNewException("You should not be trying to take" - + " a stream of an error value"); + return Stream.of(this); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index fbf0b29df..bd9fd0dfc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -36,6 +36,11 @@ public RosettaInterpreterIntegerValue(BigInteger value) { this.value = value; } + public RosettaInterpreterIntegerValue(int value) { + super(); + this.value = BigInteger.valueOf(value); + } + public BigInteger getValue() { return value; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java new file mode 100644 index 000000000..26c7903b2 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -0,0 +1,122 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.expression.DistinctOperation; +import com.regnosys.rosetta.rosetta.expression.ReverseOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.SumOperation; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterListOperatorInterpreter + extends RosettaInterpreterConcreteInterpreter { + + /** + * Interprets a Distinct Operation. + * Returns a list where duplicate elements are removed + * such that only one copy of them exists in the resulting + * list + * + * @param exp - distinct operation to interpret + * @return - list Value of distinct values + */ + public RosettaInterpreterValue interp(DistinctOperation exp) { + RosettaExpression expression = exp.getArgument(); + RosettaInterpreterValue val = expression.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(val)) { + return RosettaInterpreterErrorValue.merge(val); + } + + List distinct = + RosettaInterpreterBaseValue.valueStream(val) + .distinct() + .collect(Collectors.toList()); + + return new RosettaInterpreterListValue(distinct); + } + + /** + * Interprets a Reverse operation. + * Reverses the order of the elements in the list and returns it + * + * @param exp - Reverse operation to interpret + * @return - Reversed list + */ + public RosettaInterpreterValue interp(ReverseOperation exp) { + RosettaExpression expression = exp.getArgument(); + RosettaInterpreterValue val = expression.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(val)) { + return RosettaInterpreterErrorValue.merge(val); + } + + List values = + RosettaInterpreterBaseValue.toValueList(val); + Collections.reverse(values); + + return new RosettaInterpreterListValue(values); + } + + /** + * Interprets the sum operation. + * Returns a sum of all the summable elements of the list + * If the elements are not summable returns an error + * + * @param exp - Sum operation to interpret + * @return sum of elements or error if elements are not summable + */ + public RosettaInterpreterValue interp(SumOperation exp) { + RosettaExpression expression = exp.getArgument(); + RosettaInterpreterValue val = expression.accept(visitor); + + if (RosettaInterpreterErrorValue.errorsExist(val)) { + return RosettaInterpreterErrorValue.merge(val); + } + + // In the compiler, this returns a null rather than an error + // So I'm not exactly sure how to handle it + if (RosettaInterpreterBaseValue.toValueList(val).size() < 1) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Cannot take sum" + + " of empty list")); + } + + List values = + RosettaInterpreterBaseValue.toValueList(val); + + // Check that all values are numbers, and convert ints + // to numbers for further simplicity + for (int i = 0; i < values.size(); i++) { + RosettaInterpreterValue v = values.get(i); + if (v instanceof RosettaInterpreterIntegerValue) { + RosettaInterpreterIntegerValue valInt = + (RosettaInterpreterIntegerValue)v; + values.set(i, new RosettaInterpreterNumberValue( + BigDecimal.valueOf(valInt.getValue().longValue()))); + } + else if (!(v instanceof RosettaInterpreterNumberValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Cannot take sum" + + "of non-number value")); + } + } + + BigDecimal result = values.stream() + .map(x -> ((RosettaInterpreterNumberValue)x).getValue()) + .reduce(BigDecimal.valueOf(0), (x, y) -> x.add(y)); + + return new RosettaInterpreterNumberValue(result); + } + + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java new file mode 100644 index 000000000..c5ffd595c --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -0,0 +1,248 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import static org.junit.jupiter.api.Assertions.*; + +import java.math.BigDecimal; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ExpressionValidationHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +class RosettaInterpreterListOperatorInterpreterTest { + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + @Inject + private ExpressionValidationHelper validation; + @SuppressWarnings("unused") + private ExpressionFactory exFactory; + + @BeforeEach + public void setup() { + exFactory = ExpressionFactoryImpl.init(); + } + + @Test + void testInterpDistinctOperationUseless() { + String expressionText = "[1 ,2] distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(1), + new RosettaInterpreterIntegerValue(2))); + + assertEquals(exp, val); + } + + @Test + void testInterpDistinctOperationSimple() { + String expressionText = "[1 ,2, 2] distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(1), + new RosettaInterpreterIntegerValue(2))); + + assertEquals(exp, val); + } + + @Test + void testInterpDistinctOperationMany() { + String expressionText = "[2, 2, 2, 2, 2, 2] distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(2))); + + assertEquals(exp, val); + } + + @Test + void testInterpDistinctOperationEmpty() { + String expressionText = "[] distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of()); + + assertEquals(exp, val); + } + + @Test + void testInterpDistinctOperationNonList() { + String expressionText = "1 distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(1))); + + assertEquals(exp, val); + } + + @Test + void testInterpDistinctOperationError() { + String expressionText = "[(1 and False), 2] distinct"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + + @Test + void testInterpReverseOperationSimple() { + String expressionText = "[1 ,2] reverse"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(2), + new RosettaInterpreterIntegerValue(1))); + + assertEquals(exp, val); + } + + @Test + void testInterpReverseOperationSingle() { + String expressionText = "1 reverse"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(1))); + + assertEquals(exp, val); + } + + @Test + void testInterpReverseOperationEmpty() { + String expressionText = "[] reverse"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of()); + + assertEquals(exp, val); + } + + @Test + void testInterpReverseOperationBig() { + String expressionText = "[1 ,2, 3, 4, 5, 6] reverse"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue exp = new RosettaInterpreterListValue( + List.of(new RosettaInterpreterIntegerValue(6), + new RosettaInterpreterIntegerValue(5), + new RosettaInterpreterIntegerValue(4), + new RosettaInterpreterIntegerValue(3), + new RosettaInterpreterIntegerValue(2), + new RosettaInterpreterIntegerValue(1))); + + assertEquals(exp, val); + } + + @Test + void testInterpReverseOperationError() { + String expressionText = "[(1 and False), 2] reverse"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + + @Test + void testInterpSumOperationSimple() { + String expressionText = "[1 ,2] sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterNumberValue exp = + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)); + + assertEquals(exp, val); + } + + @Test + void testInterpSumOperationSingle() { + String expressionText = "2 sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterNumberValue exp = + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)); + + assertEquals(exp, val); + } + + @Test + void testInterpSumOperationMixed() { + String expressionText = "[2, 3.5, 0.1] sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterNumberValue exp = + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5.6)); + + assertEquals(exp, val); + } + + @Test + void testInterpSumOperationEmpty() { + String expressionText = "[] sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + + @Test + void testInterpSumOperationWrongType() { + String expressionText = "[1, True, 3] sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + + @Test + void testInterpSumOperationErrorInside() { + String expressionText = "[1, (1 and False), 3] sum"; + RosettaExpression expr = parser.parseExpression(expressionText); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + + assertTrue(val instanceof RosettaInterpreterErrorValue); + } + +} From 5489290e50a79590898f66e8ac8c7f7d48011c7a Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Sun, 26 May 2024 11:53:29 +0200 Subject: [PATCH 100/236] Fixed the number-based errors, now all tests pass --- .../visitors/RosettaInterpreterListOperatorInterpreter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 26c7903b2..a4471736e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.SumOperation; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.rosetta.model.lib.RosettaNumber; public class RosettaInterpreterListOperatorInterpreter extends RosettaInterpreterConcreteInterpreter { @@ -111,9 +112,9 @@ else if (!(v instanceof RosettaInterpreterNumberValue)) { } } - BigDecimal result = values.stream() + RosettaNumber result = values.stream() .map(x -> ((RosettaInterpreterNumberValue)x).getValue()) - .reduce(BigDecimal.valueOf(0), (x, y) -> x.add(y)); + .reduce(RosettaNumber.valueOf(BigDecimal.valueOf(0)), (x, y) -> x.add(y)); return new RosettaInterpreterNumberValue(result); } From 795f0398b70b3aa0b8e314cafe834e51405874a2 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sun, 26 May 2024 20:04:26 +0200 Subject: [PATCH 101/236] Resolved conflicts with distinct, reverse, sum --- rosetta-lang/model/RosettaExpression.xcore | 9 +++++++ ...ttaInterpreterListOperatorInterpreter.java | 26 ++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 06a146f6f..5e8ec1072 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -406,12 +406,18 @@ class DistinctOperation extends ListOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this, nv) + } } class ReverseOperation extends ListOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this, nv) + } } class FirstOperation extends ListOperation { @@ -436,6 +442,9 @@ class SumOperation extends ListOperation { op RosettaInterpreterValue accept(InterpreterVisitor v) { v.interp(this) } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this, nv) + } } class AsKeyOperation extends RosettaUnaryOperation { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index a4471736e..13831a541 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -6,11 +6,13 @@ import java.util.stream.Collectors; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -20,6 +22,18 @@ public class RosettaInterpreterListOperatorInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterValue interp(DistinctOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + public RosettaInterpreterValue interp(ReverseOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + public RosettaInterpreterValue interp(SumOperation exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } /** * Interprets a Distinct Operation. @@ -30,9 +44,9 @@ public class RosettaInterpreterListOperatorInterpreter * @param exp - distinct operation to interpret * @return - list Value of distinct values */ - public RosettaInterpreterValue interp(DistinctOperation exp) { + public RosettaInterpreterValue interp(DistinctOperation exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression expression = exp.getArgument(); - RosettaInterpreterValue val = expression.accept(visitor); + RosettaInterpreterValue val = expression.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(val)) { return RosettaInterpreterErrorValue.merge(val); @@ -53,9 +67,9 @@ public RosettaInterpreterValue interp(DistinctOperation exp) { * @param exp - Reverse operation to interpret * @return - Reversed list */ - public RosettaInterpreterValue interp(ReverseOperation exp) { + public RosettaInterpreterValue interp(ReverseOperation exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression expression = exp.getArgument(); - RosettaInterpreterValue val = expression.accept(visitor); + RosettaInterpreterValue val = expression.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(val)) { return RosettaInterpreterErrorValue.merge(val); @@ -76,9 +90,9 @@ public RosettaInterpreterValue interp(ReverseOperation exp) { * @param exp - Sum operation to interpret * @return sum of elements or error if elements are not summable */ - public RosettaInterpreterValue interp(SumOperation exp) { + public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression expression = exp.getArgument(); - RosettaInterpreterValue val = expression.accept(visitor); + RosettaInterpreterValue val = expression.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(val)) { return RosettaInterpreterErrorValue.merge(val); From c3eff23905687b85f57e9cebd061f260d4f3a884 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 28 May 2024 12:27:28 +0200 Subject: [PATCH 102/236] Added the Only-element list operation --- rosetta-lang/model/RosettaExpression.xcore | 6 ++++ rosetta-lang/model/RosettaInterpreter.xcore | 5 ++- .../RosettaInterpreterVisitor.java | 12 +++++++ ...ttaInterpreterListOperatorInterpreter.java | 36 +++++++++++++++++++ ...nterpreterListOperatorInterpreterTest.java | 30 ++++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 5e8ec1072..d30e6fb06 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -388,6 +388,12 @@ class RosettaAbsentExpression extends RosettaUnaryOperation { } class RosettaOnlyElement extends ListOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaCountOperation extends RosettaUnaryOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 75721872d..280bf1ab9 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -25,11 +25,12 @@ import com.regnosys.rosetta.rosetta.expression.JoinOperation import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation +import com.regnosys.rosetta.rosetta.expression.SumOperation import com.regnosys.rosetta.rosetta.expression.FirstOperation import com.regnosys.rosetta.rosetta.expression.LastOperation import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation -import com.regnosys.rosetta.rosetta.expression.SumOperation +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement class RosettaInterpreterBaseError{ String message @@ -59,6 +60,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaExistsExpression exp) op RosettaInterpreterValue interp (RosettaAbsentExpression exp) op RosettaInterpreterValue interp (RosettaCountOperation exp) + op RosettaInterpreterValue interp (RosettaOnlyElement exp) op RosettaInterpreterValue interp (FirstOperation exp) op RosettaInterpreterValue interp (LastOperation exp) op RosettaInterpreterValue interp (DistinctOperation exp) @@ -85,6 +87,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaExistsExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaAbsentExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaOnlyElement exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (FirstOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (LastOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (DistinctOperation exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 135c13176..664cfdc52 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -21,6 +21,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; @@ -231,6 +232,17 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp, return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); } + @Override + public RosettaInterpreterValue interp(RosettaOnlyElement exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaOnlyElement exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); + } + @Override public RosettaInterpreterValue interp(LastOperation exp) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index fd66dbfaa..2ee93d041 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -23,6 +23,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; import com.regnosys.rosetta.rosetta.expression.SumOperation; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.rosetta.model.lib.RosettaNumber; @@ -132,6 +133,37 @@ public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterBase .collect(Collectors.toList()).get(0); } } + + /** + * Interprets a only-element operation. + * If a list has exactly one element, it returns it. + * Otherwise, it returns an error. + * + * @param exp Expression on which to perform 'only-element' operation + * @return The single element of the list + */ + public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = exp.getArgument(); + RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); + + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgument)) { + return interpretedArgument; + } + + long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); + if (count == 0L) { + // List is empty + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List is empty")); + } else if (count == 1L) { + // List has one element + return RosettaInterpreterBaseValue.valueStream(interpretedArgument) + .collect(Collectors.toList()).get(0); + } else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("List contains more than one element")); + } + } /** @@ -166,6 +198,10 @@ public RosettaInterpreterValue interp(DistinctOperation exp) { return interp(exp, new RosettaInterpreterEnvironment()); } + public RosettaInterpreterValue interp(RosettaOnlyElement exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + public RosettaInterpreterValue interp(ReverseOperation exp) { return interp(exp, new RosettaInterpreterEnvironment()); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java index ebc2c04ba..58d95f53b 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -47,6 +47,36 @@ public void setup() { expFactory = ExpressionFactoryImpl.init(); } + @Test + void testOnlyElementEmptyList() { + String expected = "List is empty"; + RosettaExpression expr = parser.parseExpression("[] only-element"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + String errorMessage = ((RosettaInterpreterErrorValue)val).getErrors().get(0).getMessage(); + assertEquals(expected, errorMessage); + } + + @Test + void testOnlyElementMoreThanOne() { + String expected = "List contains more than one element"; + RosettaExpression expr = parser.parseExpression("[1, 2, 3] only-element"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + String errorMessage = ((RosettaInterpreterErrorValue)val).getErrors().get(0).getMessage(); + assertEquals(expected, errorMessage); + } + + @Test + void testOnlyElementTrue() { + RosettaInterpreterNumberValue expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)); + RosettaExpression expr = parser.parseExpression("[1.0] only-element"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterNumberValue); + RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; + assertEquals(expected, castedVal); + } + @Test void testExistsTrue() { RosettaInterpreterBooleanValue expected = new RosettaInterpreterBooleanValue(true); From 1764c3a3ab0f7512c59aabe1795bb8f8873a1e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Tue, 28 May 2024 16:10:17 +0300 Subject: [PATCH 103/236] Setup for record types --- rosetta-lang/model/Rosetta.xcore | 11 +++++++++++ rosetta-lang/model/RosettaInterpreter.xcore | 7 +++++++ .../interpreternew/RosettaInterpreterVisitor.java | 12 ++++++++++++ ...settaInterpreterRosettaRecordTypeInterpreter.java | 12 ++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 3cbc5fd21..bc0408a9c 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -11,6 +11,10 @@ import com.regnosys.rosetta.rosetta.simple.Data import com.regnosys.rosetta.rosetta.simple.Attribute import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor + +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment class RosettaModel extends RosettaDefinable { String name @@ -111,6 +115,13 @@ class RosettaSynonymSource extends RosettaRootElement , RosettaNamed { class RosettaRecordType extends RosettaRootElement, RosettaBuiltinType { contains RosettaRecordFeature[] features + + op RosettaInterpreterValue accept(InterpreterVisitor v) { + v.interp(this) + } + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaRecordFeature extends RosettaTypedFeature {} diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 75721872d..48412ca16 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -5,6 +5,8 @@ package com.regnosys.rosetta.rosetta.interpreter +import com.regnosys.rosetta.rosetta.RosettaRecordType + import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral @@ -66,6 +68,9 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp) + op RosettaInterpreterValue interp (RosettaRecordType exp) + + op RosettaInterpreterValue interp (RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env) @@ -91,5 +96,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) + } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 135c13176..67f6005a7 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -3,6 +3,7 @@ import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.RosettaRecordType; import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; @@ -38,6 +39,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaRecordTypeInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterVariableInterpreter; @@ -297,4 +299,14 @@ public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(RosettaRecordType exp) { + return interp(exp, new RosettaInterpreterEnvironment()); + } + + @Override + public RosettaInterpreterValue interp(RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterRosettaRecordTypeInterpreter().interp(exp, env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java new file mode 100644 index 000000000..fa6a3e52a --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.RosettaRecordType; + +public class RosettaInterpreterRosettaRecordTypeInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaRecordType expr, RosettaInterpreterBaseEnvironment env) { + return null; + } +} From 19047387a867a50bb5b3cf462e9b38ca6960e7e0 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 28 May 2024 19:10:53 +0200 Subject: [PATCH 104/236] Added an error propagation test --- .../RosettaInterpreterListOperatorInterpreterTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java index 58d95f53b..8f2b2220d 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -47,6 +47,16 @@ public void setup() { expFactory = ExpressionFactoryImpl.init(); } + @Test + void testOnlyElementErrorPropagation() { + String expected = "Logical Operation: Rightside is not of type Boolean\""; + RosettaExpression expr = parser.parseExpression("[(True or 2)] only-element"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertTrue(val instanceof RosettaInterpreterErrorValue); + String errorMessage = ((RosettaInterpreterErrorValue)val).getErrors().get(0).getMessage(); + assertEquals(expected, errorMessage); + } + @Test void testOnlyElementEmptyList() { String expected = "List is empty"; From 0687ede9a5f5825ff47923b1511ff1bc73766f25 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 28 May 2024 19:27:25 +0200 Subject: [PATCH 105/236] Fixed error propagation test --- ...settaInterpreterListOperatorInterpreterTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java index 8f2b2220d..c0eaf27e2 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -48,13 +48,16 @@ public void setup() { } @Test - void testOnlyElementErrorPropagation() { - String expected = "Logical Operation: Rightside is not of type Boolean\""; - RosettaExpression expr = parser.parseExpression("[(True or 2)] only-element"); + void testOnlyElementError() { + RosettaInterpreterErrorValue expected = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Logical Operation: " + + "Rightside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("(True and 1) only-element"); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); - String errorMessage = ((RosettaInterpreterErrorValue)val).getErrors().get(0).getMessage(); - assertEquals(expected, errorMessage); + RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; + assertEquals(expected, castedVal); } @Test From 5ef40b14ccf6dd08acea931dc5ef5bb2f71498aa Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 30 May 2024 11:51:57 +0200 Subject: [PATCH 106/236] Added better error messages --- rosetta-lang/.project | 6 +-- .../values/RosettaInterpreterError.java | 40 +++++++++++++++++-- ...ttaInterpreterListOperatorInterpreter.java | 2 +- .../RosettaInterpreterErrorValueTest.java | 37 ++++++++++++++++- 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/rosetta-lang/.project b/rosetta-lang/.project index f46323c08..abbd3d17f 100644 --- a/rosetta-lang/.project +++ b/rosetta-lang/.project @@ -21,17 +21,17 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.pde.ManifestBuilder - org.eclipse.pde.ManifestBuilder + org.eclipse.pde.SchemaBuilder - org.eclipse.pde.SchemaBuilder + org.eclipse.m2e.core.maven2Builder diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index f4e82f92c..e2ef5cdfb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -13,10 +13,16 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; public class RosettaInterpreterError implements RosettaInterpreterBaseError { + + private String errorMessage; + private EObject associatedExpression; + @Override public int hashCode() { return Objects.hash(errorMessage); @@ -37,18 +43,46 @@ public boolean equals(Object obj) { return Objects.equals(errorMessage, other.errorMessage); } - private String errorMessage; + @Deprecated public RosettaInterpreterError(String errorMessage) { - super(); + this.errorMessage = errorMessage; + } + + public RosettaInterpreterError(EObject obj) { + this.associatedExpression = obj; + this.errorMessage = ""; + } + + public RosettaInterpreterError(String errorMessage, EObject obj) { + this.associatedExpression = obj; this.errorMessage = errorMessage; } public String getError() { return errorMessage; } + public EObject getEobject() { return associatedExpression; } + + /** + * Gives a parsed error message associated with this error. + * Gets the INode associated in order to provide details of where the erorr ocurred. + * + * @return Error message with code information + */ + public String properErrorMessage() { + INode node = NodeModelUtils.findActualNodeFor(associatedExpression); + int startLine = node.getStartLine(); + int offset = node.getOffset(); + String text = node.getText().trim(); + String message = "Error at line " + startLine + ", position " + offset + ": " + + "\"" + text + "\". " + errorMessage; + return message; + } + @Override public String toString() { - return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; + return properErrorMessage(); + //return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 2ee93d041..d615026fd 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -278,7 +278,7 @@ public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEn if (RosettaInterpreterBaseValue.toValueList(val).size() < 1) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Cannot take sum" - + " of empty list")); + + " of empty list", exp)); } List values = diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index b58452b26..06a1b2376 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -7,18 +7,41 @@ import java.util.ArrayList; import java.util.List; +import javax.inject.Inject; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; - - +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) class RosettaInterpreterErrorValueTest { + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + @SuppressWarnings("unused") + private ExpressionFactory exFactory; + RosettaInterpreterError e1; RosettaInterpreterError e2; RosettaInterpreterError e3; @@ -42,6 +65,7 @@ void setup() { vb1 = new RosettaInterpreterBooleanValue(true); vb2 = new RosettaInterpreterBooleanValue(false); vals = new ArrayList<>(List.of(v1,v2,v3,vb1,vb2)); + exFactory = ExpressionFactoryImpl.init(); } @Test @@ -117,5 +141,14 @@ void testMergeRosettaInterpreterValueRosettaInterpreterValue() { assertEquals(val, RosettaInterpreterErrorValue.merge(v2, v3)); } + + @Test + void sumErrorNewTest() { + RosettaExpression ex = parser.parseExpression("5 + 5 + 3 + ([] sum)"); + RosettaInterpreterValue val = interpreter.interp(ex); + assertTrue(val instanceof RosettaInterpreterErrorValue); + assertEquals("Error at line 1, position 12: \"([] sum)\". Cannot take sum of empty list", + ((RosettaInterpreterErrorValue)val).getErrors().get(0).toString()); + } } From 5c8e5692edd31b35b90b8864f264ef1387a8ccec Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 31 May 2024 18:14:10 +0200 Subject: [PATCH 107/236] Setup of new project --- com.regnosys.rosetta.interpreternew/.project | 23 + .../checkstyle-SP.xml | 279 ++ com.regnosys.rosetta.interpreternew/pom.xml | 103 + .../regnosys/rosetta/interpreternew/App.java | 13 + .../rosetta/interpreternew/AppTest.java | 20 + pom.xml | 2404 ++++++++++++----- rosetta-lang/.project | 6 +- 7 files changed, 2208 insertions(+), 640 deletions(-) create mode 100644 com.regnosys.rosetta.interpreternew/.project create mode 100644 com.regnosys.rosetta.interpreternew/checkstyle-SP.xml create mode 100644 com.regnosys.rosetta.interpreternew/pom.xml create mode 100644 com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java create mode 100644 com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java diff --git a/com.regnosys.rosetta.interpreternew/.project b/com.regnosys.rosetta.interpreternew/.project new file mode 100644 index 000000000..d53fdc8e9 --- /dev/null +++ b/com.regnosys.rosetta.interpreternew/.project @@ -0,0 +1,23 @@ + + + com.regnosys.rosetta.interpreternew + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml b/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml new file mode 100644 index 000000000..3f8c27c07 --- /dev/null +++ b/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.regnosys.rosetta.interpreternew/pom.xml b/com.regnosys.rosetta.interpreternew/pom.xml new file mode 100644 index 000000000..af5138942 --- /dev/null +++ b/com.regnosys.rosetta.interpreternew/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + com.regnosys.rosetta.parent + com.regnosys.rosetta + 0.0.0.main-SNAPSHOT + + + com.regnosys.rosetta.interpreternew + + + Rosetta DSL Delft Interpreter Project + + + UTF-8 + 1.7 + 1.7 + 3.3.1 + checkstyle-SP.xml + + + + + junit + junit + test + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + checkstyle-SP.xml + true + true + warning + true + + src/main/java + src/test/java + + + + + + + diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java b/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java new file mode 100644 index 000000000..51ce9eb27 --- /dev/null +++ b/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java @@ -0,0 +1,13 @@ +package org.com.regnosys.rosetta.interpreternew; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java new file mode 100644 index 000000000..ea3573585 --- /dev/null +++ b/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java @@ -0,0 +1,20 @@ +package org.com.regnosys.rosetta.interpreternew; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/pom.xml b/pom.xml index 8176198e3..b0761e911 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + - - - 4.0.0 - - - org.finos - finos - 5 - - - com.regnosys.rosetta - com.regnosys.rosetta.parent - 0.0.0.main-SNAPSHOT - pom - - Rosetta DSL Parent POM - + --> + + + 4.0.0 + + + + + + org.finos + + + finos + + + 5 + + + + + + com.regnosys.rosetta + + + com.regnosys.rosetta.parent + + + 0.0.0.main-SNAPSHOT + + + pom + + + Rosetta DSL Parent POM + + + Rosetta is a Domain-Specific Language (DSL) that supports the modelling of operational processes for the financial markets' industry. Its purpose is to promote consistency and @@ -41,651 +59,1763 @@ This parent project manages dependencies of the modules that make up the Rosetta DSL. - https://github.com/REGnosys/rosetta-dsl - - - REGnosys - https://regnosys.com/ - - - - https://github.com/REGnosys/rosetta-dsl - scm:git:https://github.com/REGnosys/rosetta-dsl.git - scm:git:ssh://github.com/REGnosys/rosetta-dsl.git - HEAD - - - - https://github.com/REGnosys/rosetta-dsl/issues - GitHub Issues - - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - SimonCockx - Simon Cockx - infra@regnosys.com - http://github.com/SimonCockx - REGnosys - https://regnosys.com - Europe/Brussels - - Developer - - - - - - 11 - [17,18) - UTF-8 - - - ${env.GPG_KEYNAME} - ${env.GPG_PASSPHRASE} - s01.oss.sonatype.org - REGnosys Release Distribution Repository - REGnosys Development Snapshot Repository - https://regnosys.com/assets/images/common/logo.png - 10 - - - 2.27.0 - 3.14.0 - 1.11.0 - 1.22.0 - 2.2 - 1.6.0 - 3.9.6 - 3.9.6 - 3.10.2 - 2.0.9 - 1.4.14 - 1.3.0 - 2.16.0 - - - 5.10.1 - 5.8.0 - - - 1.23.0 - 3.4.1 - 3.3.1 - 3.1.1 - 3.3.2 - 3.5.0 - 3.3.1 - 3.6.1 - 3.2.2 - 3.10.2 - 3.11.0 - 1.0.5 - 2.1.0 - 3.6.3 - 1.6.13 - 1.15.0 - 20.10.0 - - - - rosetta-xcore-plugin-dependencies - rosetta-runtime - rosetta-lang - rosetta-ide - rosetta-tools - rosetta-testing - rosetta-maven-plugin - rosetta-profiling - - - - - - - org.junit - junit-bom - ${junit.version} - pom - import - - - org.eclipse.xtext - org.eclipse.xtext.xbase.testing - ${xtext.version} - - - org.mockito - mockito-core - ${mockito-core.version} - test - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - - - org.eclipse.xtext - xtext-dev-bom - ${xtext.version} - pom - import - - - org.eclipse.xtext - org.eclipse.xtext - ${xtext.version} - - - ch.qos.reload4j - reload4j - - - - - org.eclipse.xtext - org.eclipse.xtext.ide - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.testing - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.xbase - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.xbase.lib - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.generator - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.common.types - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.ecore - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.util - ${xtext.version} - - - ch.qos.reload4j - reload4j - - - - - org.eclipse.xtend - org.eclipse.xtend.lib - ${xtext.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.apache.commons - commons-text - ${commons-text.version} - - - org.eclipse.emf - org.eclipse.emf.ecore.xcore - ${org.eclipse.emf.ecore.xcore.version} - - - log4j - log4j - - - - - org.eclipse.emf - org.eclipse.emf.ecore.xcore.lib - ${org.eclipse.emf.ecore.xcore.lib.version} - - - org.eclipse.xsemantics - org.eclipse.xsemantics.runtime - ${xsemantics.version} - - - ch.qos.reload4j - reload4j - - - - - org.eclipse.xsemantics - org.eclipse.xsemantics.dsl - ${xsemantics.version} - - - org.yaml - snakeyaml - ${snakeyaml.version} - - - org.apache.maven - maven-plugin-api - ${maven-plugin-api.version} - - - org.apache.maven - maven-core - ${maven-core.version} - - - org.apache.maven.plugin-tools - maven-plugin-annotations - ${maven-plugin-annotations.version} - - - org.eclipse.xtext - xtext-maven-plugin - ${xtext.version} - - - ch.qos.reload4j - reload4j - - - - - org.slf4j - slf4j-api - ${slf4j.version} - - + + + ${env.GPG_KEYNAME} + + + ${env.GPG_PASSPHRASE} + + + s01.oss.sonatype.org + + + REGnosys Release Distribution Repository + + + REGnosys Development Snapshot Repository + + + https://regnosys.com/assets/images/common/logo.png + + + 10 + + + + + + 2.27.0 + + + 3.14.0 + + + 1.11.0 + + + 1.22.0 + + + 2.2 + + + 1.6.0 + + + 3.9.6 + + + 3.9.6 + + + 3.10.2 + + + 2.0.9 + + + 1.4.14 + + + 1.3.0 + + + 2.16.0 + + + + + + 5.10.1 + + + 5.8.0 + + + + + + 1.23.0 + + + 3.4.1 + + + 3.3.1 + + + 3.1.1 + + + 3.3.2 + + + 3.5.0 + + + 3.3.1 + + + 3.6.1 + + + 3.2.2 + + + 3.10.2 + + + 3.11.0 + + + 1.0.5 + + + 2.1.0 + + + 3.6.3 + + + 1.6.13 + + + 1.15.0 + + + 20.10.0 + + + + + + + + + rosetta-xcore-plugin-dependencies + + + rosetta-runtime + + + rosetta-lang + + + rosetta-ide + + + rosetta-tools + + + rosetta-testing + + + rosetta-maven-plugin + + + rosetta-profiling + + + + + + com.regnosys.rosetta.interpreternew + + + + + + + + + + + + + + + + + org.junit + + + junit-bom + + + ${junit.version} + + + pom + + + import + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.xbase.testing + + + ${xtext.version} + + + + + + + + + org.mockito + + + mockito-core + + + ${mockito-core.version} + + + test + + + + + + + + + ch.qos.logback + + + logback-classic + + + ${logback.version} + + + + + + + + + ch.qos.logback + + + logback-core + + + ${logback.version} + + + + + + + + + + + + org.eclipse.xtext + + + xtext-dev-bom + + + ${xtext.version} + + + pom + + + import + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext + + + ${xtext.version} + + + + + + + + + ch.qos.reload4j + + + reload4j + + + + + + + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.ide + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.testing + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.xbase + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.xbase.lib + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.generator + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.common.types + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.ecore + + + ${xtext.version} + + + + + + + + + org.eclipse.xtext + + + org.eclipse.xtext.util + + + ${xtext.version} + + + + + + + + + ch.qos.reload4j + + + reload4j + + + + + + + + + + + + + + + org.eclipse.xtend + + + org.eclipse.xtend.lib + + + ${xtext.version} + + + + + + + + + org.apache.commons + + + commons-lang3 + + + ${commons-lang3.version} + + + + + + + + + org.apache.commons + + + commons-text + + + ${commons-text.version} + + + + + + + + + org.eclipse.emf + + + org.eclipse.emf.ecore.xcore + + + ${org.eclipse.emf.ecore.xcore.version} + + + + + + + + + log4j + + + log4j + + + + + + + + + + + + + + + org.eclipse.emf + + + org.eclipse.emf.ecore.xcore.lib + + + ${org.eclipse.emf.ecore.xcore.lib.version} + + + + + + + + + org.eclipse.xsemantics + + + org.eclipse.xsemantics.runtime + + + ${xsemantics.version} + + + + + + + + + ch.qos.reload4j + + + reload4j + + + + + + + + + + + + + + + org.eclipse.xsemantics + + + org.eclipse.xsemantics.dsl + + + ${xsemantics.version} + + + + + + + + + org.yaml + + + snakeyaml + + + ${snakeyaml.version} + + + + + + + + + org.apache.maven + + + maven-plugin-api + + + ${maven-plugin-api.version} + + + + + + + + + org.apache.maven + + + maven-core + + + ${maven-core.version} + + + + + + + + + org.apache.maven.plugin-tools + + + maven-plugin-annotations + + + ${maven-plugin-annotations.version} + + + + + + + + + org.eclipse.xtext + + + xtext-maven-plugin + + + ${xtext.version} + + + + + + + + + ch.qos.reload4j + + + reload4j + + + + + + + + + + + + + + + org.slf4j + + + slf4j-api + + + ${slf4j.version} + + + + + + - - org.slf4j - log4j-over-slf4j - ${slf4j.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - - org.mdkt.compiler - InMemoryJavaCompiler - ${InMemoryJavaCompiler.version} - - - - - - - org.junit.jupiter - junit-jupiter - test - - - ch.qos.logback - logback-classic - test - - - ch.qos.logback - logback-core - test - - - org.slf4j - log4j-over-slf4j - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-java - - enforce - - - - - ${java.enforced.version} - - - - log4j:log4j - + + + + + + org.slf4j + + + log4j-over-slf4j + + + ${slf4j.version} + + + + + + + + + com.fasterxml.jackson.core + + + jackson-databind + + + ${jackson.version} + + + + + + + + + com.fasterxml.jackson.datatype + + + jackson-datatype-jdk8 + + + ${jackson.version} + + + + + + + + + com.fasterxml.jackson.dataformat + + + jackson-dataformat-yaml + + + ${jackson.version} + + + + + + + + + org.mdkt.compiler + + + InMemoryJavaCompiler + + + ${InMemoryJavaCompiler.version} + + + + + + + + + + + + + + + + + + org.junit.jupiter + + + junit-jupiter + + + test + + + + + + + + + ch.qos.logback + + + logback-classic + + + test + + + + + + + + + ch.qos.logback + + + logback-core + + + test + + + + + + + + + org.slf4j + + + log4j-over-slf4j + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + + + maven-enforcer-plugin + + + + + + + + + enforce-java + + + + + + enforce + + + + + + + + + + + + + + + ${java.enforced.version} + + + + + + + + + + + + log4j:log4j + + + org.apache.logging.log4j:log4j-core - ch.qos.reload4j:reload4j - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - checkstyle.xml - true - true - - src/main/java - src/test/java - target/xtend-gen/main/java - target/xtend-gen/test/java - - - - - Check style - - process-test-sources - - check - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-generated-sources-to-build - initialize - - add-source - - - - ${project.basedir}/src-gen/main/java - ${project.basedir}/emf-gen/main/java - + + + ch.qos.reload4j:reload4j + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.codehaus.mojo + + + build-helper-maven-plugin + + + + + + + + + add-generated-sources-to-build + + + initialize + + + + + + add-source + + + + + + + + + + + + ${project.basedir}/src-gen/main/java + + + ${project.basedir}/emf-gen/main/java + + + ${project.build.directory}/xtend-gen/main/java - - - - - add-generated-test-sources-to-build - initialize - - add-test-source - - - - ${project.basedir}/src-gen/test/java - ${project.basedir}/emf-gen/test/java - + + + + + + + + + + + + + + + add-generated-test-sources-to-build + + + initialize + + + + + + add-test-source + + + + + + + + + + + + ${project.basedir}/src-gen/test/java + + + ${project.basedir}/emf-gen/test/java + + + ${project.build.directory}/xtend-gen/test/java - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - ${nexus-staging-maven-plugin.version} - true - - https://${repoServerHost} - ossrh - true - ${stagingTimeoutInMinutes} - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - org.codehaus.mojo - build-helper-maven-plugin - ${build-helper-maven-plugin.version} - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.eclipse.xtend - xtend-maven-plugin - ${xtext.version} - - - - compile - xtend-install-debug-info - testCompile - xtend-test-install-debug-info - - - - - + + + + + + + + + + + + + + + + + + + + + org.sonatype.plugins + + + nexus-staging-maven-plugin + + + ${nexus-staging-maven-plugin.version} + + + true + + + + + + https://${repoServerHost} + + + ossrh + + + true + + + ${stagingTimeoutInMinutes} + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + + + maven-enforcer-plugin + + + ${maven-enforcer-plugin.version} + + + + + + + + + org.codehaus.mojo + + + build-helper-maven-plugin + + + ${build-helper-maven-plugin.version} + + + + + + + + + org.codehaus.mojo + + + exec-maven-plugin + + + ${exec-maven-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-clean-plugin + + + ${maven-clean-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-surefire-plugin + + + ${maven-surefire-plugin.version} + + + + + + + + + org.eclipse.xtend + + + xtend-maven-plugin + + + ${xtext.version} + + + + + + + + + + + + compile + + + xtend-install-debug-info + + + testCompile + + + xtend-test-install-debug-info + + + + + + + + + + + + + + + ${project.build.directory}/xtend-gen/main/java - + + + ${project.build.directory}/xtend-gen/test/java - false - - - - org.eclipse.xtext - xtext-maven-plugin - ${xtext.version} - - - org.apache.maven.plugins - maven-resources-plugin - ${maven-resources-plugin.version} - - - org.apache.maven.plugins - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - com.googlecode.addjars-maven-plugin - addjars-maven-plugin - ${addjars-maven-plugin.version} - - - org.codehaus.mojo - appassembler-maven-plugin - ${appassembler-maven-plugin.version} - - - com.github.eirslett - frontend-maven-plugin - ${frontend-maven-plugin.version} - - v${node.version} - ${project.basedir}/vscode - ${project.basedir}/target - - - - org.apache.maven.plugins - maven-plugin-plugin - ${maven-plugin-plugin.version} - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - false - - - - attach-javadocs - package - - jar - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - + + + false + + + + + + + + + + + + org.eclipse.xtext + + + xtext-maven-plugin + + + ${xtext.version} + + + + + + + + + org.apache.maven.plugins + + + maven-resources-plugin + + + ${maven-resources-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-dependency-plugin + + + ${maven-dependency-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-compiler-plugin + + + ${maven-compiler-plugin.version} + + + + + + + + + com.googlecode.addjars-maven-plugin + + + addjars-maven-plugin + + + ${addjars-maven-plugin.version} + + + + + + + + + org.codehaus.mojo + + + appassembler-maven-plugin + + + ${appassembler-maven-plugin.version} + + + + + + + + + com.github.eirslett + + + frontend-maven-plugin + + + ${frontend-maven-plugin.version} + + + + + + v${node.version} + + + ${project.basedir}/vscode + + + ${project.basedir}/target + + + + + + + + + + + + org.apache.maven.plugins + + + maven-plugin-plugin + + + ${maven-plugin-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-javadoc-plugin + + + ${maven-javadoc-plugin.version} + + + + + + false + + + + + + + + + + + + attach-javadocs + + + package + + + + + + jar + + + + + + + + + + + + + + + + + + + + + org.eclipse.m2e + + + lifecycle-mapping + + + 1.0.0 + + + + + + + + + + + + + + + + + + org.codehaus.mojo - + + + exec-maven-plugin - + + + [${exec-maven-plugin.version},) - - java - - - - - - - - - + + + + + + java + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins - + + + maven-enforcer-plugin - + + + [${maven-enforcer-plugin.version},) - - enforce - - - - - - - - - + + + + + + enforce + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins - + + + maven-dependency-plugin - + + + [${maven-dependency-plugin.version},) - - copy-dependencies - - - - - - - - - + + + + + + copy-dependencies + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins - + + + maven-plugin-plugin - + + + [${maven-plugin-plugin.version},) - - descriptor - - - - - - - - - - - - - + + + + + + descriptor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rosetta-lang/.project b/rosetta-lang/.project index f46323c08..abbd3d17f 100644 --- a/rosetta-lang/.project +++ b/rosetta-lang/.project @@ -21,17 +21,17 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.pde.ManifestBuilder - org.eclipse.pde.ManifestBuilder + org.eclipse.pde.SchemaBuilder - org.eclipse.pde.SchemaBuilder + org.eclipse.m2e.core.maven2Builder From 329f6447c9505dbe5498665bf5915b033f0d9915 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Fri, 31 May 2024 18:41:18 +0200 Subject: [PATCH 108/236] Running checkstyle on subproject fixed --- .../checkstyle-SP.xml | 88 +++---------------- .../regnosys/rosetta/interpreternew/App.java | 6 +- .../rosetta/interpreternew/AppTest.java | 4 +- 3 files changed, 15 insertions(+), 83 deletions(-) diff --git a/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml b/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml index 3f8c27c07..1926d3b5a 100644 --- a/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml +++ b/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml @@ -24,10 +24,6 @@ - - - - @@ -39,29 +35,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -69,9 +42,9 @@ - + - + @@ -82,7 +55,7 @@ - + @@ -114,7 +87,7 @@ - + @@ -168,50 +141,26 @@ - - - - - - - - - - - - - + - - - - - - - - - - - - - + - + - + - + @@ -240,14 +189,7 @@ - - - - - - - - + @@ -257,20 +199,10 @@ - - - - - - - - - - diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java b/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java index 51ce9eb27..d3889ae4a 100644 --- a/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java +++ b/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java @@ -1,13 +1,13 @@ package org.com.regnosys.rosetta.interpreternew; /** - * Hello world! + * Hello world!. * */ public class App { - public static void main( String[] args ) + public static void main(String[] args) { - System.out.println( "Hello World!" ); + System.out.println("Hello World!"); } } diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java index ea3573585..80e4115cd 100644 --- a/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java +++ b/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java @@ -10,11 +10,11 @@ public class AppTest { /** - * Rigorous Test :-) + * Rigorous Test :-). */ @Test public void shouldAnswerWithTrue() { - assertTrue( true ); + assertTrue(true); } } From b6340091a1c090444060ff0f0919b5b0b02dbb9f Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 31 May 2024 19:36:35 +0200 Subject: [PATCH 109/236] Moved files into new subproject --- checkstyle-SP.xml | 70 +------------------ com.regnosys.rosetta.interpreternew/pom.xml | 19 ++++- .../interpreternew/RosettaInterpreterNew.java | 0 .../RosettaInterpreterNewException.java | 0 .../RosettaInterpreterVisitor.java | 0 .../RosettaInterpreterVisitorBase.java | 0 .../values/RosettaInterpreterBaseValue.java | 2 +- .../RosettaInterpreterBooleanValue.java | 0 .../values/RosettaInterpreterEnvironment.java | 0 .../values/RosettaInterpreterError.java | 0 .../values/RosettaInterpreterErrorValue.java | 0 .../RosettaInterpreterIntegerValue.java | 0 .../values/RosettaInterpreterListValue.java | 0 .../values/RosettaInterpreterNumberValue.java | 0 .../values/RosettaInterpreterStringValue.java | 0 ...rpreterComparisonOperationInterpreter.java | 0 ...RosettaInterpreterConcreteInterpreter.java | 0 ...ettaInterpreterListLiteralInterpreter.java | 0 ...aInterpreterListOperationsInterpreter.java | 0 ...ttaInterpreterListOperatorInterpreter.java | 0 ...nterpreterLogicalOperationInterpreter.java | 0 ...osettaArithmeticOperationsInterpreter.java | 0 ...reterRosettaBooleanLiteralInterpreter.java | 0 ...settaConditionalExpressionInterpreter.java | 0 ...terpreterRosettaIntLiteralInterpreter.java | 0 ...preterRosettaNumberLiteralInterpreter.java | 0 ...preterRosettaStringLiteralInterpreter.java | 0 ...RosettaInterpreterVariableInterpreter.java | 0 .../regnosys/rosetta/interpreternew/App.java | 13 ---- rosetta-testing/pom.xml | 5 ++ 30 files changed, 23 insertions(+), 86 deletions(-) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java (99%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java (100%) rename {rosetta-lang => com.regnosys.rosetta.interpreternew}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java (100%) delete mode 100644 com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java diff --git a/checkstyle-SP.xml b/checkstyle-SP.xml index 3f8c27c07..6b8659d5f 100644 --- a/checkstyle-SP.xml +++ b/checkstyle-SP.xml @@ -5,7 +5,7 @@ This configuration file was written by the eclipse-cs plugin configuration editor --> @@ -24,10 +24,6 @@ - - - - @@ -39,29 +35,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -168,40 +141,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -242,13 +191,6 @@ - - - - - - - @@ -257,20 +199,10 @@ - - - - - - - - - - diff --git a/com.regnosys.rosetta.interpreternew/pom.xml b/com.regnosys.rosetta.interpreternew/pom.xml index af5138942..fe1c0072b 100644 --- a/com.regnosys.rosetta.interpreternew/pom.xml +++ b/com.regnosys.rosetta.interpreternew/pom.xml @@ -22,9 +22,22 @@ - junit - junit - test + junit + junit + test + + + + + com.regnosys.rosetta + com.regnosys.rosetta.lib + ${project.version} + + + + com.regnosys.rosetta + com.regnosys.rosetta + 0.0.0.main-SNAPSHOT diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java similarity index 99% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index c806f758d..d3e7186f0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -72,7 +72,7 @@ public static Stream valueStream(RosettaInterpreterValu * @param val - value to convert * @return - list of value or its contained values */ - public static List toValueList(RosettaInterpreterValue val){ + public static List toValueList(RosettaInterpreterValue val) { if (!(val instanceof RosettaInterpreterBaseValue)) { throw new RosettaInterpreterNewException("Cannot take value stream" + "of RosettaInterpreterValue"); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java similarity index 100% rename from rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java rename to com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java b/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java deleted file mode 100644 index d3889ae4a..000000000 --- a/com.regnosys.rosetta.interpreternew/src/main/java/org/com/regnosys/rosetta/interpreternew/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.com.regnosys.rosetta.interpreternew; - -/** - * Hello world!. - * - */ -public class App -{ - public static void main(String[] args) - { - System.out.println("Hello World!"); - } -} diff --git a/rosetta-testing/pom.xml b/rosetta-testing/pom.xml index aba724373..7f8ef3c02 100644 --- a/rosetta-testing/pom.xml +++ b/rosetta-testing/pom.xml @@ -35,6 +35,11 @@ com.regnosys.rosetta ${project.version} + + com.regnosys.rosetta + com.regnosys.rosetta.interpreternew + ${project.version} + From d7947f25523ae9468738a3141b0b13cac0537ea0 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 31 May 2024 19:50:24 +0200 Subject: [PATCH 110/236] Changed pipeline to build and apply checkstyle on correct folders --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d9466509..6958eef09 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing + - mvn clean package -pl com.regnosys.rosetta.interpreternew, rosetta-testing # test: @@ -20,5 +20,5 @@ checkstyle: image: maven:3.8-openjdk-17 stage: checkstyle script: - - mvn checkstyle:check -pl rosetta-lang,rosetta-testing -D"checkstyle.config.location"="checkstyle-SP.xml" + - mvn checkstyle:check -pl com.regnosys.rosetta.interpreternew From 47ee0516dfaf1cdc27788d3290e7158a50087db2 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 31 May 2024 19:52:01 +0200 Subject: [PATCH 111/236] Sorry forgot to save --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6958eef09..ac25f385d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,8 @@ build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl com.regnosys.rosetta.interpreternew, rosetta-testing + - mvn clean package -pl com.regnosys.rosetta.interpreternew,rosetta-testing + # test: From 680e77112a07dcb7026465cb215a9dba196ff3c9 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 31 May 2024 19:56:34 +0200 Subject: [PATCH 112/236] Added other folders in the pipeline build to actually make it pass (hopefully) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac25f385d..df63a6e87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl com.regnosys.rosetta.interpreternew,rosetta-testing + - mvn clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,com.regnosys.rosetta.interpreternew,rosetta-testing From 84a7d97bf3e8c76771b1556d451df8b9ee8dce52 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Sat, 1 Jun 2024 17:17:52 +0200 Subject: [PATCH 113/236] Made some changes to visitor and some xcore files to reduce the number of interp methods in the visitor. Only kept the ones that take an environment as an argument --- rosetta-lang/model/RosettaExpression.xcore | 67 +----- rosetta-lang/model/RosettaInterpreter.xcore | 28 --- .../interpreternew/RosettaInterpreterNew.java | 3 +- .../RosettaInterpreterVisitor.java | 190 +++++------------- .../values/RosettaInterpreterEnvironment.java | 28 +++ .../values/RosettaInterpreterErrorValue.java | 1 - ...rpreterComparisonOperationInterpreter.java | 16 +- ...ettaInterpreterListLiteralInterpreter.java | 5 - ...aInterpreterListOperationsInterpreter.java | 19 +- ...ttaInterpreterListOperatorInterpreter.java | 35 +--- ...osettaArithmeticOperationsInterpreter.java | 7 +- ...reterRosettaBooleanLiteralInterpreter.java | 5 - ...settaConditionalExpressionInterpreter.java | 9 +- ...terpreterRosettaIntLiteralInterpreter.java | 5 - ...preterRosettaNumberLiteralInterpreter.java | 5 - ...preterRosettaStringLiteralInterpreter.java | 5 - ...RosettaInterpreterVariableInterpreter.java | 6 +- 17 files changed, 97 insertions(+), 337 deletions(-) diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index d30e6fb06..20105051a 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -59,9 +59,6 @@ class RosettaBooleanLiteral extends RosettaLiteral { op String stringValue() { return Boolean.toString(value) } - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -76,9 +73,6 @@ class RosettaStringLiteral extends RosettaLiteral { op String stringValue() { return '"' + value + '"' } - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -93,9 +87,6 @@ class RosettaNumberLiteral extends RosettaLiteral { op String stringValue() { return value.toPlainString } - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -110,9 +101,6 @@ class RosettaIntLiteral extends RosettaLiteral { op String stringValue() { return value.toString } - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -129,8 +117,8 @@ class RosettaPatternLiteral extends RosettaLiteral { op String stringValue() { return '/' + value.toString() + '/' } - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) } } @@ -140,9 +128,6 @@ class RosettaPatternLiteral extends RosettaLiteral { class ListLiteral extends RosettaExpression { contains RosettaExpression[] elements - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -197,9 +182,6 @@ class RosettaConditionalExpression extends RosettaExpression { boolean full // whether the conditional expression has an explicit `else` branch. - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -248,18 +230,12 @@ interface RosettaBinaryOperation extends RosettaOperation, HasGeneratedInput { class ArithmeticOperation extends RosettaBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class LogicalOperation extends RosettaBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -276,9 +252,6 @@ interface ModifiableBinaryOperation extends RosettaBinaryOperation { } class EqualityOperation extends ModifiableBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -292,18 +265,12 @@ class ComparisonOperation extends ModifiableBinaryOperation { } class RosettaContainsExpression extends RosettaBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class RosettaDisjointExpression extends RosettaBinaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -311,9 +278,6 @@ class RosettaDisjointExpression extends RosettaBinaryOperation { class JoinOperation extends RosettaBinaryOperation { boolean explicitSeparator - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -370,36 +334,24 @@ enum ExistsModifier { class RosettaExistsExpression extends RosettaUnaryOperation { ExistsModifier modifier - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class RosettaAbsentExpression extends RosettaUnaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class RosettaOnlyElement extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class RosettaCountOperation extends RosettaUnaryOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } @@ -409,45 +361,30 @@ class FlattenOperation extends ListOperation, CanHandleListOfLists { } class DistinctOperation extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this, nv) } } class ReverseOperation extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this, nv) } } class FirstOperation extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class LastOperation extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this,nv) } } class SumOperation extends ListOperation { - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { v.interp(this, nv) } diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 280bf1ab9..d1de34106 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -40,34 +40,6 @@ abstract class RosettaInterpreterValue { } interface InterpreterVisitor { - op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) - op RosettaInterpreterValue interp (RosettaStringLiteral exp) - op RosettaInterpreterValue interp (RosettaNumberLiteral exp) - op RosettaInterpreterValue interp (RosettaIntLiteral exp) - op RosettaInterpreterValue interp (RosettaPatternLiteral exp) - op RosettaInterpreterValue interp (ListLiteral exp) - op RosettaInterpreterValue interp (RosettaConditionalExpression exp) - op RosettaInterpreterValue interp (LogicalOperation exp) - op RosettaInterpreterValue interp (EqualityOperation exp) - op RosettaInterpreterValue interp (ComparisonOperation exp) - op RosettaInterpreterValue interp (ArithmeticOperation exp) - op RosettaInterpreterValue interp (RosettaSymbolReference exp) - - - op RosettaInterpreterValue interp (RosettaContainsExpression exp) - op RosettaInterpreterValue interp (RosettaDisjointExpression exp) - op RosettaInterpreterValue interp (JoinOperation exp) - op RosettaInterpreterValue interp (RosettaExistsExpression exp) - op RosettaInterpreterValue interp (RosettaAbsentExpression exp) - op RosettaInterpreterValue interp (RosettaCountOperation exp) - op RosettaInterpreterValue interp (RosettaOnlyElement exp) - op RosettaInterpreterValue interp (FirstOperation exp) - op RosettaInterpreterValue interp (LastOperation exp) - op RosettaInterpreterValue interp (DistinctOperation exp) - op RosettaInterpreterValue interp (ReverseOperation exp) - op RosettaInterpreterValue interp (SumOperation exp) - - op RosettaInterpreterValue interp (RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index a898996c0..d0abf808b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -3,6 +3,7 @@ import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -23,7 +24,7 @@ public RosettaInterpreterValue interp(RosettaExpression expression) { } public RosettaInterpreterValue interp(RosettaExpression expression, - RosettaInterpreterEnvironment env) { + RosettaInterpreterBaseEnvironment env) { return expression.accept(visitor, env); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 664cfdc52..5d7a4c37d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -44,53 +44,33 @@ public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase { - @Override - public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } @Override public RosettaInterpreterValue interp(RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(RosettaStringLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaBooleanLiteralInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaStringLiteralInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(RosettaNumberLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaStringLiteralInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaNumberLiteralInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(RosettaIntLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaNumberLiteralInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaIntLiteral exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaIntLiteralInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaIntLiteralInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override @@ -99,214 +79,138 @@ public RosettaInterpreterValue interp(RosettaPatternLiteral exp, return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Pattern literals are not supported")); } - - @Override - public RosettaInterpreterValue interp(ListLiteral exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } @Override public RosettaInterpreterValue interp(ListLiteral exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListLiteralInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(RosettaConditionalExpression exp) { - return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp); + return new RosettaInterpreterListLiteralInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaConditionalExpression exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(LogicalOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaConditionalExpressionInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(LogicalOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterLogicalOperationInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(EqualityOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterLogicalOperationInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(EqualityOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterComparisonOperationInterpreter().interp(exp); - } - - @Override - public RosettaInterpreterValue interp(ComparisonOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(ComparisonOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(ArithmeticOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterComparisonOperationInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(ArithmeticOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaArithmeticOperationsInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(RosettaSymbolReference exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterRosettaArithmeticOperationsInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaSymbolReference exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterVariableInterpreter().interp(exp, env); + return new RosettaInterpreterVariableInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } - @Override - public RosettaInterpreterValue interp(RosettaContainsExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - @Override public RosettaInterpreterValue interp(RosettaContainsExpression exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperationsInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaDisjointExpression exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(JoinOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperationsInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(JoinOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperationsInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(RosettaExistsExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperationsInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaExistsExpression exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } - - @Override - public RosettaInterpreterValue interp(RosettaAbsentExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - @Override public RosettaInterpreterValue interp(RosettaAbsentExpression exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(RosettaOnlyElement exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } - - @Override - public RosettaInterpreterValue interp(LastOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } @Override public RosettaInterpreterValue interp(LastOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(FirstOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(RosettaCountOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(DistinctOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(DistinctOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(ReverseOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(ReverseOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); - } - - @Override - public RosettaInterpreterValue interp(SumOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } @Override public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); + return new RosettaInterpreterListOperatorInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); } } + diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java index 59baf9cdb..9a368eddc 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Objects; import com.regnosys.rosetta.rosetta.impl.RosettaInterpreterBaseEnvironmentImpl; @@ -63,5 +64,32 @@ public void addValue(String name, } + + @Override + public int hashCode() { + return Objects.hash(environment); + } + + @Override + public String toString() { + return "RosettaInterpreterListValue [environment = " + environment.toString() + "]"; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterEnvironment other = (RosettaInterpreterEnvironment) obj; + return Objects.equals(environment, other.environment); + } + + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index d8848f2c8..4baa53792 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -8,7 +8,6 @@ import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 477e3f8db..6ddfcea1a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ModifiableBinaryOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -32,19 +31,6 @@ public class RosettaInterpreterComparisonOperationInterpreter extends "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterStringValue"); - /** - * Interprets a comparison operation, evaluating the comparison between two operands. - * - * @param expr The ComparisonOperation expression to interpret - * @return If no errors are encountered, a RosettaInterpreterBooleanValue representing - * the result of the comparison operation. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } - /** * Interprets a comparison operation, evaluating the comparison between two operands. @@ -58,7 +44,7 @@ public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr) { * the error. */ public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { if (!comparisonOperators.contains(expr.getOperator())) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java index 22db70b08..542be596e 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.rosetta.expression.ListLiteral; @@ -17,10 +16,6 @@ public RosettaInterpreterListLiteralInterpreter() { super(); } - public RosettaInterpreterBaseValue interp(ListLiteral expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } - /** * Interprets a list literal, evaluating it to a list value. * diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 1540063ff..ed2341479 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; @@ -20,10 +19,6 @@ public class RosettaInterpreterListOperationsInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterValue interp(RosettaContainsExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - /** * Interprets a rosetta contains expression. * Checks if the right element, which may be a single element or a list, @@ -33,7 +28,7 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp) { * @return value of contains expression */ public RosettaInterpreterValue interp(RosettaContainsExpression exp, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { RosettaExpression leftExp = exp.getLeft(); RosettaExpression rightExp = exp.getRight(); @@ -59,10 +54,6 @@ public RosettaInterpreterValue interp(RosettaContainsExpression exp, return new RosettaInterpreterBooleanValue(contains); } - public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - /** * Interprets a rosetta disjoint expression. * Checks if the right element, which may be a single element or a list, @@ -72,7 +63,7 @@ public RosettaInterpreterValue interp(RosettaDisjointExpression exp) { * @return value of contains expression */ public RosettaInterpreterValue interp(RosettaDisjointExpression exp, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { RosettaExpression leftExp = exp.getLeft(); RosettaExpression rightExp = exp.getRight(); @@ -97,10 +88,6 @@ public RosettaInterpreterValue interp(RosettaDisjointExpression exp, return new RosettaInterpreterBooleanValue(notContains); } - - public RosettaInterpreterValue interp(JoinOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } /** * Interprets a join operation. @@ -111,7 +98,7 @@ public RosettaInterpreterValue interp(JoinOperation exp) { * @return concatenated string */ public RosettaInterpreterValue interp(JoinOperation exp, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { RosettaExpression stringsExp = exp.getLeft(); RosettaExpression delimExp = exp.getRight(); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 2ee93d041..9c7cbdb0b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -14,7 +14,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; @@ -40,7 +39,7 @@ public class RosettaInterpreterListOperatorInterpreter * @param exp Exists operation to interpret * @return Boolean indicating if the argument exists or not */ - public RosettaInterpreterValue interp(RosettaExistsExpression exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(RosettaExistsExpression exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -74,7 +73,7 @@ public RosettaInterpreterValue interp(RosettaExistsExpression exp, RosettaInterp * @param exp "Is absent" expression to intepret * @return Boolean indicating if the interpreted argument is absent */ - public RosettaInterpreterValue interp(RosettaAbsentExpression exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(RosettaAbsentExpression exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -94,7 +93,7 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp, RosettaInterp * @param exp Expression to perform 'count' on * @return Integer indicating how many elements there are in the list */ - public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -114,7 +113,7 @@ public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpre * @param exp Expression on which to perform 'first' operation * @return First element of the list */ - public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -142,7 +141,7 @@ public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterBase * @param exp Expression on which to perform 'only-element' operation * @return The single element of the list */ - public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -174,7 +173,7 @@ public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreter * @param exp Expression on which to perform 'last' operation * @return Last element of the list */ - public RosettaInterpreterValue interp(LastOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(LastOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression argument = exp.getArgument(); RosettaInterpreterValue interpretedArgument = argument.accept(visitor, env); @@ -194,22 +193,6 @@ public RosettaInterpreterValue interp(LastOperation exp, RosettaInterpreterBaseE } } - public RosettaInterpreterValue interp(DistinctOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - - public RosettaInterpreterValue interp(RosettaOnlyElement exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - - public RosettaInterpreterValue interp(ReverseOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - - public RosettaInterpreterValue interp(SumOperation exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - /** * Interprets a Distinct Operation. * Returns a list where duplicate elements are removed @@ -219,7 +202,7 @@ public RosettaInterpreterValue interp(SumOperation exp) { * @param exp - distinct operation to interpret * @return - list Value of distinct values */ - public RosettaInterpreterValue interp(DistinctOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(DistinctOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression expression = exp.getArgument(); RosettaInterpreterValue val = expression.accept(visitor, env); @@ -242,7 +225,7 @@ public RosettaInterpreterValue interp(DistinctOperation exp, RosettaInterpreterB * @param exp - Reverse operation to interpret * @return - Reversed list */ - public RosettaInterpreterValue interp(ReverseOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ReverseOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression expression = exp.getArgument(); RosettaInterpreterValue val = expression.accept(visitor, env); @@ -265,7 +248,7 @@ public RosettaInterpreterValue interp(ReverseOperation exp, RosettaInterpreterBa * @param exp - Sum operation to interpret * @return sum of elements or error if elements are not summable */ - public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterEnvironment env) { RosettaExpression expression = exp.getArgument(); RosettaInterpreterValue val = expression.accept(visitor, env); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index ffc17b61a..0057f1551 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -8,7 +8,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -18,10 +17,6 @@ public class RosettaInterpreterRosettaArithmeticOperationsInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterValue interp(ArithmeticOperation expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } - /** * Interprets an arithmetic operation, evaluating the operation between the two terms. * @@ -33,7 +28,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr) { * the error. */ public RosettaInterpreterValue interp(ArithmeticOperation expr, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { String leftString = null; String rightString = null; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java index be0780f36..2a8981194 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java @@ -1,16 +1,11 @@ package com.regnosys.rosetta.interpreternew.visitors; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; public class RosettaInterpreterRosettaBooleanLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - - public RosettaInterpreterBaseValue interp(RosettaBooleanLiteral expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } public RosettaInterpreterBooleanValue interp(RosettaBooleanLiteral expr, RosettaInterpreterEnvironment env) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index ee78fd37e..954c1755d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -16,10 +15,6 @@ public class RosettaInterpreterRosettaConditionalExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } - /** * Interpreter method for Conditional Expressions. * @@ -27,7 +22,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr) { * @return The interpreted value */ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { boolean ifResult = false; RosettaExpression ifExpression = expr.getIf(); @@ -52,7 +47,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, if (expr.isFull()) { elseThen = expr.getElsethen(); - elseThenValue = elseThen.accept(visitor); + elseThenValue = elseThen.accept(visitor, env); RosettaInterpreterBaseValue ifInstance = ((RosettaInterpreterBaseValue) ifThenValue); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java index 2ecf6cdfa..c4c262f4d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java @@ -1,6 +1,5 @@ package com.regnosys.rosetta.interpreternew.visitors; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; @@ -8,10 +7,6 @@ public class RosettaInterpreterRosettaIntLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterBaseValue interp(RosettaIntLiteral expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } - public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr, RosettaInterpreterEnvironment env) { return new RosettaInterpreterIntegerValue(expr.getValue()); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java index 0b687bd12..6fe9c1c93 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java @@ -1,16 +1,11 @@ package com.regnosys.rosetta.interpreternew.visitors; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; public class RosettaInterpreterRosettaNumberLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - - public RosettaInterpreterBaseValue interp(RosettaNumberLiteral expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } public RosettaInterpreterNumberValue interp(RosettaNumberLiteral exp, RosettaInterpreterEnvironment env) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java index 33e9acea6..957fddeca 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java @@ -1,16 +1,11 @@ package com.regnosys.rosetta.interpreternew.visitors; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; public class RosettaInterpreterRosettaStringLiteralInterpreter extends RosettaInterpreterConcreteInterpreter { - - public RosettaInterpreterBaseValue interp(RosettaStringLiteral expr) { - return interp(expr, new RosettaInterpreterEnvironment()); - } public RosettaInterpreterStringValue interp(RosettaStringLiteral exp, RosettaInterpreterEnvironment env) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 93cc624cf..63ea284c1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -2,7 +2,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -12,7 +11,7 @@ public class RosettaInterpreterVariableInterpreter { * Interprets a variable, returns the value of it. * * @param exp The RosettaSymbolReference expression to interpret - * @param environment RosettaInterpreterBaseEnvironment that keeps track + * @param env RosettaInterpreterBaseEnvironment that keeps track * of the current state of the program * @return If no errors are encountered, a RosettaInterpreterValue representing * the value of the variable. @@ -20,8 +19,7 @@ public class RosettaInterpreterVariableInterpreter { * the error. */ public RosettaInterpreterValue interp(RosettaSymbolReference exp, - RosettaInterpreterBaseEnvironment environment) { - RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) environment; + RosettaInterpreterEnvironment env) { //Search for variable in environment RosettaInterpreterBaseValue varValue = env.findValue(exp.getSymbol().getName()); From 90594147273889a670ccb759912acfc7b079bb5a Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Sat, 1 Jun 2024 17:32:41 +0200 Subject: [PATCH 114/236] Enum declaration (without the value reference) implementation as a reference for my ideas --- rosetta-lang/model/Rosetta.xcore | 10 ++ rosetta-lang/model/RosettaInterpreter.xcore | 2 + .../interpreternew/RosettaInterpreterNew.java | 6 ++ .../RosettaInterpreterVisitor.java | 9 ++ .../RosettaInterpreterEnumElementValue.java | 63 +++++++++++++ .../values/RosettaInterpreterEnumValue.java | 65 +++++++++++++ ...ettaInterpreterEnumerationInterpreter.java | 41 ++++++++ .../RosettaInterpreterEnumTest.java | 93 +++++++++++++++++++ 8 files changed, 289 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 3cbc5fd21..4240f5257 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -12,6 +12,12 @@ import com.regnosys.rosetta.rosetta.simple.Attribute import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor + +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment + class RosettaModel extends RosettaDefinable { String name String version = "0.0.0" @@ -143,6 +149,10 @@ class RosettaEnumeration extends RosettaRootElement, RosettaType, RosettaDefinab refers RosettaEnumeration superType contains RosettaSynonym[] synonyms contains RosettaEnumValue[] enumValues opposite enumeration + + op RosettaInterpreterBaseEnvironment accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaEnumValue extends RosettaNamed, RosettaDefinable, RosettaFeature, References { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index d1de34106..bb0e3e12b 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -18,6 +18,7 @@ import com.regnosys.rosetta.rosetta.expression.ComparisonOperation import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment +import com.regnosys.rosetta.rosetta.RosettaEnumeration import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression @@ -65,6 +66,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (DistinctOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterBaseEnvironment interp (RosettaEnumeration exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index d0abf808b..a49d16def 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -3,6 +3,7 @@ import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -27,4 +28,9 @@ public RosettaInterpreterValue interp(RosettaExpression expression, RosettaInterpreterBaseEnvironment env) { return expression.accept(visitor, env); } + + public RosettaInterpreterEnvironment interp(RosettaEnumeration expression, + RosettaInterpreterBaseEnvironment env) { + return (RosettaInterpreterEnvironment) expression.accept(visitor, env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5d7a4c37d..aba2196f0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -2,6 +2,7 @@ import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; @@ -31,6 +32,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEnumerationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; @@ -212,5 +214,12 @@ public RosettaInterpreterValue interp(SumOperation exp, return new RosettaInterpreterListOperatorInterpreter().interp(exp, (RosettaInterpreterEnvironment) env); } + + @Override + public RosettaInterpreterEnvironment interp(RosettaEnumeration exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterEnumerationInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java new file mode 100644 index 000000000..269e14184 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java @@ -0,0 +1,63 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterEnumElementValue extends RosettaInterpreterBaseValue { + + private String enumName; + private String value; + + /** + * Constructor for an Enum Element Value. + * + * @param n Name of the Enum + * @param v The String value + */ + public RosettaInterpreterEnumElementValue(String n, String v) { + super(); + this.enumName = n; + this.value = v; + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return "RosettaInterpreterEnumElementValue [value=" + value + "]"; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterEnumElementValue other = (RosettaInterpreterEnumElementValue) obj; + return Objects.equals(value, other.value) && Objects.equals(enumName, other.enumName); + } + + public String getValue() { return value; } + + public String getEnumName() { return enumName; } + + @Override + public Stream toElementStream() { + return Stream.of(value); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java new file mode 100644 index 000000000..a705033ae --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java @@ -0,0 +1,65 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterEnumValue extends RosettaInterpreterBaseValue { + + private String name; + private List values; + + /** + * Constructor for an Enum Value. + * + * @param name Name of the Enum + * @param values A list of all the String values that the Enum accepts + */ + public RosettaInterpreterEnumValue(String name, List values) { + super(); + this.name = name; + this.values = values; + } + + @Override + public int hashCode() { + return Objects.hash(values); + } + + @Override + public String toString() { + return "RosettaInterpreterListValue [name = " + name + ", values=" + values.toString() + "]"; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterEnumValue other = (RosettaInterpreterEnumValue) obj; + return Objects.equals(values, other.values) && Objects.equals(name, other.name); + } + + public List getValues() { return values; } + + + public String getName() { return name; } + + @Override + public Stream toElementStream() { + return Stream.of(values.toArray()); + } + + @Override + public Stream toValueStream() { + return values.stream(); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java new file mode 100644 index 000000000..9de9f63bf --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java @@ -0,0 +1,41 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.ArrayList; +import java.util.List; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.rosetta.RosettaEnumValue; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterEnumerationInterpreter + extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterEnumerationInterpreter() { + super(); + } + + /** + * Interprets a list literal, evaluating it to a list value. + * + * @param exp the expression to be interpreted + * @return the list value it represents + */ + public RosettaInterpreterEnvironment interp(RosettaEnumeration exp, + RosettaInterpreterEnvironment env) { + String enumName = exp.getName(); + List values = new ArrayList<>(); + for (RosettaEnumValue v : exp.getEnumValues()) { + values.add(new RosettaInterpreterEnumElementValue( + enumName, v.getName())); + } + RosettaInterpreterEnumValue enumeration = + new RosettaInterpreterEnumValue(enumName, values); + env.addValue(enumName, enumeration); + + return env; + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java new file mode 100644 index 000000000..c7a406d0c --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java @@ -0,0 +1,93 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; +//import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +//import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ModelHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterEnumTest { + + @Inject + RosettaInterpreterNew interpreter; + + @Inject + ModelHelper mh; + +// private ExpressionFactory exFactory; +// +// @BeforeEach +// public void setup() { +// exFactory = ExpressionFactoryImpl.init(); +// +// } + + @Test + public void enumAddsToEnvironmentTest() { + RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALU_E1 displayName \"VALU.E1\"\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result Foo (1..1)\r\n" + + " set result:\r\n" + + " Foo -> VALU_E1"); + RosettaInterpreterEnvironment expectedEnv = + new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Foo", + new RosettaInterpreterEnumValue("Foo", + List.of(new RosettaInterpreterEnumElementValue("Foo", "VALU_E1"), + new RosettaInterpreterEnumElementValue("Foo", "VALUE2")))); + RosettaInterpreterEnvironment actualEnv = + new RosettaInterpreterEnvironment(); + RosettaEnumeration enumeration = (RosettaEnumeration) model.getElements().get(0); + RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) + interpreter.interp(enumeration, actualEnv); + assertEquals((RosettaInterpreterEnvironment) env, + (RosettaInterpreterEnvironment) expectedEnv); + } + +// @Test +// public void enumRefTest() { +// RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" +// + " VALU_E1 displayName \"VALU.E1\"\r\n" +// + " VALUE2\r\n" +// + "\r\n" +// + "func MyTest:\r\n" +// + " output: result Foo (1..1)\r\n" +// + " set result:\r\n" +// + " Foo -> VALU_E1"); +// RosettaInterpreterEnvironment expectedEnv = +// new RosettaInterpreterEnvironment(); +// expectedEnv.addValue("Foo", +// new RosettaInterpreterEnumValue("Foo", +// List.of(new RosettaInterpreterEnumElementValue("Foo", "VALU_E1"), +// new RosettaInterpreterEnumElementValue("Foo", "VALUE2")))); +// RosettaInterpreterEnvironment actualEnv = +// new RosettaInterpreterEnvironment(); +// RosettaEnumeration enumeration = (RosettaEnumeration) model.getElements().get(0); +// RosettaExpression refCall = ((FunctionImpl) model.getElements().get(1)).getOperations() +// .get(0).getExpression(); +// RosettaInterpreterValue env = (RosettaInterpreterEnvironment) +// interpreter.interp(refCall, actualEnv); +// assertEquals((RosettaInterpreterEnvironment) env, +// (RosettaInterpreterEnvironment) expectedEnv); +// } + +} \ No newline at end of file From 0659dd179eb89ae0818a4e18377ce668cf714d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Sun, 2 Jun 2024 01:06:18 +0300 Subject: [PATCH 115/236] Added classes for date/time values --- .../RosettaInterpreterDateTimeValue.java | 21 ++++++++++++++++++ .../values/RosettaInterpreterDateValue.java | 22 +++++++++++++++++++ .../values/RosettaInterpreterTimeValue.java | 21 ++++++++++++++++++ .../RosettaInterpreterZonedDateTimeValue.java | 22 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java new file mode 100644 index 000000000..c0a931f80 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java @@ -0,0 +1,21 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterDateTimeValue extends RosettaInterpreterBaseValue { + + private RosettaInterpreterDateValue date; + private RosettaInterpreterTimeValue time; + + @Override + public Stream toElementStream() { + return Stream.of(date, time); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java new file mode 100644 index 000000000..346e36e47 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java @@ -0,0 +1,22 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { + + private Integer day; + private Integer month; + private Integer year; + + @Override + public Stream toElementStream() { + return Stream.of(day, month, year); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java new file mode 100644 index 000000000..3dea4b109 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -0,0 +1,21 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.time.LocalTime; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterTimeValue extends RosettaInterpreterBaseValue { + + private LocalTime time; + + @Override + public Stream toElementStream() { + return Stream.of(time); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java new file mode 100644 index 000000000..fdd5945d2 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java @@ -0,0 +1,22 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterZonedDateTimeValue extends RosettaInterpreterBaseValue { + + private RosettaInterpreterDateValue date; + private RosettaInterpreterTimeValue time; + private String timeZone; + + @Override + public Stream toElementStream() { + return Stream.of(date, time, timeZone); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } +} From 34e25ad86c1770fdb2e896e61d79ff50f3dfa744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Sun, 2 Jun 2024 23:47:53 +0300 Subject: [PATCH 116/236] Added Simon's changes --- .../scoping/RosettaScopeProvider.xtend | 6 +- .../rosetta/tests/util/ExpressionParser.xtend | 232 +++++++++--------- ...aInterpreterConditionalExpressionTest.java | 17 ++ .../tests/util/ExpressionParserTest.xtend | 56 +++++ 4 files changed, 190 insertions(+), 121 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/tests/util/ExpressionParserTest.xtend diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/scoping/RosettaScopeProvider.xtend b/rosetta-lang/src/main/java/com/regnosys/rosetta/scoping/RosettaScopeProvider.xtend index a0357efe7..22d26e316 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/scoping/RosettaScopeProvider.xtend +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/scoping/RosettaScopeProvider.xtend @@ -252,12 +252,12 @@ class RosettaScopeProvider extends ImportedNamespaceAwareLocalScopeProvider { } private def IScope defaultScope(EObject object, EReference reference) { - filteredScope(super.getScope(object,reference), [it.EClass !== FUNCTION_DISPATCH]) + filteredScope(super.getScope(object, reference), [it.EClass !== FUNCTION_DISPATCH]) } private def IScope getSymbolParentScope(EObject object, EReference reference, IScope outer) { - if (object === null) { - return IScope.NULLSCOPE + if (object.eContainer === null) { + return defaultScope(object, reference) } val parentScope = getSymbolParentScope(object.eContainer, reference, outer) switch (object) { diff --git a/rosetta-testing/src/main/java/com/regnosys/rosetta/tests/util/ExpressionParser.xtend b/rosetta-testing/src/main/java/com/regnosys/rosetta/tests/util/ExpressionParser.xtend index 0840354bb..a1dc948ed 100644 --- a/rosetta-testing/src/main/java/com/regnosys/rosetta/tests/util/ExpressionParser.xtend +++ b/rosetta-testing/src/main/java/com/regnosys/rosetta/tests/util/ExpressionParser.xtend @@ -11,88 +11,100 @@ import org.eclipse.xtext.nodemodel.util.NodeModelUtils import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.diagnostics.IDiagnosticConsumer import org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer -import java.util.Map -import org.eclipse.xtext.diagnostics.IDiagnosticProducer import org.eclipse.xtext.nodemodel.INode import org.eclipse.emf.ecore.EReference -import org.eclipse.xtext.CrossReference -import org.eclipse.xtext.nodemodel.ICompositeNode -import org.eclipse.xtext.RuleCall -import org.eclipse.xtext.ParserRule -import org.eclipse.xtext.GrammarUtil -import com.google.common.collect.Iterables -import org.eclipse.xtext.linking.impl.LinkingDiagnosticProducer import org.eclipse.xtext.diagnostics.Severity import org.eclipse.xtext.naming.QualifiedName -import org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider -import org.eclipse.xtext.linking.impl.Linker import com.regnosys.rosetta.rosetta.simple.Attribute -import com.regnosys.rosetta.builtin.RosettaBuiltinsService -import org.eclipse.emf.ecore.resource.ResourceSet -import com.regnosys.rosetta.rosetta.RosettaType import java.util.Collection -import java.util.Collections import com.regnosys.rosetta.scoping.RosettaScopeProvider import org.eclipse.emf.ecore.resource.Resource import org.eclipse.xtext.scoping.IScope import com.regnosys.rosetta.rosetta.RosettaModel import javax.inject.Inject +import java.util.List +import com.google.common.base.Predicate +import org.eclipse.xtext.resource.IEObjectDescription +import org.eclipse.xtext.scoping.Scopes +import static java.util.Collections.singletonList +import org.eclipse.xtext.linking.lazy.LazyLinker +import javax.inject.Provider +import org.eclipse.xtext.resource.XtextResource +import org.eclipse.emf.common.util.URI +import org.eclipse.xtext.EcoreUtil2 +import org.eclipse.emf.ecore.util.InternalEList +import org.eclipse.xtext.linking.lazy.LazyLinkingResource +import org.eclipse.xtext.linking.impl.DefaultLinkingService class ExpressionParser { @Inject IParser parser @Inject RosettaGrammarAccess grammar + @Inject ModelHelper modelHelper + @Inject Provider resourceProvider @Inject RosettaStaticLinker linker - Map basicTypes - - @Inject - new(RosettaBuiltinsService builtins, ResourceSet resourceSet) { - resourceSet.getResource(builtins.basicTypesURI, true).getContents().get(0) as RosettaModel => [ - basicTypes = elements - .filter[it instanceof RosettaType] - .map[it as RosettaType] - .toMap[name] - ] - } - def RosettaExpression parseExpression(CharSequence expr) { - return parseExpression(expr, Collections.emptyList) + return parseExpression(expr, emptyList) } def RosettaExpression parseExpression(CharSequence expr, Collection attrs) { - val attributes = attrs.map[createAttribute].toList - return parseExpression(expr, attributes) + return parseExpression(expr, defaultContext, attrs) + } + + def RosettaExpression parseExpression(CharSequence expr, List context, Collection attrs) { + val attributes = attrs.map[createAttribute(context)].toList + return parseExpression(expr, context, attributes) } def RosettaExpression parseExpression(CharSequence expr, Attribute... attributes) { + return parseExpression(expr, defaultContext, attributes) + } + + def RosettaExpression parseExpression(CharSequence expr, List context, Attribute... attributes) { val IParseResult result = parser.parse(grammar.rosettaCalcExpressionRule, new StringReader(expr.toString())) assertFalse(result.hasSyntaxErrors) val expression = result.rootASTElement as RosettaExpression - linkVariables(expression, attributes) + val exprRes = createResource("expr", expression, context) + link(expression, context, attributes) + deleteResource(exprRes, context) return expression } - private def void linkVariables(EObject obj, Collection attrs) { - val attributeMap = attrs - .toMap[name] - link(obj, attributeMap) + def Attribute createAttribute(CharSequence attr) { + return createAttribute(attr, defaultContext) } - def Attribute createAttribute(CharSequence attr) { + def Attribute createAttribute(CharSequence attr, List context) { val IParseResult result = parser.parse(grammar.attributeRule, new StringReader(attr.toString())) assertFalse(result.hasSyntaxErrors) val attribute = result.rootASTElement as Attribute - - link(attribute, basicTypes) - attribute + val attrRes = createResource("attribute " + attr, attribute, context) + link(attribute, context, emptyList) + deleteResource(attrRes, context) + return attribute + } + + private def Resource createResource(String name, EObject content, List context) { + val resource = resourceProvider.get() + resource.URI = URI.createURI("synthetic://" + name) + resource.contents.add(content) + context.head.eResource.resourceSet.resources.add(resource) + resource + } + private def void deleteResource(Resource resource, List context) { + context.head.eResource.resourceSet.resources.remove(resource) + } + + private def List defaultContext() { + return newArrayList(modelHelper.testResourceSet.resources.map[contents.head as RosettaModel]) } - private def void link(EObject obj, Map globals) { - linker.setGlobalsForNextLink(globals) + private def void link(EObject obj, List context, Collection globals) { + linker.setStateForNextLink(context, globals) val consumer = new ListBasedDiagnosticConsumer linker.linkModel(obj, consumer) - val errors = consumer.getResult(Severity.ERROR) + val errors = consumer.getResult(Severity.ERROR) + obj.eResource.errors val warnings = consumer.getResult(Severity.WARNING) if (!errors.empty) { throw new RuntimeException(errors.toString) @@ -102,98 +114,82 @@ class ExpressionParser { } } - private static class RosettaNullResourceScopeProvider extends RosettaScopeProvider { - override protected IScope getResourceScope(Resource res, EReference reference) { - return IScope.NULLSCOPE - } + private static class RosettaContextBasedScopeProvider extends RosettaScopeProvider { + List context = emptyList - override protected IScope getLocalElementsScope(IScope parent, EObject context, - EReference reference) { - return parent + def void setContext(List context) { + this.context = context } - } - private static class RosettaStaticLinker extends Linker { - @Inject - RosettaNullResourceScopeProvider scopeProvider - @Inject - ILinkingDiagnosticMessageProvider linkingDiagnosticMessageProvider - Map globals = newHashMap - - def void setGlobalsForNextLink(Map globals) { - this.globals = globals + + override protected getImplicitImports(boolean ignoreCase) { + (super.getImplicitImports(ignoreCase) + context.map[name].toSet.map[createImportedNamespaceResolver(it + ".*", ignoreCase)]).toList } - private def void clearGlobals() { - globals = newHashMap + + override protected IScope getResourceScope(Resource res, EReference reference) { + return createImportScope(getGlobalScope(this.context.head.eResource, reference), getImplicitImports(isIgnoreCase(reference)), null, reference.getEReferenceType(), isIgnoreCase(reference)) } - override protected doLinkModel(EObject root, IDiagnosticConsumer consumer) { - val producer = new LinkingDiagnosticProducer(consumer); - val iterator = getAllLinkableContents(root) - while (iterator.hasNext()) { - val eObject = iterator.next(); - installLinks(eObject, producer); + override protected IScope getLocalElementsScope(IScope parent, EObject context, EReference reference) { + var result = parent; + val allDescriptions = getAllDescriptions(this.context.head.eResource); + val name = getQualifiedNameOfLocalElement(context); + val ignoreCase = isIgnoreCase(reference); + val namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase); + if (!namespaceResolvers.isEmpty()) { + if (isRelativeImport() && name!==null && !name.isEmpty()) { + val localNormalizer = doCreateImportNormalizer(name, true, ignoreCase); + result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference)); + } + result = createImportScope(result, namespaceResolvers, null, reference.getEReferenceType(), isIgnoreCase(reference)); + } + if (name!==null) { + val localNormalizer = doCreateImportNormalizer(name, true, ignoreCase); + result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference)); } - clearGlobals + return result; } - override void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) { - + + override protected getGlobalScope(Resource context, EReference reference, Predicate filter) { + super.getGlobalScope(this.context.head.eResource, reference, filter) } + } + private static class RosettaStaticLinker extends LazyLinker { + @Inject + RosettaContextBasedScopeProvider scopeProvider + + IScope staticScope = IScope.NULLSCOPE - protected def void installLinks(EObject obj, IDiagnosticProducer producer) { - val node = NodeModelUtils.getNode(obj); - if (node === null) - return; - installLinks(obj, producer, node, false); + def void setStateForNextLink(List context, Collection globals) { + scopeProvider.setContext(context) + staticScope = Scopes.scopeFor(globals) } - - private def void installLinks(EObject obj, IDiagnosticProducer producer, ICompositeNode parentNode, boolean dontCheckParent) { - val eClass = obj.eClass(); - if (eClass.EAllReferences.size - eClass.EAllContainments.size === 0) - return; - - for (var node = parentNode.firstChild; node !== null; node = node.nextSibling) { - val grammarElement = node.grammarElement - if (grammarElement instanceof CrossReference && hasLeafNodes(node)) { - producer.setNode(node); - val crossReference = grammarElement as CrossReference; - val eRef = GrammarUtil.getReference(crossReference, eClass); - if (eRef === null) { - val parserRule = GrammarUtil.containingParserRule(crossReference); - val feature = GrammarUtil.containingAssignment(crossReference).getFeature(); - throw new IllegalStateException("Couldn't find EReference for crossreference '"+eClass.getName()+"::"+feature+"' in parser rule '"+parserRule.getName()+"'."); - } - setLink(obj, node, eRef, producer); - } else if (grammarElement instanceof RuleCall && node instanceof ICompositeNode) { - val ruleCall = grammarElement as RuleCall; - val calledRule = ruleCall.getRule(); - if (calledRule instanceof ParserRule && (calledRule as ParserRule).isFragment()) { - installLinks(obj, producer, node as ICompositeNode, true); - } - } - } - if (!dontCheckParent && shouldCheckParentNode(parentNode)) { - installLinks(obj, producer, parentNode.getParent(), dontCheckParent); - } + private def void clearState() { + scopeProvider.setContext(emptyList) + staticScope = IScope.NULLSCOPE } - private def void setLink(EObject obj, INode node, EReference eRef, IDiagnosticProducer producer) { + override protected doLinkModel(EObject root, IDiagnosticConsumer consumer) { + // TODO: this is hacky + ((root.eResource as LazyLinkingResource).linkingService as DefaultLinkingService).setScopeProvider(scopeProvider) + + super.doLinkModel(root, consumer) + EcoreUtil2.resolveAll(root) + clearState + } + + protected override void createAndSetProxy(EObject obj, INode node, EReference eRef) { val varName = NodeModelUtils.getTokenText(node) - val scope = scopeProvider.getScope(obj, eRef) - val elementInScope = scope.getSingleElement(QualifiedName.create(varName)) - if (elementInScope !== null) { - obj.eSet(eRef, elementInScope) - } else { - val elementInGlobals = globals.get(varName) - if (elementInGlobals !== null) { - obj.eSet(eRef, elementInGlobals) + val staticElement = staticScope.getSingleElement(QualifiedName.create(varName)) + if (staticElement !== null) { + val resolved = staticElement.getEObjectOrProxy() + if (eRef.isMany()) { + (obj.eGet(eRef, false) as InternalEList).addUnique(resolved) } else { - producer.addDiagnostic(linkingDiagnosticMessageProvider.getUnresolvedProxyMessage(createDiagnosticContext(obj, eRef, node))) + obj.eSet(eRef, resolved); } + } else { + super.createAndSetProxy(obj, node, eRef) } } - - protected def boolean hasLeafNodes(INode node) { - return !Iterables.isEmpty(node.getLeafNodes()); - } } } \ No newline at end of file diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index c3db7c203..cd3e2fbb8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -24,8 +24,11 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; import com.rosetta.model.lib.RosettaNumber; +import com.regnosys.rosetta.rosetta.RosettaModel; + @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) public class RosettaInterpreterConditionalExpressionTest { @@ -36,6 +39,10 @@ public class RosettaInterpreterConditionalExpressionTest { @Inject RosettaInterpreterNew interpreter; + @Inject + ModelHelper mh; + + @Test public void integerTest() { RosettaExpression expr = parser.parseExpression("if True then 1"); @@ -220,5 +227,15 @@ public void noElseTest() { assertEquals(null, result); } + + @Test + public void test() { + RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" + + "{\r\n" + + " day int\r\n" + + " month int\r\n" + + " year int }"); + System.out.println(expr.getElements().get(0).getClass()); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/tests/util/ExpressionParserTest.xtend b/rosetta-testing/src/test/java/com/regnosys/rosetta/tests/util/ExpressionParserTest.xtend new file mode 100644 index 000000000..5ce3c42e1 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/tests/util/ExpressionParserTest.xtend @@ -0,0 +1,56 @@ +package com.regnosys.rosetta.tests.util + +import com.regnosys.rosetta.tests.util.ModelHelper +import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.^extension.ExtendWith + +import javax.inject.Inject +import com.regnosys.rosetta.tests.RosettaInjectorProvider + +@ExtendWith(InjectionExtension) +@InjectWith(RosettaInjectorProvider) +class ExpressionParserTest { + + @Inject extension ExpressionParser + @Inject extension ExpressionValidationHelper + @Inject extension ModelHelper + + @Test + def void simpleExpressionParseTest() { + "(1 + 1) / 2" + .parseExpression + .assertNoIssues + } + + @Test + def void expressionWithVariablesParseTest() { + "(a + b) / 2" + .parseExpression(#["a int (1..1)", "b number(max: 5) (0..1)"]) + .assertNoIssues + } + + @Test + def void expressionWithContextParseTest() { + val model = ''' + type Foo: + attr int (0..1) + + func Bar: + inputs: + foo Foo (1..1) + output: + result int (1..1) + + alias part: foo -> attr + 1 + + set result: + part + 1 + '''.parseRosettaWithNoIssues + + "foo -> attr - Bar(foo)" + .parseExpression(#[model], #["foo Foo (1..1)"]) + .assertNoIssues + } +} \ No newline at end of file From a9cea42cfb04b11c7a2570e6615cbea5f724ec19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 3 Jun 2024 01:35:55 +0300 Subject: [PATCH 117/236] Added implementation for constructor expressions --- rosetta-lang/model/RosettaExpression.xcore | 4 + rosetta-lang/model/RosettaInterpreter.xcore | 2 + .../RosettaInterpreterVisitor.java | 7 ++ .../RosettaInterpreterDateTimeValue.java | 13 ++++ .../values/RosettaInterpreterDateValue.java | 19 +++++ .../values/RosettaInterpreterTimeValue.java | 8 ++ .../RosettaInterpreterZonedDateTimeValue.java | 18 +++++ ...settaConstructorExpressionInterpreter.java | 77 +++++++++++++++++++ ...aInterpreterConditionalExpressionTest.java | 12 ++- 9 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index d30e6fb06..2bfccb876 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -208,6 +208,10 @@ class RosettaConditionalExpression extends RosettaExpression { class RosettaConstructorExpression extends RosettaExpression, RosettaTyped { contains ConstructorKeyValuePair[] values boolean implicitEmpty + + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ConstructorKeyValuePair { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 9115d853d..ca7687cb1 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -26,6 +26,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression import com.regnosys.rosetta.rosetta.expression.JoinOperation import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression +import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation import com.regnosys.rosetta.rosetta.expression.SumOperation import com.regnosys.rosetta.rosetta.expression.FirstOperation @@ -100,6 +101,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 15495ae7e..eccbf36e3 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -19,6 +19,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; @@ -38,6 +39,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperatorInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConstructorExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaRecordTypeInterpreter; @@ -321,4 +323,9 @@ public RosettaInterpreterValue interp(RosettaRecordType exp) { public RosettaInterpreterValue interp(RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaRecordTypeInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterRosettaConstructorExpressionInterpreter().interp(exp, env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java index c0a931f80..13d3b0d73 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java @@ -9,6 +9,19 @@ public class RosettaInterpreterDateTimeValue extends RosettaInterpreterBaseValue private RosettaInterpreterDateValue date; private RosettaInterpreterTimeValue time; + public RosettaInterpreterDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time) { + this.date = date; + this.time = time; + } + + public RosettaInterpreterDateValue getDate() { + return date; + } + + public RosettaInterpreterTimeValue getTime() { + return time; + } + @Override public Stream toElementStream() { return Stream.of(date, time); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java index 346e36e47..b49500dc2 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java @@ -9,6 +9,25 @@ public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { private Integer day; private Integer month; private Integer year; + + public RosettaInterpreterDateValue(Integer day, Integer month, Integer year) { + this.day = day; + this.month = month; + this.year = year; + } + + public Integer getDay() { + return day; + } + + public Integer getMonth() { + return month; + } + + public Integer getYear() { + return year; + } + @Override public Stream toElementStream() { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java index 3dea4b109..d518c4d40 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -9,6 +9,14 @@ public class RosettaInterpreterTimeValue extends RosettaInterpreterBaseValue { private LocalTime time; + public RosettaInterpreterTimeValue(LocalTime time) { + this.time = time; + } + + public LocalTime getTime() { + return time; + } + @Override public Stream toElementStream() { return Stream.of(time); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java index fdd5945d2..d2ca92e81 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java @@ -10,6 +10,24 @@ public class RosettaInterpreterZonedDateTimeValue extends RosettaInterpreterBase private RosettaInterpreterTimeValue time; private String timeZone; + public RosettaInterpreterZonedDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time, String timeZone) { + this.date = date; + this.time = time; + this.timeZone = timeZone; + } + + public RosettaInterpreterDateValue getDate() { + return date; + } + + public RosettaInterpreterTimeValue getTime() { + return time; + } + + public String getTimeZone() { + return timeZone; + } + @Override public Stream toElementStream() { return Stream.of(date, time, timeZone); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java new file mode 100644 index 000000000..1280e4edd --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -0,0 +1,77 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import org.eclipse.emf.common.util.EList; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.rosetta.RosettaFeature; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.TypeCall; +import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; +import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp + (RosettaConstructorExpression expr, RosettaInterpreterBaseEnvironment env) { + String typeCall = expr.getTypeCall().getType().getName(); + EList values = expr.getValues(); + + switch (typeCall) { + case "date": { + RosettaInterpreterValue day = values.get(0).getValue().accept(visitor, env); + RosettaInterpreterValue month = values.get(1).getValue().accept(visitor, env); + RosettaInterpreterValue year = values.get(2).getValue().accept(visitor, env); + + if (day instanceof RosettaInterpreterIntegerValue + && month instanceof RosettaInterpreterIntegerValue + && year instanceof RosettaInterpreterIntegerValue) { + return new RosettaInterpreterDateValue( + ((RosettaInterpreterIntegerValue) day).getValue().intValue(), + ((RosettaInterpreterIntegerValue) month).getValue().intValue(), + ((RosettaInterpreterIntegerValue) year).getValue().intValue()); + } + break; + } + case "dateTime": { + RosettaInterpreterValue date = values.get(0).getValue().accept(visitor, env); + RosettaInterpreterValue time = values.get(1).getValue().accept(visitor, env); + + if (date instanceof RosettaInterpreterDateValue + && time instanceof RosettaInterpreterTimeValue) { + return new RosettaInterpreterDateTimeValue( + ((RosettaInterpreterDateValue) date), + ((RosettaInterpreterTimeValue) time)); + } + break; + } + case "zonedDateTime": { + RosettaInterpreterValue date = values.get(0).getValue().accept(visitor, env); + RosettaInterpreterValue time = values.get(1).getValue().accept(visitor, env); + RosettaInterpreterValue timeZone = values.get(2).getValue().accept(visitor, env); + + if (date instanceof RosettaInterpreterIntegerValue + && time instanceof RosettaInterpreterIntegerValue + && timeZone instanceof RosettaInterpreterIntegerValue) { + return new RosettaInterpreterZonedDateTimeValue( + ((RosettaInterpreterDateValue) date), + ((RosettaInterpreterTimeValue) time), + ((RosettaInterpreterStringValue) timeZone).getValue()); + } + break; + } + default: { + // needed for data types + break; + } + } + + return null; + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index cd3e2fbb8..fadb03a71 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; @@ -235,7 +237,15 @@ public void test() { + " day int\r\n" + " month int\r\n" + " year int }"); - System.out.println(expr.getElements().get(0).getClass()); + System.out.println(expr.getElements().get(0).getModel()); + } + + @Test + public void test1() { + RosettaExpression expr = parser.parseExpression("dateTime { date: date { day: 5, month: 5, year: 2000 }, time: \"05:00:00\" }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + System.out.println(((RosettaInterpreterDateTimeValue) result)); } } From 51c1a47c058176c7c9c9dd2a15aa283a081ea53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 3 Jun 2024 02:02:42 +0300 Subject: [PATCH 118/236] Added tests for Constructor Expressions for Record Types --- ...settaConstructorExpressionInterpreter.java | 6 +- ...aInterpreterConditionalExpressionTest.java | 27 ------ ...aInterpreterConstructorExpressionTest.java | 85 +++++++++++++++++++ 3 files changed, 88 insertions(+), 30 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 1280e4edd..fc8eeb882 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -56,9 +56,9 @@ public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends R RosettaInterpreterValue time = values.get(1).getValue().accept(visitor, env); RosettaInterpreterValue timeZone = values.get(2).getValue().accept(visitor, env); - if (date instanceof RosettaInterpreterIntegerValue - && time instanceof RosettaInterpreterIntegerValue - && timeZone instanceof RosettaInterpreterIntegerValue) { + if (date instanceof RosettaInterpreterDateValue + && time instanceof RosettaInterpreterTimeValue + && timeZone instanceof RosettaInterpreterStringValue) { return new RosettaInterpreterZonedDateTimeValue( ((RosettaInterpreterDateValue) date), ((RosettaInterpreterTimeValue) time), diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index fadb03a71..c3db7c203 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -14,8 +14,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; @@ -26,11 +24,8 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; -import com.regnosys.rosetta.tests.util.ModelHelper; import com.rosetta.model.lib.RosettaNumber; -import com.regnosys.rosetta.rosetta.RosettaModel; - @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) public class RosettaInterpreterConditionalExpressionTest { @@ -41,10 +36,6 @@ public class RosettaInterpreterConditionalExpressionTest { @Inject RosettaInterpreterNew interpreter; - @Inject - ModelHelper mh; - - @Test public void integerTest() { RosettaExpression expr = parser.parseExpression("if True then 1"); @@ -229,23 +220,5 @@ public void noElseTest() { assertEquals(null, result); } - - @Test - public void test() { - RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" - + "{\r\n" - + " day int\r\n" - + " month int\r\n" - + " year int }"); - System.out.println(expr.getElements().get(0).getModel()); - } - - @Test - public void test1() { - RosettaExpression expr = parser.parseExpression("dateTime { date: date { day: 5, month: 5, year: 2000 }, time: \"05:00:00\" }"); - RosettaInterpreterValue result = interpreter.interp(expr); - - System.out.println(((RosettaInterpreterDateTimeValue) result)); - } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java new file mode 100644 index 000000000..702c1b6de --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -0,0 +1,85 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalTime; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterConstructorExpressionTest { + + @Inject + private ExpressionParser parser; + + @Inject + RosettaInterpreterNew interpreter; + + @Inject + ModelHelper mh; + + @Test + public void test() { + RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" + + "{\r\n" + + " day int\r\n" + + " month int\r\n" + + " year int }"); + System.out.println(expr.getElements().get(0).getModel()); + } + + @Test + public void testDate() { + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2000 }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(5, ((RosettaInterpreterDateValue) result).getDay()); + assertEquals(7, ((RosettaInterpreterDateValue) result).getMonth()); + assertEquals(2000, ((RosettaInterpreterDateValue) result).getYear()); + } + + @Test + public void testDateTime() { + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 5, month: 7, year: 2022 }, time: \"05:00:00\" }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(5, 7, 2022); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(LocalTime.now()); + + assertEquals(date, ((RosettaInterpreterDateTimeValue) result).getDate()); + assertEquals(time, ((RosettaInterpreterDateTimeValue) result).getTime()); + } + + @Test + public void testZonedDateTime() { + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2022 }" + + ", time: \"05:00:00\", timezone: \"CET\" }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(5, 7, 2022); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(LocalTime.now()); + + assertEquals(date, ((RosettaInterpreterDateTimeValue) result).getDate()); + assertEquals(time, ((RosettaInterpreterDateTimeValue) result).getTime()); + assertEquals("CET", ((RosettaInterpreterStringValue) result).getValue()); + } +} From 2d3e676b792ed48a37e74d58c1b1a8b87cea3b45 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 10:20:29 +0200 Subject: [PATCH 119/236] Improved environment --- rosetta-lang/model/Rosetta.xcore | 3 +- rosetta-lang/model/RosettaExpression.xcore | 2 +- rosetta-lang/model/RosettaInterpreter.xcore | 6 +- .../RosettaInterpreterVisitor.java | 2 +- .../values/RosettaInterpreterBaseValue.java | 2 +- .../values/RosettaInterpreterEnvironment.java | 179 ++++++++++++++++-- .../values/RosettaInterpreterErrorValue.java | 1 - ...rpreterComparisonOperationInterpreter.java | 2 +- ...aInterpreterListOperationsInterpreter.java | 2 +- ...ttaInterpreterListOperatorInterpreter.java | 2 +- ...osettaArithmeticOperationsInterpreter.java | 2 +- ...settaConditionalExpressionInterpreter.java | 2 +- ...RosettaInterpreterVariableInterpreter.java | 7 +- 13 files changed, 184 insertions(+), 28 deletions(-) diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 3cbc5fd21..afc01f0ba 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -90,8 +90,7 @@ class TypeCallArgument { contains RosettaExpression value } -abstract class RosettaInterpreterBaseEnvironment { -} + /********************************************************************** diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index d30e6fb06..7093f7e63 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -19,7 +19,7 @@ import org.eclipse.emf.common.util.BasicEList import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment interface RosettaExpression { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 280bf1ab9..71596c59a 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -17,7 +17,6 @@ import com.regnosys.rosetta.rosetta.expression.EqualityOperation import com.regnosys.rosetta.rosetta.expression.ComparisonOperation import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression @@ -39,6 +38,11 @@ class RosettaInterpreterBaseError{ abstract class RosettaInterpreterValue { } +abstract class RosettaInterpreterBaseEnvironment { + op RosettaInterpreterValue findValue(String name) + op RosettaInterpreterValue addValue(String name, RosettaInterpreterValue v) +} + interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaBooleanLiteral exp) op RosettaInterpreterValue interp (RosettaStringLiteral exp) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 664cfdc52..c42b139cf 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -2,7 +2,7 @@ import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index c806f758d..d3e7186f0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -72,7 +72,7 @@ public static Stream valueStream(RosettaInterpreterValu * @param val - value to convert * @return - list of value or its contained values */ - public static List toValueList(RosettaInterpreterValue val){ + public static List toValueList(RosettaInterpreterValue val) { if (!(val instanceof RosettaInterpreterBaseValue)) { throw new RosettaInterpreterNewException("Cannot take value stream" + "of RosettaInterpreterValue"); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java index 59baf9cdb..6d35ecb9b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java @@ -1,26 +1,40 @@ package com.regnosys.rosetta.interpreternew.values; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; -import com.regnosys.rosetta.rosetta.impl.RosettaInterpreterBaseEnvironmentImpl; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; -public class RosettaInterpreterEnvironment extends RosettaInterpreterBaseEnvironmentImpl { - private Map environment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterEnvironment implements RosettaInterpreterBaseEnvironment { + private Map environment; public RosettaInterpreterEnvironment() { this.setEnvironment(new HashMap<>()); } - public RosettaInterpreterEnvironment(Map el) { + public RosettaInterpreterEnvironment(Map el) { this.setEnvironment(el); } - public Map getEnvironment() { + public Map getEnvironment() { return environment; } - public void setEnvironment(Map env) { + public void setEnvironment(Map env) { this.environment = env; } @@ -31,7 +45,7 @@ public void setEnvironment(Map env) { * @return - the value iff variable exists in environment * error otherwise */ - public RosettaInterpreterBaseValue findValue(String name) { + public RosettaInterpreterValue findValue(String name) { if (environment.containsKey(name)) { return environment.get(name); } @@ -50,16 +64,159 @@ public RosettaInterpreterBaseValue findValue(String name) { * @param name - name of the variable * @param val - value of the variable */ - public void addValue(String name, - RosettaInterpreterBaseValue val) { + public RosettaInterpreterValue addValue(String name, + RosettaInterpreterValue val) { if (environment.containsKey(name)) { //update env - environment.replace(name, val); + return environment.replace(name, val); } else { - environment.put(name, val); + return environment.put(name, val); + } + + } + + + + @Override + public int hashCode() { + return Objects.hash(environment); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; } + RosettaInterpreterEnvironment other = (RosettaInterpreterEnvironment) obj; + return Objects.equals(environment, other.environment); + } + + + @Override + public String toString() { + return "RosettaInterpreterEnvironment [environment=" + environment + "]"; + } + + // womp womppppp + @Override + public EClass eClass() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource eResource() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EObject eContainer() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EStructuralFeature eContainingFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EReference eContainmentFeature() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TreeIterator eAllContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eIsProxy() { + // TODO Auto-generated method stub + return false; + } + + @Override + public EList eCrossReferences() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object eGet(EStructuralFeature feature, boolean resolve) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void eSet(EStructuralFeature feature, Object newValue) { + // TODO Auto-generated method stub + + } + + @Override + public boolean eIsSet(EStructuralFeature feature) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eUnset(EStructuralFeature feature) { + // TODO Auto-generated method stub + + } + + @Override + public Object eInvoke(EOperation operation, EList arguments) throws InvocationTargetException { + // TODO Auto-generated method stub + return null; + } + + @Override + public EList eAdapters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean eDeliver() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void eSetDeliver(boolean deliver) { + // TODO Auto-generated method stub + + } + + @Override + public void eNotify(Notification notification) { + // TODO Auto-generated method stub } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index d8848f2c8..4baa53792 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -8,7 +8,6 @@ import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 477e3f8db..0fab3bbca 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -10,7 +10,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ModifiableBinaryOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 1540063ff..4eaff273f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 2ee93d041..9b33b4d2b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -14,7 +14,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index ffc17b61a..ab6b567bb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -8,7 +8,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index ee78fd37e..f1233a07f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 93cc624cf..137b663d8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -1,8 +1,6 @@ package com.regnosys.rosetta.interpreternew.visitors; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -21,10 +19,9 @@ public class RosettaInterpreterVariableInterpreter { */ public RosettaInterpreterValue interp(RosettaSymbolReference exp, RosettaInterpreterBaseEnvironment environment) { - RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) environment; //Search for variable in environment - RosettaInterpreterBaseValue varValue = env.findValue(exp.getSymbol().getName()); + RosettaInterpreterValue varValue = environment.findValue(exp.getSymbol().getName()); return varValue; } From d0acad718ea69ae96d39a0a0b016a2820d97f50c Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 10:38:46 +0200 Subject: [PATCH 120/236] Removed eobject implementation bloat --- .../RosettaInterpreterVisitor.java | 6 +- .../RosettaInterpreterVisitorBase.java | 133 ------------------ .../values/RosettaInterpreterBaseValue.java | 132 +---------------- .../values/RosettaInterpreterError.java | 132 +---------------- .../values/RosettaInterpreterErrorValue.java | 1 - 5 files changed, 11 insertions(+), 393 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 664cfdc52..79b21a8db 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -19,6 +19,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; @@ -26,6 +27,9 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.expression.SumOperation; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -42,7 +46,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterVariableInterpreter; -public class RosettaInterpreterVisitor extends RosettaInterpreterVisitorBase { +public class RosettaInterpreterVisitor extends MinimalEObjectImpl implements InterpreterVisitor { @Override public RosettaInterpreterValue interp(RosettaBooleanLiteral exp) { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java deleted file mode 100644 index 82ca1aa5d..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.regnosys.rosetta.interpreternew; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.Resource; - -import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor; - -public abstract class RosettaInterpreterVisitorBase implements InterpreterVisitor { - @Override - public EClass eClass() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource eResource() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EObject eContainer() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EStructuralFeature eContainingFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EReference eContainmentFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TreeIterator eAllContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eIsProxy() { - // TODO Auto-generated method stub - return false; - } - - @Override - public EList eCrossReferences() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature, boolean resolve) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void eSet(EStructuralFeature feature, Object newValue) { - // TODO Auto-generated method stub - - } - - @Override - public boolean eIsSet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eUnset(EStructuralFeature feature) { - // TODO Auto-generated method stub - - } - - @Override - public Object eInvoke(EOperation operation, EList arguments) - throws InvocationTargetException { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eAdapters() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eDeliver() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eSetDeliver(boolean deliver) { - // TODO Auto-generated method stub - - } - - @Override - public void eNotify(Notification notification) { - // TODO Auto-generated method stub - - } -} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java index c806f758d..f44de31f8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java @@ -1,24 +1,14 @@ package com.regnosys.rosetta.interpreternew.values; -import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -public abstract class RosettaInterpreterBaseValue implements RosettaInterpreterValue { +public abstract class RosettaInterpreterBaseValue extends MinimalEObjectImpl implements RosettaInterpreterValue { /** * Converts a Value to a Stream of the elements it contains. @@ -72,127 +62,11 @@ public static Stream valueStream(RosettaInterpreterValu * @param val - value to convert * @return - list of value or its contained values */ - public static List toValueList(RosettaInterpreterValue val){ + public static List toValueList(RosettaInterpreterValue val) { if (!(val instanceof RosettaInterpreterBaseValue)) { throw new RosettaInterpreterNewException("Cannot take value stream" + "of RosettaInterpreterValue"); } return valueStream(val).collect(Collectors.toList()); } - - @Override - public EClass eClass() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource eResource() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EObject eContainer() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EStructuralFeature eContainingFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EReference eContainmentFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TreeIterator eAllContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eIsProxy() { - // TODO Auto-generated method stub - return false; - } - - @Override - public EList eCrossReferences() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature, boolean resolve) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void eSet(EStructuralFeature feature, Object newValue) { - // TODO Auto-generated method stub - - } - - @Override - public boolean eIsSet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eUnset(EStructuralFeature feature) { - // TODO Auto-generated method stub - - } - - @Override - public Object eInvoke(EOperation operation, EList arguments) - throws InvocationTargetException { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eAdapters() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eDeliver() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eSetDeliver(boolean deliver) { - // TODO Auto-generated method stub - - } - - @Override - public void eNotify(Notification notification) { - // TODO Auto-generated method stub - - } - } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index f4e82f92c..1f5dff508 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -1,22 +1,12 @@ package com.regnosys.rosetta.interpreternew.values; -import java.lang.reflect.InvocationTargetException; import java.util.Objects; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; -public class RosettaInterpreterError implements RosettaInterpreterBaseError { +public class RosettaInterpreterError extends MinimalEObjectImpl implements RosettaInterpreterBaseError { @Override public int hashCode() { return Objects.hash(errorMessage); @@ -51,121 +41,6 @@ public String toString() { return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; } - @Override - public EClass eClass() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource eResource() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EObject eContainer() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EStructuralFeature eContainingFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EReference eContainmentFeature() { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TreeIterator eAllContents() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eIsProxy() { - // TODO Auto-generated method stub - return false; - } - - @Override - public EList eCrossReferences() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object eGet(EStructuralFeature feature, boolean resolve) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void eSet(EStructuralFeature feature, Object newValue) { - // TODO Auto-generated method stub - - } - - @Override - public boolean eIsSet(EStructuralFeature feature) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eUnset(EStructuralFeature feature) { - // TODO Auto-generated method stub - - } - - @Override - public Object eInvoke(EOperation operation, EList arguments) - throws InvocationTargetException { - // TODO Auto-generated method stub - return null; - } - - @Override - public EList eAdapters() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean eDeliver() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void eSetDeliver(boolean deliver) { - // TODO Auto-generated method stub - - } - - @Override - public void eNotify(Notification notification) { - // TODO Auto-generated method stub - - } - @Override public String getMessage() { return errorMessage; @@ -173,7 +48,6 @@ public String getMessage() { @Override public void setMessage(String value) { - // TODO Auto-generated method stub - + this.errorMessage = value; } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index d8848f2c8..4baa53792 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -8,7 +8,6 @@ import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From 342f2320b3e30c630ce7c26bbbfa1b411dbbd28f Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 11:21:38 +0200 Subject: [PATCH 121/236] Improved error handling --- .../RosettaInterpreterVisitor.java | 4 +- .../values/RosettaInterpreterEmptyError.java | 55 +++++++++++++++++++ .../values/RosettaInterpreterEnvironment.java | 2 +- .../values/RosettaInterpreterError.java | 10 ++-- .../values/RosettaInterpreterErrorValue.java | 1 - ...rpreterComparisonOperationInterpreter.java | 22 ++++---- ...aInterpreterListOperationsInterpreter.java | 4 +- ...ttaInterpreterListOperatorInterpreter.java | 10 ++-- ...nterpreterLogicalOperationInterpreter.java | 13 +++-- ...osettaArithmeticOperationsInterpreter.java | 15 +++-- ...settaConditionalExpressionInterpreter.java | 6 +- ...taInterpreterArithmeticOperationsTest.java | 4 +- .../RosettaInterpreterComparisonTest.java | 12 ++-- ...aInterpreterConditionalExpressionTest.java | 36 +++++++----- .../RosettaInterpreterEqualityTest.java | 20 ++++--- .../RosettaInterpreterErrorTest.java | 6 +- .../RosettaInterpreterLiteralsTest.java | 3 +- ...settaInterpreterLogicalOperationsTest.java | 29 +++++----- .../RosettaInterpreterVariableTest.java | 33 +++++------ .../RosettaInterpreterErrorValueTest.java | 8 +-- ...erpreterListOperationsInterpreterTest.java | 6 +- ...nterpreterListOperatorInterpreterTest.java | 40 ++++++++------ 22 files changed, 211 insertions(+), 128 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEmptyError.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 664cfdc52..4fb88d4c7 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -26,9 +26,9 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.expression.SumOperation; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEmptyError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; @@ -97,7 +97,7 @@ public RosettaInterpreterValue interp(RosettaPatternLiteral exp) { public RosettaInterpreterValue interp(RosettaPatternLiteral exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Pattern literals are not supported")); + new RosettaInterpreterEmptyError("Pattern literals are not supported")); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEmptyError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEmptyError.java new file mode 100644 index 000000000..a1922c3a9 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEmptyError.java @@ -0,0 +1,55 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.Objects; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; + +public class RosettaInterpreterEmptyError extends MinimalEObjectImpl implements RosettaInterpreterBaseError { + + private String errorMessage; + + public RosettaInterpreterEmptyError(String message) { + this.errorMessage = message; + } + + public RosettaInterpreterEmptyError() { + this.errorMessage = ""; + } + + @Override + public String getMessage() { + return errorMessage; + } + + @Override + public void setMessage(String value) { + this.errorMessage = value; + } + + @Override + public int hashCode() { + return Objects.hash(errorMessage); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterEmptyError other = (RosettaInterpreterEmptyError) obj; + return Objects.equals(errorMessage, other.errorMessage); + } + + @Override + public String toString() { + return errorMessage; + } +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java index 59baf9cdb..fd9e6cbf7 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java @@ -37,7 +37,7 @@ public RosettaInterpreterBaseValue findValue(String name) { } else { return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( + new RosettaInterpreterEmptyError( name + " does not exist in the environment")); } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index e2ef5cdfb..84b4e7212 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -42,12 +42,6 @@ public boolean equals(Object obj) { RosettaInterpreterError other = (RosettaInterpreterError) obj; return Objects.equals(errorMessage, other.errorMessage); } - - - @Deprecated - public RosettaInterpreterError(String errorMessage) { - this.errorMessage = errorMessage; - } public RosettaInterpreterError(EObject obj) { this.associatedExpression = obj; @@ -70,6 +64,10 @@ public RosettaInterpreterError(String errorMessage, EObject obj) { * @return Error message with code information */ public String properErrorMessage() { + if (associatedExpression == null) { + return errorMessage; + } + INode node = NodeModelUtils.findActualNodeFor(associatedExpression); int startLine = node.getStartLine(); int offset = node.getOffset(); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index d8848f2c8..4baa53792 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -8,7 +8,6 @@ import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 477e3f8db..48801922c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -4,6 +4,8 @@ import java.util.Arrays; import java.util.List; +import org.eclipse.emf.ecore.EObject; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; @@ -62,7 +64,7 @@ public RosettaInterpreterBaseValue interp(ModifiableBinaryOperation expr, if (!comparisonOperators.contains(expr.getOperator())) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "operator not suppported")); + "operator not suppported", expr)); } RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); @@ -93,29 +95,29 @@ else if (RosettaInterpreterErrorValue.errorsExist(rightValue)) { return new RosettaInterpreterBooleanValue(result); case ANY: - return compareAny(leftValue, rightValue, expr.getOperator()); + return compareAny(leftValue, rightValue, expr.getOperator(), expr); case ALL: - return compareAll(leftValue, rightValue, expr.getOperator()); + return compareAll(leftValue, rightValue, expr.getOperator(), expr); default: return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cardinality modifier " + expr.getCardMod() - + " not supported")); + + " not supported", expr)); } } private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, - String operator) { + String operator, EObject ass) { //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); + "cannot compare two lists", ass)); } //list vs element case: @@ -143,18 +145,18 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ANY\" keyword " - + "to compare two elements")); + + "to compare two elements", ass)); } private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, - String operator) { + String operator, EObject ass) { //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); + "cannot compare two lists", ass)); } //list vs element case: @@ -182,7 +184,7 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ALL\" keyword " - + "to compare two elements")); + + "to compare two elements", ass)); } private boolean checkComparableTypes(RosettaInterpreterValue leftValue, diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 1540063ff..c4c9f54ea 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -128,12 +128,12 @@ public RosettaInterpreterValue interp(JoinOperation exp, if (!allStrings) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The list of values for a join " - + "operation must be a list of strings")); + + "operation must be a list of strings", exp)); } if (!(delimVal instanceof RosettaInterpreterStringValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The delimiter for a join" - + " operation must be a string")); + + " operation must be a string", exp)); } if (RosettaInterpreterBaseValue.valueStream(stringsVal) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index d615026fd..e1ab05cc8 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -126,7 +126,7 @@ public RosettaInterpreterValue interp(FirstOperation exp, RosettaInterpreterBase if (count == 0L) { // List is empty return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); + new RosettaInterpreterError("List is empty", exp)); } else { // List has at least one element return RosettaInterpreterBaseValue.valueStream(interpretedArgument) @@ -154,14 +154,14 @@ public RosettaInterpreterValue interp(RosettaOnlyElement exp, RosettaInterpreter if (count == 0L) { // List is empty return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); + new RosettaInterpreterError("List is empty", exp)); } else if (count == 1L) { // List has one element return RosettaInterpreterBaseValue.valueStream(interpretedArgument) .collect(Collectors.toList()).get(0); } else { return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List contains more than one element")); + new RosettaInterpreterError("List contains more than one element", exp)); } } @@ -186,7 +186,7 @@ public RosettaInterpreterValue interp(LastOperation exp, RosettaInterpreterBaseE if (count == 0L) { // List is empty return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); + new RosettaInterpreterError("List is empty", exp)); } else { // List has at least one element return RosettaInterpreterBaseValue.valueStream(interpretedArgument) @@ -297,7 +297,7 @@ public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEn else if (!(v instanceof RosettaInterpreterNumberValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Cannot take sum" - + "of non-number value")); + + "of non-number value", exp)); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index dff13447a..7fc0d47a6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -2,6 +2,8 @@ import java.util.List; +import org.eclipse.emf.ecore.EObject; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; @@ -41,9 +43,9 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr, } else { // Check for errors in the left or right side of the binary operation RosettaInterpreterErrorValue leftErrors = - checkForErrors(leftInterpreted, "Leftside"); + checkForErrors(leftInterpreted, "Leftside", expr); RosettaInterpreterErrorValue rightErrors = - checkForErrors(rightInterpreted, "Rightside"); + checkForErrors(rightInterpreted, "Rightside", expr); return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); } @@ -57,7 +59,7 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr, return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Logical Operation: Wrong operator " - + "- only 'and' / 'or' supported")); + + "- only 'and' / 'or' supported", null)); } } @@ -73,7 +75,8 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr, * if the interpretedValue does not cause an error */ private RosettaInterpreterErrorValue checkForErrors( - RosettaInterpreterValue interpretedValue, String side) { + RosettaInterpreterValue interpretedValue, String side, + EObject ass) { if (interpretedValue instanceof RosettaInterpreterBooleanValue) { // No errors found. // I return an error value without any errors in its list, @@ -88,7 +91,7 @@ private RosettaInterpreterErrorValue checkForErrors( return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Logical Operation: " + side - + " is not of type Boolean")); + + " is not of type Boolean",ass)); } } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index ffc17b61a..0a9c21880 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -2,6 +2,8 @@ import java.util.List; +import org.eclipse.emf.ecore.EObject; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; @@ -52,9 +54,9 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, // Check for errors in the left or right side of the binary operation RosettaInterpreterErrorValue leftErrors = - checkForErrors(leftInterpreted, "Leftside"); + checkForErrors(leftInterpreted, "Leftside", expr); RosettaInterpreterErrorValue rightErrors = - checkForErrors(rightInterpreted, "Rightside"); + checkForErrors(rightInterpreted, "Rightside", expr); return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); } @@ -67,7 +69,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "The terms of the operation " - + "are neither both strings nor both numbers")); + + "are neither both strings nor both numbers", expr)); } if (leftInterpreted instanceof RosettaInterpreterStringValue) { @@ -82,7 +84,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "The terms are strings but the operation " - + "is not concatenation: not implemented")); + + "is not concatenation: not implemented", expr)); } } @@ -132,7 +134,8 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, * if the interpretedValue does not cause an error */ private RosettaInterpreterErrorValue checkForErrors( - RosettaInterpreterValue interpretedValue, String side) { + RosettaInterpreterValue interpretedValue, String side, + EObject ass) { if (interpretedValue instanceof RosettaInterpreterNumberValue || interpretedValue instanceof RosettaInterpreterStringValue || interpretedValue instanceof RosettaInterpreterIntegerValue) { @@ -150,7 +153,7 @@ else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Arithmetic Operation: " + side - + " is not of type Number/String")); + + " is not of type Number/String", ass)); } } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index ee78fd37e..0ddb7ae55 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -47,7 +47,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, } else { return new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Conditional expression: condition " - + "is not a boolean value.")); + + "is not a boolean value.", expr)); } if (expr.isFull()) { @@ -69,7 +69,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, new RosettaInterpreterError( "Conditional expression: " + "then and else " - + "need to have the same type.")); + + "need to have the same type.", expr)); } } @@ -98,7 +98,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) exp; RosettaInterpreterErrorValue newExpError = new RosettaInterpreterErrorValue( - new RosettaInterpreterError(message)); + new RosettaInterpreterError(message, exp)); return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java index 2d99230f6..aafee7391 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java @@ -180,10 +180,10 @@ public void complexTest() { List expected = List.of( new RosettaInterpreterError( "The terms are strings but the operation " - + "is not concatenation: not implemented"), + + "is not concatenation: not implemented", expr), new RosettaInterpreterError( "Arithmetic Operation: Rightside " - + "is not of type Number/String") + + "is not of type Number/String", expr) ); assertEquals(expected, ((RosettaInterpreterErrorValue)val) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index ac5c9576c..dae5d5291 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -68,10 +68,10 @@ public void booleanLessEqualTest() { @Test public void cardinalityAllListsTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] all >= [0]"); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); - RosettaExpression expr = parser.parseExpression("[1,2,3] all >= [0]"); + "cannot compare two lists", expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors().get(0).getMessage(), ((RosettaInterpreterErrorValue)val) @@ -94,10 +94,10 @@ public void cardinalityAnySimpleTest() { @Test public void errorThrownListTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] any <= [1,2]"); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); - RosettaExpression expr = parser.parseExpression("[1,2,3] any <= [1,2]"); + "cannot compare two lists", expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors(), ((RosettaInterpreterErrorValue)val).getErrors()); @@ -108,11 +108,11 @@ public void errorThrownListTest() { @Test public void errorThrownAllElementsTest() { + RosettaExpression expr = parser.parseExpression("1 all > 3"); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ALL\" keyword " - + "to compare two elements")); - RosettaExpression expr = parser.parseExpression("1 all > 3"); + + "to compare two elements", expr)); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; assertEquals(expectedError.getErrors(), diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index c3db7c203..a4192b0ef 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -119,13 +119,14 @@ public void complexTest() { @Test public void errorThenTest() { + RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Conditional expression: then is an error value.")); + "Conditional expression: then is an error value.", expr)); expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); + "cannot use \"ALL\" keyword " + "to compare two elements", expr)); - RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; @@ -136,13 +137,14 @@ public void errorThenTest() { @Test public void errorElseTest() { + RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Conditional expression: else is an error value.")); + "Conditional expression: else is an error value.",expr)); expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); + "cannot use \"ALL\" keyword " + "to compare two elements",expr)); - RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; @@ -153,11 +155,12 @@ public void errorElseTest() { @Test public void notSameTypeThenTest() { + RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); + + "then and else need to have the same type.",expr)); - RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; @@ -168,11 +171,12 @@ public void notSameTypeThenTest() { @Test public void notSameTypeElseTest() { + RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); + + "then and else need to have the same type.",expr)); - RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; @@ -183,11 +187,12 @@ public void notSameTypeElseTest() { @Test public void conditionNotBooleanTest() { + RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Conditional expression: " - + "condition is not a boolean value.")); + + "condition is not a boolean value.",expr)); - RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; @@ -198,13 +203,14 @@ public void conditionNotBooleanTest() { @Test public void conditionErrorTypeTest() { + RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Conditional expression: " - + "condition is an error value.")); + + "condition is an error value.",expr)); expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); + "cannot use \"ALL\" keyword " + "to compare two elements",expr)); - RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java index 060d59405..fe3b05d29 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java @@ -88,10 +88,11 @@ public void equalityAnyFalseTest() { @Test public void equalityAnyTwoListsTest() { + RosettaExpression expr = parser.parseExpression("[1,2,2] any = [1]"); + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); - RosettaExpression expr = parser.parseExpression("[1,2,2] any = [1]"); + "cannot compare two lists",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors().get(0).getMessage(), ((RosettaInterpreterErrorValue)val) @@ -107,12 +108,13 @@ public void equalityAnyTrueTest() { @Test public void equalityAnyErrorTest() { + RosettaExpression expr = parser.parseExpression("2 any = 2"); + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ANY\" keyword " - + "to compare two elements")); + + "to compare two elements",expr)); - RosettaExpression expr = parser.parseExpression("2 any = 2"); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors(), ((RosettaInterpreterErrorValue)val).getErrors()); @@ -120,10 +122,11 @@ public void equalityAnyErrorTest() { @Test public void errorThrownListTest() { + RosettaExpression expr = parser.parseExpression("[1,2,3] any = [1,2]"); + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists")); - RosettaExpression expr = parser.parseExpression("[1,2,3] any = [1,2]"); + "cannot compare two lists",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors(), ((RosettaInterpreterErrorValue)val).getErrors()); @@ -131,11 +134,12 @@ public void errorThrownListTest() { @Test public void errorThrownAllElementsTest() { + RosettaExpression expr = parser.parseExpression("1 all = 3"); + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ALL\" keyword " - + "to compare two elements")); - RosettaExpression expr = parser.parseExpression("1 all = 3"); + + "to compare two elements",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals(expectedError.getErrors(), ((RosettaInterpreterErrorValue)val).getErrors()); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java index b534bef0c..a1b7beeb3 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java @@ -19,8 +19,8 @@ public class RosettaInterpreterErrorTest { @Test public void simpleErrorTest() { - RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); - RosettaInterpreterError e2 = new RosettaInterpreterError("e2"); + RosettaInterpreterError e1 = new RosettaInterpreterError("e1",null); + RosettaInterpreterError e2 = new RosettaInterpreterError("e2",null); RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(); RosettaInterpreterErrorValue val2 = new RosettaInterpreterErrorValue(); @@ -36,7 +36,7 @@ public void simpleErrorTest() { @Test public void errorMessageExists() { - RosettaInterpreterError e1 = new RosettaInterpreterError("e1"); + RosettaInterpreterError e1 = new RosettaInterpreterError("e1",null); RosettaInterpreterErrorValue val1 = new RosettaInterpreterErrorValue(e1); assertEquals("e1", val1.getErrors().get(0).getMessage()); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 9684e7afd..5684a8206 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -118,7 +118,8 @@ public void intTest() { public void numberTest() { RosettaExpression expr = parser.parseExpression("5.5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), ((RosettaInterpreterNumberValue)val).getValue()); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), + ((RosettaInterpreterNumberValue)val).getValue()); } @Test diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java index 2d5ee49d8..e3f2599d3 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java @@ -127,12 +127,14 @@ public void nestedBooleansLogicalTest() { @Test public void wrongOperatorTest() { List expected = new ArrayList(); - expected.add(new RosettaInterpreterError( - "Logical Operation: Wrong operator - only 'and' / 'or' supported")); - RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); LogicalOperation expr = createLogicalOperation("xor", trueLiteral, falseLiteral); + + expected.add(new RosettaInterpreterError( + "Logical Operation: Wrong operator - only 'and' / 'or' supported",expr)); + + RosettaInterpreterValue result = interpreter.interp(expr); assertTrue(result instanceof RosettaInterpreterErrorValue); @@ -143,10 +145,11 @@ public void wrongOperatorTest() { @Test public void notBooleanValueTest() { List expected = new ArrayList(); - expected.add(new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); + RosettaExpression expr = parser.parseExpression("1 and False"); + expected.add(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean",expr)); RosettaInterpreterValue result = interpreter.interp(expr); assertTrue(result instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedResult = (RosettaInterpreterErrorValue) result; @@ -157,14 +160,14 @@ public void notBooleanValueTest() { public void errorOnRightSideTest() { List expected = new ArrayList(); // This is the case: (False and (True or 1)) - expected.add(new RosettaInterpreterError( - "Logical Operation: Rightside is not of type Boolean")); + RosettaIntLiteral intLiteral = exFactory.createRosettaIntLiteral(); intLiteral.setValue(BigInteger.valueOf(1)); RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); - + expected.add(new RosettaInterpreterError( + "Logical Operation: Rightside is not of type Boolean",expr)); RosettaBooleanLiteral falseLiteral = createBooleanLiteral(false); LogicalOperation nestedExpr = createLogicalOperation("and", falseLiteral, expr); @@ -178,16 +181,16 @@ public void errorOnRightSideTest() { public void errorsOnBothSidesTest() { List expected = new ArrayList(); // This is the case: ("string" and (True or 1)) - expected.add(new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); - expected.add(new RosettaInterpreterError( - "Logical Operation: Rightside is not of type Boolean")); + RosettaIntLiteral intLiteral = exFactory.createRosettaIntLiteral(); intLiteral.setValue(BigInteger.valueOf(1)); RosettaBooleanLiteral trueLiteral = createBooleanLiteral(true); LogicalOperation expr = createLogicalOperation("or", trueLiteral, intLiteral); - + expected.add(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean",expr)); + expected.add(new RosettaInterpreterError( + "Logical Operation: Rightside is not of type Boolean",expr)); RosettaStringLiteral stringLiteral = exFactory.createRosettaStringLiteral(); stringLiteral.setValue("string"); LogicalOperation nestedExpr = createLogicalOperation("and", stringLiteral, expr); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java index 951553836..e55dc20c0 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java @@ -19,6 +19,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEmptyError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; @@ -72,14 +73,14 @@ public void variableLeftErrorComparisonTest() { RosettaInterpreterIntegerValue intValue = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); env.addValue("a", intValue); - + RosettaExpression expr = parser.parseExpression("b >= 2", + List.of("b int (1..1)")); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "b does not exist in the environment")); + "b does not exist in the environment",expr)); //give a different environment to the parser - RosettaExpression expr = parser.parseExpression("b >= 2", - List.of("b int (1..1)")); + RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -92,14 +93,14 @@ public void variableLeftErrorComparisonTest() { public void variableRightErrorComparisonTest() { //create empty environment RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - + RosettaExpression expr = parser.parseExpression("1 = b", + List.of("b int (1..1)")); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "b does not exist in the environment")); + "b does not exist in the environment",expr)); //give a different environment to the parser - RosettaExpression expr = parser.parseExpression("1 = b", - List.of("b int (1..1)")); + RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -112,16 +113,16 @@ public void variableRightErrorComparisonTest() { public void variableBothErrorTest() { //create empty environment RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - - List expected = new ArrayList(); - expected.add(new RosettaInterpreterError( + RosettaExpression expr = parser.parseExpression("a <= b", + List.of("a int (1..1)", "b int (1..1)")); + List expected = new ArrayList(); + expected.add(new RosettaInterpreterEmptyError( "a does not exist in the environment")); - expected.add(new RosettaInterpreterError( + expected.add(new RosettaInterpreterEmptyError( "b does not exist in the environment")); //give a different environment to the parser - RosettaExpression expr = parser.parseExpression("a <= b", - List.of("a int (1..1)", "b int (1..1)")); + RosettaInterpreterValue val = interpreter.interp(expr,env); @@ -130,8 +131,8 @@ public void variableBothErrorTest() { assertEquals(expected.size(), errors.size()); for (int i = 0; i < expected.size(); i++) { - RosettaInterpreterError newError = (RosettaInterpreterError) errors.get(i); - assertEquals(expected.get(i).getError(), newError.getError()); + RosettaInterpreterEmptyError newError = (RosettaInterpreterEmptyError) errors.get(i); + assertEquals(expected.get(i).getMessage(), newError.getMessage()); } } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index 06a1b2376..5e7c8a2e8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -55,10 +55,10 @@ class RosettaInterpreterErrorValueTest { @BeforeEach void setup() { - e1 = new RosettaInterpreterError("e1"); - e2 = new RosettaInterpreterError("e2"); - e3 = new RosettaInterpreterError("e3"); - e4 = new RosettaInterpreterError("e4"); + e1 = new RosettaInterpreterError("e1",null); + e2 = new RosettaInterpreterError("e2",null); + e3 = new RosettaInterpreterError("e3",null); + e4 = new RosettaInterpreterError("e4",null); v1 = new RosettaInterpreterErrorValue(e1); v2 = new RosettaInterpreterErrorValue(e2); v3 = new RosettaInterpreterErrorValue(e3); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java index 0974e7e42..4357c3095 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java @@ -88,7 +88,7 @@ void testInterpContainsError() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); + "Logical Operation: Leftside is not of type Boolean",expr)); assertEquals(err, val); } @@ -118,7 +118,7 @@ void testInterpDisjointError() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); + "Logical Operation: Leftside is not of type Boolean",expr)); assertEquals(err, val); } @@ -197,7 +197,7 @@ void testInterpJoinError() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue err = new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); + "Logical Operation: Leftside is not of type Boolean",expr)); assertEquals(err, val); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java index c0eaf27e2..ce4f8332f 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -49,11 +49,12 @@ public void setup() { @Test void testOnlyElementError() { + RosettaExpression expr = parser.parseExpression("(True and 1) only-element"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) only-element"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -152,11 +153,12 @@ void testExistsMultipleFalse() { @Test void testExistsError() { + RosettaExpression expr = parser.parseExpression("(True and 1) single exists"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) single exists"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -185,11 +187,12 @@ void testIsAbsentFalse() { @Test void testIsAbsentError() { + RosettaExpression expr = parser.parseExpression("(True and 1) is absent"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) is absent"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -220,11 +223,12 @@ void testCount() { @Test void testCountError() { + RosettaExpression expr = parser.parseExpression("(True and 1) count"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) count"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -233,10 +237,11 @@ void testCountError() { @Test void testFirstEmptyList() { + RosettaExpression expr = parser.parseExpression("[] first"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); - RosettaExpression expr = parser.parseExpression("[] first"); + new RosettaInterpreterError("List is empty",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -256,11 +261,12 @@ void testFirst() { @Test void testFirstError() { + RosettaExpression expr = parser.parseExpression("(True and 1) first"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) first"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -269,10 +275,11 @@ void testFirstError() { @Test void testLastEmptyList() { + RosettaExpression expr = parser.parseExpression("[] last"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("List is empty")); - RosettaExpression expr = parser.parseExpression("[] last"); + new RosettaInterpreterError("List is empty",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; @@ -292,11 +299,12 @@ void testLast() { @Test void testLastError() { + RosettaExpression expr = parser.parseExpression("(True and 1) last"); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Logical Operation: " - + "Rightside is not of type Boolean")); - RosettaExpression expr = parser.parseExpression("(True and 1) last"); + + "Rightside is not of type Boolean",expr)); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(val instanceof RosettaInterpreterErrorValue); RosettaInterpreterErrorValue castedVal = (RosettaInterpreterErrorValue)val; From 1f66ef2672340815293acfac2b5b4752fc5c5d50 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 11:26:02 +0200 Subject: [PATCH 122/236] Revert project --- rosetta-lang/.project | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/.project b/rosetta-lang/.project index abbd3d17f..f46323c08 100644 --- a/rosetta-lang/.project +++ b/rosetta-lang/.project @@ -21,17 +21,17 @@ - org.eclipse.pde.ManifestBuilder + org.eclipse.m2e.core.maven2Builder - org.eclipse.pde.SchemaBuilder + org.eclipse.pde.ManifestBuilder - org.eclipse.m2e.core.maven2Builder + org.eclipse.pde.SchemaBuilder From e99513c2b4cf626c6ff95248e6461e6f1025cabc Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 11:46:42 +0200 Subject: [PATCH 123/236] new readme --- README.md | 169 +++++++++------------------------------------- README_project.md | 153 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 138 deletions(-) create mode 100644 README_project.md diff --git a/README.md b/README.md index 61d70f8b3..e21ad1c36 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,46 @@ ---- -title: "Rune DSL Overview" -date: 2022-02-09T00:38:25+09:00 -description: "Rune is a Domain-Specific Language (DSL) that supports the modelling of operational processes for the financial markets' industry. Its purpose is to promote consistency and inter-operability between the various implementations of these processes." -draft: false -weight: 1 ---- +# Rune DSL Interpreter -# Rune DSL +An interpreter for a subset of the Rune DSl. -[![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://community.finos.org/docs/governance/Software-Projects/stages/incubating) +For most practical information, refer to the [original readme file](README_project.md) -**Continuous Integration:** [![Maven Central](https://img.shields.io/maven-central/v/com.regnosys.rosetta/com.regnosys.rosetta.parent.svg?maxAge=2592000)](https://search.maven.org/#artifactdetails%7Ccom.regnosys.rosetta%7Ccom.regnosys.rosetta.parent%7C2%7Cpom) +## Authors +- Jacek Kulik +- Antonio Lupu +- Maria Cristucsecu +- Bogdan Damian +- Diana Śutać -*Rune DSL* is a Domain-Specific Language (DSL) that supports the modelling of operational processes for the financial markets' industry. Its purpose is to promote consistency and inter-operability between the various implementations of these processes. +## Project Structure -{{< notice info "Note" >}} -In software engineering, a [domain model](https://olegchursin.medium.com/a-brief-introduction-to-domain-modeling-862a30b38353) is a conceptual model of a business domain that incorporates both *data* and *logic* (i.e. rules and processes). -{{< /notice >}} +FIGURE HERE -The key idea behind the Rune DSL is that, whilst financial markets' operational infrastructure is largely electronified, many of its underlying IT systems tend to operate in silos. +Rune operations are defined in [xcore files](rosetta-lang/model/RosettaInterpreter.xcore) -For instance, the same data are often represented differently between different applications - usually a reasonable choice when considering the respective purpose of each application. But without any formalised translation between them, data cannot easily flow from one application to another and the overall architecture looses cohesiveness. Applications also tend to mix the specification of their business logic with its technical implementation. Once buried in code, an application's logic is hard to extract and must usually be documented separately, with no guarantee of consistency. +All interpretable operations implement an interp method which takes in an expression and an environment. -**The Rune DSL allows to represent data and business logic in a system- and technology-agnostic way** into a cohesive domain model. By supporting a shared, formalised understanding of the financial markets' domain, it enables different technology implementations to "talk" to each other in the same native language. +There is a visitor which accepts the expressions and passes them along to the correct concrete interpreter to perform their operations. -A model expressed in the Rune DSL provides more than a technical specification: it automatically generates executable code, to be used directly in an implementation. Both the Rune DSL and associated code generators are available in open source. +## How to extend -**One important application of the Rune DSL concerns regulatory reporting**. While many financial institutions share the same reporting obligations, they usually implement their logic in slightly different ways because of siloed technology approaches. This exposes firms to non-compliance risk and fines and degrades the quality and comparability of the data that regulators collect. +### New Expression +The simplest extension is by adding new Rune constructs to interpret. The process for this is: + 1. Define the interp method for this expression in [RosettaExpression.xcore](rosetta-lang/model/RosettaExpression.xcore) + 2. Create a new class inside [interpreternew.visitors](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/) OR use one of the already existing ones if it fits thematically + 3. Implement a new interp method in [RosettaInterpreterVisitor.java](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java) to accept the new expression + 4. Implement the interpretation of the expression + 5. Test the expression in [the testing module](rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/) -Instead, Rune empowers many users within firms to take part in interpreting and codifying reporting rules, without the risk of loss-in-translation once they get implemented in IT systems. The language itself is designed to be human-readable, so that domain experts without programming experience (e.g. operations or compliance professionals) can write fully functional regulatory logic directly – a bit like in Excel. +### New Value Domain Type +Right now this process doesn't have any additional steps, but this may change in the future. -## Rosetta +1. Create a new class in [the value domain folder](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/) +2. Optionally also test the class if it requires it -A complete end to end development environment called [Rosetta](https://ui.rosetta-technology.io/) is provided to help industry participants to create, edit or extend models using the Rune DSL. Rosetta also provides integration tools designed to facilitate firms' adoption and implementation of models within their own technology architecture. +### New Expression Function -Much like how software engineers use programming languages and tools to build and test software, it is useful to think of Rosetta as a platform with a set of tools to build and test a domain model using the Rune DSL. The [Rosetta products documentation](https://docs.rosetta-technology.io/rosetta/rosetta-products/) details the various tools and products that are available in the Rosetta platform. +Currently there is only the interpretation function defined for the expressions, but the visitor pattern allows for easily adding a new one. -In order to facilitate the use of the Rune DSL by industry members, a *Community Edition* of Rosetta that already features many of the platform's functionalities is available as a free web application. Through Rosetta, users can also access a number of open-source [modelling projects](https://docs.rosetta-technology.io/rosetta/projects/) that are based on the Rune DSL, allowing them to use, edit or extend those models. - -## Rune DSL Components - -The Rune DSL comprises 2 components, both open-source: - -- *Syntax* - defines the language and rules for editing a model using the Rune DSL, also known as a *grammar* -- *Code generators* - from a model expressed in the Rune DSL, automatically generates executable code in other programming languages - -### Syntax - -The [Rune DSL repository](https://github.com/finos/rune-dsl/) contains the definition of the language. It is based on the [Eclipe Modelling Framework](https://www.eclipse.org/modeling/emf/). - -The language components available in the Rune DSL and their syntax are detailed in the [Rune Modelling Components](https://docs.rosetta-technology.io/rosetta/rosetta-dsl/rosetta-modelling-component/) section of the documentation. - -A [demonstration model](https://github.com/rosetta-models/demo), also available in open source, provides a set of working examples of those modelling components. Snippets extracted from this model are being used to support the DSL documentation. - -### Code Generator - -Code generators remove the need for software developers to translate the model specifications into executable code while ensuring the inter-operability of different implementations. The Rune DSL repository provides one default code generator, for [Java](https://www.oracle.com/java/). - -To make models agnostic to the technology platform in which they are being implemented, other code generators have been provided in a variety of languages. A separate [code generator repository](https://github.com/REGnosys/rosetta-code-generators), also open source, allows the community to create and share code generators in potentially any software language. - -The [Code Generator documentation](https://docs.rosetta-technology.io/rosetta/rosetta-dsl/rosetta-code-generators/) details the available code generators, the code generation mechanism and how to write and test one. - -## Development setup - -### Setup for developers -This guide is meant for everyone who wants to contribute to the Rune DSL and needs to get things up and running. - -If this guide does not work for you, be sure to raise an issue. This way we can help you figure out what the problem is and update this guide to prevent the same problem for future users. - -### 1. Building with Maven -Start by cloning the project: `git clone https://github.com/finos/rune-dsl` - -Our project runs with Java 17. Make sure that your Maven also uses this version of Java by running `mvn -v`. - -To build the project, run `mvn clean install`. - -### 2. Setting things up in Eclipse -#### Install Eclipse IDE for Java and DSL Developers -Install the latest version of the "Eclipse IDE for Java and DSL Developers" using the [Eclipse Installer](https://www.eclipse.org/downloads/packages/installer). - -#### Install the Checkstyle plugin -We use [Checkstyle](https://checkstyle.sourceforge.io/) for enforcing good coding practices. The Eclipse plugin for Checkstyle can be found here: [https://checkstyle.org/eclipse-cs/#!/](https://checkstyle.org/eclipse-cs/#!/). - -#### Install the Xsemantics plugin -We use the [Xsemantics DSL](https://github.com/eclipse/xsemantics) to define the type system of Rune. To enable language support for it in Eclipse, follow these steps: -1. Find out which version of Xsemantics you need by looking in the `pom.xml` file of the parent project. There should be a property called `xsemantics.version`. -2. Go to Help > Install New Software... -3. In 'Work with' fill in [https://download.eclipse.org/xsemantics/milestones/](https://download.eclipse.org/xsemantics/milestones/). -4. Install the appropriate version of XSemantics. - -#### Setup the project -1. **Open the project in Eclipse**: File > Open Projects from File System..., select the right folder, click Finish. -2. **Update Maven dependencies**: right click on the `com.regnosys.rosetta.parent` project > Maven > Update project... and finish. - -##### Troubleshooting -Make sure you have successfully run `mvn clean install`. (see section 1 of this guide) - -If you're seeing 1000+ errors in the "Problems" window of Eclipse, try the following. -1. Disable auto-building. (Project > Build automatically) -2. Close Eclipse and open it again. -3. Update Maven dependencies again. -4. Re-enable auto-building. - -### 3. Setting things up in Intellij -Support for developing Xtext projects in Intellij is limited. It has no support for -- editing `Xtend` files -- editing the `Xtext` file -- editing the `Xsemantics` file -- running `GenerateRosetta.mwe2`. - -You can however let Maven take care of that, and still edit regular Java files, run tests, etc. - -Unfortunately, there is an issue in Intellij that lets the Maven build fail, see -- https://youtrack.jetbrains.com/issue/IDEA-262695 -- https://github.com/eclipse/xtext/issues/1953 - -In the stacktrace, you'll see a reference to a file called `plexus-classworlds.license`. It is safe to delete this file. -Once you do this, the build should succeed. - -## Roadmap - -Coming soon... - -## Contributing -For any questions, bugs or feature requests please open an [issue](https://github.com/finos/rune-dsl/issues) -For anything else please send an email to {project mailing list}. - -To submit a contribution: -1. Fork it () -2. Create your feature branch (`git checkout -b feature/fooBar`) -3. Read our [contribution guidelines](.github/CONTRIBUTING.md) and [Community Code of Conduct](https://www.finos.org/code-of-conduct) -4. Commit your changes (`git commit -am 'Add some fooBar'`) -5. Push to the branch (`git push origin feature/fooBar`) -6. Create a new Pull Request - -_NOTE:_ Commits and pull requests to FINOS repositories will only be accepted from those contributors with an active, executed Individual Contributor License Agreement (ICLA) with FINOS OR who are covered under an existing and active Corporate Contribution License Agreement (CCLA) executed with FINOS. Commits from individuals not covered under an ICLA or CCLA will be flagged and blocked by the FINOS Clabot tool (or [EasyCLA](https://community.finos.org/docs/governance/Software-Projects/easycla)). Please note that some CCLAs require individuals/employees to be explicitly named on the CCLA. - -* Unsure if you are covered under an existing CCLA? Email [help@finos.org](mailto:help@finos.org)* - -## Get in touch with the Rune Team - - Get in touch with the Rune team by creating a [GitHub issue](https://github.com/REGnosys/rosetta-dsl/issues/new) and labelling it with "help wanted". - - We encourage the community to get in touch via the [FINOS Slack](https://www.finos.org/blog/finos-announces-new-community-slack). - -## License - -Copyright 2019 REGnosys - -Distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). - -SPDX-License-Identifier: [Apache-2.0](https://spdx.org/licenses/Apache-2.0) +1. Create a new main visitor (like RosettaTypeCheckVisitor) +2. Define accept methods for this visitor for all the expressions +3. Implement concrete acceptors in the new visitor or in new files stemming from it \ No newline at end of file diff --git a/README_project.md b/README_project.md new file mode 100644 index 000000000..61d70f8b3 --- /dev/null +++ b/README_project.md @@ -0,0 +1,153 @@ +--- +title: "Rune DSL Overview" +date: 2022-02-09T00:38:25+09:00 +description: "Rune is a Domain-Specific Language (DSL) that supports the modelling of operational processes for the financial markets' industry. Its purpose is to promote consistency and inter-operability between the various implementations of these processes." +draft: false +weight: 1 +--- + +# Rune DSL + +[![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://community.finos.org/docs/governance/Software-Projects/stages/incubating) + +**Continuous Integration:** [![Maven Central](https://img.shields.io/maven-central/v/com.regnosys.rosetta/com.regnosys.rosetta.parent.svg?maxAge=2592000)](https://search.maven.org/#artifactdetails%7Ccom.regnosys.rosetta%7Ccom.regnosys.rosetta.parent%7C2%7Cpom) + +*Rune DSL* is a Domain-Specific Language (DSL) that supports the modelling of operational processes for the financial markets' industry. Its purpose is to promote consistency and inter-operability between the various implementations of these processes. + +{{< notice info "Note" >}} +In software engineering, a [domain model](https://olegchursin.medium.com/a-brief-introduction-to-domain-modeling-862a30b38353) is a conceptual model of a business domain that incorporates both *data* and *logic* (i.e. rules and processes). +{{< /notice >}} + +The key idea behind the Rune DSL is that, whilst financial markets' operational infrastructure is largely electronified, many of its underlying IT systems tend to operate in silos. + +For instance, the same data are often represented differently between different applications - usually a reasonable choice when considering the respective purpose of each application. But without any formalised translation between them, data cannot easily flow from one application to another and the overall architecture looses cohesiveness. Applications also tend to mix the specification of their business logic with its technical implementation. Once buried in code, an application's logic is hard to extract and must usually be documented separately, with no guarantee of consistency. + +**The Rune DSL allows to represent data and business logic in a system- and technology-agnostic way** into a cohesive domain model. By supporting a shared, formalised understanding of the financial markets' domain, it enables different technology implementations to "talk" to each other in the same native language. + +A model expressed in the Rune DSL provides more than a technical specification: it automatically generates executable code, to be used directly in an implementation. Both the Rune DSL and associated code generators are available in open source. + +**One important application of the Rune DSL concerns regulatory reporting**. While many financial institutions share the same reporting obligations, they usually implement their logic in slightly different ways because of siloed technology approaches. This exposes firms to non-compliance risk and fines and degrades the quality and comparability of the data that regulators collect. + +Instead, Rune empowers many users within firms to take part in interpreting and codifying reporting rules, without the risk of loss-in-translation once they get implemented in IT systems. The language itself is designed to be human-readable, so that domain experts without programming experience (e.g. operations or compliance professionals) can write fully functional regulatory logic directly – a bit like in Excel. + +## Rosetta + +A complete end to end development environment called [Rosetta](https://ui.rosetta-technology.io/) is provided to help industry participants to create, edit or extend models using the Rune DSL. Rosetta also provides integration tools designed to facilitate firms' adoption and implementation of models within their own technology architecture. + +Much like how software engineers use programming languages and tools to build and test software, it is useful to think of Rosetta as a platform with a set of tools to build and test a domain model using the Rune DSL. The [Rosetta products documentation](https://docs.rosetta-technology.io/rosetta/rosetta-products/) details the various tools and products that are available in the Rosetta platform. + +In order to facilitate the use of the Rune DSL by industry members, a *Community Edition* of Rosetta that already features many of the platform's functionalities is available as a free web application. Through Rosetta, users can also access a number of open-source [modelling projects](https://docs.rosetta-technology.io/rosetta/projects/) that are based on the Rune DSL, allowing them to use, edit or extend those models. + +## Rune DSL Components + +The Rune DSL comprises 2 components, both open-source: + +- *Syntax* - defines the language and rules for editing a model using the Rune DSL, also known as a *grammar* +- *Code generators* - from a model expressed in the Rune DSL, automatically generates executable code in other programming languages + +### Syntax + +The [Rune DSL repository](https://github.com/finos/rune-dsl/) contains the definition of the language. It is based on the [Eclipe Modelling Framework](https://www.eclipse.org/modeling/emf/). + +The language components available in the Rune DSL and their syntax are detailed in the [Rune Modelling Components](https://docs.rosetta-technology.io/rosetta/rosetta-dsl/rosetta-modelling-component/) section of the documentation. + +A [demonstration model](https://github.com/rosetta-models/demo), also available in open source, provides a set of working examples of those modelling components. Snippets extracted from this model are being used to support the DSL documentation. + +### Code Generator + +Code generators remove the need for software developers to translate the model specifications into executable code while ensuring the inter-operability of different implementations. The Rune DSL repository provides one default code generator, for [Java](https://www.oracle.com/java/). + +To make models agnostic to the technology platform in which they are being implemented, other code generators have been provided in a variety of languages. A separate [code generator repository](https://github.com/REGnosys/rosetta-code-generators), also open source, allows the community to create and share code generators in potentially any software language. + +The [Code Generator documentation](https://docs.rosetta-technology.io/rosetta/rosetta-dsl/rosetta-code-generators/) details the available code generators, the code generation mechanism and how to write and test one. + +## Development setup + +### Setup for developers +This guide is meant for everyone who wants to contribute to the Rune DSL and needs to get things up and running. + +If this guide does not work for you, be sure to raise an issue. This way we can help you figure out what the problem is and update this guide to prevent the same problem for future users. + +### 1. Building with Maven +Start by cloning the project: `git clone https://github.com/finos/rune-dsl` + +Our project runs with Java 17. Make sure that your Maven also uses this version of Java by running `mvn -v`. + +To build the project, run `mvn clean install`. + +### 2. Setting things up in Eclipse +#### Install Eclipse IDE for Java and DSL Developers +Install the latest version of the "Eclipse IDE for Java and DSL Developers" using the [Eclipse Installer](https://www.eclipse.org/downloads/packages/installer). + +#### Install the Checkstyle plugin +We use [Checkstyle](https://checkstyle.sourceforge.io/) for enforcing good coding practices. The Eclipse plugin for Checkstyle can be found here: [https://checkstyle.org/eclipse-cs/#!/](https://checkstyle.org/eclipse-cs/#!/). + +#### Install the Xsemantics plugin +We use the [Xsemantics DSL](https://github.com/eclipse/xsemantics) to define the type system of Rune. To enable language support for it in Eclipse, follow these steps: +1. Find out which version of Xsemantics you need by looking in the `pom.xml` file of the parent project. There should be a property called `xsemantics.version`. +2. Go to Help > Install New Software... +3. In 'Work with' fill in [https://download.eclipse.org/xsemantics/milestones/](https://download.eclipse.org/xsemantics/milestones/). +4. Install the appropriate version of XSemantics. + +#### Setup the project +1. **Open the project in Eclipse**: File > Open Projects from File System..., select the right folder, click Finish. +2. **Update Maven dependencies**: right click on the `com.regnosys.rosetta.parent` project > Maven > Update project... and finish. + +##### Troubleshooting +Make sure you have successfully run `mvn clean install`. (see section 1 of this guide) + +If you're seeing 1000+ errors in the "Problems" window of Eclipse, try the following. +1. Disable auto-building. (Project > Build automatically) +2. Close Eclipse and open it again. +3. Update Maven dependencies again. +4. Re-enable auto-building. + +### 3. Setting things up in Intellij +Support for developing Xtext projects in Intellij is limited. It has no support for +- editing `Xtend` files +- editing the `Xtext` file +- editing the `Xsemantics` file +- running `GenerateRosetta.mwe2`. + +You can however let Maven take care of that, and still edit regular Java files, run tests, etc. + +Unfortunately, there is an issue in Intellij that lets the Maven build fail, see +- https://youtrack.jetbrains.com/issue/IDEA-262695 +- https://github.com/eclipse/xtext/issues/1953 + +In the stacktrace, you'll see a reference to a file called `plexus-classworlds.license`. It is safe to delete this file. +Once you do this, the build should succeed. + +## Roadmap + +Coming soon... + +## Contributing +For any questions, bugs or feature requests please open an [issue](https://github.com/finos/rune-dsl/issues) +For anything else please send an email to {project mailing list}. + +To submit a contribution: +1. Fork it () +2. Create your feature branch (`git checkout -b feature/fooBar`) +3. Read our [contribution guidelines](.github/CONTRIBUTING.md) and [Community Code of Conduct](https://www.finos.org/code-of-conduct) +4. Commit your changes (`git commit -am 'Add some fooBar'`) +5. Push to the branch (`git push origin feature/fooBar`) +6. Create a new Pull Request + +_NOTE:_ Commits and pull requests to FINOS repositories will only be accepted from those contributors with an active, executed Individual Contributor License Agreement (ICLA) with FINOS OR who are covered under an existing and active Corporate Contribution License Agreement (CCLA) executed with FINOS. Commits from individuals not covered under an ICLA or CCLA will be flagged and blocked by the FINOS Clabot tool (or [EasyCLA](https://community.finos.org/docs/governance/Software-Projects/easycla)). Please note that some CCLAs require individuals/employees to be explicitly named on the CCLA. + +* Unsure if you are covered under an existing CCLA? Email [help@finos.org](mailto:help@finos.org)* + +## Get in touch with the Rune Team + + Get in touch with the Rune team by creating a [GitHub issue](https://github.com/REGnosys/rosetta-dsl/issues/new) and labelling it with "help wanted". + + We encourage the community to get in touch via the [FINOS Slack](https://www.finos.org/blog/finos-announces-new-community-slack). + +## License + +Copyright 2019 REGnosys + +Distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). + +SPDX-License-Identifier: [Apache-2.0](https://spdx.org/licenses/Apache-2.0) From 123df2fab64a4d8df648add89e6144b0bfdaf0b5 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 13:28:59 +0200 Subject: [PATCH 124/236] Update .gitlab-ci.yml file to show coverage --- .gitlab-ci.yml | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df63a6e87..2719f0412 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,14 @@ stages: - build - # - test + - test + - visualize - checkstyle build: image: maven:3.8-openjdk-17 stage: build script: - - mvn clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,com.regnosys.rosetta.interpreternew,rosetta-testing + - mvn -D"maven.test.skip=true" clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew @@ -15,7 +16,32 @@ build: # image: maven:3.8-openjdk-17 # stage: test # script: -# - mvn test -Dtest="/com.regnosys.rosetta.tests/src/test/java/com/regnosys/rosetta/interpreternew/*.java" -Dsurefire.failIfNoSpecifiedTests=false +# - mvn test -pl rosetta-testing + +test-jdk17: + stage: test + image: maven:3.8-openjdk-17 + script: + - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl com.regnosys.rosetta.interpreternew + artifacts: + paths: + - target/site/jacoco/jacoco.xml + +coverage-jdk17: + # Must be in a stage later than test-jdk17's stage. + # The `visualize` stage does not exist by default. + # Please define it first, or choose an existing stage like `deploy`. + stage: visualize + image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9 + script: + # convert report from jacoco to cobertura, using relative project path + - python /opt/cover2cover.py com.regnosys.rosetta.interpreternew/target/site/jacoco/jacoco.xml com.regnosys.rosetta.interpreternew/src/main/java/ > com.regnosys.rosetta.interpreternew/target/site/cobertura.xml + needs: ["test-jdk17"] + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: com.regnosys.rosetta.interpreternew/target/site/cobertura.xml checkstyle: image: maven:3.8-openjdk-17 From 76e215af97dde863fca2cc37e6d0a7e360858e2b Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 13:42:53 +0200 Subject: [PATCH 125/236] Update .gitlab-ci.yml file to resolve dependencies --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2719f0412..bb8bcbe58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ test-jdk17: stage: test image: maven:3.8-openjdk-17 script: - - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl com.regnosys.rosetta.interpreternew + - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew artifacts: paths: - target/site/jacoco/jacoco.xml From 29c8630e90e0d8b31adb90485968bc6ef1fd7408 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 14:03:54 +0200 Subject: [PATCH 126/236] Update .gitlab-ci.yml file to find target directory --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb8bcbe58..25596c67a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ coverage-jdk17: image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9 script: # convert report from jacoco to cobertura, using relative project path - - python /opt/cover2cover.py com.regnosys.rosetta.interpreternew/target/site/jacoco/jacoco.xml com.regnosys.rosetta.interpreternew/src/main/java/ > com.regnosys.rosetta.interpreternew/target/site/cobertura.xml + - python /opt/cover2cover.py com.regnosys.rosetta.interpreternew/target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/com.regnosys.rosetta.interpreternew/src/main/java/ > com.regnosys.rosetta.interpreternew/target/site/cobertura.xml needs: ["test-jdk17"] artifacts: reports: From 5df64a2c5c067d2ae6988cc10426ea7c104bf474 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 14:19:09 +0200 Subject: [PATCH 127/236] Moved tests --- com.regnosys.rosetta.interpreternew/pom.xml | 12 +++++++++-- ...taInterpreterArithmeticOperationsTest.java | 0 .../RosettaInterpreterComparisonTest.java | 0 ...aInterpreterConditionalExpressionTest.java | 0 .../RosettaInterpreterEqualityTest.java | 0 .../RosettaInterpreterErrorTest.java | 0 .../RosettaInterpreterLiteralsTest.java | 0 ...settaInterpreterLogicalOperationsTest.java | 0 .../RosettaInterpreterVariableTest.java | 0 .../RosettaInterpreterErrorValueTest.java | 0 ...erpreterListOperationsInterpreterTest.java | 0 ...nterpreterListOperatorInterpreterTest.java | 0 .../rosetta/interpreternew/AppTest.java | 20 ------------------- rosetta-testing/pom.xml | 10 +++++----- 14 files changed, 15 insertions(+), 27 deletions(-) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java (100%) rename {rosetta-testing => com.regnosys.rosetta.interpreternew}/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java (100%) delete mode 100644 com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java diff --git a/com.regnosys.rosetta.interpreternew/pom.xml b/com.regnosys.rosetta.interpreternew/pom.xml index fe1c0072b..84ed8886b 100644 --- a/com.regnosys.rosetta.interpreternew/pom.xml +++ b/com.regnosys.rosetta.interpreternew/pom.xml @@ -37,7 +37,12 @@ com.regnosys.rosetta com.regnosys.rosetta - 0.0.0.main-SNAPSHOT + ${project.version} + + + com.regnosys.rosetta + com.regnosys.rosetta.tests + ${project.version} @@ -85,7 +90,10 @@ 3.0.0 - + + org.jacoco + jacoco-maven-plugin + diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java similarity index 100% rename from rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java rename to com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java deleted file mode 100644 index 80e4115cd..000000000 --- a/com.regnosys.rosetta.interpreternew/src/test/java/org/com/regnosys/rosetta/interpreternew/AppTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.com.regnosys.rosetta.interpreternew; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class AppTest -{ - /** - * Rigorous Test :-). - */ - @Test - public void shouldAnswerWithTrue() - { - assertTrue(true); - } -} diff --git a/rosetta-testing/pom.xml b/rosetta-testing/pom.xml index 7f8ef3c02..85d9eb891 100644 --- a/rosetta-testing/pom.xml +++ b/rosetta-testing/pom.xml @@ -35,11 +35,6 @@ com.regnosys.rosetta ${project.version} - - com.regnosys.rosetta - com.regnosys.rosetta.interpreternew - ${project.version} - @@ -79,6 +74,11 @@ org.eclipse.xtend xtend-maven-plugin + + org.jacoco + jacoco-maven-plugin + + \ No newline at end of file From 81e751b419e5abb8cfcfe6b92f7460330cab6af1 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 14:34:29 +0200 Subject: [PATCH 128/236] Update .gitlab-ci.yml file to show coverage using jacoco --- .gitlab-ci.yml | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25596c67a..5fac0fc1c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ stages: - build - test - - visualize - checkstyle build: @@ -10,39 +9,16 @@ build: script: - mvn -D"maven.test.skip=true" clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew - - -# test: -# image: maven:3.8-openjdk-17 -# stage: test -# script: -# - mvn test -pl rosetta-testing - test-jdk17: stage: test image: maven:3.8-openjdk-17 script: - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew + - cat com.regnosys.rosetta.interpreternew/target/site/jacoco/index.html | grep -o -E "Total[^%]+?%" | sed -E "s/<.*>//" | sed -E "s/Total/TestCoverage:/" artifacts: paths: - target/site/jacoco/jacoco.xml -coverage-jdk17: - # Must be in a stage later than test-jdk17's stage. - # The `visualize` stage does not exist by default. - # Please define it first, or choose an existing stage like `deploy`. - stage: visualize - image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9 - script: - # convert report from jacoco to cobertura, using relative project path - - python /opt/cover2cover.py com.regnosys.rosetta.interpreternew/target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/com.regnosys.rosetta.interpreternew/src/main/java/ > com.regnosys.rosetta.interpreternew/target/site/cobertura.xml - needs: ["test-jdk17"] - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: com.regnosys.rosetta.interpreternew/target/site/cobertura.xml - checkstyle: image: maven:3.8-openjdk-17 stage: checkstyle From 2184b1dfcd64a068f329e045f79350eb941e4533 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 15:02:01 +0200 Subject: [PATCH 129/236] fix checkstyle and cache dependencies to make pipeline faster --- .gitlab-ci.yml | 7 +++++++ .../interpreternew/RosettaInterpreterLiteralsTest.java | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5fac0fc1c..3a5cb53b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,13 @@ stages: - build - test - checkstyle + +image: maven:3.8-openjdk-17 + +cache: + paths: + - .m2/repository + build: image: maven:3.8-openjdk-17 diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 9684e7afd..5684a8206 100644 --- a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -118,7 +118,8 @@ public void intTest() { public void numberTest() { RosettaExpression expr = parser.parseExpression("5.5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), ((RosettaInterpreterNumberValue)val).getValue()); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), + ((RosettaInterpreterNumberValue)val).getValue()); } @Test From d260d273d5e4ac276da0b6724332ef98b9dc9658 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 15:29:16 +0200 Subject: [PATCH 130/236] Update .gitlab-ci.yml file to show coverage --- .gitlab-ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a5cb53b0..8d0b6a754 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,33 +1,31 @@ -stages: - - build - - test - - checkstyle - image: maven:3.8-openjdk-17 cache: paths: - .m2/repository +stages: + - build + - test + - checkstyle + build: - image: maven:3.8-openjdk-17 stage: build script: - mvn -D"maven.test.skip=true" clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew test-jdk17: stage: test - image: maven:3.8-openjdk-17 script: - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew - cat com.regnosys.rosetta.interpreternew/target/site/jacoco/index.html | grep -o -E "Total[^%]+?%" | sed -E "s/<.*>//" | sed -E "s/Total/TestCoverage:/" artifacts: paths: - target/site/jacoco/jacoco.xml + coverage: /TestCoverage:(\d+)%/ checkstyle: - image: maven:3.8-openjdk-17 stage: checkstyle script: - mvn checkstyle:check -pl com.regnosys.rosetta.interpreternew From 09a8b86962c60889fdb5e9cbcba1626ccf65bd22 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 15:31:41 +0200 Subject: [PATCH 131/236] Update .gitlab-ci.yml file to cache dependencies --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d0b6a754..93da31237 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,8 @@ image: maven:3.8-openjdk-17 cache: paths: - .m2/repository + key: one-key-to-rule-them-all + stages: - build From d647da6bc5052aa8294fdc296b1f88549418b5cc Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 4 Jun 2024 15:54:18 +0200 Subject: [PATCH 132/236] Update .gitlab-ci.yml file to (hopefully) cache dependencies --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93da31237..321c55f0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: maven:3.8-openjdk-17 +variables: + MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository" + cache: paths: - .m2/repository From c0fe4e3c855e83fa7b2227ecb6e26a6d972f1af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Tue, 4 Jun 2024 17:25:45 +0300 Subject: [PATCH 133/236] Removed unnecessary things --- rosetta-lang/model/Rosetta.xcore | 6 ------ rosetta-lang/model/RosettaInterpreter.xcore | 4 ---- .../interpreternew/RosettaInterpreterVisitor.java | 11 ----------- ...settaInterpreterRosettaRecordTypeInterpreter.java | 12 ------------ 4 files changed, 33 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index bc0408a9c..20e7dcab0 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -116,12 +116,6 @@ class RosettaSynonymSource extends RosettaRootElement , RosettaNamed { class RosettaRecordType extends RosettaRootElement, RosettaBuiltinType { contains RosettaRecordFeature[] features - op RosettaInterpreterValue accept(InterpreterVisitor v) { - v.interp(this) - } - op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { - v.interp(this,nv) - } } class RosettaRecordFeature extends RosettaTypedFeature {} diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index ca7687cb1..3f2ea5bdb 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -71,9 +71,6 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp) - op RosettaInterpreterValue interp (RosettaRecordType exp) - - op RosettaInterpreterValue interp (RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env) @@ -100,7 +97,6 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) - op RosettaInterpreterValue interp (RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index eccbf36e3..32617a49d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -42,7 +42,6 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConstructorExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; -import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaRecordTypeInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterVariableInterpreter; @@ -314,16 +313,6 @@ public RosettaInterpreterValue interp(SumOperation exp, return new RosettaInterpreterListOperatorInterpreter().interp(exp, env); } - @Override - public RosettaInterpreterValue interp(RosettaRecordType exp) { - return interp(exp, new RosettaInterpreterEnvironment()); - } - - @Override - public RosettaInterpreterValue interp(RosettaRecordType exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaRecordTypeInterpreter().interp(exp, env); - } - @Override public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaConstructorExpressionInterpreter().interp(exp, env); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java deleted file mode 100644 index fa6a3e52a..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaRecordTypeInterpreter.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.regnosys.rosetta.interpreternew.visitors; - -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; -import com.regnosys.rosetta.rosetta.RosettaRecordType; - -public class RosettaInterpreterRosettaRecordTypeInterpreter extends RosettaInterpreterConcreteInterpreter { - - public RosettaInterpreterBaseValue interp(RosettaRecordType expr, RosettaInterpreterBaseEnvironment env) { - return null; - } -} From 6f69683f92619f01cacf0e674b9ae64249bf1603 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 18:02:07 +0200 Subject: [PATCH 134/236] improved readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e21ad1c36..6fa52c52b 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ For most practical information, refer to the [original readme file](README_proje ## Authors - Jacek Kulik - Antonio Lupu -- Maria Cristucsecu +- Maria Cristescu - Bogdan Damian -- Diana Śutać +- Diana Şutac ## Project Structure From 6c44bb76c0ffc7b80ae21666dfdbfcb289c209f6 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 18:25:29 +0200 Subject: [PATCH 135/236] intercontinental ballistic missile --- .../.project | 0 .../checkstyle-SP.xml | 0 .../pom.xml | 0 .../regnosys/rosetta/interpreternew/RosettaInterpreterNew.java | 0 .../rosetta/interpreternew/RosettaInterpreterNewException.java | 0 .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 0 .../rosetta/interpreternew/RosettaInterpreterVisitorBase.java | 0 .../interpreternew/values/RosettaInterpreterBaseValue.java | 0 .../interpreternew/values/RosettaInterpreterBooleanValue.java | 0 .../interpreternew/values/RosettaInterpreterEnvironment.java | 0 .../rosetta/interpreternew/values/RosettaInterpreterError.java | 0 .../interpreternew/values/RosettaInterpreterErrorValue.java | 0 .../interpreternew/values/RosettaInterpreterIntegerValue.java | 0 .../interpreternew/values/RosettaInterpreterListValue.java | 0 .../interpreternew/values/RosettaInterpreterNumberValue.java | 0 .../interpreternew/values/RosettaInterpreterStringValue.java | 0 .../RosettaInterpreterComparisonOperationInterpreter.java | 0 .../visitors/RosettaInterpreterConcreteInterpreter.java | 0 .../visitors/RosettaInterpreterListLiteralInterpreter.java | 0 .../visitors/RosettaInterpreterListOperationsInterpreter.java | 0 .../visitors/RosettaInterpreterListOperatorInterpreter.java | 0 .../visitors/RosettaInterpreterLogicalOperationInterpreter.java | 0 .../RosettaInterpreterRosettaArithmeticOperationsInterpreter.java | 0 .../RosettaInterpreterRosettaBooleanLiteralInterpreter.java | 0 ...RosettaInterpreterRosettaConditionalExpressionInterpreter.java | 0 .../visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java | 0 .../RosettaInterpreterRosettaNumberLiteralInterpreter.java | 0 .../RosettaInterpreterRosettaStringLiteralInterpreter.java | 0 .../visitors/RosettaInterpreterVariableInterpreter.java | 0 .../RosettaInterpreterArithmeticOperationsTest.java | 0 .../rosetta/interpreternew/RosettaInterpreterComparisonTest.java | 0 .../RosettaInterpreterConditionalExpressionTest.java | 0 .../rosetta/interpreternew/RosettaInterpreterEqualityTest.java | 0 .../rosetta/interpreternew/RosettaInterpreterErrorTest.java | 0 .../rosetta/interpreternew/RosettaInterpreterLiteralsTest.java | 0 .../interpreternew/RosettaInterpreterLogicalOperationsTest.java | 0 .../rosetta/interpreternew/RosettaInterpreterVariableTest.java | 0 .../interpreternew/value/RosettaInterpreterErrorValueTest.java | 0 .../visitors/RosettaInterpreterListOperationsInterpreterTest.java | 0 .../visitors/RosettaInterpreterListOperatorInterpreterTest.java | 0 40 files changed, 0 insertions(+), 0 deletions(-) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/.project (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/checkstyle-SP.xml (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/pom.xml (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java (100%) rename {com.regnosys.rosetta.interpreternew => rosetta-interpreter}/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java (100%) diff --git a/com.regnosys.rosetta.interpreternew/.project b/rosetta-interpreter/.project similarity index 100% rename from com.regnosys.rosetta.interpreternew/.project rename to rosetta-interpreter/.project diff --git a/com.regnosys.rosetta.interpreternew/checkstyle-SP.xml b/rosetta-interpreter/checkstyle-SP.xml similarity index 100% rename from com.regnosys.rosetta.interpreternew/checkstyle-SP.xml rename to rosetta-interpreter/checkstyle-SP.xml diff --git a/com.regnosys.rosetta.interpreternew/pom.xml b/rosetta-interpreter/pom.xml similarity index 100% rename from com.regnosys.rosetta.interpreternew/pom.xml rename to rosetta-interpreter/pom.xml diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNewException.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitorBase.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBaseValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterBooleanValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnvironment.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterConcreteInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListLiteralInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaBooleanLiteralInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaNumberLiteralInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaStringLiteralInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java rename to rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEqualityTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterErrorTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLogicalOperationsTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreterTest.java diff --git a/com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java similarity index 100% rename from com.regnosys.rosetta.interpreternew/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java rename to rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java From b36e1d13c716fd917a48a53a5aad29eea245e0a2 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 18:27:59 +0200 Subject: [PATCH 136/236] attempt to remove references to old directory --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 321c55f0f..f5e682ff9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,13 +18,13 @@ stages: build: stage: build script: - - mvn -D"maven.test.skip=true" clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew + - mvn -D"maven.test.skip=true" clean package -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,rosetta-interpreter test-jdk17: stage: test script: - - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,com.regnosys.rosetta.interpreternew - - cat com.regnosys.rosetta.interpreternew/target/site/jacoco/index.html | grep -o -E "Total[^%]+?%" | sed -E "s/<.*>//" | sed -E "s/Total/TestCoverage:/" + - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report -pl rosetta-xcore-plugin-dependencies,rosetta-lang,rosetta-testing,rosetta-interpreter + - cat rosetta-interpreter/target/site/jacoco/index.html | grep -o -E "Total[^%]+?%" | sed -E "s/<.*>//" | sed -E "s/Total/TestCoverage:/" artifacts: paths: - target/site/jacoco/jacoco.xml @@ -33,5 +33,5 @@ test-jdk17: checkstyle: stage: checkstyle script: - - mvn checkstyle:check -pl com.regnosys.rosetta.interpreternew + - mvn checkstyle:check -pl rosetta-interpreter From 2fa33ce6c25323a40461d81e2038d2d47bbb830f Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 4 Jun 2024 18:31:33 +0200 Subject: [PATCH 137/236] attempt to remove references to old directory --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b0761e911..3e6ea9df1 100644 --- a/pom.xml +++ b/pom.xml @@ -343,7 +343,7 @@ - com.regnosys.rosetta.interpreternew + rosetta-interpreter From 305d9ee9223e946f056e7b9fe593984f81fa208d Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 4 Jun 2024 19:51:11 +0200 Subject: [PATCH 138/236] Added support for enum references as well --- rosetta-lang/model/Rosetta.xcore | 2 +- rosetta-lang/model/RosettaExpression.xcore | 4 + rosetta-lang/model/RosettaInterpreter.xcore | 2 + .../RosettaInterpreterVisitor.java | 9 ++ .../values/RosettaInterpreterEnumValue.java | 16 ++- ...ettaInterpreterFeatureCallInterpreter.java | 99 +++++++++++++++++++ .../RosettaInterpreterEnumTest.java | 59 ++++++----- 7 files changed, 158 insertions(+), 33 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 4240f5257..0c7b6d8aa 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -13,7 +13,7 @@ import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue +//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 20105051a..6b18dccbb 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -173,6 +173,10 @@ class RosettaImplicitVariable extends RosettaReference, RosettaNamed { class RosettaFeatureCall extends RosettaExpression { contains RosettaExpression receiver refers RosettaFeature feature + + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this, nv) + } } class RosettaConditionalExpression extends RosettaExpression { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index bb0e3e12b..d0ad169f4 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -21,6 +21,7 @@ import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment import com.regnosys.rosetta.rosetta.RosettaEnumeration import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression import com.regnosys.rosetta.rosetta.expression.JoinOperation import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression @@ -66,6 +67,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (DistinctOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterBaseEnvironment interp (RosettaEnumeration exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index aba2196f0..6daa89715 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -18,6 +18,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -33,6 +34,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEnumerationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterFeatureCallInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; @@ -221,5 +223,12 @@ public RosettaInterpreterEnvironment interp(RosettaEnumeration exp, return new RosettaInterpreterEnumerationInterpreter().interp(exp, (RosettaInterpreterEnvironment) env); } + + @Override + public RosettaInterpreterValue interp(RosettaFeatureCall exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterFeatureCallInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java index a705033ae..606d6387a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java @@ -32,6 +32,21 @@ public int hashCode() { public String toString() { return "RosettaInterpreterListValue [name = " + name + ", values=" + values.toString() + "]"; } + + /** + * Method that checks that the enum contains a certain value. + * + * @param name Name of the value that the enum should contain + */ + public boolean containsValueName(String name) { + boolean ok = false; + for (RosettaInterpreterValue v : values) { + if (((RosettaInterpreterEnumElementValue) v).getValue().equals(name)) { + ok = true; + } + } + return ok; + } @Override public boolean equals(Object obj) { @@ -50,7 +65,6 @@ public boolean equals(Object obj) { public List getValues() { return values; } - public String getName() { return name; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java new file mode 100644 index 000000000..e2411f5f2 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java @@ -0,0 +1,99 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.RosettaEnumValue; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; +import com.regnosys.rosetta.rosetta.impl.RosettaEnumValueImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterFeatureCallInterpreter + extends RosettaInterpreterConcreteInterpreter { + + /** + * Based on what class the symbol reference belongs to, it chooses what method to send it to. + * + * @param expr The RosettaFeatureCall expression to redirect + * @param env The Environment + * @return If no errors are encountered, a RosettaInterpreterNumberValue or + * RosettaInterpreterStringValue representing + * the result of the arithmetic/concatenation operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(RosettaFeatureCall expr, + RosettaInterpreterEnvironment env) { + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) expr.getReceiver(); + RosettaEnumValue enumVal; + //if(expr.getFeature() instanceof RosettaEnumValueImpl) { + enumVal = (RosettaEnumValueImpl) expr.getFeature(); + RosettaEnumeration enumeration = (RosettaEnumeration) ref.getSymbol(); + return interpEnum(enumeration, enumVal, env); + //} + //else Here comes the DataType ref call implementation that will have a different interp method + + } + + /** + * Interprets an enum feature call. + * + * @param enumeration The RosettaEnumeration to interpret alongside + * @param val The enum value to interpret + * @param env The Environment + * @return If no errors are encountered, a RosettaInterpreterNumberValue or + * RosettaInterpreterStringValue representing + * the result of the arithmetic/concatenation operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, RosettaEnumValue val, + RosettaInterpreterEnvironment env) { + + //The comments check some possible errors, + //but the model parser already does not allow it, + //so it's not really useful but I also don't wanna delete it + +// if (env.findValue(enumeration.getName()) instanceof RosettaInterpreterEnumValue) { +// if (((RosettaInterpreterEnumValue) env.findValue(enumeration.getName())) +// .containsValueName(val.getName())) { + return new RosettaInterpreterEnumElementValue(val.getEnumeration().getName(), + val.getName()); +// } else { +// return new RosettaInterpreterErrorValue( +// new RosettaInterpreterError( +// "The " + val.getEnumeration().getName() +// + " enum does not contain value " +// + val.getName())); +// } +// } else { +// return (RosettaInterpreterErrorValue) env.findValue(enumeration.getName()); +// } + } + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java index c7a406d0c..f2a86a7f6 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java @@ -14,9 +14,9 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.rosetta.RosettaEnumeration; -//import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -//import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ModelHelper; @@ -41,18 +41,18 @@ public class RosettaInterpreterEnumTest { @Test public void enumAddsToEnvironmentTest() { RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" - + " VALU_E1 displayName \"VALU.E1\"\r\n" + + " VALUE1 displayName \"VALUE1\"\r\n" + " VALUE2\r\n" + "\r\n" + "func MyTest:\r\n" + " output: result Foo (1..1)\r\n" + " set result:\r\n" - + " Foo -> VALU_E1"); + + " Foo -> VALUE1"); RosettaInterpreterEnvironment expectedEnv = new RosettaInterpreterEnvironment(); expectedEnv.addValue("Foo", new RosettaInterpreterEnumValue("Foo", - List.of(new RosettaInterpreterEnumElementValue("Foo", "VALU_E1"), + List.of(new RosettaInterpreterEnumElementValue("Foo", "VALUE1"), new RosettaInterpreterEnumElementValue("Foo", "VALUE2")))); RosettaInterpreterEnvironment actualEnv = new RosettaInterpreterEnvironment(); @@ -63,31 +63,28 @@ public void enumAddsToEnvironmentTest() { (RosettaInterpreterEnvironment) expectedEnv); } -// @Test -// public void enumRefTest() { -// RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" -// + " VALU_E1 displayName \"VALU.E1\"\r\n" -// + " VALUE2\r\n" -// + "\r\n" -// + "func MyTest:\r\n" -// + " output: result Foo (1..1)\r\n" -// + " set result:\r\n" -// + " Foo -> VALU_E1"); -// RosettaInterpreterEnvironment expectedEnv = -// new RosettaInterpreterEnvironment(); -// expectedEnv.addValue("Foo", -// new RosettaInterpreterEnumValue("Foo", -// List.of(new RosettaInterpreterEnumElementValue("Foo", "VALU_E1"), -// new RosettaInterpreterEnumElementValue("Foo", "VALUE2")))); -// RosettaInterpreterEnvironment actualEnv = -// new RosettaInterpreterEnvironment(); -// RosettaEnumeration enumeration = (RosettaEnumeration) model.getElements().get(0); -// RosettaExpression refCall = ((FunctionImpl) model.getElements().get(1)).getOperations() -// .get(0).getExpression(); -// RosettaInterpreterValue env = (RosettaInterpreterEnvironment) -// interpreter.interp(refCall, actualEnv); -// assertEquals((RosettaInterpreterEnvironment) env, -// (RosettaInterpreterEnvironment) expectedEnv); -// } + @Test + public void enumRefTest() { + RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALUE1 displayName \"VALUE1\"\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result Foo (1..1)\r\n" + + " set result:\r\n" + + " Foo -> VALUE1"); + RosettaInterpreterEnvironment expectedEnv = + new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Foo", + new RosettaInterpreterEnumValue("Foo", + List.of(new RosettaInterpreterEnumElementValue("Foo", "VALUE1"), + new RosettaInterpreterEnumElementValue("Foo", "VALUE2")))); + RosettaExpression refCall = ((FunctionImpl) model.getElements().get(1)).getOperations() + .get(0).getExpression(); + RosettaInterpreterEnumElementValue val = (RosettaInterpreterEnumElementValue) + interpreter.interp(refCall, expectedEnv); + assertEquals(val, + new RosettaInterpreterEnumElementValue("Foo", "VALUE1")); + } } \ No newline at end of file From 5f80df100e726d3a4cab2fa1f604dd3670f48ab9 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 4 Jun 2024 20:02:11 +0200 Subject: [PATCH 139/236] Added environment value in the interpreter --- .../interpreternew/RosettaInterpreterNew.java | 32 +++++++++++++++++-- .../RosettaInterpreterEnumTest.java | 20 ++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index a49d16def..9816642cd 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; + import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; @@ -13,6 +14,9 @@ public class RosettaInterpreterNew { @Inject private RosettaInterpreterVisitor visitor; + @Inject + private RosettaInterpreterEnvironment environment; + /** * Simple example interpret function to allow for better understanding * of the development workflow. @@ -21,7 +25,7 @@ public class RosettaInterpreterNew { * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { - return expression.accept(visitor, new RosettaInterpreterEnvironment()); + return expression.accept(visitor, environment); } public RosettaInterpreterValue interp(RosettaExpression expression, @@ -29,8 +33,32 @@ public RosettaInterpreterValue interp(RosettaExpression expression, return expression.accept(visitor, env); } + /** + * Simple example interpret function to allow for better understanding + * of the development workflow. + * + * @param expression the expression to be interpreted + * @return value of RosettaIntLiteral otherwise exception + */ public RosettaInterpreterEnvironment interp(RosettaEnumeration expression, RosettaInterpreterBaseEnvironment env) { - return (RosettaInterpreterEnvironment) expression.accept(visitor, env); + + environment = (RosettaInterpreterEnvironment) expression.accept(visitor, env); + + return environment; + } + + /** + * Simple example interpret function to allow for better understanding + * of the development workflow. + * + * @param expression the expression to be interpreted + * @return value of RosettaIntLiteral otherwise exception + */ + public RosettaInterpreterEnvironment interp(RosettaEnumeration expression) { + + environment = (RosettaInterpreterEnvironment) expression.accept(visitor, environment); + + return environment; } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java index f2a86a7f6..e0d3184da 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java @@ -87,4 +87,24 @@ public void enumRefTest() { new RosettaInterpreterEnumElementValue("Foo", "VALUE1")); } + @Test + public void combinedTest() { + RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALUE1 displayName \"VALUE1\"\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result Foo (1..1)\r\n" + + " set result:\r\n" + + " Foo -> VALUE1"); + RosettaEnumeration enumeration = (RosettaEnumeration) model.getElements().get(0); + interpreter.interp(enumeration); + RosettaExpression refCall = ((FunctionImpl) model.getElements().get(1)).getOperations() + .get(0).getExpression(); + RosettaInterpreterEnumElementValue val = (RosettaInterpreterEnumElementValue) + interpreter.interp(refCall); + assertEquals(val, + new RosettaInterpreterEnumElementValue("Foo", "VALUE1")); + } + } \ No newline at end of file From f3aab4ed98e9fcd545a0c36660f5c0463b220a37 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 5 Jun 2024 14:14:02 +0200 Subject: [PATCH 140/236] Removed Integer Value and changed some tests --- .../RosettaInterpreterIntegerValue.java | 120 +++--- .../values/RosettaInterpreterNumberValue.java | 5 + ...ttaInterpreterListOperatorInterpreter.java | 14 +- ...osettaArithmeticOperationsInterpreter.java | 86 ++--- ...terpreterRosettaIntLiteralInterpreter.java | 8 +- ...aInterpreterConditionalExpressionTest.java | 342 +++++++++--------- .../RosettaInterpreterLiteralsTest.java | 47 +-- ...nterpreterListOperatorInterpreterTest.java | 64 ++-- 8 files changed, 319 insertions(+), 367 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index bd9fd0dfc..c3edb3e43 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -1,60 +1,60 @@ -package com.regnosys.rosetta.interpreternew.values; - -import java.math.BigInteger; -import java.util.Objects; -import java.util.stream.Stream; - -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue - implements Comparable { - - private BigInteger value; - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; - return Objects.equals(value, other.value); - } - - public RosettaInterpreterIntegerValue(BigInteger value) { - super(); - this.value = value; - } - - public RosettaInterpreterIntegerValue(int value) { - super(); - this.value = BigInteger.valueOf(value); - } - - public BigInteger getValue() { return value; } - - @Override - public int compareTo(RosettaInterpreterIntegerValue o) { - return this.value.compareTo(o.value); - } - - @Override - public Stream toElementStream() { - return Stream.of(value); - } - - @Override - public Stream toValueStream() { - return Stream.of(this); - } -} +//package com.regnosys.rosetta.interpreternew.values; +// +//import java.math.BigInteger; +//import java.util.Objects; +//import java.util.stream.Stream; +// +//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +// +//public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue +// implements Comparable { +// +// private BigInteger value; +// +// @Override +// public int hashCode() { +// return Objects.hash(value); +// } +// +// @Override +// public boolean equals(Object obj) { +// if (this == obj) { +// return true; +// } +// if (obj == null) { +// return false; +// } +// if (getClass() != obj.getClass()) { +// return false; +// } +// RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; +// return Objects.equals(value, other.value); +// } +// +// public RosettaInterpreterIntegerValue(BigInteger value) { +// super(); +// this.value = value; +// } +// +// public RosettaInterpreterIntegerValue(int value) { +// super(); +// this.value = BigInteger.valueOf(value); +// } +// +// public BigInteger getValue() { return value; } +// +// @Override +// public int compareTo(RosettaInterpreterIntegerValue o) { +// return this.value.compareTo(o.value); +// } +// +// @Override +// public Stream toElementStream() { +// return Stream.of(value); +// } +// +// @Override +// public Stream toValueStream() { +// return Stream.of(this); +// } +//} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index ae21f68cb..9627fd2a6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -23,6 +23,11 @@ public RosettaInterpreterNumberValue(RosettaNumber value) { this.value = value; } + public RosettaInterpreterNumberValue(double value) { + super(); + this.value = RosettaNumber.valueOf(value); + } + public RosettaNumber getValue() { return value; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 2ee93d041..f5a1a9b39 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -1,7 +1,6 @@ package com.regnosys.rosetta.interpreternew.visitors; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -11,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; @@ -92,7 +90,7 @@ public RosettaInterpreterValue interp(RosettaAbsentExpression exp, RosettaInterp * Return the number of elements in a list * * @param exp Expression to perform 'count' on - * @return Integer indicating how many elements there are in the list + * @return Number indicating how many elements there are in the list */ public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = exp.getArgument(); @@ -103,7 +101,7 @@ public RosettaInterpreterValue interp(RosettaCountOperation exp, RosettaInterpre } long count = RosettaInterpreterBaseValue.valueStream(interpretedArgument).count(); - return new RosettaInterpreterIntegerValue(BigInteger.valueOf(count)); + return new RosettaInterpreterNumberValue(BigDecimal.valueOf(count)); } /** @@ -288,13 +286,7 @@ public RosettaInterpreterValue interp(SumOperation exp, RosettaInterpreterBaseEn // to numbers for further simplicity for (int i = 0; i < values.size(); i++) { RosettaInterpreterValue v = values.get(i); - if (v instanceof RosettaInterpreterIntegerValue) { - RosettaInterpreterIntegerValue valInt = - (RosettaInterpreterIntegerValue)v; - values.set(i, new RosettaInterpreterNumberValue( - BigDecimal.valueOf(valInt.getValue().longValue()))); - } - else if (!(v instanceof RosettaInterpreterNumberValue)) { + if (!(v instanceof RosettaInterpreterNumberValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("Cannot take sum" + "of non-number value")); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index ffc17b61a..8082c6a4f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -34,21 +34,15 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr) { */ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterBaseEnvironment env) { - - String leftString = null; - String rightString = null; - RosettaExpression left = expr.getLeft(); RosettaExpression right = expr.getRight(); RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); if (!(leftInterpreted instanceof RosettaInterpreterNumberValue - || leftInterpreted instanceof RosettaInterpreterStringValue - || leftInterpreted instanceof RosettaInterpreterIntegerValue) + || leftInterpreted instanceof RosettaInterpreterStringValue) || !(rightInterpreted instanceof RosettaInterpreterNumberValue - || rightInterpreted instanceof RosettaInterpreterStringValue - || rightInterpreted instanceof RosettaInterpreterIntegerValue)) { + || rightInterpreted instanceof RosettaInterpreterStringValue)) { // Check for errors in the left or right side of the binary operation RosettaInterpreterErrorValue leftErrors = @@ -56,24 +50,13 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterErrorValue rightErrors = checkForErrors(rightInterpreted, "Rightside"); return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); - } + } - boolean sameType = - (leftInterpreted instanceof RosettaInterpreterStringValue - && rightInterpreted instanceof RosettaInterpreterStringValue) - || (!(leftInterpreted instanceof RosettaInterpreterStringValue) - && !(rightInterpreted instanceof RosettaInterpreterStringValue)); - if (!sameType) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "The terms of the operation " - + "are neither both strings nor both numbers")); - } - - if (leftInterpreted instanceof RosettaInterpreterStringValue) { - leftString = ((RosettaInterpreterStringValue) leftInterpreted) + if (leftInterpreted instanceof RosettaInterpreterStringValue + && rightInterpreted instanceof RosettaInterpreterStringValue) { + String leftString = ((RosettaInterpreterStringValue) leftInterpreted) .getValue(); - rightString = ((RosettaInterpreterStringValue) rightInterpreted) + String rightString = ((RosettaInterpreterStringValue) rightInterpreted) .getValue(); if (expr.getOperator().equals("+")) { return new RosettaInterpreterStringValue(leftString + rightString); @@ -84,39 +67,29 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, "The terms are strings but the operation " + "is not concatenation: not implemented")); } - } - - RosettaNumber leftNumber; - RosettaNumber rightNumber; + } else if (leftInterpreted instanceof RosettaInterpreterNumberValue + && rightInterpreted instanceof RosettaInterpreterNumberValue) { + RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); + RosettaNumber rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); - if (leftInterpreted instanceof RosettaInterpreterNumberValue) { - leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); - } - else { - leftNumber = RosettaNumber - .valueOf(((RosettaInterpreterIntegerValue) leftInterpreted) - .getValue()); - } - if (rightInterpreted instanceof RosettaInterpreterNumberValue) { - rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); - } else { - rightNumber = RosettaNumber - .valueOf(((RosettaInterpreterIntegerValue) rightInterpreted) - .getValue()); - } - if (expr.getOperator().equals("+")) { - return new RosettaInterpreterNumberValue((leftNumber - .add(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("-")) { - return new RosettaInterpreterNumberValue((leftNumber - .subtract(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("*")) { - return new RosettaInterpreterNumberValue((leftNumber - .multiply(rightNumber)).bigDecimalValue()); + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterNumberValue((leftNumber + .add(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("-")) { + return new RosettaInterpreterNumberValue((leftNumber + .subtract(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("*")) { + return new RosettaInterpreterNumberValue((leftNumber + .multiply(rightNumber)).bigDecimalValue()); + } else { + return new RosettaInterpreterNumberValue((leftNumber + .divide(rightNumber)).bigDecimalValue()); + } } else { - return new RosettaInterpreterNumberValue((leftNumber - .divide(rightNumber)).bigDecimalValue()); - } + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "The terms of the operation are neither both strings nor both numbers")); + } } @@ -134,8 +107,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, private RosettaInterpreterErrorValue checkForErrors( RosettaInterpreterValue interpretedValue, String side) { if (interpretedValue instanceof RosettaInterpreterNumberValue - || interpretedValue instanceof RosettaInterpreterStringValue - || interpretedValue instanceof RosettaInterpreterIntegerValue) { + || interpretedValue instanceof RosettaInterpreterStringValue) { // If the value satisfies the type conditions, we return an empty // error value so that the merger has two error values to merge return new RosettaInterpreterErrorValue(); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java index 2ecf6cdfa..720e504a1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaIntLiteralInterpreter.java @@ -1,8 +1,10 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.math.BigDecimal; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; public class RosettaInterpreterRosettaIntLiteralInterpreter @@ -12,8 +14,8 @@ public RosettaInterpreterBaseValue interp(RosettaIntLiteral expr) { return interp(expr, new RosettaInterpreterEnvironment()); } - public RosettaInterpreterIntegerValue interp(RosettaIntLiteral expr, + public RosettaInterpreterNumberValue interp(RosettaIntLiteral expr, RosettaInterpreterEnvironment env) { - return new RosettaInterpreterIntegerValue(expr.getValue()); + return new RosettaInterpreterNumberValue(new BigDecimal(expr.getValue())); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index c3db7c203..7bc458344 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -2,8 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.math.BigDecimal; -import java.math.BigInteger; import java.util.List; import javax.inject.Inject; @@ -16,7 +14,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; @@ -24,7 +21,6 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; -import com.rosetta.model.lib.RosettaNumber; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -36,189 +32,175 @@ public class RosettaInterpreterConditionalExpressionTest { @Inject RosettaInterpreterNew interpreter; - @Test - public void integerTest() { - RosettaExpression expr = parser.parseExpression("if True then 1"); - RosettaInterpreterValue result = interpreter.interp(expr); - - BigInteger number = BigInteger.valueOf(1); - - assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); - } - - @Test - public void integerElseTest() { - RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); - RosettaInterpreterValue result = interpreter.interp(expr); - - BigInteger number = BigInteger.valueOf(2); - - assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); - } - - @Test - public void integerThenTest() { - RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); - RosettaInterpreterValue result = interpreter.interp(expr); - - BigInteger number = BigInteger.valueOf(1); - - assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); - } - - @Test - public void booleanTest() { - RosettaExpression expr = parser.parseExpression("if True then False"); - RosettaInterpreterValue result = interpreter.interp(expr); - - assertEquals(false, ((RosettaInterpreterBooleanValue) result).getValue()); - } - - @Test - public void stringTest() { - RosettaExpression expr = parser.parseExpression("if True then \"abc\""); - RosettaInterpreterValue result = interpreter.interp(expr); - - assertEquals("abc", ((RosettaInterpreterStringValue) result).getValue()); - } - - @Test - public void numberTest() { - RosettaExpression expr = parser.parseExpression("if True then 1.2"); - RosettaInterpreterValue result = interpreter.interp(expr); - - RosettaNumber number = RosettaNumber.valueOf(BigDecimal.valueOf(1.2)); - - assertEquals(number, ((RosettaInterpreterNumberValue) result).getValue()); - } - - @Test - public void listTest() { - RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); - RosettaInterpreterValue result = interpreter.interp(expr); - - RosettaInterpreterIntegerValue one = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(1)); - RosettaInterpreterIntegerValue two = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(2)); - - List list = List.of(one, two); - - assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); - } +// @Test +// public void integerTest() { +// RosettaExpression expr = parser.parseExpression("if True then 1"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(new RosettaInterpreterNumberValue(1), result); +// } +// +// @Test +// public void integerElseTest() { +// RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(new RosettaInterpreterNumberValue(2), result); +// } +// +// @Test +// public void integerThenTest() { +// RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(new RosettaInterpreterNumberValue(1), result); +// } +// +// @Test +// public void booleanTest() { +// RosettaExpression expr = parser.parseExpression("if True then False"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(false, ((RosettaInterpreterBooleanValue) result).getValue()); +// } +// +// @Test +// public void stringTest() { +// RosettaExpression expr = parser.parseExpression("if True then \"abc\""); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals("abc", ((RosettaInterpreterStringValue) result).getValue()); +// } +// +// @Test +// public void numberTest() { +// RosettaExpression expr = parser.parseExpression("if True then 1.2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(new RosettaInterpreterNumberValue(1.2), result); +// } +// +// @Test +// public void listTest() { +// RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// List list = List.of(new RosettaInterpreterNumberValue(1), +// new RosettaInterpreterNumberValue(2)); +// +// assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); +// } @Test public void complexTest() { RosettaExpression expr = parser.parseExpression("if 3 > 2 then 1 else 2"); RosettaInterpreterValue result = interpreter.interp(expr); - BigInteger number = BigInteger.valueOf(1); - - assertEquals(number, ((RosettaInterpreterIntegerValue) result).getValue()); + assertEquals(new RosettaInterpreterNumberValue(1), result); } - @Test - public void errorThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Conditional expression: then is an error value.")); - expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); - - RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void errorElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Conditional expression: else is an error value.")); - expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); - - RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void notSameTypeThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); - - RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void notSameTypeElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); - - RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void conditionNotBooleanTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "condition is not a boolean value.")); - - RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void conditionErrorTypeTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "condition is an error value.")); - expected.addError(new RosettaInterpreterError( - "cannot use \"ALL\" keyword " + "to compare two elements")); - - RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void noElseTest() { - RosettaExpression expr = parser.parseExpression("if False then 1.2"); - RosettaInterpreterValue result = interpreter.interp(expr); - - assertEquals(null, result); - } +// @Test +// public void errorThenTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError( +// "Conditional expression: then is an error value.")); +// expected.addError(new RosettaInterpreterError( +// "cannot use \"ALL\" keyword " + "to compare two elements")); +// +// RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void errorElseTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError( +// "Conditional expression: else is an error value.")); +// expected.addError(new RosettaInterpreterError( +// "cannot use \"ALL\" keyword " + "to compare two elements")); +// +// RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void notSameTypeThenTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError("Conditional expression: " +// + "then and else need to have the same type.")); +// +// RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void notSameTypeElseTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError("Conditional expression: " +// + "then and else need to have the same type.")); +// +// RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void conditionNotBooleanTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError("Conditional expression: " +// + "condition is not a boolean value.")); +// +// RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void conditionErrorTypeTest() { +// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( +// new RosettaInterpreterError("Conditional expression: " +// + "condition is an error value.")); +// expected.addError(new RosettaInterpreterError( +// "cannot use \"ALL\" keyword " + "to compare two elements")); +// +// RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; +// +// assertEquals(expected.getErrors(), errorResult.getErrors()); +// assertEquals(expected.getErrors().get(0).getMessage(), +// errorResult.getErrors().get(0).getMessage()); +// } +// +// @Test +// public void noElseTest() { +// RosettaExpression expr = parser.parseExpression("if False then 1.2"); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(null, result); +// } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 9684e7afd..60b80b8eb 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -60,10 +60,10 @@ public void listTest() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(2)))); + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(2)))); assertEquals(expected, val); } @@ -75,12 +75,12 @@ public void nestedListTest() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(2)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(3)))); + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(2)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(3)))); assertEquals(expected, val); } @@ -92,16 +92,16 @@ public void veryNestedListTest() { RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(1)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(2)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(3)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(4)), - new RosettaInterpreterIntegerValue( - BigInteger.valueOf(5)))); + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(2)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(3)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(4)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(5)))); assertEquals(expected, val); } @@ -110,15 +110,16 @@ public void veryNestedListTest() { public void intTest() { RosettaExpression expr = parser.parseExpression("5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(BigInteger.valueOf(5), - ((RosettaInterpreterIntegerValue)val).getValue()); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5)), + ((RosettaInterpreterNumberValue)val).getValue()); } @Test public void numberTest() { RosettaExpression expr = parser.parseExpression("5.5"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), ((RosettaInterpreterNumberValue)val).getValue()); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(5.5)), + ((RosettaInterpreterNumberValue)val).getValue()); } @Test diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java index c0eaf27e2..0ce2ffd4d 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreterTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.*; -import java.math.BigInteger; import java.math.BigDecimal; import java.util.List; @@ -18,7 +17,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; @@ -198,23 +196,23 @@ void testIsAbsentError() { @Test void testCountEmptyList() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(0)); + RosettaInterpreterNumberValue expected = + new RosettaInterpreterNumberValue(0); RosettaExpression expr = parser.parseExpression("[] count"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertTrue(val instanceof RosettaInterpreterNumberValue); + RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; assertEquals(expected, castedVal); } @Test void testCount() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaInterpreterNumberValue expected = + new RosettaInterpreterNumberValue(3); RosettaExpression expr = parser.parseExpression("[1, 2, 3] count"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertTrue(val instanceof RosettaInterpreterNumberValue); + RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; assertEquals(expected, castedVal); } @@ -245,12 +243,12 @@ void testFirstEmptyList() { @Test void testFirst() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(3)); + RosettaInterpreterNumberValue expected = + new RosettaInterpreterNumberValue(3); RosettaExpression expr = parser.parseExpression("[3, 4, 5] first"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertTrue(val instanceof RosettaInterpreterNumberValue); + RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; assertEquals(expected, castedVal); } @@ -281,12 +279,12 @@ void testLastEmptyList() { @Test void testLast() { - RosettaInterpreterIntegerValue expected = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaInterpreterNumberValue expected = + new RosettaInterpreterNumberValue(5); RosettaExpression expr = parser.parseExpression("[3, 4, 5] last"); RosettaInterpreterValue val = interpreter.interp(expr); - assertTrue(val instanceof RosettaInterpreterIntegerValue); - RosettaInterpreterIntegerValue castedVal = (RosettaInterpreterIntegerValue)val; + assertTrue(val instanceof RosettaInterpreterNumberValue); + RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; assertEquals(expected, castedVal); } @@ -310,8 +308,8 @@ void testInterpDistinctOperationUseless() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(1), - new RosettaInterpreterIntegerValue(2))); + List.of(new RosettaInterpreterNumberValue(1), + new RosettaInterpreterNumberValue(2))); assertEquals(exp, val); } @@ -323,8 +321,8 @@ void testInterpDistinctOperationSimple() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(1), - new RosettaInterpreterIntegerValue(2))); + List.of(new RosettaInterpreterNumberValue(1), + new RosettaInterpreterNumberValue(2))); assertEquals(exp, val); } @@ -336,7 +334,7 @@ void testInterpDistinctOperationMany() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(2))); + List.of(new RosettaInterpreterNumberValue(2))); assertEquals(exp, val); } @@ -360,7 +358,7 @@ void testInterpDistinctOperationNonList() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(1))); + List.of(new RosettaInterpreterNumberValue(1))); assertEquals(exp, val); } @@ -382,8 +380,8 @@ void testInterpReverseOperationSimple() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(2), - new RosettaInterpreterIntegerValue(1))); + List.of(new RosettaInterpreterNumberValue(2), + new RosettaInterpreterNumberValue(1))); assertEquals(exp, val); } @@ -395,7 +393,7 @@ void testInterpReverseOperationSingle() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(1))); + List.of(new RosettaInterpreterNumberValue(1))); assertEquals(exp, val); } @@ -419,12 +417,12 @@ void testInterpReverseOperationBig() { validation.assertNoIssues(expr); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterListValue exp = new RosettaInterpreterListValue( - List.of(new RosettaInterpreterIntegerValue(6), - new RosettaInterpreterIntegerValue(5), - new RosettaInterpreterIntegerValue(4), - new RosettaInterpreterIntegerValue(3), - new RosettaInterpreterIntegerValue(2), - new RosettaInterpreterIntegerValue(1))); + List.of(new RosettaInterpreterNumberValue(6), + new RosettaInterpreterNumberValue(5), + new RosettaInterpreterNumberValue(4), + new RosettaInterpreterNumberValue(3), + new RosettaInterpreterNumberValue(2), + new RosettaInterpreterNumberValue(1))); assertEquals(exp, val); } From f9c38a03687f8e797f86136811121685d1e7914e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 5 Jun 2024 15:42:42 +0300 Subject: [PATCH 141/236] Added implementation for feature calls and fixed constructor tests --- rosetta-lang/model/RosettaExpression.xcore | 4 + rosetta-lang/model/RosettaInterpreter.xcore | 4 +- .../RosettaInterpreterVisitor.java | 7 ++ .../values/RosettaInterpreterDateValue.java | 15 ++-- .../values/RosettaInterpreterTimeValue.java | 45 +++++++++-- .../RosettaInterpreterZonedDateTimeValue.java | 7 +- ...settaConstructorExpressionInterpreter.java | 9 ++- ...erpreterRosettaFeatureCallInterpreter.java | 48 +++++++++++ ...aInterpreterConstructorExpressionTest.java | 81 ++++++++++++------- .../RosettaInterpreterFeatureCallTest.java | 44 ++++++++++ 10 files changed, 213 insertions(+), 51 deletions(-) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 2bfccb876..d9a4aa43a 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -188,6 +188,10 @@ class RosettaImplicitVariable extends RosettaReference, RosettaNamed { class RosettaFeatureCall extends RosettaExpression { contains RosettaExpression receiver refers RosettaFeature feature + + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaConditionalExpression extends RosettaExpression { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 3f2ea5bdb..30294f59d 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -5,8 +5,6 @@ package com.regnosys.rosetta.rosetta.interpreter -import com.regnosys.rosetta.rosetta.RosettaRecordType - import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral @@ -34,6 +32,7 @@ import com.regnosys.rosetta.rosetta.expression.LastOperation import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall class RosettaInterpreterBaseError{ String message @@ -98,6 +97,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 32617a49d..7021aa186 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -18,6 +18,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; @@ -40,6 +41,7 @@ import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaBooleanLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConditionalExpressionInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaConstructorExpressionInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaFeatureCallInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaIntLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaNumberLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaStringLiteralInterpreter; @@ -317,4 +319,9 @@ public RosettaInterpreterValue interp(SumOperation exp, public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaConstructorExpressionInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java index b49500dc2..9ef110011 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java @@ -6,25 +6,26 @@ public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { - private Integer day; - private Integer month; - private Integer year; + private RosettaInterpreterIntegerValue day; + private RosettaInterpreterIntegerValue month; + private RosettaInterpreterIntegerValue year; - public RosettaInterpreterDateValue(Integer day, Integer month, Integer year) { + public RosettaInterpreterDateValue(RosettaInterpreterIntegerValue day, + RosettaInterpreterIntegerValue month, RosettaInterpreterIntegerValue year) { this.day = day; this.month = month; this.year = year; } - public Integer getDay() { + public RosettaInterpreterIntegerValue getDay() { return day; } - public Integer getMonth() { + public RosettaInterpreterIntegerValue getMonth() { return month; } - public Integer getYear() { + public RosettaInterpreterIntegerValue getYear() { return year; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java index d518c4d40..339e74151 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -7,19 +7,52 @@ public class RosettaInterpreterTimeValue extends RosettaInterpreterBaseValue { - private LocalTime time; + private RosettaInterpreterNumberValue hours; + private RosettaInterpreterNumberValue minutes; + private RosettaInterpreterNumberValue seconds; - public RosettaInterpreterTimeValue(LocalTime time) { - this.time = time; + + public RosettaInterpreterTimeValue(RosettaInterpreterNumberValue hours, + RosettaInterpreterNumberValue minutes, RosettaInterpreterNumberValue seconds) { + this.hours = hours; + this.minutes = minutes; + this.seconds = seconds; } - public LocalTime getTime() { - return time; + + public RosettaInterpreterNumberValue getHours() { + return hours; + } + + + public RosettaInterpreterNumberValue getMinutes() { + return minutes; + } + + + public RosettaInterpreterNumberValue getSeconds() { + return seconds; + } + + + public void setHours(RosettaInterpreterNumberValue hours) { + this.hours = hours; + } + + + public void setMinutes(RosettaInterpreterNumberValue minutes) { + this.minutes = minutes; } + + public void setSeconds(RosettaInterpreterNumberValue seconds) { + this.seconds = seconds; + } + + @Override public Stream toElementStream() { - return Stream.of(time); + return Stream.of(hours, minutes, seconds); } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java index d2ca92e81..2826eaa18 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java @@ -8,9 +8,10 @@ public class RosettaInterpreterZonedDateTimeValue extends RosettaInterpreterBase private RosettaInterpreterDateValue date; private RosettaInterpreterTimeValue time; - private String timeZone; + private RosettaInterpreterStringValue timeZone; - public RosettaInterpreterZonedDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time, String timeZone) { + public RosettaInterpreterZonedDateTimeValue(RosettaInterpreterDateValue date, + RosettaInterpreterTimeValue time, RosettaInterpreterStringValue timeZone) { this.date = date; this.time = time; this.timeZone = timeZone; @@ -24,7 +25,7 @@ public RosettaInterpreterTimeValue getTime() { return time; } - public String getTimeZone() { + public RosettaInterpreterStringValue getTimeZone() { return timeZone; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index fc8eeb882..01ae914c1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -6,6 +6,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; @@ -33,9 +34,9 @@ public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends R && month instanceof RosettaInterpreterIntegerValue && year instanceof RosettaInterpreterIntegerValue) { return new RosettaInterpreterDateValue( - ((RosettaInterpreterIntegerValue) day).getValue().intValue(), - ((RosettaInterpreterIntegerValue) month).getValue().intValue(), - ((RosettaInterpreterIntegerValue) year).getValue().intValue()); + ((RosettaInterpreterIntegerValue) day), + ((RosettaInterpreterIntegerValue) month), + ((RosettaInterpreterIntegerValue) year)); } break; } @@ -62,7 +63,7 @@ public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends R return new RosettaInterpreterZonedDateTimeValue( ((RosettaInterpreterDateValue) date), ((RosettaInterpreterTimeValue) time), - ((RosettaInterpreterStringValue) timeZone).getValue()); + ((RosettaInterpreterStringValue) timeZone)); } break; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java new file mode 100644 index 000000000..aaeb0135a --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -0,0 +1,48 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { + RosettaExpression receiver = exp.getReceiver(); + RosettaInterpreterValue receiverValue = receiver.accept(visitor); + + String feature = exp.getFeature().getGetNameOrDefault(); + + if (receiverValue instanceof RosettaInterpreterDateValue) { + switch (feature) { + case "day": return ((RosettaInterpreterDateValue) receiverValue).getDay(); + case "month": return ((RosettaInterpreterDateValue) receiverValue).getMonth(); + case "year": return ((RosettaInterpreterDateValue) receiverValue).getYear(); + default: //error + } + + } else if (receiverValue instanceof RosettaInterpreterDateTimeValue) { + switch (feature) { + case "date": return ((RosettaInterpreterDateTimeValue) receiverValue).getDate(); + case "time": return ((RosettaInterpreterDateTimeValue) receiverValue).getTime(); + default: //error + } + + } else if (receiverValue instanceof RosettaInterpreterZonedDateTimeValue) { + switch (feature) { + case "date": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getDate(); + case "time": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTime(); + case "timeZone": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); + default: //error + } + + } else { + // add implementation for data types and error handling + } + return null; + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 702c1b6de..b8eb81468 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -2,7 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.time.LocalTime; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.List; import javax.inject.Inject; @@ -13,10 +15,15 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; @@ -35,51 +42,67 @@ public class RosettaInterpreterConstructorExpressionTest { @Inject ModelHelper mh; - @Test - public void test() { - RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" - + "{\r\n" - + " day int\r\n" - + " month int\r\n" - + " year int }"); - System.out.println(expr.getElements().get(0).getModel()); - } + RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); + RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + + +// @Test +// public void test() { +// RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" +// + "{\r\n" +// + " day int\r\n" +// + " month int\r\n" +// + " year int }"); +// System.out.println(expr.getElements().get(0).getModel()); +// } @Test public void testDate() { - RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2000 }"); + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 }"); RosettaInterpreterValue result = interpreter.interp(expr); - assertEquals(5, ((RosettaInterpreterDateValue) result).getDay()); - assertEquals(7, ((RosettaInterpreterDateValue) result).getMonth()); - assertEquals(2000, ((RosettaInterpreterDateValue) result).getYear()); + assertEquals(day, ((RosettaInterpreterDateValue) result).getDay()); + assertEquals(month, ((RosettaInterpreterDateValue) result).getMonth()); + assertEquals(year, ((RosettaInterpreterDateValue) result).getYear()); } @Test public void testDateTime() { - RosettaExpression expr = parser.parseExpression( - "dateTime { date: date { day: 5, month: 7, year: 2022 }, time: \"05:00:00\" }"); - RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); - RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(5, 7, 2022); - RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(LocalTime.now()); + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 5, month: 7, year: 2024 }, time: t }", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); - assertEquals(date, ((RosettaInterpreterDateTimeValue) result).getDate()); + assertEquals(day, ((RosettaInterpreterDateTimeValue) result).getDate().getDay()); + assertEquals(month, ((RosettaInterpreterDateTimeValue) result).getDate().getMonth()); + assertEquals(year, ((RosettaInterpreterDateTimeValue) result).getDate().getYear()); assertEquals(time, ((RosettaInterpreterDateTimeValue) result).getTime()); } @Test public void testZonedDateTime() { - RosettaExpression expr = parser.parseExpression( - "zonedDateTime { date: date { day: 5, month: 7, year: 2022 }" - + ", time: \"05:00:00\", timezone: \"CET\" }"); - RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); - RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(5, 7, 2022); - RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(LocalTime.now()); + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" }", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); - assertEquals(date, ((RosettaInterpreterDateTimeValue) result).getDate()); - assertEquals(time, ((RosettaInterpreterDateTimeValue) result).getTime()); - assertEquals("CET", ((RosettaInterpreterStringValue) result).getValue()); + assertEquals(day, ((RosettaInterpreterZonedDateTimeValue) result).getDate().getDay()); + assertEquals(month, ((RosettaInterpreterZonedDateTimeValue) result).getDate().getMonth()); + assertEquals(year, ((RosettaInterpreterZonedDateTimeValue) result).getDate().getYear()); + assertEquals(time, ((RosettaInterpreterZonedDateTimeValue) result).getTime()); + assertEquals("CET", ((RosettaInterpreterZonedDateTimeValue) result).getTimeZone().getValue()); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java new file mode 100644 index 000000000..881e7d924 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -0,0 +1,44 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterFeatureCallTest { + + @Inject + private ExpressionParser parser; + + @Inject + RosettaInterpreterNew interpreter; + + @Inject + ModelHelper mh; + + @Test + public void testDate() { + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2000 } -> day"); + + System.out.println(((RosettaFeatureCallImpl) expr).getFeature().getGetNameOrDefault()); +// RosettaInterpreterValue result = interpreter.interp(expr); +// +// assertEquals(5, ((RosettaInterpreterDateValue) result).getDay()); +// assertEquals(7, ((RosettaInterpreterDateValue) result).getMonth()); +// assertEquals(2000, ((RosettaInterpreterDateValue) result).getYear()); + } +} From f21805a8416e10934dee5a785de061eb6cb6ace6 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Wed, 5 Jun 2024 14:51:24 +0200 Subject: [PATCH 142/236] Fixed tests --- ...ettaInterpreterComparisonOperationInterpreter.java | 2 -- ...rpreterRosettaArithmeticOperationsInterpreter.java | 1 - .../RosettaInterpreterLiteralsTest.java | 1 - .../RosettaInterpreterVariableTest.java | 11 +++++------ 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 477e3f8db..55402a9cf 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -26,8 +26,6 @@ public class RosettaInterpreterComparisonOperationInterpreter extends "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterBooleanValue", "com.regnosys.rosetta.interpreternew.values." - + "RosettaInterpreterIntegerValue", - "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterNumberValue", "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterStringValue"); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 8082c6a4f..9776f6c1d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -5,7 +5,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 60b80b8eb..4e14daa12 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -15,7 +15,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java index 951553836..9d92d73b5 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -20,7 +19,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; @@ -52,8 +51,8 @@ public void setup() { public void variableGoodComparisonTest() { //create the environment and add variable 'a' to it RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaInterpreterIntegerValue intValue = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaInterpreterNumberValue intValue = + new RosettaInterpreterNumberValue(5); env.addValue("a", intValue); //give the same environment to the parser @@ -69,8 +68,8 @@ public void variableGoodComparisonTest() { public void variableLeftErrorComparisonTest() { //create the environment and add variable 'a' to it RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaInterpreterIntegerValue intValue = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaInterpreterNumberValue intValue = + new RosettaInterpreterNumberValue(5); env.addValue("a", intValue); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( From 5dd0d2527b195048de7ce652015c3e8ec3056fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 6 Jun 2024 03:31:43 +0300 Subject: [PATCH 143/236] Added tests for feature calls and fixed some checkstyle --- .../RosettaInterpreterDateTimeValue.java | 6 + .../values/RosettaInterpreterDateValue.java | 41 ++++++- .../values/RosettaInterpreterTimeValue.java | 15 ++- .../RosettaInterpreterZonedDateTimeValue.java | 14 ++- ...erpreterRosettaFeatureCallInterpreter.java | 4 +- ...aInterpreterConstructorExpressionTest.java | 18 --- .../RosettaInterpreterFeatureCallTest.java | 114 ++++++++++++++++-- 7 files changed, 173 insertions(+), 39 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java index 13d3b0d73..5e8717b65 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java @@ -9,6 +9,12 @@ public class RosettaInterpreterDateTimeValue extends RosettaInterpreterBaseValue private RosettaInterpreterDateValue date; private RosettaInterpreterTimeValue time; + /** + * Constructor for dateTime value. + * + * @param date date value + * @param time time value + */ public RosettaInterpreterDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time) { this.date = date; this.time = time; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java index 9ef110011..a1f8a6bf3 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; import java.util.stream.Stream; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -9,9 +10,17 @@ public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { private RosettaInterpreterIntegerValue day; private RosettaInterpreterIntegerValue month; private RosettaInterpreterIntegerValue year; - - public RosettaInterpreterDateValue(RosettaInterpreterIntegerValue day, - RosettaInterpreterIntegerValue month, RosettaInterpreterIntegerValue year) { + + /** + * Constructor for date value. + * + * @param day day value + * @param month month value + * @param year year value + */ + public RosettaInterpreterDateValue(RosettaInterpreterIntegerValue day, RosettaInterpreterIntegerValue month, + RosettaInterpreterIntegerValue year) { + super(); this.day = day; this.month = month; this.year = year; @@ -30,6 +39,27 @@ public RosettaInterpreterIntegerValue getYear() { } + @Override + public int hashCode() { + return Objects.hash(day, month, year); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterDateValue other = (RosettaInterpreterDateValue) obj; + return Objects.equals(day, other.day) && Objects.equals(month, other.month) + && Objects.equals(year, other.year); + } + @Override public Stream toElementStream() { return Stream.of(day, month, year); @@ -39,4 +69,9 @@ public Stream toElementStream() { public Stream toValueStream() { return Stream.of(this); } + + @Override + public String toString() { + return "RosettaInterpreterDateValue [day=" + day + ", month=" + month + ", year=" + year + "]"; + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java index 339e74151..503df0ee6 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -1,6 +1,5 @@ package com.regnosys.rosetta.interpreternew.values; -import java.time.LocalTime; import java.util.stream.Stream; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -11,14 +10,20 @@ public class RosettaInterpreterTimeValue extends RosettaInterpreterBaseValue { private RosettaInterpreterNumberValue minutes; private RosettaInterpreterNumberValue seconds; - - public RosettaInterpreterTimeValue(RosettaInterpreterNumberValue hours, - RosettaInterpreterNumberValue minutes, RosettaInterpreterNumberValue seconds) { + /** + * Constructor for time value. + * + * @param hours hour value + * @param minutes minute value + * @param seconds second value + */ + public RosettaInterpreterTimeValue(RosettaInterpreterNumberValue hours, RosettaInterpreterNumberValue minutes, + RosettaInterpreterNumberValue seconds) { + super(); this.hours = hours; this.minutes = minutes; this.seconds = seconds; } - public RosettaInterpreterNumberValue getHours() { return hours; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java index 2826eaa18..600562e87 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java @@ -10,13 +10,21 @@ public class RosettaInterpreterZonedDateTimeValue extends RosettaInterpreterBase private RosettaInterpreterTimeValue time; private RosettaInterpreterStringValue timeZone; - public RosettaInterpreterZonedDateTimeValue(RosettaInterpreterDateValue date, - RosettaInterpreterTimeValue time, RosettaInterpreterStringValue timeZone) { + /** + * Constructor method for zonedDateTime value. + * + * @param date date value + * @param time time value + * @param timeZone timezone value + */ + public RosettaInterpreterZonedDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time, + RosettaInterpreterStringValue timeZone) { + super(); this.date = date; this.time = time; this.timeZone = timeZone; } - + public RosettaInterpreterDateValue getDate() { return date; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index aaeb0135a..0747c4acf 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -13,7 +13,7 @@ public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInte public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression receiver = exp.getReceiver(); - RosettaInterpreterValue receiverValue = receiver.accept(visitor); + RosettaInterpreterValue receiverValue = receiver.accept(visitor, env); String feature = exp.getFeature().getGetNameOrDefault(); @@ -36,7 +36,7 @@ public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpr switch (feature) { case "date": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getDate(); case "time": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTime(); - case "timeZone": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); + case "timezone": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); default: //error } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index b8eb81468..ecd3ea435 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -18,16 +18,12 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; -import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; -import com.regnosys.rosetta.tests.util.ModelHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -39,9 +35,6 @@ public class RosettaInterpreterConstructorExpressionTest { @Inject RosettaInterpreterNew interpreter; - @Inject - ModelHelper mh; - RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); @@ -52,17 +45,6 @@ public class RosettaInterpreterConstructorExpressionTest { RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); - -// @Test -// public void test() { -// RosettaModel expr = mh.parseRosettaWithNoErrors("recordType date\r\n" -// + "{\r\n" -// + " day int\r\n" -// + " month int\r\n" -// + " year int }"); -// System.out.println(expr.getElements().get(0).getModel()); -// } - @Test public void testDate() { RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 }"); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 881e7d924..69f9f2a4f 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -2,6 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.List; + import javax.inject.Inject; import org.eclipse.xtext.testing.InjectWith; @@ -9,7 +13,14 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -30,15 +41,102 @@ public class RosettaInterpreterFeatureCallTest { @Inject ModelHelper mh; + RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); + RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); + RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + + @Test + public void testDateDay() { + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 } -> day"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(day, result); + } + + @Test + public void testDateMonth() { + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 } -> month"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(month, result); + } + + @Test + public void testDateYear() { + RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 } -> year"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(year, result); + } + + @Test + public void testDateTimeTime() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 5, month: 7, year: 2024 }, time: t } -> time", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(time, result); + } + + @Test + public void testDateTimeDay() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 5, month: 7, year: 2024 }, time: t } -> date -> day", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(day, result); + } + + @Test + public void testZonedDateTimeTimeZone() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" } -> timezone", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals("CET", ((RosettaInterpreterStringValue) result).getValue()); + } + @Test - public void testDate() { - RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2000 } -> day"); + public void testZonedDateTimeDate() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" } -> date -> year", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(year, result); + } + + @Test + public void testZonedDateTimeTime() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" } -> time", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); - System.out.println(((RosettaFeatureCallImpl) expr).getFeature().getGetNameOrDefault()); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(5, ((RosettaInterpreterDateValue) result).getDay()); -// assertEquals(7, ((RosettaInterpreterDateValue) result).getMonth()); -// assertEquals(2000, ((RosettaInterpreterDateValue) result).getYear()); + assertEquals(time, result); } } From cfff180cd6854644aa2d8e853a32848a2bd8fb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 6 Jun 2024 03:35:22 +0300 Subject: [PATCH 144/236] Fixed more checkstyle issues --- ...terRosettaConstructorExpressionInterpreter.java | 14 +++++++++----- ...taInterpreterRosettaFeatureCallInterpreter.java | 7 +++++++ .../RosettaInterpreterFeatureCallTest.java | 7 ------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 01ae914c1..132fbf42d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -6,21 +6,25 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; -import com.regnosys.rosetta.rosetta.RosettaFeature; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; -import com.regnosys.rosetta.rosetta.TypeCall; import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { - public RosettaInterpreterBaseValue interp - (RosettaConstructorExpression expr, RosettaInterpreterBaseEnvironment env) { + /** + * Interpreter method for Constructor Expressions. + * + * @param expr RosettaConstructorExpression to be interpreted + * @param env the environment used + * @return the interpreted value + */ + public RosettaInterpreterBaseValue interp( + RosettaConstructorExpression expr, RosettaInterpreterBaseEnvironment env) { String typeCall = expr.getTypeCall().getType().getName(); EList values = expr.getValues(); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index 0747c4acf..f4deb7344 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -11,6 +11,13 @@ public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInterpreterConcreteInterpreter { + /** + * Interpreter method for Feature Calls. + * + * @param exp RosettaFeatureCall to be interpreted + * @param env the environment used + * @return the interpreted value + */ public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression receiver = exp.getReceiver(); RosettaInterpreterValue receiverValue = receiver.accept(visitor, env); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 69f9f2a4f..a44acfbb6 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -13,20 +13,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; -import com.regnosys.rosetta.tests.util.ModelHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -38,9 +34,6 @@ public class RosettaInterpreterFeatureCallTest { @Inject RosettaInterpreterNew interpreter; - @Inject - ModelHelper mh; - RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); From 8a2baa80b78abcd5c2b6bb224025f0a87737760f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 6 Jun 2024 03:51:08 +0300 Subject: [PATCH 145/236] Changed implementation of feature calls --- ...erpreterRosettaFeatureCallInterpreter.java | 30 ++++++++++--------- .../RosettaInterpreterFeatureCallTest.java | 18 +++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index f4deb7344..c2c2c369f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -25,26 +25,28 @@ public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpr String feature = exp.getFeature().getGetNameOrDefault(); if (receiverValue instanceof RosettaInterpreterDateValue) { - switch (feature) { - case "day": return ((RosettaInterpreterDateValue) receiverValue).getDay(); - case "month": return ((RosettaInterpreterDateValue) receiverValue).getMonth(); - case "year": return ((RosettaInterpreterDateValue) receiverValue).getYear(); - default: //error + if (feature.equals("day")) { + return ((RosettaInterpreterDateValue) receiverValue).getDay(); + } else if (feature.equals("month")) { + return ((RosettaInterpreterDateValue) receiverValue).getMonth(); + } else { + return ((RosettaInterpreterDateValue) receiverValue).getYear(); } } else if (receiverValue instanceof RosettaInterpreterDateTimeValue) { - switch (feature) { - case "date": return ((RosettaInterpreterDateTimeValue) receiverValue).getDate(); - case "time": return ((RosettaInterpreterDateTimeValue) receiverValue).getTime(); - default: //error + if (feature.equals("date")) { + return ((RosettaInterpreterDateTimeValue) receiverValue).getDate(); + } else { + return ((RosettaInterpreterDateTimeValue) receiverValue).getTime(); } } else if (receiverValue instanceof RosettaInterpreterZonedDateTimeValue) { - switch (feature) { - case "date": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getDate(); - case "time": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTime(); - case "timezone": return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); - default: //error + if (feature.equals("date")) { + return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getDate(); + } else if (feature.equals("time")) { + return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTime(); + } else { + return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); } } else { diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index a44acfbb6..f2fbeed93 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -15,6 +15,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; @@ -44,6 +46,9 @@ public class RosettaInterpreterFeatureCallTest { RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + RosettaInterpreterErrorValue error = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Feature call: feature not found.")); + @Test public void testDateDay() { RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 } -> day"); @@ -112,6 +117,19 @@ public void testZonedDateTimeDate() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); env.addValue("t", time); + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" } -> date", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(date, result); + } + + @Test + public void testZonedDateTimeDateYear() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + RosettaExpression expr = parser.parseExpression( "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + ", time: t, timezone: \"CET\" } -> date -> year", List.of("t time (1..1)")); From 01bf5e20d6236965b8dd601be0f6f5f0eda89f7a Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 09:17:03 +0200 Subject: [PATCH 146/236] Removed RosettaInterpreterIntegerValue class --- .../RosettaInterpreterIntegerValue.java | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java deleted file mode 100644 index c3edb3e43..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ /dev/null @@ -1,60 +0,0 @@ -//package com.regnosys.rosetta.interpreternew.values; -// -//import java.math.BigInteger; -//import java.util.Objects; -//import java.util.stream.Stream; -// -//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -// -//public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue -// implements Comparable { -// -// private BigInteger value; -// -// @Override -// public int hashCode() { -// return Objects.hash(value); -// } -// -// @Override -// public boolean equals(Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (getClass() != obj.getClass()) { -// return false; -// } -// RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; -// return Objects.equals(value, other.value); -// } -// -// public RosettaInterpreterIntegerValue(BigInteger value) { -// super(); -// this.value = value; -// } -// -// public RosettaInterpreterIntegerValue(int value) { -// super(); -// this.value = BigInteger.valueOf(value); -// } -// -// public BigInteger getValue() { return value; } -// -// @Override -// public int compareTo(RosettaInterpreterIntegerValue o) { -// return this.value.compareTo(o.value); -// } -// -// @Override -// public Stream toElementStream() { -// return Stream.of(value); -// } -// -// @Override -// public Stream toValueStream() { -// return Stream.of(this); -// } -//} From dadf1c2eacd905aef82d2fd4d8981753e9703852 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 09:24:38 +0200 Subject: [PATCH 147/236] Made some changes so that the tests pass --- ...rpreterComparisonOperationInterpreter.java | 2 - ...osettaArithmeticOperationsInterpreter.java | 1 - ...aInterpreterConditionalExpressionTest.java | 322 +++++++++--------- .../RosettaInterpreterLiteralsTest.java | 1 - .../RosettaInterpreterVariableTest.java | 14 +- 5 files changed, 168 insertions(+), 172 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 477e3f8db..55402a9cf 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -26,8 +26,6 @@ public class RosettaInterpreterComparisonOperationInterpreter extends "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterBooleanValue", "com.regnosys.rosetta.interpreternew.values." - + "RosettaInterpreterIntegerValue", - "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterNumberValue", "com.regnosys.rosetta.interpreternew.values." + "RosettaInterpreterStringValue"); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 8082c6a4f..9776f6c1d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -5,7 +5,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 7bc458344..4368a2710 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -32,64 +32,64 @@ public class RosettaInterpreterConditionalExpressionTest { @Inject RosettaInterpreterNew interpreter; -// @Test -// public void integerTest() { -// RosettaExpression expr = parser.parseExpression("if True then 1"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(new RosettaInterpreterNumberValue(1), result); -// } -// -// @Test -// public void integerElseTest() { -// RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(new RosettaInterpreterNumberValue(2), result); -// } -// -// @Test -// public void integerThenTest() { -// RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(new RosettaInterpreterNumberValue(1), result); -// } -// -// @Test -// public void booleanTest() { -// RosettaExpression expr = parser.parseExpression("if True then False"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(false, ((RosettaInterpreterBooleanValue) result).getValue()); -// } -// -// @Test -// public void stringTest() { -// RosettaExpression expr = parser.parseExpression("if True then \"abc\""); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals("abc", ((RosettaInterpreterStringValue) result).getValue()); -// } -// -// @Test -// public void numberTest() { -// RosettaExpression expr = parser.parseExpression("if True then 1.2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(new RosettaInterpreterNumberValue(1.2), result); -// } -// -// @Test -// public void listTest() { -// RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// List list = List.of(new RosettaInterpreterNumberValue(1), -// new RosettaInterpreterNumberValue(2)); -// -// assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); -// } + @Test + public void integerTest() { + RosettaExpression expr = parser.parseExpression("if True then 1"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(1), result); + } + + @Test + public void integerElseTest() { + RosettaExpression expr = parser.parseExpression("if False then 1 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(2), result); + } + + @Test + public void integerThenTest() { + RosettaExpression expr = parser.parseExpression("if True then 1 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(1), result); + } + + @Test + public void booleanTest() { + RosettaExpression expr = parser.parseExpression("if True then False"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(false, ((RosettaInterpreterBooleanValue) result).getValue()); + } + + @Test + public void stringTest() { + RosettaExpression expr = parser.parseExpression("if True then \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals("abc", ((RosettaInterpreterStringValue) result).getValue()); + } + + @Test + public void numberTest() { + RosettaExpression expr = parser.parseExpression("if True then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(1.2), result); + } + + @Test + public void listTest() { + RosettaExpression expr = parser.parseExpression("if True then [1, 2]"); + RosettaInterpreterValue result = interpreter.interp(expr); + + List list = List.of(new RosettaInterpreterNumberValue(1), + new RosettaInterpreterNumberValue(2)); + + assertEquals(list, ((RosettaInterpreterListValue) result).getExpressions()); + } @Test public void complexTest() { @@ -99,108 +99,108 @@ public void complexTest() { assertEquals(new RosettaInterpreterNumberValue(1), result); } -// @Test -// public void errorThenTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError( -// "Conditional expression: then is an error value.")); -// expected.addError(new RosettaInterpreterError( -// "cannot use \"ALL\" keyword " + "to compare two elements")); -// -// RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void errorElseTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError( -// "Conditional expression: else is an error value.")); -// expected.addError(new RosettaInterpreterError( -// "cannot use \"ALL\" keyword " + "to compare two elements")); -// -// RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void notSameTypeThenTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError("Conditional expression: " -// + "then and else need to have the same type.")); -// -// RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void notSameTypeElseTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError("Conditional expression: " -// + "then and else need to have the same type.")); -// -// RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void conditionNotBooleanTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError("Conditional expression: " -// + "condition is not a boolean value.")); -// -// RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void conditionErrorTypeTest() { -// RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( -// new RosettaInterpreterError("Conditional expression: " -// + "condition is an error value.")); -// expected.addError(new RosettaInterpreterError( -// "cannot use \"ALL\" keyword " + "to compare two elements")); -// -// RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; -// -// assertEquals(expected.getErrors(), errorResult.getErrors()); -// assertEquals(expected.getErrors().get(0).getMessage(), -// errorResult.getErrors().get(0).getMessage()); -// } -// -// @Test -// public void noElseTest() { -// RosettaExpression expr = parser.parseExpression("if False then 1.2"); -// RosettaInterpreterValue result = interpreter.interp(expr); -// -// assertEquals(null, result); -// } + @Test + public void errorThenTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: then is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if True then 1 all = 3 else 2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void errorElseTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Conditional expression: else is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if False then 2 else 1 all = 3"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void notSameTypeThenTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "then and else need to have the same type.")); + + RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void notSameTypeElseTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "then and else need to have the same type.")); + + RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void conditionNotBooleanTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "condition is not a boolean value.")); + + RosettaExpression expr = parser.parseExpression("if 1 then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void conditionErrorTypeTest() { + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Conditional expression: " + + "condition is an error value.")); + expected.addError(new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + "to compare two elements")); + + RosettaExpression expr = parser.parseExpression("if 1 all = 3 then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; + + assertEquals(expected.getErrors(), errorResult.getErrors()); + assertEquals(expected.getErrors().get(0).getMessage(), + errorResult.getErrors().get(0).getMessage()); + } + + @Test + public void noElseTest() { + RosettaExpression expr = parser.parseExpression("if False then 1.2"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(null, result); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 60b80b8eb..4e14daa12 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -15,7 +15,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java index 951553836..977b9c166 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVariableTest.java @@ -20,7 +20,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; @@ -52,9 +52,9 @@ public void setup() { public void variableGoodComparisonTest() { //create the environment and add variable 'a' to it RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaInterpreterIntegerValue intValue = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); - env.addValue("a", intValue); + RosettaInterpreterNumberValue value = + new RosettaInterpreterNumberValue(5); + env.addValue("a", value); //give the same environment to the parser RosettaExpression expr = parser.parseExpression("a >= 2", @@ -69,9 +69,9 @@ public void variableGoodComparisonTest() { public void variableLeftErrorComparisonTest() { //create the environment and add variable 'a' to it RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaInterpreterIntegerValue intValue = - new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); - env.addValue("a", intValue); + RosettaInterpreterNumberValue value = + new RosettaInterpreterNumberValue(5); + env.addValue("a", value); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( From ec0b054782b0f4e9e6208d8f0aac24004666dbf9 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 09:31:22 +0200 Subject: [PATCH 148/236] Added tests to check equality between ints, floats and doubles --- .../RosettaInterpreterLiteralsTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 4e14daa12..934a523fd 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -121,6 +121,30 @@ public void numberTest() { ((RosettaInterpreterNumberValue)val).getValue()); } + @Test + public void intEqualsFloatTest() { + RosettaExpression expr = parser.parseExpression("5 = 5.0"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(true, + ((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void intEqualsDoubleTest() { + RosettaExpression expr = parser.parseExpression("5 = 5.00"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(true, + ((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void floatEqualsDoubleTest() { + RosettaExpression expr = parser.parseExpression("5.0 = 5.00"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(true, + ((RosettaInterpreterBooleanValue)val).getValue()); + } + @Test public void stringTest() { RosettaExpression expr = parser.parseExpression("\"hello\""); From d1d0d92c19a730ccbee94725e964bed1b4a72c57 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 09:33:00 +0200 Subject: [PATCH 149/236] Removed unused import --- .../rosetta/interpreternew/RosettaInterpreterLiteralsTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index 934a523fd..adecea5f5 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.*; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.List; import javax.inject.Inject; From 4edc145efa45d6c0a8e1ea40aa93fc7be0890a62 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 09:39:31 +0200 Subject: [PATCH 150/236] Added case for division by 0 --- ...preterRosettaArithmeticOperationsInterpreter.java | 6 ++++++ .../RosettaInterpreterArithmeticOperationsTest.java | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 9776f6c1d..251f88a83 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -81,6 +81,12 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, return new RosettaInterpreterNumberValue((leftNumber .multiply(rightNumber)).bigDecimalValue()); } else { + // Division by 0 is not allowed + if(rightNumber.floatValue() == 0.0) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Division by 0 is not allowed")); + } return new RosettaInterpreterNumberValue((leftNumber .divide(rightNumber)).bigDecimalValue()); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java index 2d99230f6..ca904ed34 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java @@ -87,6 +87,18 @@ public void divideTest() { assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(3)), ((RosettaInterpreterNumberValue)val).getValue()); } + + @Test + public void divisionByZeroTest() { + RosettaExpression expr = parser.parseExpression("6/0"); + RosettaInterpreterValue val = interpreter.interp(expr); + List expected = List.of( + new RosettaInterpreterError( + "Division by 0 is not allowed")); + + assertEquals(expected, + ((RosettaInterpreterErrorValue)val).getErrors()); + } @Test public void stringConcatenationTest() { From 453e493fbb29dc9f4391a29514c4e8f08067b106 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 6 Jun 2024 09:42:13 +0200 Subject: [PATCH 151/236] Incomplete function impl, doesn't support aliases and doesn't have full branch coverage yet --- rosetta-lang/model/RosettaInterpreter.xcore | 3 + rosetta-lang/model/RosettaSimple.xcore | 8 + .../interpreternew/RosettaInterpreterNew.java | 18 +- .../RosettaInterpreterVisitor.java | 9 + ...RosettaInterpreterVariableInterpreter.java | 231 +++++++++++++++++- 5 files changed, 266 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index d1de34106..471a252ee 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -18,6 +18,7 @@ import com.regnosys.rosetta.rosetta.expression.ComparisonOperation import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment +import com.regnosys.rosetta.rosetta.simple.Function import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression @@ -66,5 +67,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterBaseEnvironment interp (Function exp, RosettaInterpreterBaseEnvironment env) + } \ No newline at end of file diff --git a/rosetta-lang/model/RosettaSimple.xcore b/rosetta-lang/model/RosettaSimple.xcore index 47b534f8c..2d2d1e448 100644 --- a/rosetta-lang/model/RosettaSimple.xcore +++ b/rosetta-lang/model/RosettaSimple.xcore @@ -21,6 +21,9 @@ import org.eclipse.emf.common.util.BasicEList import com.regnosys.rosetta.rosetta.expression.RosettaExpression import com.regnosys.rosetta.rosetta.RosettaAttributeReferenceSegment import com.regnosys.rosetta.rosetta.RosettaCardinality +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor + +import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment abstract class RootElement extends RosettaRootElement, RosettaNamed, RosettaDefinable, Annotated { } @@ -81,6 +84,11 @@ class Function extends RootElement, RosettaNamed, RosettaCallableWithArgs, Refer op int numberOfParameters() { inputs.size } + + + op RosettaInterpreterBaseEnvironment accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class FunctionDispatch extends Function { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index d0abf808b..745a625c7 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -2,16 +2,21 @@ import javax.inject.Inject; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Function; public class RosettaInterpreterNew { @Inject private RosettaInterpreterVisitor visitor; + @Inject + private RosettaInterpreterEnvironment environment; + /** * Simple example interpret function to allow for better understanding * of the development workflow. @@ -20,11 +25,22 @@ public class RosettaInterpreterNew { * @return value of RosettaIntLiteral otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { - return expression.accept(visitor, new RosettaInterpreterEnvironment()); + return expression.accept(visitor, environment); } public RosettaInterpreterValue interp(RosettaExpression expression, RosettaInterpreterBaseEnvironment env) { return expression.accept(visitor, env); } + + public RosettaInterpreterBaseEnvironment interp(Function func) { + return func.accept(visitor, environment); + } + + public RosettaInterpreterBaseEnvironment interp(Function func, + RosettaInterpreterBaseEnvironment env) { + return func.accept(visitor, env); + } + + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5d7a4c37d..57dd9eb12 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -20,6 +20,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Function; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; @@ -31,6 +32,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterFunctionDeclarationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; @@ -212,5 +214,12 @@ public RosettaInterpreterValue interp(SumOperation exp, return new RosettaInterpreterListOperatorInterpreter().interp(exp, (RosettaInterpreterEnvironment) env); } + + @Override + public RosettaInterpreterEnvironment interp(Function exp, + RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterFunctionDeclarationInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 63ea284c1..eea6cb68f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -1,12 +1,37 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Condition; +import com.regnosys.rosetta.rosetta.simple.Operation; +import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; public class RosettaInterpreterVariableInterpreter { - + + @Inject + protected RosettaInterpreterVisitor visitor = new RosettaInterpreterVisitor(); + + + /** * Interprets a variable, returns the value of it. * @@ -21,10 +46,212 @@ public class RosettaInterpreterVariableInterpreter { public RosettaInterpreterValue interp(RosettaSymbolReference exp, RosettaInterpreterEnvironment env) { + if (exp.getSymbol() instanceof FunctionImpl) { + return interp((FunctionImpl) exp.getSymbol(), exp.getRawArgs(), env); + } + + return interp(exp.getSymbol().getName(), env); + } + + /** + * Interprets a variable, returns the value of it. + * + * @param varName The name of the variable to interpret + * @param env RosettaInterpreterEnvironment that keeps track + * of the current state of the program + * @return If no errors are encountered, a RosettaInterpreterValue representing + * the value of the variable. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(String varName, + RosettaInterpreterEnvironment env) { + //Search for variable in environment - RosettaInterpreterBaseValue varValue = env.findValue(exp.getSymbol().getName()); + RosettaInterpreterBaseValue varValue = env.findValue(varName); return varValue; } + + /** + * Interprets a function, returns the result. + * + * @param func The name of the function to interpret + * @param env RosettaInterpreterEnvironment that keeps track + * of the current state of the program + * @return If no errors are encountered, a RosettaInterpreterValue representing + * the value of the function. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(FunctionImpl func, List args, + RosettaInterpreterEnvironment env) { + + String varName = func.getName(); + FunctionImpl f = ((RosettaInterpreterFunctionValue) env.findValue(varName)) + .getFunction(); + + //interpret the raw arguments + List interpretedArgs = new ArrayList<>(); + for (RosettaExpression e : args) { + interpretedArgs.add(e.accept(visitor, env)); + } + + //check if there are any errors in interpreting the arguments. If so, return them + RosettaInterpreterErrorValue acc = new RosettaInterpreterErrorValue(); + if (RosettaInterpreterErrorValue.errorsExist(interpretedArgs)) { + for (RosettaInterpreterValue value : interpretedArgs) { + if (value instanceof RosettaInterpreterErrorValue) { + acc.addAllErrors(value); + } + } + if (acc.getErrors().size() > 0) { + return acc; + } + } + + //check that all argument/passed value correspond in type and cardinality + //if not, return errors pointing to each attribute reference where this is the case + int inputSize = f.getInputs().size(); + for (int i = 0 ; i < inputSize ; i++) { + if (!checkPair((AttributeImpl) f.getInputs().get(i), + (RosettaInterpreterBaseValue) interpretedArgs.get(i))) { + acc.addError(new RosettaInterpreterError("Argument " + + f.getInputs().get(i).getName() + + " does not correspond with its passed value")); + } + } + if (acc.getErrors().size() > 0) { + return acc; + } + + //add all the argument/value pairs to the NEW environment + RosettaInterpreterEnvironment nv = new RosettaInterpreterEnvironment(); + for (int i = 0 ; i < inputSize ; i++) { + AttributeImpl attr = (AttributeImpl) f.getInputs().get(i); + RosettaInterpreterBaseValue value = (RosettaInterpreterBaseValue) interpretedArgs.get(i); + nv.addValue(attr.getName(), value); + } + + //check the pre-conditions of the function + List conditions = func.getConditions(); + for (Condition c : conditions) { + RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); + if (v instanceof RosettaInterpreterBooleanValue) { + if (((RosettaInterpreterBooleanValue) v).getValue() == false) { + acc.addError(new RosettaInterpreterError("Condition " + + c.getName() + " does not hold for this function call")); + } + } else { //must be an error if not a boolean value + acc.addAllErrors(v); + } + } + if (acc.getErrors().size() > 0) { + return acc; + } + + + //compute the results of all operations in the function + List resultList = new ArrayList<>(); + for (Operation o : f.getOperations()) { + if (o.isAdd()) { + resultList.add(o.getExpression().accept(visitor, nv)); + } else { + resultList = ((RosettaInterpreterBaseValue) o.getExpression().accept(visitor, nv)) + .toValueStream().collect(Collectors.toList()); + } + } + + RosettaInterpreterListValue result = new RosettaInterpreterListValue(resultList); + //check the post-conditions of the function + nv.addValue(f.getOutput().getName(), result); + conditions = func.getPostConditions(); + for (Condition c : conditions) { + RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); + if (v instanceof RosettaInterpreterBooleanValue) { + if (((RosettaInterpreterBooleanValue) v).getValue() == false) { + acc.addError(new RosettaInterpreterError("Condition " + + c.getName() + " does not hold for this function call")); + } + } else { //must be an error if not a boolean value + acc.addAllErrors(v); + } + } + if (acc.getErrors().size() > 0) { + return acc; + } + + //if post-conditions pass, return the result + return result; + } + + /** + * Subroutine for checking that the function call is valid based on cardinality and type checking. + * + * @param attr The attribute object that contains the pertinent information + * @param value The interpreted value that is passed to the function + * @return True if the type and cardinality of the attribute and value match, false otherwise + */ + public boolean checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) { + //This will consider only basic types, this will be changed after datatypes are done + String typeName = attr.getTypeCall().getType().getName(); + List vals = value.toValueStream() + .collect(Collectors.toList()); + + //check that the cardinality of the arg and the value match + int paramSize = vals.size(); + int lowerLimit = attr.getCard().getInf(); + if (paramSize < lowerLimit) { + return false; + } + int upperLimit = attr.getCard().isUnbounded() ? Integer.MAX_VALUE : attr.getCard().getSup(); + if (paramSize > upperLimit) { + return false; + } + + //checking that the potential list of elements in arg and value are of the same type + switch (typeName) { + case "number": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterNumberValue + || val instanceof RosettaInterpreterIntegerValue)) { + return false; + } + } + break; + case "int": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterNumberValue + || val instanceof RosettaInterpreterIntegerValue)) { + return false; + } + } + break; + case "boolean": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterBooleanValue)) { + return false; + } + } + break; + case "string": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterStringValue)) { + return false; + } + } + break; + // this will be implemented after record types + // case "time": + // if (!(val instanceof RosettaInterpreterNumberValue + // || val instanceof RosettaInterpreterIntegerValue)) { + // return false; + // } + default: + } + //if all checks pass, return true + return true; + + } } From 436806058f439dfaf4dfd66805ee30455b79b935 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 6 Jun 2024 09:42:37 +0200 Subject: [PATCH 152/236] Added some untracked files --- .../RosettaInterpreterFunctionValue.java | 49 +++++ ...rpreterFunctionDeclarationInterpreter.java | 24 +++ .../RosettaInterpreterFunctionTest.java | 197 ++++++++++++++++++ 3 files changed, 270 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionDeclarationInterpreter.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java new file mode 100644 index 000000000..46f491c6c --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java @@ -0,0 +1,49 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.Objects; +import java.util.stream.Stream; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; + +public class RosettaInterpreterFunctionValue extends RosettaInterpreterBaseValue { + + private FunctionImpl function; + + public RosettaInterpreterFunctionValue(FunctionImpl f) { + super(); + function = f; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterFunctionValue other = (RosettaInterpreterFunctionValue) obj; + return Objects.equals(function, other.function); + } + + public FunctionImpl getFunction() { + return function; + } + + @Override + public Stream toElementStream() { + return Stream.of(function); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } + + + + +} \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionDeclarationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionDeclarationInterpreter.java new file mode 100644 index 000000000..f6ad4c930 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionDeclarationInterpreter.java @@ -0,0 +1,24 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; +import com.regnosys.rosetta.rosetta.simple.Function; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; + +public class RosettaInterpreterFunctionDeclarationInterpreter extends + RosettaInterpreterConcreteInterpreter { + + /** + * Interprets a function declaration, and adds it to the environment. + * + * @param func the function to be interpreter + * @return the list value it represents + */ + public RosettaInterpreterEnvironment interp(Function func, + RosettaInterpreterEnvironment env) { + RosettaInterpreterFunctionValue val = + new RosettaInterpreterFunctionValue((FunctionImpl) func); + env.addValue(func.getName(), val); + return env; + } +} \ No newline at end of file diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java new file mode 100644 index 000000000..8353eb7a8 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java @@ -0,0 +1,197 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.math.BigDecimal; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ModelHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterFunctionTest { + + @Inject + RosettaInterpreterNew interpreter; + + @Inject + ModelHelper mh; + +// private ExpressionFactory exFactory; +// +// @BeforeEach +// public void setup() { +// exFactory = ExpressionFactoryImpl.init(); +// +// } + + @Test + public void funcAddsToEnvironmentTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " 3\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + assertEquals(env.findValue(function.getName()), + new RosettaInterpreterFunctionValue(function)); + } + + @Test + public void cardinalityMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add([1.0, 2.0])\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Argument a does not correspond with its passed value")); + assertEquals(res, expected); + } + + @Test + public void funcSimpleSetTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " Add(1.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)))); + assertEquals(res, expected); + } + + @Test + public void funcConditionTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..10)\r\n" + + " condition Alarger:\r\n" + + " a > b\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " Add(3.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)))); + assertEquals(res, expected); + } + + @Test + public void funcConditionTestError() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..10)\r\n" + + " condition Alarger:\r\n" + + " a > b\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " Add(1.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Condition Alarger does not hold for this function call")); + assertEquals(res, expected); + } + + @Test + public void complexFunctionText() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..10)\r\n" + + " condition Alarger:\r\n" + + " a > b\r\n" +// + " post-condition Countt:\r\n" +// + " result count = (a + b)\r\n" + + " set result:\r\n" + + " a + b\r\n" + + " add result: 1.0\r\n" + + " add result: 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " Add(2.0, 1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + assertEquals(res, expected); + } + +} \ No newline at end of file From 1753116162df8d6760669333ee4076b4af244dc6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 10:38:18 +0200 Subject: [PATCH 153/236] Changed conditional to not evaluate both branches of if all the time --- ...settaConditionalExpressionInterpreter.java | 41 +++++-------------- ...aInterpreterConditionalExpressionTest.java | 35 ++-------------- 2 files changed, 13 insertions(+), 63 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index ee78fd37e..cbc61aa2f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -32,13 +32,10 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, RosettaExpression ifExpression = expr.getIf(); RosettaExpression ifThen = expr.getIfthen(); + RosettaExpression elseThen = expr.getElsethen(); RosettaInterpreterValue ifValue = ifExpression.accept(visitor, env); - RosettaInterpreterValue ifThenValue = ifThen.accept(visitor, env); - - RosettaExpression elseThen = null; - RosettaInterpreterValue elseThenValue = null; - + if (ifValue instanceof RosettaInterpreterBooleanValue) { ifResult = ((RosettaInterpreterBooleanValue) ifValue).getValue(); } else if (RosettaInterpreterErrorValue.errorsExist(ifValue)) { @@ -50,30 +47,8 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, + "is not a boolean value.")); } - if (expr.isFull()) { - elseThen = expr.getElsethen(); - elseThenValue = elseThen.accept(visitor); - - RosettaInterpreterBaseValue ifInstance = - ((RosettaInterpreterBaseValue) ifThenValue); - - RosettaInterpreterBaseValue elseInstance = - ((RosettaInterpreterBaseValue) elseThenValue); - - if (!ifInstance.getClass().equals(elseInstance.getClass()) - && !(ifInstance - instanceof RosettaInterpreterErrorValue) - && !(elseInstance - instanceof RosettaInterpreterErrorValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Conditional expression: " - + "then and else " - + "need to have the same type.")); - } - } - - if (ifResult) { + if (ifResult) { + RosettaInterpreterValue ifThenValue = ifThen.accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(ifThenValue)) { return createErrors(ifThenValue, "Conditional expression: then is an error value."); @@ -82,15 +57,19 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, return ((RosettaInterpreterBaseValue) ifThenValue); } else if (expr.isFull()) { + RosettaInterpreterValue elseThenValue = elseThen.accept(visitor); if (RosettaInterpreterErrorValue.errorsExist(elseThenValue)) { return createErrors(elseThenValue, "Conditional expression: else is an error value."); } return ((RosettaInterpreterBaseValue) elseThenValue); + } else { + // Else branch should be evaluated but it does not exist + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Else branch should be evaluated but does not exist")); } - - return null; } private RosettaInterpreterBaseValue diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index 4368a2710..58c35f826 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -133,36 +133,6 @@ public void errorElseTest() { errorResult.getErrors().get(0).getMessage()); } - @Test - public void notSameTypeThenTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); - - RosettaExpression expr = parser.parseExpression("if True then 1.2 else \"abc\""); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - - @Test - public void notSameTypeElseTest() { - RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Conditional expression: " - + "then and else need to have the same type.")); - - RosettaExpression expr = parser.parseExpression("if False then 1.2 else \"abc\""); - RosettaInterpreterValue result = interpreter.interp(expr); - RosettaInterpreterErrorValue errorResult = (RosettaInterpreterErrorValue) result; - - assertEquals(expected.getErrors(), errorResult.getErrors()); - assertEquals(expected.getErrors().get(0).getMessage(), - errorResult.getErrors().get(0).getMessage()); - } - @Test public void conditionNotBooleanTest() { RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( @@ -199,8 +169,9 @@ public void conditionErrorTypeTest() { public void noElseTest() { RosettaExpression expr = parser.parseExpression("if False then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); - - assertEquals(null, result); + RosettaInterpreterError expected = new RosettaInterpreterError( + "Else branch should be evaluated but does not exist"); + assertEquals(expected, ((RosettaInterpreterErrorValue)result).getErrors().get(0)); } } From 1c4906cbd74f7fc20c5cced9dfe10a32c5cb3bab Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 6 Jun 2024 11:56:23 +0200 Subject: [PATCH 154/236] List edge case test --- .../RosettaInterpreterLiteralsTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java index adecea5f5..2979af779 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterLiteralsTest.java @@ -104,6 +104,22 @@ public void veryNestedListTest() { } + @Test + public void emptyElementInListTest() { + RosettaExpression expr = parser.parseExpression("[1, [2, 3], empty]"); + validation.assertNoIssues(expr); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterListValue expected = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(2)), + new RosettaInterpreterNumberValue( + BigDecimal.valueOf(3)))); + assertEquals(expected, val); + } + @Test public void intTest() { RosettaExpression expr = parser.parseExpression("5"); From bf150ae135429e4471cad37e58bb4a5cf3b39c51 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 6 Jun 2024 12:51:55 +0200 Subject: [PATCH 155/236] Reverted .project file --- rosetta-lang/.project | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rosetta-lang/.project b/rosetta-lang/.project index abbd3d17f..f46323c08 100644 --- a/rosetta-lang/.project +++ b/rosetta-lang/.project @@ -21,17 +21,17 @@ - org.eclipse.pde.ManifestBuilder + org.eclipse.m2e.core.maven2Builder - org.eclipse.pde.SchemaBuilder + org.eclipse.pde.ManifestBuilder - org.eclipse.m2e.core.maven2Builder + org.eclipse.pde.SchemaBuilder From 3959ebf86786eff91526de37f430d33fb710888e Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 6 Jun 2024 13:03:34 +0200 Subject: [PATCH 156/236] Complete implementation of functions --- ...RosettaInterpreterVariableInterpreter.java | 114 +++-- .../RosettaInterpreterFunctionTest.java | 425 +++++++++++++++++- 2 files changed, 483 insertions(+), 56 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index eea6cb68f..58ad01d9c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -13,7 +13,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; @@ -22,6 +21,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.simple.Condition; import com.regnosys.rosetta.rosetta.simple.Operation; +import com.regnosys.rosetta.rosetta.simple.ShortcutDeclaration; import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; @@ -87,8 +87,7 @@ public RosettaInterpreterValue interp(String varName, public RosettaInterpreterValue interp(FunctionImpl func, List args, RosettaInterpreterEnvironment env) { - String varName = func.getName(); - FunctionImpl f = ((RosettaInterpreterFunctionValue) env.findValue(varName)) + final FunctionImpl f = ((RosettaInterpreterFunctionValue) env.findValue(func.getName())) .getFunction(); //interpret the raw arguments @@ -99,27 +98,19 @@ public RosettaInterpreterValue interp(FunctionImpl func, List //check if there are any errors in interpreting the arguments. If so, return them RosettaInterpreterErrorValue acc = new RosettaInterpreterErrorValue(); - if (RosettaInterpreterErrorValue.errorsExist(interpretedArgs)) { - for (RosettaInterpreterValue value : interpretedArgs) { - if (value instanceof RosettaInterpreterErrorValue) { - acc.addAllErrors(value); - } - } - if (acc.getErrors().size() > 0) { - return acc; - } + for (RosettaInterpreterValue value : interpretedArgs) { + acc.addAllErrors(value); } - + if (acc.getErrors().size() > 0) { + return acc; + } + //check that all argument/passed value correspond in type and cardinality //if not, return errors pointing to each attribute reference where this is the case int inputSize = f.getInputs().size(); for (int i = 0 ; i < inputSize ; i++) { - if (!checkPair((AttributeImpl) f.getInputs().get(i), - (RosettaInterpreterBaseValue) interpretedArgs.get(i))) { - acc.addError(new RosettaInterpreterError("Argument " - + f.getInputs().get(i).getName() - + " does not correspond with its passed value")); - } + acc.addAllErrors(checkPair((AttributeImpl) f.getInputs().get(i), + (RosettaInterpreterBaseValue) interpretedArgs.get(i))); } if (acc.getErrors().size() > 0) { return acc; @@ -139,8 +130,8 @@ public RosettaInterpreterValue interp(FunctionImpl func, List RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); if (v instanceof RosettaInterpreterBooleanValue) { if (((RosettaInterpreterBooleanValue) v).getValue() == false) { - acc.addError(new RosettaInterpreterError("Condition " - + c.getName() + " does not hold for this function call")); + acc.addError(new RosettaInterpreterError("Condition \"" + + c.getName() + "\" does not hold for this function call")); } } else { //must be an error if not a boolean value acc.addAllErrors(v); @@ -149,7 +140,18 @@ public RosettaInterpreterValue interp(FunctionImpl func, List if (acc.getErrors().size() > 0) { return acc; } - + + //Add all aliases to the environment, throw errors if any are found + List aliases = f.getShortcuts(); + for (ShortcutDeclaration alias : aliases) { + RosettaInterpreterBaseValue val = (RosettaInterpreterBaseValue) + alias.getExpression().accept(visitor, nv); + acc.addAllErrors(val); + nv.addValue(alias.getName(), val); + } if (acc.getErrors().size() > 0) { + return acc; + } + //compute the results of all operations in the function List resultList = new ArrayList<>(); @@ -162,7 +164,28 @@ public RosettaInterpreterValue interp(FunctionImpl func, List } } - RosettaInterpreterListValue result = new RosettaInterpreterListValue(resultList); + //check that the function operations yield no errors + for (RosettaInterpreterValue value : resultList) { + acc.addAllErrors(value); + } if (acc.getErrors().size() > 0) { + return acc; + } + + //check cardinality and type of output matches computed value + RosettaInterpreterBaseValue result; + int upperLimit = f.getOutput().getCard().isUnbounded() ? Integer.MAX_VALUE : + f.getOutput().getCard().getSup(); + int lowerLimit = f.getOutput().getCard().getInf(); + if (upperLimit == 1 && lowerLimit == 1) { + result = (RosettaInterpreterBaseValue) resultList.get(0); + } else { + result = new RosettaInterpreterListValue(resultList); + } + acc.addAllErrors(checkPair((AttributeImpl) f.getOutput(), result)); + if (acc.getErrors().size() > 0) { + return acc; + } + //check the post-conditions of the function nv.addValue(f.getOutput().getName(), result); conditions = func.getPostConditions(); @@ -170,8 +193,8 @@ public RosettaInterpreterValue interp(FunctionImpl func, List RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); if (v instanceof RosettaInterpreterBooleanValue) { if (((RosettaInterpreterBooleanValue) v).getValue() == false) { - acc.addError(new RosettaInterpreterError("Condition " - + c.getName() + " does not hold for this function call")); + acc.addError(new RosettaInterpreterError("Condition \"" + + c.getName() + "\" does not hold for this function call")); } } else { //must be an error if not a boolean value acc.addAllErrors(v); @@ -181,6 +204,7 @@ public RosettaInterpreterValue interp(FunctionImpl func, List return acc; } + //if post-conditions pass, return the result return result; } @@ -192,7 +216,7 @@ public RosettaInterpreterValue interp(FunctionImpl func, List * @param value The interpreted value that is passed to the function * @return True if the type and cardinality of the attribute and value match, false otherwise */ - public boolean checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) { + public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) { //This will consider only basic types, this will be changed after datatypes are done String typeName = attr.getTypeCall().getType().getName(); List vals = value.toValueStream() @@ -202,42 +226,58 @@ public boolean checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) int paramSize = vals.size(); int lowerLimit = attr.getCard().getInf(); if (paramSize < lowerLimit) { - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" has cardinality lower than the limit " + + lowerLimit)); } int upperLimit = attr.getCard().isUnbounded() ? Integer.MAX_VALUE : attr.getCard().getSup(); if (paramSize > upperLimit) { - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" has cardinality higher than the limit " + + upperLimit)); } //checking that the potential list of elements in arg and value are of the same type switch (typeName) { case "number": for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterNumberValue - || val instanceof RosettaInterpreterIntegerValue)) { - return false; + if (!(val instanceof RosettaInterpreterNumberValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a number, but received a " + + val.getClass())); } } break; case "int": for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterNumberValue - || val instanceof RosettaInterpreterIntegerValue)) { - return false; + if (!(val instanceof RosettaInterpreterNumberValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a number, but received a " + + val.getClass())); } } break; case "boolean": for (RosettaInterpreterValue val : vals) { if (!(val instanceof RosettaInterpreterBooleanValue)) { - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a boolean, but received a " + + val.getClass())); } } break; case "string": for (RosettaInterpreterValue val : vals) { if (!(val instanceof RosettaInterpreterStringValue)) { - return false; + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a string, but received a " + + val.getClass())); } } break; @@ -250,7 +290,7 @@ public boolean checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) default: } //if all checks pass, return true - return true; + return new RosettaInterpreterErrorValue(); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java index 8353eb7a8..c9ed63509 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java @@ -15,9 +15,11 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -58,7 +60,7 @@ public void funcAddsToEnvironmentTest() { } @Test - public void cardinalityMismatch() { + public void inputCardinalityTooHigh() { //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own RosettaModel model = mh.parseRosetta( "func Add:\r\n" @@ -78,8 +80,137 @@ public void cardinalityMismatch() { (RosettaInterpreterEnvironment) interpreter.interp(function); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Argument a does not correspond with its passed value")); - assertEquals(res, expected); + new RosettaInterpreterError("The attribute \"a\" has cardinality higher than the limit 1")); + assertEquals(expected, res); + } + + @Test + public void inputCardinalityTooLow() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (2..3)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" has cardinality lower than the limit 2")); + assertEquals(expected, res); + } + + @Test + public void numberMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(\"Hi\")\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a number, but received a " + + (new RosettaInterpreterStringValue("")).getClass())); + assertEquals(expected, res); + } + + @Test + public void stringMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a string (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a string, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); + } + + @Test + public void intMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(\"Hi\")\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a number, but received a " + + (new RosettaInterpreterStringValue("")).getClass())); + assertEquals(expected, res); + } + + @Test + public void booleanMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a boolean (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + 2.0\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a boolean, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); } @Test @@ -89,11 +220,11 @@ public void funcSimpleSetTest() { + " inputs:" + " a number (1..1)\r\n" + " b int (1..1)\r\n" - + " output: result number (1..10)\r\n" + + " output: result number (1..1)\r\n" + " set result:\r\n" + " a + b\r\n" + "func MyTest:\r\n" - + " output: result number (1..10)\r\n" + + " output: result number (1..1)\r\n" + " set result:\r\n" + " Add(1.0, 2.0)\r\n"); FunctionImpl function = (FunctionImpl) model.getElements().get(0); @@ -102,25 +233,48 @@ public void funcSimpleSetTest() { RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterNumberValue expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)); + assertEquals(expected, res); + } + + @Test + public void funcSimpleBooleanSetTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a boolean (1..*)\r\n" + + " output: result boolean (1..*)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result boolean (1..*)\r\n" + + " set result:\r\n" + + " Add(True)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)))); - assertEquals(res, expected); + new RosettaInterpreterBooleanValue(true))); + assertEquals(expected, res); } @Test - public void funcConditionTest() { + public void funcPreConditionTest() { RosettaModel model = mh.parseRosettaWithNoErrors( "func Add:\r\n" + " inputs:" + " a number (1..1)\r\n" + " b int (1..1)\r\n" - + " output: result number (1..10)\r\n" + + " output: result number (1..1)\r\n" + " condition Alarger:\r\n" + " a > b\r\n" + " set result:\r\n" + " a + b\r\n" + "func MyTest:\r\n" - + " output: result number (1..10)\r\n" + + " output: result number (1..1)\r\n" + " set result:\r\n" + " Add(3.0, 2.0)\r\n"); FunctionImpl function = (FunctionImpl) model.getElements().get(0); @@ -129,13 +283,37 @@ public void funcConditionTest() { RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); RosettaInterpreterValue res = interpreter.interp(ref, env); - RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( - new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)))); - assertEquals(res, expected); + RosettaInterpreterNumberValue expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + assertEquals(expected, res); } @Test - public void funcConditionTestError() { + public void funcPostConditionTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a string (1..1)\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + " post-condition TrueString:\r\n" + + " result = \"True\"\r\n" + + "func MyTest:\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " Add(\"True\")\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterStringValue expected = new RosettaInterpreterStringValue("True"); + assertEquals(expected, res); + } + + @Test + public void funcPreConditionTestError() { RosettaModel model = mh.parseRosettaWithNoErrors( "func Add:\r\n" + " inputs:" @@ -157,8 +335,217 @@ public void funcConditionTestError() { (RosettaInterpreterEnvironment) interpreter.interp(function); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Condition Alarger does not hold for this function call")); - assertEquals(res, expected); + new RosettaInterpreterError("Condition \"Alarger\" does not hold for this function call")); + assertEquals(expected, res); + } + + @Test + public void funcBadPreConditionTest() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " condition Alarger:\r\n" + + " a any > [b]\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(3.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("cannot use \"ANY\" keyword " + + "to compare two elements")); + assertEquals(expected, res); + } + + @Test + public void funcBadPostConditionTest() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + b\r\n" + + " post-condition Alarger:\r\n" + + " [a] any > [b]\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(3.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("cannot compare two lists")); + assertEquals(expected, res); + } + + @Test + public void funcOperationError() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + True\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Arithmetic Operation: Rightside" + + " is not of type Number/String")); + assertEquals(expected, res); + } + + @Test + public void funcArgumentInterpretError() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add((1.0 + True))\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Arithmetic Operation: Rightside" + + " is not of type Number/String")); + assertEquals(expected, res); + } + + @Test + public void funcPostConditionTestError() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a string (1..1)\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + " post-condition FalseString:\r\n" + + " result = \"False\"\r\n" + + "func MyTest:\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " Add(\"True\")\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Condition \"FalseString\" does not hold for this function call")); + assertEquals(expected, res); + } + + @Test + public void funcOutputWrongTypeError() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a string (1..1)\r\n" + + " output: result string (0..1)\r\n" + + " set result:\r\n" + + " 3.0\r\n" + + "func MyTest:\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " Add(\"True\")\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"result\" requires a string, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); + } + + @Test + public void aliasTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..10)\r\n" + + " alias bee: b " + + " set result:\r\n" + + " a + bee\r\n" + + "func MyTest:\r\n" + + " output: result number (1..10)\r\n" + + " set result:\r\n" + + " Add(2.0, 1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)))); + assertEquals(expected, res); + } + + @Test + public void aliasErrorTest() { + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " alias bee: b + True\r\n" + + " set result:\r\n" + + " a + bee\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(2.0, 1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Arithmetic Operation: Rightside" + + " is not of type Number/String")); + assertEquals(expected, res); } @Test @@ -171,12 +558,12 @@ public void complexFunctionText() { + " output: result number (1..10)\r\n" + " condition Alarger:\r\n" + " a > b\r\n" -// + " post-condition Countt:\r\n" -// + " result count = (a + b)\r\n" + " set result:\r\n" + " a + b\r\n" + " add result: 1.0\r\n" + " add result: 2.0\r\n" + + " post-condition Countt:\r\n" + + " result count = 3\r\n" + "func MyTest:\r\n" + " output: result number (1..10)\r\n" + " set result:\r\n" @@ -191,7 +578,7 @@ public void complexFunctionText() { new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)), new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); - assertEquals(res, expected); + assertEquals(expected, res); } } \ No newline at end of file From 989c9d37d8f006d4fc8b826a4f3657ddc6aca144 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 6 Jun 2024 13:14:12 +0200 Subject: [PATCH 157/236] Final touches to enums --- ...ettaInterpreterFeatureCallInterpreter.java | 40 +------------------ .../RosettaInterpreterEnumTest.java | 8 ---- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java index e2411f5f2..f7f33b4ac 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java @@ -54,46 +54,10 @@ public RosettaInterpreterValue interp(RosettaFeatureCall expr, public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, RosettaEnumValue val, RosettaInterpreterEnvironment env) { - //The comments check some possible errors, - //but the model parser already does not allow it, - //so it's not really useful but I also don't wanna delete it - -// if (env.findValue(enumeration.getName()) instanceof RosettaInterpreterEnumValue) { -// if (((RosettaInterpreterEnumValue) env.findValue(enumeration.getName())) -// .containsValueName(val.getName())) { return new RosettaInterpreterEnumElementValue(val.getEnumeration().getName(), val.getName()); -// } else { -// return new RosettaInterpreterErrorValue( -// new RosettaInterpreterError( -// "The " + val.getEnumeration().getName() -// + " enum does not contain value " -// + val.getName())); -// } -// } else { -// return (RosettaInterpreterErrorValue) env.findValue(enumeration.getName()); -// } - } - - - - - - - - - - - - - - - - - - - - + + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java index e0d3184da..cd38dab4a 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java @@ -30,14 +30,6 @@ public class RosettaInterpreterEnumTest { @Inject ModelHelper mh; -// private ExpressionFactory exFactory; -// -// @BeforeEach -// public void setup() { -// exFactory = ExpressionFactoryImpl.init(); -// -// } - @Test public void enumAddsToEnvironmentTest() { RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" From 34e49c52a27d0be56a5e34974fa0f28e2882e43e Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 6 Jun 2024 13:52:22 +0200 Subject: [PATCH 158/236] Increased coverage in interpreternew.values --- .../values/RosettaInterpreterError.java | 28 +++--- .../values/RosettaInterpreterErrorValue.java | 1 - .../values/RosettaInterpreterListValue.java | 2 +- .../values/RosettaInterpreterNumberValue.java | 5 + .../values/RosettaInterpreterStringValue.java | 5 + .../RosettaInterpreterBooleanValueTest.java | 54 ++++++++++ .../RosettaInterpreterEnvironmentTest.java | 32 ++++++ .../value/RosettaInterpreterErrorTest.java | 49 ++++++++++ .../RosettaInterpreterErrorValueTest.java | 40 ++++++++ .../RosettaInterpreterListValueTest.java | 98 +++++++++++++++++++ .../RosettaInterpreterNumberValueTest.java | 39 ++++++++ .../RosettaInterpreterStringValueTest.java | 88 +++++++++++++++++ 12 files changed, 425 insertions(+), 16 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBooleanValueTest.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnvironmentTest.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterListValueTest.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterNumberValueTest.java create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterStringValueTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index f4e82f92c..9623d9256 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -17,6 +17,20 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; public class RosettaInterpreterError implements RosettaInterpreterBaseError { + private String errorMessage; + + public RosettaInterpreterError(String errorMessage) { + super(); + this.errorMessage = errorMessage; + } + + public String getError() { return errorMessage; } + + @Override + public String toString() { + return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; + } + @Override public int hashCode() { return Objects.hash(errorMessage); @@ -37,20 +51,6 @@ public boolean equals(Object obj) { return Objects.equals(errorMessage, other.errorMessage); } - private String errorMessage; - - public RosettaInterpreterError(String errorMessage) { - super(); - this.errorMessage = errorMessage; - } - - public String getError() { return errorMessage; } - - @Override - public String toString() { - return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; - } - @Override public EClass eClass() { // TODO Auto-generated method stub diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index d8848f2c8..4baa53792 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -8,7 +8,6 @@ import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNewException; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java index 704df4774..16a926357 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterListValue.java @@ -21,7 +21,7 @@ public int hashCode() { @Override public String toString() { - return "RosettaInterpreterListValue [expressions=" + expressions + "]"; + return "RosettaInterpreterListValue [expressions=" + expressions.toString() + "]"; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java index 9627fd2a6..3a5043324 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterNumberValue.java @@ -65,4 +65,9 @@ public Stream toValueStream() { return Stream.of(this); } + @Override + public String toString() { + return "RosettaInterpreterNumberValue [" + value.toString() + "]"; + } + } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java index 0bc0e075a..51ebdc8e0 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterStringValue.java @@ -61,4 +61,9 @@ public Stream toValueStream() { return Stream.of(this); } + @Override + public String toString() { + return "RosettaInterpreterStringValue [" + value + "]"; + } + } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBooleanValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBooleanValueTest.java new file mode 100644 index 000000000..6d9a07a31 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBooleanValueTest.java @@ -0,0 +1,54 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; + +public class RosettaInterpreterBooleanValueTest { + + @Test + void equalsGoodWeatherTest() { + RosettaInterpreterBooleanValue b1 = new RosettaInterpreterBooleanValue(true); + RosettaInterpreterBooleanValue b2 = new RosettaInterpreterBooleanValue(true); + + assertTrue(b1.equals(b1)); + assertTrue(b1.equals(b2)); + } + + @Test + void equalsBadWeatherTest() { + RosettaInterpreterBooleanValue b1 = new RosettaInterpreterBooleanValue(true); + RosettaInterpreterBooleanValue b2 = new RosettaInterpreterBooleanValue(false); + + assertFalse(b1.equals(b2)); + assertFalse(b1.equals(null)); + assertFalse(b1.equals(true)); + } + + @Test + void streamElementTest() { + RosettaInterpreterBooleanValue b1 = new RosettaInterpreterBooleanValue(true); + List result = new ArrayList(); + result.add(true); + + assertEquals(result, b1.toElementStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + RosettaInterpreterBooleanValue b1 = new RosettaInterpreterBooleanValue(true); + + assertEquals("RosettaInterpreterBooleanValue [value=true]", b1.toString()); + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnvironmentTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnvironmentTest.java new file mode 100644 index 000000000..f5519cdb5 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnvironmentTest.java @@ -0,0 +1,32 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; + +public class RosettaInterpreterEnvironmentTest { + + @Test + void replaceValueTest() { + Map map = new HashMap<>(); + map.put("a", new RosettaInterpreterNumberValue(2)); + + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(map); + + env.addValue("a", new RosettaInterpreterNumberValue(3)); + + Map updatedMap = new HashMap<>(); + updatedMap.put("a", new RosettaInterpreterNumberValue(3)); + + assertEquals(updatedMap, env.getEnvironment()); + + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java new file mode 100644 index 000000000..fdd709ea2 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java @@ -0,0 +1,49 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; + +public class RosettaInterpreterErrorTest { + + @Test + void hashTest() { + RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e2 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e3 = new RosettaInterpreterError("error3"); + + assertEquals(e1.hashCode(), e2.hashCode()); + assertNotEquals(e1.hashCode(), e3.hashCode()); + } + + @Test + void equalsGoodWeatherTest() { + RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e2 = new RosettaInterpreterError("error1"); + + assertTrue(e1.equals(e1)); + assertTrue(e1.equals(e2)); + } + + @Test + void equalsBadWeatherTest() { + RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e2 = new RosettaInterpreterError("error2"); + + assertFalse(e1.equals(e2)); + assertFalse(e1.equals(null)); + assertFalse(e1.equals("notAnError")); + } + + @Test + void toStringTest() { + RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); + + assertEquals("RosettaInterpreterError [errorMessage=error1]", e1.toString()); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index b58452b26..ae3f3f1a5 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -6,12 +6,15 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseError; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -30,6 +33,10 @@ class RosettaInterpreterErrorValueTest { RosettaInterpreterBooleanValue vb1; List vals; + RosettaInterpreterBaseError b1; + RosettaInterpreterBaseError b2; + List baseErr; + @BeforeEach void setup() { e1 = new RosettaInterpreterError("e1"); @@ -42,6 +49,10 @@ void setup() { vb1 = new RosettaInterpreterBooleanValue(true); vb2 = new RosettaInterpreterBooleanValue(false); vals = new ArrayList<>(List.of(v1,v2,v3,vb1,vb2)); + + b1 = new RosettaInterpreterError("b1"); + b2 = new RosettaInterpreterError("b2"); + baseErr = new ArrayList<>(List.of(b1,b2)); } @Test @@ -118,4 +129,33 @@ void testMergeRosettaInterpreterValueRosettaInterpreterValue() { assertEquals(val, RosettaInterpreterErrorValue.merge(v2, v3)); } + @Test + void hashTest() { + RosettaInterpreterErrorValue err1 = new RosettaInterpreterErrorValue(baseErr); + RosettaInterpreterErrorValue err2 = new RosettaInterpreterErrorValue(baseErr); + + assertEquals(err1.hashCode(), err2.hashCode()); + } + + @Test + void toStringTest() { + assertEquals( + "RosettaInterpreterErrorValue [errors=[RosettaInterpreterError [errorMessage=e1]]]", + v1.toString()); + } + + @Test + void streamElementTest() { + List result = new ArrayList(); + result.add(e1); + + assertEquals(result, v1.toElementStream().collect(Collectors.toList()).get(0)); + } + + @Test + void equalsBadWeatherTest() { + assertFalse(v1.equals(null)); + assertFalse(v1.equals("error")); + } + } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterListValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterListValueTest.java new file mode 100644 index 000000000..53bc2e0cb --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterListValueTest.java @@ -0,0 +1,98 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; + +public class RosettaInterpreterListValueTest { + + @Test + void hashTest() { + RosettaInterpreterListValue l1 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + RosettaInterpreterListValue l2 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + RosettaInterpreterListValue l3 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)))); + + assertEquals(l1.hashCode(), l2.hashCode()); + assertNotEquals(l1.hashCode(), l3.hashCode()); + + } + + @Test + void equalsGoodWeatherTest() { + RosettaInterpreterListValue l1 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + RosettaInterpreterListValue l2 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + + assertTrue(l1.equals(l1)); + assertTrue(l1.equals(l2)); + + } + + @Test + void equalsBadWeatherTest() { + RosettaInterpreterListValue l1 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + RosettaInterpreterListValue l2 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)))); + + assertFalse(l1.equals(l2)); + assertFalse(l1.equals(null)); + assertFalse(l1.equals("hey")); + } + + @Test + void toStringTest() { + RosettaInterpreterListValue l1 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + + assertEquals("RosettaInterpreterListValue " + + "[expressions=[RosettaInterpreterNumberValue [1], " + + "RosettaInterpreterNumberValue [2]]]", + l1.toString()); + } + + @Test + void streamElementTest() { + RosettaInterpreterListValue l1 = + new RosettaInterpreterListValue(List.of( + new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)), + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)))); + + List result = new ArrayList(); + result.add(new RosettaInterpreterNumberValue(BigDecimal.valueOf(1))); + result.add(new RosettaInterpreterNumberValue(BigDecimal.valueOf(2))); + + assertEquals(result, l1.toElementStream().collect(Collectors.toList())); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterNumberValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterNumberValueTest.java new file mode 100644 index 000000000..671d5a427 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterNumberValueTest.java @@ -0,0 +1,39 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; + +public class RosettaInterpreterNumberValueTest { + + @Test + void equalsTest() { + RosettaInterpreterNumberValue n1 = new RosettaInterpreterNumberValue(1); + RosettaInterpreterNumberValue n2 = new RosettaInterpreterNumberValue(2); + + + assertTrue(n1.equals(n1)); + assertFalse(n1.equals(n2)); + assertFalse(n1.equals(null)); + assertFalse(n1.equals(3)); + } + + @Test + void streamElementTest() { + RosettaInterpreterNumberValue n1 = new RosettaInterpreterNumberValue(2); + List result = new ArrayList(); + result.add(new RosettaInterpreterNumberValue(BigDecimal.valueOf(2)).getValue()); + + assertEquals(result, n1.toElementStream().collect(Collectors.toList())); + } + +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterStringValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterStringValueTest.java new file mode 100644 index 000000000..7be189f21 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterStringValueTest.java @@ -0,0 +1,88 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; + +public class RosettaInterpreterStringValueTest { + + @Test + void hashTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("string1"); + RosettaInterpreterStringValue s2 = new RosettaInterpreterStringValue("string1"); + RosettaInterpreterStringValue s3 = new RosettaInterpreterStringValue("string2"); + + assertEquals(s1.hashCode(), s2.hashCode()); + assertNotEquals(s1.hashCode(), s3.hashCode()); + } + + @Test + void getValueTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("string1"); + + assertEquals("string1", s1.getValue()); + } + + @Test + void equalsTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("string1"); + RosettaInterpreterStringValue s2 = new RosettaInterpreterStringValue("string1"); + + assertTrue(s1.equals(s2)); + assertTrue(s1.equals(s1)); + } + + @Test + void equalsBadWeatherTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("string1"); + RosettaInterpreterStringValue s2 = new RosettaInterpreterStringValue("string2"); + + + assertFalse(s1.equals(s2)); + assertFalse(s1.equals(null)); + assertFalse(s1.equals("notString")); + } + + + @Test + void compareToTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("a"); + RosettaInterpreterStringValue s2 = new RosettaInterpreterStringValue("a"); + RosettaInterpreterStringValue s3 = new RosettaInterpreterStringValue("c"); + + assertEquals(0, s1.compareTo(s2)); + assertEquals(-1, s1.compareTo(s3)); + assertEquals(1, s3.compareTo(s2)); + } + + @Test + void streamElementTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("a"); + + assertEquals(List.of("a"), s1.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("a"); + List stream = Stream.of(s1).collect(Collectors.toList()); + assertEquals(stream, s1.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + RosettaInterpreterStringValue s1 = new RosettaInterpreterStringValue("a"); + + assertEquals("RosettaInterpreterStringValue [a]", s1.toString()); + } + +} From 52a659a747e165a591ff668d11fa9f87ae1bdb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 6 Jun 2024 14:55:39 +0300 Subject: [PATCH 159/236] Added hash/equals/to-string methods --- .../RosettaInterpreterDateTimeValue.java | 27 ++++++++++++++ .../values/RosettaInterpreterTimeValue.java | 36 ++++++++++++------- .../RosettaInterpreterZonedDateTimeValue.java | 28 +++++++++++++++ 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java index 5e8717b65..8b8a3c99a 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateTimeValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; import java.util.stream.Stream; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -16,6 +17,7 @@ public class RosettaInterpreterDateTimeValue extends RosettaInterpreterBaseValue * @param time time value */ public RosettaInterpreterDateTimeValue(RosettaInterpreterDateValue date, RosettaInterpreterTimeValue time) { + super(); this.date = date; this.time = time; } @@ -28,6 +30,31 @@ public RosettaInterpreterTimeValue getTime() { return time; } + @Override + public int hashCode() { + return Objects.hash(date, time); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterDateTimeValue other = (RosettaInterpreterDateTimeValue) obj; + return Objects.equals(date, other.date) && Objects.equals(time, other.time); + } + + @Override + public String toString() { + return "RosettaInterpreterDateTimeValue [date=" + date + ", time=" + time + "]"; + } + @Override public Stream toElementStream() { return Stream.of(date, time); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java index 503df0ee6..2857a4478 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; import java.util.stream.Stream; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -39,22 +40,27 @@ public RosettaInterpreterNumberValue getSeconds() { return seconds; } - - public void setHours(RosettaInterpreterNumberValue hours) { - this.hours = hours; - } - - - public void setMinutes(RosettaInterpreterNumberValue minutes) { - this.minutes = minutes; + @Override + public int hashCode() { + return Objects.hash(hours, minutes, seconds); } - - public void setSeconds(RosettaInterpreterNumberValue seconds) { - this.seconds = seconds; + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterTimeValue other = (RosettaInterpreterTimeValue) obj; + return Objects.equals(hours, other.hours) && Objects.equals(minutes, other.minutes) + && Objects.equals(seconds, other.seconds); } - @Override public Stream toElementStream() { return Stream.of(hours, minutes, seconds); @@ -64,4 +70,10 @@ public Stream toElementStream() { public Stream toValueStream() { return Stream.of(this); } + + @Override + public String toString() { + return "RosettaInterpreterTimeValue [hours=" + hours + + ", minutes=" + minutes + ", seconds=" + seconds + "]"; + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java index 600562e87..a38f9797b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterZonedDateTimeValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.Objects; import java.util.stream.Stream; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -37,6 +38,27 @@ public RosettaInterpreterStringValue getTimeZone() { return timeZone; } + @Override + public int hashCode() { + return Objects.hash(date, time, timeZone); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterZonedDateTimeValue other = (RosettaInterpreterZonedDateTimeValue) obj; + return Objects.equals(date, other.date) && Objects.equals(time, other.time) + && Objects.equals(timeZone, other.timeZone); + } + @Override public Stream toElementStream() { return Stream.of(date, time, timeZone); @@ -46,4 +68,10 @@ public Stream toElementStream() { public Stream toValueStream() { return Stream.of(this); } + + @Override + public String toString() { + return "RosettaInterpreterZonedDateTimeValue [date=" + date + + ", time=" + time + ", timeZone=" + timeZone + "]"; + } } From 4e021c1c33d0079925cb9390ecf0291f49409c91 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 6 Jun 2024 19:26:14 +0200 Subject: [PATCH 160/236] Increased coverage even more and removed unreachable branches --- ...rpreterComparisonOperationInterpreter.java | 28 ++---- .../RosettaInterpreterComparisonTest.java | 92 ++++++++++++++++++- .../RosettaInterpreterBaseValueTest.java | 26 ++++++ .../RosettaInterpreterErrorValueTest.java | 11 +++ 4 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBaseValueTest.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 55402a9cf..44d6ad5a9 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -82,25 +82,19 @@ else if (RosettaInterpreterErrorValue.errorsExist(rightValue)) { } //check cardinality operation - switch (expr.getCardMod()) { - case NONE: - //normally compare left and right side. - boolean result = checkComparableTypes(leftValue, - rightValue, - expr.getOperator()); - return new RosettaInterpreterBooleanValue(result); - + switch (expr.getCardMod()) { case ANY: return compareAny(leftValue, rightValue, expr.getOperator()); case ALL: return compareAll(leftValue, rightValue, expr.getOperator()); - default: - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "cardinality modifier " + expr.getCardMod() - + " not supported")); + default: //case NONE + //normally compare left and right side. + boolean result = checkComparableTypes(leftValue, + rightValue, + expr.getOperator()); + return new RosettaInterpreterBooleanValue(result); } } @@ -235,20 +229,18 @@ private boolean compareComparableValues(int comparisonResult, String operator) { return false; } switch (operator) { - case "=": - return comparisonResult == 0; case "<>": return comparisonResult != 0; case "<": return comparisonResult == -1; case "<=": - return comparisonResult == -1 || comparisonResult == 0; + return comparisonResult <= 0; case ">": return comparisonResult == 1; case ">=": - return comparisonResult == 1 || comparisonResult == 0; + return comparisonResult >= 0; default: - return false; //should never happen + return comparisonResult == 0; //case "=" } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index ac5c9576c..fd67e6824 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -15,7 +15,11 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.expression.CardinalityModifier; +import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.LogicalOperation; +import com.regnosys.rosetta.rosetta.expression.RosettaBooleanLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -33,6 +37,17 @@ public class RosettaInterpreterComparisonTest { @SuppressWarnings("unused") private ExpressionFactory exFactory; + private ComparisonOperation createComparisonOperation( + String operator, RosettaExpression left, RosettaExpression right, CardinalityModifier cardMod) { + ComparisonOperation operation = exFactory.createComparisonOperation(); + operation.setOperator(operator); + operation.setLeft(left); + operation.setRight(right); + operation.setCardMod(cardMod); + return operation; + } + + @BeforeEach public void setup() { exFactory = ExpressionFactoryImpl.init(); @@ -46,12 +61,19 @@ public void nestedTest() { } @Test - public void intSmallerTest() { + public void intSmallerTrueTest() { RosettaExpression expr = parser.parseExpression("1 < 2"); RosettaInterpreterValue val = interpreter.interp(expr); assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test + public void intSmallerFalseTest() { + RosettaExpression expr = parser.parseExpression("2 < 1"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + @Test public void stringBiggerTest() { RosettaExpression expr = parser.parseExpression("\"bro\" > \"dude\""); @@ -59,6 +81,7 @@ public void stringBiggerTest() { assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test public void booleanLessEqualTest() { RosettaExpression expr = parser.parseExpression("False <= False"); @@ -66,6 +89,20 @@ public void booleanLessEqualTest() { assertTrue(((RosettaInterpreterBooleanValue)val).getValue()); } + @Test + public void numberLessEqualTest() { + RosettaExpression expr = parser.parseExpression("2 <= 1"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + + @Test + public void numberMoreEqualTest() { + RosettaExpression expr = parser.parseExpression("1 >= 2"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertFalse(((RosettaInterpreterBooleanValue)val).getValue()); + } + @Test public void cardinalityAllListsTest() { RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( @@ -123,4 +160,57 @@ public void errorThrownAllElementsTest() { .getError())); } + @Test + void badOperatorTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "operator not suppported")); + + RosettaBooleanLiteral ex = exFactory.createRosettaBooleanLiteral(); + ex.setValue(true); + RosettaExpression expr = createComparisonOperation("><", ex,ex, CardinalityModifier.NONE); + + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; + + assertEquals(((RosettaInterpreterError)expectedError.getErrors().get(0)).getError(), + (((RosettaInterpreterError)(errorVal.getErrors().get(0))) + .getError())); + + } + + @Test + void wrongListLengthAnyTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ANY\" keyword " + + "to compare two elements")); + RosettaExpression expr = parser.parseExpression("[1] any < 3"); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; + assertEquals(expectedError.getErrors(), + (errorVal.getErrors())); + + assertEquals(((RosettaInterpreterError)expectedError.getErrors().get(0)).getError(), + (((RosettaInterpreterError)(errorVal.getErrors().get(0))) + .getError())); + } + + @Test + void wrongListLengthAllTest() { + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "cannot use \"ALL\" keyword " + + "to compare two elements")); + RosettaExpression expr = parser.parseExpression("[1] all <= 3"); + RosettaInterpreterValue val = interpreter.interp(expr); + RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; + assertEquals(expectedError.getErrors(), + (errorVal.getErrors())); + + assertEquals(((RosettaInterpreterError)expectedError.getErrors().get(0)).getError(), + (((RosettaInterpreterError)(errorVal.getErrors().get(0))) + .getError())); + } + } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBaseValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBaseValueTest.java new file mode 100644 index 000000000..db919f478 --- /dev/null +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterBaseValueTest.java @@ -0,0 +1,26 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterBaseValueTest { + + @Test + void elementStreamTest() { + RosettaInterpreterValue val = new RosettaInterpreterNumberValue(4); + List result = new ArrayList(); + result.add(new RosettaInterpreterNumberValue(BigDecimal.valueOf(4)).getValue()); + + assertEquals(result, RosettaInterpreterBaseValue.elementStream(val).collect(Collectors.toList())); + } +} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index ae3f3f1a5..757a6e6a0 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -128,6 +128,17 @@ void testMergeRosettaInterpreterValueRosettaInterpreterValue() { assertEquals(val, RosettaInterpreterErrorValue.merge(v2, v3)); } + + @Test + void mergeBadWeatherTest() { + List list = new ArrayList<>(); + list.add(vb1); + list.add(vb2); + + assertThrows(IllegalArgumentException.class, () -> { + RosettaInterpreterErrorValue.merge(list); + }); + } @Test void hashTest() { From 691a95ca4fe1a74c237f1400452075efb6258fc1 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 7 Jun 2024 08:32:57 +0200 Subject: [PATCH 161/236] Reolved Antonio's comments --- rosetta-lang/model/Rosetta.xcore | 1 - .../values/RosettaInterpreterEnumValue.java | 33 +++++++++---------- ...ettaInterpreterFeatureCallInterpreter.java | 3 -- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 0c7b6d8aa..ab9348e6a 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -13,7 +13,6 @@ import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression -//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java index 606d6387a..9a7929d7c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java @@ -23,29 +23,32 @@ public RosettaInterpreterEnumValue(String name, List va this.values = values; } - @Override - public int hashCode() { - return Objects.hash(values); - } - - @Override - public String toString() { - return "RosettaInterpreterListValue [name = " + name + ", values=" + values.toString() + "]"; - } - /** * Method that checks that the enum contains a certain value. * * @param name Name of the value that the enum should contain */ public boolean containsValueName(String name) { - boolean ok = false; for (RosettaInterpreterValue v : values) { if (((RosettaInterpreterEnumElementValue) v).getValue().equals(name)) { - ok = true; + return true; } } - return ok; + return false; + } + + public List getValues() { return values; } + + public String getName() { return name; } + + @Override + public int hashCode() { + return Objects.hash(values); + } + + @Override + public String toString() { + return "RosettaInterpreterListValue [name = " + name + ", values=" + values.toString() + "]"; } @Override @@ -63,10 +66,6 @@ public boolean equals(Object obj) { return Objects.equals(values, other.values) && Objects.equals(name, other.name); } - public List getValues() { return values; } - - public String getName() { return name; } - @Override public Stream toElementStream() { return Stream.of(values.toArray()); diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java index f7f33b4ac..7906f77e1 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java @@ -1,10 +1,7 @@ package com.regnosys.rosetta.interpreternew.visitors; -//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; -//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.rosetta.RosettaEnumValue; import com.regnosys.rosetta.rosetta.RosettaEnumeration; import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; From 4aaf355d63d982dd3ba8f292188b965868d115b7 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 7 Jun 2024 08:46:37 +0200 Subject: [PATCH 162/236] Added some extra comments --- .../visitors/RosettaInterpreterVariableInterpreter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 58ad01d9c..9fe294bac 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -176,6 +176,7 @@ public RosettaInterpreterValue interp(FunctionImpl func, List int upperLimit = f.getOutput().getCard().isUnbounded() ? Integer.MAX_VALUE : f.getOutput().getCard().getSup(); int lowerLimit = f.getOutput().getCard().getInf(); + //make the result a single element or a list depending on its stated cardinality if (upperLimit == 1 && lowerLimit == 1) { result = (RosettaInterpreterBaseValue) resultList.get(0); } else { @@ -205,7 +206,7 @@ public RosettaInterpreterValue interp(FunctionImpl func, List } - //if post-conditions pass, return the result + //if everything went well, return the result return result; } From 3a0926eb754bf2b12774a449bd8de5e5707c3803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 7 Jun 2024 11:51:44 +0300 Subject: [PATCH 163/236] Removed unused imports --- rosetta-lang/model/Rosetta.xcore | 4 ---- .../rosetta/interpreternew/RosettaInterpreterVisitor.java | 1 - 2 files changed, 5 deletions(-) diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 20e7dcab0..8fe318272 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -11,10 +11,6 @@ import com.regnosys.rosetta.rosetta.simple.Data import com.regnosys.rosetta.rosetta.simple.Attribute import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue -import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor - -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment class RosettaModel extends RosettaDefinable { String name diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 4d342e576..a8ff49583 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -3,7 +3,6 @@ import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; -import com.regnosys.rosetta.rosetta.RosettaRecordType; import com.regnosys.rosetta.rosetta.expression.ReverseOperation; import com.regnosys.rosetta.rosetta.expression.ComparisonOperation; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; From 6c370c14fded6503d55b004edf814e3b5d043c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 7 Jun 2024 12:11:47 +0300 Subject: [PATCH 164/236] Added error handling --- ...RosettaConstructorExpressionInterpreter.java | 5 ++++- ...nterpreterRosettaFeatureCallInterpreter.java | 17 ++++++++++++++--- .../RosettaInterpreterFeatureCallTest.java | 16 ++++++++++++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 132fbf42d..cb7c4865c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -5,6 +5,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -77,6 +79,7 @@ public RosettaInterpreterBaseValue interp( } } - return null; + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expressions: constructor doesn't exist.")); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index c2c2c369f..f533a9e03 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -1,8 +1,12 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.List; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -49,9 +53,16 @@ public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpr return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); } - } else { - // add implementation for data types and error handling + } else if (RosettaInterpreterErrorValue.errorsExist(receiverValue)) { + RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) receiverValue; + RosettaInterpreterErrorValue newExpError = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Feature calls: the " + + "receiver is an error value.")); + + return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); } - return null; + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Feature calls: receiver doesn't exist.")); } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index f2fbeed93..7ffa06803 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -46,8 +46,10 @@ public class RosettaInterpreterFeatureCallTest { RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); - RosettaInterpreterErrorValue error = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Feature call: feature not found.")); + RosettaInterpreterErrorValue error1 = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Feature calls: the receiver is an error value.")); + RosettaInterpreterErrorValue error2 = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "dates does not exist in the environment")); @Test public void testDateDay() { @@ -150,4 +152,14 @@ public void testZonedDateTimeTime() { assertEquals(time, result); } + + @Test + public void testError() { + RosettaExpression expr = parser.parseExpression( + "dates -> day", List.of("dates date (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr); + + RosettaInterpreterErrorValue errors = RosettaInterpreterErrorValue.merge(error1, error2); + assertEquals(errors, result); + } } From 67fbb241bd92865b3d6a0ba817ea12999529c6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 7 Jun 2024 12:40:41 +0300 Subject: [PATCH 165/236] Added valid method for time value --- .../values/RosettaInterpreterTimeValue.java | 16 +++++++++ ...settaConstructorExpressionInterpreter.java | 18 ++++++++-- ...aInterpreterConstructorExpressionTest.java | 34 +++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java index 2857a4478..96faf8f1d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTimeValue.java @@ -39,6 +39,22 @@ public RosettaInterpreterNumberValue getMinutes() { public RosettaInterpreterNumberValue getSeconds() { return seconds; } + + /** + * Method to check if the time value is a valid time. + * + * @return true if it's valid, false otherwise + */ + public boolean valid() { + if (hours.getValue().intValue() > 24 || hours.getValue().intValue() < 0) { + return false; + } else if (minutes.getValue().intValue() > 59 || minutes.getValue().intValue() < 0) { + return false; + } else if (seconds.getValue().intValue() > 59 || seconds.getValue().intValue() < 0) { + return false; + } + return true; + } @Override public int hashCode() { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index cb7c4865c..599be747c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -52,9 +52,16 @@ public RosettaInterpreterBaseValue interp( if (date instanceof RosettaInterpreterDateValue && time instanceof RosettaInterpreterTimeValue) { - return new RosettaInterpreterDateTimeValue( + boolean check = ((RosettaInterpreterTimeValue) time).valid(); + + if (!check) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expressions: time isn't valid.")); + } else { + return new RosettaInterpreterDateTimeValue( ((RosettaInterpreterDateValue) date), ((RosettaInterpreterTimeValue) time)); + } } break; } @@ -66,10 +73,17 @@ public RosettaInterpreterBaseValue interp( if (date instanceof RosettaInterpreterDateValue && time instanceof RosettaInterpreterTimeValue && timeZone instanceof RosettaInterpreterStringValue) { - return new RosettaInterpreterZonedDateTimeValue( + boolean check = ((RosettaInterpreterTimeValue) time).valid(); + + if (!check) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expressions: time isn't valid.")); + } else { + return new RosettaInterpreterZonedDateTimeValue( ((RosettaInterpreterDateValue) date), ((RosettaInterpreterTimeValue) time), ((RosettaInterpreterStringValue) timeZone)); + } } break; } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index ecd3ea435..95bfdc579 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -16,6 +16,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -45,6 +47,12 @@ public class RosettaInterpreterConstructorExpressionTest { RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + RosettaInterpreterNumberValue hoursError = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue timeError = new RosettaInterpreterTimeValue(hoursError, minutes, seconds); + + RosettaInterpreterErrorValue error = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expressions: time isn't valid.")); + @Test public void testDate() { RosettaExpression expr = parser.parseExpression("date { day: 5, month: 7, year: 2024 }"); @@ -71,6 +79,19 @@ public void testDateTime() { assertEquals(time, ((RosettaInterpreterDateTimeValue) result).getTime()); } + @Test + public void testDateTimeNotValid() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", timeError); + + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 5, month: 7, year: 2024 }, time: t }", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(error, result); + } + @Test public void testZonedDateTime() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); @@ -87,4 +108,17 @@ public void testZonedDateTime() { assertEquals(time, ((RosettaInterpreterZonedDateTimeValue) result).getTime()); assertEquals("CET", ((RosettaInterpreterZonedDateTimeValue) result).getTimeZone().getValue()); } + + @Test + public void testZonedDateTimeNotValid() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", timeError); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" }", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(error, result); + } } From 8cc679b62dcb6092a0f8b3ed906f212899e5b45f Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 7 Jun 2024 12:15:11 +0200 Subject: [PATCH 166/236] Fixed the javadoc in the main interpreter --- .../interpreternew/RosettaInterpreterNew.java | 15 ++++++++++----- .../RosettaInterpreterEnumerationInterpreter.java | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index 9816642cd..110c47d16 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -22,23 +22,28 @@ public class RosettaInterpreterNew { * of the development workflow. * * @param expression the expression to be interpreted - * @return value of RosettaIntLiteral otherwise exception + * @return value of RosettaExpression otherwise exception */ public RosettaInterpreterValue interp(RosettaExpression expression) { return expression.accept(visitor, environment); } + /** + * Main interpret function to redirect the interpreter to the correct interpreter. + * + * @param expression the expression to be interpreted + * @return value of RosettaExpression otherwise exception + */ public RosettaInterpreterValue interp(RosettaExpression expression, RosettaInterpreterBaseEnvironment env) { return expression.accept(visitor, env); } /** - * Simple example interpret function to allow for better understanding - * of the development workflow. + * Main interpret function for handling enum declaration. * * @param expression the expression to be interpreted - * @return value of RosettaIntLiteral otherwise exception + * @return value of RosettaExpression otherwise exception */ public RosettaInterpreterEnvironment interp(RosettaEnumeration expression, RosettaInterpreterBaseEnvironment env) { @@ -50,7 +55,7 @@ public RosettaInterpreterEnvironment interp(RosettaEnumeration expression, /** * Simple example interpret function to allow for better understanding - * of the development workflow. + * of the development workflow. It is used in testing for simplification. * * @param expression the expression to be interpreted * @return value of RosettaIntLiteral otherwise exception diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java index 9de9f63bf..6afa8f0d4 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterEnumerationInterpreter.java @@ -18,10 +18,11 @@ public RosettaInterpreterEnumerationInterpreter() { } /** - * Interprets a list literal, evaluating it to a list value. + * Interprets the definition of an enumeration expression, + * then adds the enum value to the environment. * * @param exp the expression to be interpreted - * @return the list value it represents + * @return the new environment after adding the enum to it */ public RosettaInterpreterEnvironment interp(RosettaEnumeration exp, RosettaInterpreterEnvironment env) { From f0181a03bea5e52a74235acbdc0d77afe693f7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 7 Jun 2024 15:22:52 +0300 Subject: [PATCH 167/236] Fixed environment imports --- ...settaInterpreterRosettaConstructorExpressionInterpreter.java | 2 +- .../RosettaInterpreterRosettaFeatureCallInterpreter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 599be747c..e6efb6b9f 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -11,7 +11,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index f533a9e03..69bcb09bb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -8,7 +8,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; -import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From c2dca0e101a1172b948e46aaa65bbb5eaa8242ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 10 Jun 2024 03:07:26 +0300 Subject: [PATCH 168/236] Start of implementation --- rosetta-lang/model/Rosetta.xcore | 6 ++++++ rosetta-lang/model/RosettaInterpreter.xcore | 2 ++ .../interpreternew/RosettaInterpreterVisitor.java | 7 +++++++ .../RosettaInterpreterRosettaTypedInterpreter.java | 12 ++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 28f8fb564..0e8aee8ab 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -11,6 +11,8 @@ import com.regnosys.rosetta.rosetta.simple.Data import com.regnosys.rosetta.rosetta.simple.Attribute import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment class RosettaModel extends RosettaDefinable { String name @@ -42,6 +44,10 @@ interface RosettaTyped { derived boolean isTypeInferred get { return typeCall === null } + + op RosettaInterpreterBaseEnvironment accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class RosettaFeature extends RosettaNamed { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index dc2907612..672f86e3b 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -32,6 +32,7 @@ import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall +import com.regnosys.rosetta.rosetta.RosettaTyped class RosettaInterpreterBaseError{ String message @@ -74,6 +75,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterBaseEnvironment interp (RosettaTyped exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 784573cec..9abd0a585 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew; +import com.regnosys.rosetta.rosetta.RosettaTyped; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; @@ -230,5 +231,11 @@ public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaI public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterBaseEnvironment interp(RosettaTyped exp, RosettaInterpreterBaseEnvironment env) { + // TODO Auto-generated method stub + return null; + } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java new file mode 100644 index 000000000..248c090ed --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java @@ -0,0 +1,12 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.rosetta.RosettaTyped; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; + +public class RosettaInterpreterRosettaTypedInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseEnvironment interp(RosettaTyped expr, RosettaInterpreterEnvironment env) { + return null; + } +} From 87a10d89d8ada240d4d517e894a7329a16cae951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 10 Jun 2024 03:47:10 +0300 Subject: [PATCH 169/236] Added classes for typed and typed feature values --- .../RosettaInterpreterTypedFeatureValue.java | 71 +++++++++++++++++++ .../values/RosettaInterpreterTypedValue.java | 63 ++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java create mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java new file mode 100644 index 000000000..3c54bb78b --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java @@ -0,0 +1,71 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.RosettaCardinality; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterTypedFeatureValue extends RosettaInterpreterBaseValue { + + public String name; + public RosettaInterpreterBaseValue value; + public RosettaCardinality card; + + public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterBaseValue value, + RosettaCardinality card) { + super(); + this.name = name; + this.value = value; + this.card = card; + } + + public String getName() { + return name; + } + + public RosettaInterpreterBaseValue getValue() { + return value; + } + + public RosettaCardinality getCard() { + return card; + } + + @Override + public Stream toElementStream() { + return Stream.of(name, value, card); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } + + @Override + public int hashCode() { + return Objects.hash(card, name, value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterTypedFeatureValue other = (RosettaInterpreterTypedFeatureValue) obj; + return Objects.equals(card, other.card) && Objects.equals(name, other.name) + && Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "RosettaInterpreterTypedFeatureValue [name=" + name + ", value=" + value + ", card=" + card + "]"; + } + +} diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java new file mode 100644 index 000000000..7475d6986 --- /dev/null +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -0,0 +1,63 @@ +package com.regnosys.rosetta.interpreternew.values; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterTypedValue extends RosettaInterpreterBaseValue { + + public String name; + public List attributes; + + public RosettaInterpreterTypedValue(String name, List attributes) { + super(); + this.name = name; + this.attributes = attributes; + } + + public String getName() { + return name; + } + + public List getAttributes() { + return attributes; + } + + @Override + public Stream toElementStream() { + return Stream.of(name, attributes); + } + + @Override + public Stream toValueStream() { + return Stream.of(this); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RosettaInterpreterTypedValue other = (RosettaInterpreterTypedValue) obj; + return Objects.equals(attributes, other.attributes) && Objects.equals(name, other.name); + } + + @Override + public String toString() { + return "RosettaInterpreterTypedValue [name=" + name + ", attributes=" + attributes + "]"; + } + +} From 0825bfee58bd42d9e4dc39592e17a0340274b9a3 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Mon, 10 Jun 2024 10:31:20 +0200 Subject: [PATCH 170/236] Implemented code review suggestions --- .../values/RosettaInterpreterError.java | 16 +++++----------- ...nterpreterComparisonOperationInterpreter.java | 12 ++++++------ ...taInterpreterLogicalOperationInterpreter.java | 4 ++-- ...erRosettaArithmeticOperationsInterpreter.java | 4 ++-- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index 84b4e7212..846eabdfe 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -21,7 +21,7 @@ public class RosettaInterpreterError implements RosettaInterpreterBaseError { private String errorMessage; - private EObject associatedExpression; + private EObject associatedObject; @Override public int hashCode() { @@ -43,19 +43,14 @@ public boolean equals(Object obj) { return Objects.equals(errorMessage, other.errorMessage); } - public RosettaInterpreterError(EObject obj) { - this.associatedExpression = obj; - this.errorMessage = ""; - } - public RosettaInterpreterError(String errorMessage, EObject obj) { - this.associatedExpression = obj; + this.associatedObject = obj; this.errorMessage = errorMessage; } public String getError() { return errorMessage; } - public EObject getEobject() { return associatedExpression; } + public EObject getEobject() { return associatedObject; } /** * Gives a parsed error message associated with this error. @@ -64,11 +59,11 @@ public RosettaInterpreterError(String errorMessage, EObject obj) { * @return Error message with code information */ public String properErrorMessage() { - if (associatedExpression == null) { + if (associatedObject == null) { return errorMessage; } - INode node = NodeModelUtils.findActualNodeFor(associatedExpression); + INode node = NodeModelUtils.findActualNodeFor(associatedObject); int startLine = node.getStartLine(); int offset = node.getOffset(); String text = node.getText().trim(); @@ -80,7 +75,6 @@ public String properErrorMessage() { @Override public String toString() { return properErrorMessage(); - //return "RosettaInterpreterError [errorMessage=" + errorMessage + "]"; } @Override diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java index 48801922c..960eff4fb 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterComparisonOperationInterpreter.java @@ -111,13 +111,13 @@ else if (RosettaInterpreterErrorValue.errorsExist(rightValue)) { private RosettaInterpreterBaseValue compareAny(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, - String operator, EObject ass) { + String operator, EObject associatedObject) { //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists", ass)); + "cannot compare two lists", associatedObject)); } //list vs element case: @@ -145,18 +145,18 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ANY\" keyword " - + "to compare two elements", ass)); + + "to compare two elements", associatedObject)); } private RosettaInterpreterBaseValue compareAll(RosettaInterpreterValue leftValue, RosettaInterpreterValue rightValue, - String operator, EObject ass) { + String operator, EObject associatedObject) { //list vs list case: if (leftValue instanceof RosettaInterpreterListValue && rightValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "cannot compare two lists", ass)); + "cannot compare two lists", associatedObject)); } //list vs element case: @@ -184,7 +184,7 @@ else if (leftValue instanceof RosettaInterpreterListValue) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ALL\" keyword " - + "to compare two elements", ass)); + + "to compare two elements", associatedObject)); } private boolean checkComparableTypes(RosettaInterpreterValue leftValue, diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java index 7fc0d47a6..f1cd1bc5c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterLogicalOperationInterpreter.java @@ -76,7 +76,7 @@ public RosettaInterpreterBaseValue interp(LogicalOperation expr, */ private RosettaInterpreterErrorValue checkForErrors( RosettaInterpreterValue interpretedValue, String side, - EObject ass) { + EObject associatedObject) { if (interpretedValue instanceof RosettaInterpreterBooleanValue) { // No errors found. // I return an error value without any errors in its list, @@ -91,7 +91,7 @@ private RosettaInterpreterErrorValue checkForErrors( return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Logical Operation: " + side - + " is not of type Boolean",ass)); + + " is not of type Boolean", associatedObject)); } } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 0a9c21880..6f66cd289 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -135,7 +135,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, */ private RosettaInterpreterErrorValue checkForErrors( RosettaInterpreterValue interpretedValue, String side, - EObject ass) { + EObject associatedObject) { if (interpretedValue instanceof RosettaInterpreterNumberValue || interpretedValue instanceof RosettaInterpreterStringValue || interpretedValue instanceof RosettaInterpreterIntegerValue) { @@ -153,7 +153,7 @@ else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Arithmetic Operation: " + side - + " is not of type Number/String", ass)); + + " is not of type Number/String", associatedObject)); } } } From e9cfc81fca271d08bc47db31bd2ed42a6c535657 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Mon, 10 Jun 2024 11:17:35 +0200 Subject: [PATCH 171/236] Added hashCode and toString, as well as some JavaDoc to the Function Value class --- .../RosettaInterpreterFunctionValue.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java index 46f491c6c..849f9cefe 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java @@ -9,6 +9,12 @@ public class RosettaInterpreterFunctionValue extends RosettaInterpreterBaseValue private FunctionImpl function; + + /** + * Constructor for the function Value wrapper. + * + * @param f the function implementation to be interpreted + */ public RosettaInterpreterFunctionValue(FunctionImpl f) { super(); function = f; @@ -29,9 +35,21 @@ public boolean equals(Object obj) { return Objects.equals(function, other.function); } + @Override + public String toString() { + return "RosettaInterpreterFunctionValue [function=" + function + "]"; + } + + @Override + public int hashCode() { + return Objects.hash(function); + } + public FunctionImpl getFunction() { return function; } + + @Override public Stream toElementStream() { From 575356bd9a5f9083c9b6188eeacb97141eb9f1c1 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Mon, 10 Jun 2024 11:37:21 +0200 Subject: [PATCH 172/236] Added some commented changes that will be necessary once we have Enums and Data types implemented. --- ...RosettaInterpreterVariableInterpreter.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 9fe294bac..acb26c59d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -2,12 +2,14 @@ import java.util.ArrayList; import java.util.List; +//import java.util.Map; import java.util.stream.Collectors; import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -116,8 +118,12 @@ public RosettaInterpreterValue interp(FunctionImpl func, List return acc; } - //add all the argument/value pairs to the NEW environment + //create a copy of the enums and data types in the passed environment + //since those are the only "global" variables +// RosettaInterpreterEnvironment nv = copyDataTypesOnly(env); + //Create a new environment to use for evaluating the operations RosettaInterpreterEnvironment nv = new RosettaInterpreterEnvironment(); + //add all the argument/value pairs to the NEW environment for (int i = 0 ; i < inputSize ; i++) { AttributeImpl attr = (AttributeImpl) f.getInputs().get(i); RosettaInterpreterBaseValue value = (RosettaInterpreterBaseValue) interpretedArgs.get(i); @@ -294,5 +300,18 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue(); } + + //This will be used once enum values and data types are implemented and merged + //For now, this branch knows nothing of such "global"ly available variables +// public RosettaInterpreterEnvironment copyDataTypesOnly(RosettaInterpreterEnvironment env) { +// RosettaInterpreterEnvironment result = new RosettaInterpreterEnvironment(); +// Map environment = env.getEnvironment(); +// for (Map.Entry entry : environment.entrySet()) { +// if (entry.getValue() instanceof RosettaInterpreterEnumValue) { +// result.addValue(entry.getKey(), entry.getValue()); +// } +// } +// return result; +// } } From d8af9adc4e4e71b666aaabd8f0dcd50cb44713ea Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Mon, 10 Jun 2024 15:04:41 +0200 Subject: [PATCH 173/236] Fixed IntegerValue problems in record types --- .../values/RosettaInterpreterDateValue.java | 16 ++++++++-------- ...rRosettaConstructorExpressionInterpreter.java | 14 +++++++------- ...ettaInterpreterConstructorExpressionTest.java | 8 +++----- .../RosettaInterpreterFeatureCallTest.java | 7 +++---- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java index a1f8a6bf3..314688718 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterDateValue.java @@ -7,9 +7,9 @@ public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { - private RosettaInterpreterIntegerValue day; - private RosettaInterpreterIntegerValue month; - private RosettaInterpreterIntegerValue year; + private RosettaInterpreterNumberValue day; + private RosettaInterpreterNumberValue month; + private RosettaInterpreterNumberValue year; /** * Constructor for date value. @@ -18,23 +18,23 @@ public class RosettaInterpreterDateValue extends RosettaInterpreterBaseValue { * @param month month value * @param year year value */ - public RosettaInterpreterDateValue(RosettaInterpreterIntegerValue day, RosettaInterpreterIntegerValue month, - RosettaInterpreterIntegerValue year) { + public RosettaInterpreterDateValue(RosettaInterpreterNumberValue day, RosettaInterpreterNumberValue month, + RosettaInterpreterNumberValue year) { super(); this.day = day; this.month = month; this.year = year; } - public RosettaInterpreterIntegerValue getDay() { + public RosettaInterpreterNumberValue getDay() { return day; } - public RosettaInterpreterIntegerValue getMonth() { + public RosettaInterpreterNumberValue getMonth() { return month; } - public RosettaInterpreterIntegerValue getYear() { + public RosettaInterpreterNumberValue getYear() { return year; } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index e6efb6b9f..d51fd43a4 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -7,7 +7,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; @@ -36,13 +36,13 @@ public RosettaInterpreterBaseValue interp( RosettaInterpreterValue month = values.get(1).getValue().accept(visitor, env); RosettaInterpreterValue year = values.get(2).getValue().accept(visitor, env); - if (day instanceof RosettaInterpreterIntegerValue - && month instanceof RosettaInterpreterIntegerValue - && year instanceof RosettaInterpreterIntegerValue) { + if (day instanceof RosettaInterpreterNumberValue + && month instanceof RosettaInterpreterNumberValue + && year instanceof RosettaInterpreterNumberValue) { return new RosettaInterpreterDateValue( - ((RosettaInterpreterIntegerValue) day), - ((RosettaInterpreterIntegerValue) month), - ((RosettaInterpreterIntegerValue) year)); + ((RosettaInterpreterNumberValue) day), + ((RosettaInterpreterNumberValue) month), + ((RosettaInterpreterNumberValue) year)); } break; } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 95bfdc579..f4be66e08 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.List; import javax.inject.Inject; @@ -18,7 +17,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; @@ -37,9 +35,9 @@ public class RosettaInterpreterConstructorExpressionTest { @Inject RosettaInterpreterNew interpreter; - RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); - RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); - RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 7ffa06803..1300fd4df 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -17,7 +17,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -36,9 +35,9 @@ public class RosettaInterpreterFeatureCallTest { @Inject RosettaInterpreterNew interpreter; - RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); - RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); - RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); From f4045d53cbce964525f9213b16dbe3e903ace6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Tue, 11 Jun 2024 02:49:01 +0300 Subject: [PATCH 174/236] Added implementation for data type constructor and removed data type interp --- rosetta-lang/model/Rosetta.xcore | 5 - rosetta-lang/model/RosettaInterpreter.xcore | 5 +- .../RosettaInterpreterVisitor.java | 7 - .../RosettaInterpreterTypedFeatureValue.java | 23 ++-- ...settaConditionalExpressionInterpreter.java | 1 - ...settaConstructorExpressionInterpreter.java | 35 ++++- ...ttaInterpreterRosettaTypedInterpreter.java | 12 -- ...aInterpreterConstructorExpressionTest.java | 129 ++++++++++++++++++ 8 files changed, 170 insertions(+), 47 deletions(-) delete mode 100644 rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java diff --git a/rosetta-lang/model/Rosetta.xcore b/rosetta-lang/model/Rosetta.xcore index 0e8aee8ab..4bb350c24 100644 --- a/rosetta-lang/model/Rosetta.xcore +++ b/rosetta-lang/model/Rosetta.xcore @@ -11,8 +11,6 @@ import com.regnosys.rosetta.rosetta.simple.Data import com.regnosys.rosetta.rosetta.simple.Attribute import com.regnosys.rosetta.rosetta.simple.RosettaRuleReference import com.regnosys.rosetta.rosetta.expression.RosettaExpression -import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment class RosettaModel extends RosettaDefinable { String name @@ -45,9 +43,6 @@ interface RosettaTyped { return typeCall === null } - op RosettaInterpreterBaseEnvironment accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { - v.interp(this,nv) - } } class RosettaFeature extends RosettaNamed { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 672f86e3b..905878008 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -32,7 +32,6 @@ import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall -import com.regnosys.rosetta.rosetta.RosettaTyped class RosettaInterpreterBaseError{ String message @@ -74,8 +73,6 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) - op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) - op RosettaInterpreterBaseEnvironment interp (RosettaTyped exp, RosettaInterpreterBaseEnvironment env) - + op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 9abd0a585..784573cec 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -1,6 +1,5 @@ package com.regnosys.rosetta.interpreternew; -import com.regnosys.rosetta.rosetta.RosettaTyped; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.LogicalOperation; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; @@ -231,11 +230,5 @@ public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaI public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, env); } - - @Override - public RosettaInterpreterBaseEnvironment interp(RosettaTyped exp, RosettaInterpreterBaseEnvironment env) { - // TODO Auto-generated method stub - return null; - } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java index 3c54bb78b..f9d96a37c 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java @@ -9,32 +9,26 @@ public class RosettaInterpreterTypedFeatureValue extends RosettaInterpreterBaseValue { public String name; - public RosettaInterpreterBaseValue value; - public RosettaCardinality card; + public RosettaInterpreterValue value; + //public RosettaCardinality card; - public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterBaseValue value, - RosettaCardinality card) { + public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterValue value) { super(); this.name = name; this.value = value; - this.card = card; } public String getName() { return name; } - public RosettaInterpreterBaseValue getValue() { + public RosettaInterpreterValue getValue() { return value; } - public RosettaCardinality getCard() { - return card; - } - @Override public Stream toElementStream() { - return Stream.of(name, value, card); + return Stream.of(name, value); } @Override @@ -44,7 +38,7 @@ public Stream toValueStream() { @Override public int hashCode() { - return Objects.hash(card, name, value); + return Objects.hash(name, value); } @Override @@ -59,13 +53,12 @@ public boolean equals(Object obj) { return false; } RosettaInterpreterTypedFeatureValue other = (RosettaInterpreterTypedFeatureValue) obj; - return Objects.equals(card, other.card) && Objects.equals(name, other.name) - && Objects.equals(value, other.value); + return Objects.equals(name, other.name) && Objects.equals(value, other.value); } @Override public String toString() { - return "RosettaInterpreterTypedFeatureValue [name=" + name + ", value=" + value + ", card=" + card + "]"; + return "RosettaInterpreterTypedFeatureValue [name=" + name + ", value=" + value + "]"; } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index b0ea65d20..954c1755d 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index e6efb6b9f..7148d5f9b 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -1,5 +1,8 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.emf.common.util.EList; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; @@ -10,6 +13,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; @@ -88,12 +93,36 @@ public RosettaInterpreterBaseValue interp( break; } default: { - // needed for data types - break; + // check that the data type is defined before, if not return error + List attributes = new ArrayList<>(); + + for (ConstructorKeyValuePair pair : values) { + String name = pair.getKey().getName(); + RosettaInterpreterValue value = pair.getValue().accept(visitor, env); + + if (RosettaInterpreterErrorValue.errorsExist(value)) { + RosettaInterpreterErrorValue expError = + (RosettaInterpreterErrorValue) value; + RosettaInterpreterErrorValue newExpError = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Constructor Expression" + + ": the attribute \"" + + name + "\" is an " + + "error value.")); + + return RosettaInterpreterErrorValue.merge( + List.of(newExpError, expError)); + } + + attributes.add(new RosettaInterpreterTypedFeatureValue(name, value)); + } + + return new RosettaInterpreterTypedValue(typeCall, attributes); } } return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: constructor doesn't exist.")); + "Constructor Expressions: attribute type is not valid.")); } } diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java deleted file mode 100644 index 248c090ed..000000000 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaTypedInterpreter.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.regnosys.rosetta.interpreternew.visitors; - -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.rosetta.RosettaTyped; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; - -public class RosettaInterpreterRosettaTypedInterpreter extends RosettaInterpreterConcreteInterpreter { - - public RosettaInterpreterBaseEnvironment interp(RosettaTyped expr, RosettaInterpreterEnvironment env) { - return null; - } -} diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 95bfdc579..80f8a19e8 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -20,12 +20,20 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterIntegerValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -37,6 +45,9 @@ public class RosettaInterpreterConstructorExpressionTest { @Inject RosettaInterpreterNew interpreter; + @Inject + ModelHelper mh; + RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); @@ -52,6 +63,8 @@ public class RosettaInterpreterConstructorExpressionTest { RosettaInterpreterErrorValue error = new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Constructor Expressions: time isn't valid.")); + RosettaInterpreterErrorValue errorAtt = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expressions: attribute type is not valid.")); @Test public void testDate() { @@ -63,6 +76,30 @@ public void testDate() { assertEquals(year, ((RosettaInterpreterDateValue) result).getYear()); } + @Test + public void testDateNotValidDay() { + RosettaExpression expr = parser.parseExpression("date { day: \"F\", month: 7, year: 2024 }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(errorAtt, result); + } + + @Test + public void testDateNotValidMonth() { + RosettaExpression expr = parser.parseExpression("date { day: 3, month: True, year: 2024 }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(errorAtt, result); + } + + @Test + public void testDateNotValidYear() { + RosettaExpression expr = parser.parseExpression("date { day: 3, month: 7, year: [1, 2] }"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(errorAtt, result); + } + @Test public void testDateTime() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); @@ -92,6 +129,32 @@ public void testDateTimeNotValid() { assertEquals(error, result); } + @Test + public void testDateTimeNotValidDate() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: \"F\", month: 7, year: 2024 }, time: t }", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(errorAtt, result); + } + + @Test + public void testDateTimeNotValidTime() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", day); + + RosettaExpression expr = parser.parseExpression( + "dateTime { date: date { day: 3, month: 7, year: 2024 }, time: t }", + List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(errorAtt, result); + } + @Test public void testZonedDateTime() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); @@ -121,4 +184,70 @@ public void testZonedDateTimeNotValid() { assertEquals(error, result); } + + @Test + public void testZonedDateTimeNotValidDate() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: True, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" }", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(errorAtt, result); + } + + @Test + public void testZonedDateTimeNotValidTime() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", month); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: \"CET\" }", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(errorAtt, result); + } + + @Test + public void testZonedDateTimeNotValidZone() { + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("t", time); + + RosettaExpression expr = parser.parseExpression( + "zonedDateTime { date: date { day: 5, month: 7, year: 2024 }" + + ", time: t, timezone: 56 }", List.of("t time (1..1)")); + RosettaInterpreterValue result = interpreter.interp(expr, env); + + assertEquals(errorAtt, result); + } + + @Test + public void testDataType() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "func M: output: result Person (1..1) set result: Person { name: \"F\" }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Person", result.getName()); + assertEquals("name", result.getAttributes().get(0).getName()); + assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) + .getValue()); + } + +// @Test +// public void testDataTypeError() { +// RosettaModel model = mh.parseRosettaWithNoErrors("type Test: value boolean (1..1) " +// + "func M: output: result Test (1..1) set result: Test { value: 1 and True }"); +// +// RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( +// FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); +// RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); +// +// assertEquals(error, result); +// } } From 2eb117797a2c26db2f69a79225429af8566a9595 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Tue, 11 Jun 2024 15:20:56 +0200 Subject: [PATCH 175/236] Fix checkstyle --- ...settaInterpreterRosettaArithmeticOperationsInterpreter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 1b7fdcf01..57013b0f4 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -79,7 +78,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, .multiply(rightNumber)).bigDecimalValue()); } else { // Division by 0 is not allowed - if(rightNumber.floatValue() == 0.0) { + if (rightNumber.floatValue() == 0.0) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Division by 0 is not allowed")); From 4a8e7c8573a3dbe05ed967e80bd824470533aa36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 12 Jun 2024 04:06:19 +0300 Subject: [PATCH 176/236] Added feature call implementation --- .../values/RosettaInterpreterTypedValue.java | 11 +++++++ ...erpreterRosettaFeatureCallInterpreter.java | 15 ++++++++++ ...aInterpreterConstructorExpressionTest.java | 29 ++++++++++--------- .../RosettaInterpreterFeatureCallTest.java | 19 ++++++++++++ 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java index 7475d6986..27b647d19 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -1,5 +1,6 @@ package com.regnosys.rosetta.interpreternew.values; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Stream; @@ -24,6 +25,16 @@ public String getName() { public List getAttributes() { return attributes; } + + public List getAttributesNames() { + List names = new ArrayList<>(); + + for (RosettaInterpreterTypedFeatureValue att : attributes) { + names.add(att.getName()); + } + + return names; + } @Override public Stream toElementStream() { diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index 69bcb09bb..367fedcff 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -7,6 +7,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; @@ -61,7 +63,20 @@ public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpr + "receiver is an error value.")); return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); + } else { + List attributes = ((RosettaInterpreterTypedValue) + receiverValue).getAttributes(); + + for (RosettaInterpreterTypedFeatureValue att : attributes) { + if (att.getName().equals(feature)) { + return (RosettaInterpreterBaseValue) (( + RosettaInterpreterTypedFeatureValue) att).getValue(); + } + } + } + + // statement never reached return new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Feature calls: receiver doesn't exist.")); } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 80f8a19e8..1fbfb55e3 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -28,8 +28,6 @@ import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; -import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; @@ -239,15 +237,20 @@ public void testDataType() { .getValue()); } -// @Test -// public void testDataTypeError() { -// RosettaModel model = mh.parseRosettaWithNoErrors("type Test: value boolean (1..1) " -// + "func M: output: result Test (1..1) set result: Test { value: 1 and True }"); -// -// RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( -// FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); -// RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); -// -// assertEquals(error, result); -// } + @Test + public void testDataTypeError() { + RosettaModel model = mh.parseRosetta("type Test: value boolean (1..1) " + + "func M: output: result Test (1..1) set result: Test { value: 1 and True }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue errorBool = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Logical Operation: Leftside is not of type Boolean")); + RosettaInterpreterErrorValue errorValue = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Constructor Expression: the attribute \"value\" is an error value.")); + + assertEquals(RosettaInterpreterErrorValue.merge(errorValue, errorBool), result); + } } diff --git a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 7ffa06803..de489abf4 100644 --- a/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -21,10 +21,14 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -36,6 +40,9 @@ public class RosettaInterpreterFeatureCallTest { @Inject RosettaInterpreterNew interpreter; + @Inject + ModelHelper mh; + RosettaInterpreterIntegerValue day = new RosettaInterpreterIntegerValue(BigInteger.valueOf(5)); RosettaInterpreterIntegerValue month = new RosettaInterpreterIntegerValue(BigInteger.valueOf(7)); RosettaInterpreterIntegerValue year = new RosettaInterpreterIntegerValue(BigInteger.valueOf(2024)); @@ -162,4 +169,16 @@ public void testError() { RosettaInterpreterErrorValue errors = RosettaInterpreterErrorValue.merge(error1, error2); assertEquals(errors, result); } + + @Test + public void testDataType() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "func M: output: result string (1..1) set result: Person { name: \"F\" } -> name"); + + RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) + model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(featureCall); + + assertEquals("F", ((RosettaInterpreterStringValue) result).getValue()); + } } From 3352ba818a0c900b2f8abb93133a0e57da8f4c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 12 Jun 2024 04:14:14 +0300 Subject: [PATCH 177/236] Removed unused method --- .../values/RosettaInterpreterTypedValue.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java index 27b647d19..fe0942cb3 100644 --- a/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java +++ b/rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -25,16 +25,6 @@ public String getName() { public List getAttributes() { return attributes; } - - public List getAttributesNames() { - List names = new ArrayList<>(); - - for (RosettaInterpreterTypedFeatureValue att : attributes) { - names.add(att.getName()); - } - - return names; - } @Override public Stream toElementStream() { From 2f8dded5537bef358ea52717976790981e987e60 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 10:15:27 +0200 Subject: [PATCH 178/236] Fixed all conflicts --- rosetta-interpreter/checkstyle-SP.xml | 443 ++++++++++-------- rosetta-interpreter/pom.xml | 238 +++++----- .../RosettaInterpreterVisitor.java | 6 +- ...erpreterRosettaFeatureCallInterpreter.java | 57 ++- 4 files changed, 425 insertions(+), 319 deletions(-) diff --git a/rosetta-interpreter/checkstyle-SP.xml b/rosetta-interpreter/checkstyle-SP.xml index 1926d3b5a..c6c5c02a8 100644 --- a/rosetta-interpreter/checkstyle-SP.xml +++ b/rosetta-interpreter/checkstyle-SP.xml @@ -2,210 +2,253 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rosetta-interpreter/pom.xml b/rosetta-interpreter/pom.xml index 84ed8886b..aaa7679d2 100644 --- a/rosetta-interpreter/pom.xml +++ b/rosetta-interpreter/pom.xml @@ -1,124 +1,130 @@ - - 4.0.0 - - com.regnosys.rosetta.parent - com.regnosys.rosetta - 0.0.0.main-SNAPSHOT - + + 4.0.0 + + com.regnosys.rosetta.parent + com.regnosys.rosetta + 0.0.0.main-SNAPSHOT + - com.regnosys.rosetta.interpreternew - + com.regnosys.rosetta.interpreternew - Rosetta DSL Delft Interpreter Project - - UTF-8 - 1.7 - 1.7 - 3.3.1 - checkstyle-SP.xml - + Rosetta DSL Delft Interpreter Project - - - junit - junit - test - - - - - com.regnosys.rosetta - com.regnosys.rosetta.lib - ${project.version} - + + UTF-8 + 1.7 + 1.7 + 3.3.1 + checkstyle-SP.xml + - - com.regnosys.rosetta - com.regnosys.rosetta - ${project.version} - - - com.regnosys.rosetta - com.regnosys.rosetta.tests - ${project.version} - - + + + junit + junit + test + - - - - - - maven-clean-plugin - 3.1.0 - - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - org.jacoco - jacoco-maven-plugin - - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - checkstyle-SP.xml - true - true - warning - true - - src/main/java - src/test/java - - - - - - + + + com.regnosys.rosetta + com.regnosys.rosetta.lib + ${project.version} + + + + com.regnosys.rosetta + com.regnosys.rosetta + ${project.version} + + + com.regnosys.rosetta + com.regnosys.rosetta.tests + ${project.version} + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + org.jacoco + jacoco-maven-plugin + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + checkstyle-SP.xml + true + true + warning + true + + src/main/java + src/test/java + + + + + + diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5bd6ff39a..598875ac7 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -39,7 +39,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEnumerationInterpreter; -import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterFeatureCallInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListOperationsInterpreter; @@ -238,6 +237,9 @@ public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaI @Override public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { - return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, env); + return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); + + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index 69bcb09bb..df7a44d7f 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -5,16 +5,71 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.RosettaEnumValue; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; +import com.regnosys.rosetta.rosetta.impl.RosettaEnumValueImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInterpreterConcreteInterpreter { + + + + /** + * Based on what class the symbol reference belongs to, it chooses what method to send it to. + * + * @param expr The RosettaFeatureCall expression to redirect + * @param env The Environment + * @return If no errors are encountered, a RosettaInterpreterNumberValue or + * RosettaInterpreterStringValue representing + * the result of the arithmetic/concatenation operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(RosettaFeatureCall expr, + RosettaInterpreterEnvironment env) { + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) expr.getReceiver(); + RosettaEnumValue enumVal; + if(expr.getFeature() instanceof RosettaEnumValueImpl) { + enumVal = (RosettaEnumValueImpl) expr.getFeature(); + RosettaEnumeration enumeration = (RosettaEnumeration) ref.getSymbol(); + return interpEnum(enumeration, enumVal, env); + } + else { + return interpRecord(expr, env); + } + + } + + /** + * Interprets an enum feature call. + * + * @param enumeration The RosettaEnumeration to interpret alongside + * @param val The enum value to interpret + * @param env The Environment + * @return If no errors are encountered, a RosettaInterpreterNumberValue or + * RosettaInterpreterStringValue representing + * the result of the arithmetic/concatenation operation. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, RosettaEnumValue val, + RosettaInterpreterEnvironment env) { + + return new RosettaInterpreterEnumElementValue(val.getEnumeration().getName(), + val.getName()); + } + + /** * Interpreter method for Feature Calls. * @@ -22,7 +77,7 @@ public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInte * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterBaseValue interpRecord(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression receiver = exp.getReceiver(); RosettaInterpreterValue receiverValue = receiver.accept(visitor, env); From 25d88d19b922795651cee0a94b9a6662677819a0 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 10:34:08 +0200 Subject: [PATCH 179/236] Fixed a bug in the tests --- .../RosettaInterpreterRosettaFeatureCallInterpreter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index df7a44d7f..13f97587d 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -37,11 +37,11 @@ public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInte */ public RosettaInterpreterValue interp(RosettaFeatureCall expr, RosettaInterpreterEnvironment env) { - RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) expr.getReceiver(); RosettaEnumValue enumVal; if(expr.getFeature() instanceof RosettaEnumValueImpl) { enumVal = (RosettaEnumValueImpl) expr.getFeature(); - RosettaEnumeration enumeration = (RosettaEnumeration) ref.getSymbol(); + RosettaEnumeration enumeration = (RosettaEnumeration) + ((RosettaSymbolReferenceImpl) expr.getReceiver()).getSymbol(); return interpEnum(enumeration, enumVal, env); } else { From 2a90cfa73cf44668b79c04c47970dad79b5aa022 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 10:57:08 +0200 Subject: [PATCH 180/236] Temp --- ...osettaArithmeticOperationsInterpreter.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 57013b0f4..7ed890a88 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -1,7 +1,13 @@ package com.regnosys.rosetta.interpreternew.visitors; +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; @@ -34,10 +40,13 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); + //Check that the types are correct for the operations if (!(leftInterpreted instanceof RosettaInterpreterNumberValue - || leftInterpreted instanceof RosettaInterpreterStringValue) - || !(rightInterpreted instanceof RosettaInterpreterNumberValue - || rightInterpreted instanceof RosettaInterpreterStringValue)) { + || leftInterpreted instanceof RosettaInterpreterStringValue + || rightInterpreted instanceof RosettaInterpreterDateValue) + || !(rightInterpreted instanceof RosettaInterpreterNumberValue + || leftInterpreted instanceof RosettaInterpreterStringValue + || rightInterpreted instanceof RosettaInterpreterDateValue)) { // Check for errors in the left or right side of the binary operation RosettaInterpreterErrorValue leftErrors = @@ -47,6 +56,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); } + //Interpret string concatenation if (leftInterpreted instanceof RosettaInterpreterStringValue && rightInterpreted instanceof RosettaInterpreterStringValue) { String leftString = ((RosettaInterpreterStringValue) leftInterpreted) @@ -62,6 +72,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, "The terms are strings but the operation " + "is not concatenation: not implemented")); } + //Interpret number operations } else if (leftInterpreted instanceof RosettaInterpreterNumberValue && rightInterpreted instanceof RosettaInterpreterNumberValue) { RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); @@ -86,10 +97,23 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, return new RosettaInterpreterNumberValue((leftNumber .divide(rightNumber)).bigDecimalValue()); } + } else if (leftInterpreted instanceof RosettaInterpreterDateValue + && rightInterpreted instanceof RosettaInterpreterDateValue) { + RosettaInterpreterDateValue l = (RosettaInterpreterDateValue) leftInterpreted; + RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; + if (expr.getOperator().equals("-")) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); + String inputString1 = "23 01 1997"; + String inputString2 = "27 04 1997"; + + LocalDateTime date1 = LocalDate.parse(inputString1, dtf); + LocalDateTime date2 = LocalDate.parse(inputString2, dtf); + long daysBetween = Duration.between(date1, date2).toDays(); + System.out.println ("Days: " + daysBetween); } else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "The terms of the operation are neither both strings nor both numbers")); + "The terms of the operation are not both strings or both numbers or both dates")); } } @@ -108,7 +132,8 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, private RosettaInterpreterErrorValue checkForErrors( RosettaInterpreterValue interpretedValue, String side) { if (interpretedValue instanceof RosettaInterpreterNumberValue - || interpretedValue instanceof RosettaInterpreterStringValue) { + || interpretedValue instanceof RosettaInterpreterStringValue + || interpretedValue instanceof RosettaInterpreterDateValue) { // If the value satisfies the type conditions, we return an empty // error value so that the merger has two error values to merge return new RosettaInterpreterErrorValue(); @@ -123,7 +148,7 @@ else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Arithmetic Operation: " + side - + " is not of type Number/String")); + + " is not of type Number/String/Date")); } } } From 1d5119eeae1ee3e401df53bd96d3810c310ab1e4 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 11:00:34 +0200 Subject: [PATCH 181/236] Fixed checkstyle issues and reverted changes to pom and checkstyle --- rosetta-interpreter/checkstyle-SP.xml | 443 ++++++++---------- rosetta-interpreter/pom.xml | 238 +++++----- ...aInterpreterListOperationsInterpreter.java | 1 - ...ttaInterpreterListOperatorInterpreter.java | 1 - ...settaConditionalExpressionInterpreter.java | 1 - 5 files changed, 316 insertions(+), 368 deletions(-) diff --git a/rosetta-interpreter/checkstyle-SP.xml b/rosetta-interpreter/checkstyle-SP.xml index c6c5c02a8..1926d3b5a 100644 --- a/rosetta-interpreter/checkstyle-SP.xml +++ b/rosetta-interpreter/checkstyle-SP.xml @@ -2,253 +2,210 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rosetta-interpreter/pom.xml b/rosetta-interpreter/pom.xml index aaa7679d2..84ed8886b 100644 --- a/rosetta-interpreter/pom.xml +++ b/rosetta-interpreter/pom.xml @@ -1,130 +1,124 @@ - - 4.0.0 - - com.regnosys.rosetta.parent - com.regnosys.rosetta - 0.0.0.main-SNAPSHOT - + + 4.0.0 + + com.regnosys.rosetta.parent + com.regnosys.rosetta + 0.0.0.main-SNAPSHOT + - com.regnosys.rosetta.interpreternew + com.regnosys.rosetta.interpreternew + + Rosetta DSL Delft Interpreter Project - Rosetta DSL Delft Interpreter Project + + UTF-8 + 1.7 + 1.7 + 3.3.1 + checkstyle-SP.xml + - - UTF-8 - 1.7 - 1.7 - 3.3.1 - checkstyle-SP.xml - + + + junit + junit + test + + + + + com.regnosys.rosetta + com.regnosys.rosetta.lib + ${project.version} + - - - junit - junit - test - + + com.regnosys.rosetta + com.regnosys.rosetta + ${project.version} + + + com.regnosys.rosetta + com.regnosys.rosetta.tests + ${project.version} + + - - - com.regnosys.rosetta - com.regnosys.rosetta.lib - ${project.version} - - - - com.regnosys.rosetta - com.regnosys.rosetta - ${project.version} - - - com.regnosys.rosetta - com.regnosys.rosetta.tests - ${project.version} - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - org.jacoco - jacoco-maven-plugin - - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - checkstyle-SP.xml - true - true - warning - true - - src/main/java - src/test/java - - - - - - + + + + + + maven-clean-plugin + 3.1.0 + + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + org.jacoco + jacoco-maven-plugin + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + checkstyle-SP.xml + true + true + warning + true + + src/main/java + src/test/java + + + + + + diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 578bcec0d..ed2341479 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 4cc574cd8..5fcd1d0e3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -12,7 +12,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 4a273e152..e44e5ba4d 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From 3362fe1aee9f5e39d3a2a911c766e9f51dd43fbc Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 11:36:56 +0200 Subject: [PATCH 182/236] Added support for date subtraction --- ...osettaArithmeticOperationsInterpreter.java | 41 ++++++++-- ...taInterpreterArithmeticOperationsTest.java | 79 ++++++++++++++++--- 2 files changed, 101 insertions(+), 19 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 7ed890a88..26c80946a 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -43,9 +43,9 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, //Check that the types are correct for the operations if (!(leftInterpreted instanceof RosettaInterpreterNumberValue || leftInterpreted instanceof RosettaInterpreterStringValue - || rightInterpreted instanceof RosettaInterpreterDateValue) + || leftInterpreted instanceof RosettaInterpreterDateValue) || !(rightInterpreted instanceof RosettaInterpreterNumberValue - || leftInterpreted instanceof RosettaInterpreterStringValue + || rightInterpreted instanceof RosettaInterpreterStringValue || rightInterpreted instanceof RosettaInterpreterDateValue)) { // Check for errors in the left or right side of the binary operation @@ -69,7 +69,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "The terms are strings but the operation " + "Both terms are strings but the operation " + "is not concatenation: not implemented")); } //Interpret number operations @@ -103,13 +103,38 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; if (expr.getOperator().equals("-")) { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); - String inputString1 = "23 01 1997"; - String inputString2 = "27 04 1997"; + String dayL = l.getDay().getValue().bigDecimalValue().toBigInteger().toString(); + if (dayL.length() == 1) { + dayL = "0" + dayL; + } + String monthL = l.getMonth().getValue().bigDecimalValue().toBigInteger().toString(); + if (monthL.length() == 1) { + monthL = "0" + monthL; + } + String yearL = l.getYear().getValue().bigDecimalValue().toBigInteger().toString(); + String dayR = r.getDay().getValue().bigDecimalValue().toBigInteger().toString(); + if (dayR.length() == 1) { + dayR = "0" + dayR; + } + String monthR = r.getMonth().getValue().bigDecimalValue().toBigInteger().toString(); + if (monthR.length() == 1) { + monthR = "0" + monthR; + } + String yearR = r.getYear().getValue().bigDecimalValue().toBigInteger().toString(); + + String inputString1 = dayL + " " + monthL + " " + yearL; + String inputString2 = dayR + " " + monthR + " " + yearR; - LocalDateTime date1 = LocalDate.parse(inputString1, dtf); - LocalDateTime date2 = LocalDate.parse(inputString2, dtf); + LocalDateTime date1 = LocalDate.parse(inputString1, dtf).atStartOfDay(); + LocalDateTime date2 = LocalDate.parse(inputString2, dtf).atStartOfDay(); long daysBetween = Duration.between(date1, date2).toDays(); - System.out.println ("Days: " + daysBetween); + return new RosettaInterpreterNumberValue(BigDecimal.valueOf(daysBetween)); + } else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Both terms are dates but the operation " + + "is not subtraction: not implemented")); + } } else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java index ca904ed34..8065c96a7 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java @@ -40,6 +40,64 @@ public void setup() { exFactory = ExpressionFactoryImpl.init(); } + @Test + public void dateSubtractionTest1() { + RosettaExpression expr = parser.parseExpression( + "date { day: 5, month: 7, year: 2025 } - date { day: 5, month: 7, year: 2026 }"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(365)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void dateSubtractionTest2() { + RosettaExpression expr = parser.parseExpression( + "date { day: 10, month: 10, year: 2025 } - date { day: 10, month: 10, year: 2026 }"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals(RosettaNumber.valueOf(BigDecimal.valueOf(365)), + ((RosettaInterpreterNumberValue)val).getValue()); + } + + @Test + public void dateNoSubError() { + RosettaExpression expr = parser.parseExpression( + "date { day: 5, month: 7, year: 2025 } + date { day: 10, month: 10, year: 2026 }"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Both terms are dates but the operation " + + "is not subtraction: not implemented", + ((RosettaInterpreterErrorValue)val).getErrors() + .get(0).getMessage()); + } + + @Test + public void mixedTypesLeftTestWithDate() { + RosettaExpression expr = parser.parseExpression("5 - date { day: 10, month: 10, year: 2026 }"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms of the operation " + + "are not both strings or both numbers or both dates", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void mixedTypesRightTestWithDate() { + RosettaExpression expr = parser.parseExpression("date { day: 10, month: 10, year: 2026 } - 5"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("The terms of the operation " + + "are not both strings or both numbers or both dates", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + + @Test + public void wrongTypeRightTestWithDate() { + RosettaExpression expr = parser.parseExpression("date { day: 10, month: 10, year: 2026 } + True"); + RosettaInterpreterValue val = interpreter.interp(expr); + assertEquals("Arithmetic Operation: Rightside is not of type Number/String/Date", + ((RosettaInterpreterErrorValue)val) + .getErrors().get(0).getMessage()); + } + @Test public void plusTest() { RosettaExpression expr = parser.parseExpression("1+2"); @@ -95,7 +153,6 @@ public void divisionByZeroTest() { List expected = List.of( new RosettaInterpreterError( "Division by 0 is not allowed")); - assertEquals(expected, ((RosettaInterpreterErrorValue)val).getErrors()); } @@ -112,7 +169,7 @@ public void correctTypesMixedTest() { RosettaExpression expr = parser.parseExpression("\"Hello \" + 5"); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals("The terms of the operation " - + "are neither both strings nor both numbers", + + "are not both strings or both numbers or both dates", ((RosettaInterpreterErrorValue)val).getErrors() .get(0).getMessage()); } @@ -122,7 +179,7 @@ public void correctTypesMixedTestTheOtherWay() { RosettaExpression expr = parser.parseExpression("5 + \"Hello\""); RosettaInterpreterValue val = interpreter.interp(expr); assertEquals("The terms of the operation " - + "are neither both strings nor both numbers", + + "are not both strings or both numbers or both dates", ((RosettaInterpreterErrorValue)val).getErrors() .get(0).getMessage()); } @@ -131,7 +188,7 @@ public void correctTypesMixedTestTheOtherWay() { public void stringConcatenationErrorTest() { RosettaExpression expr = parser.parseExpression("\"Hello \" - \"World\""); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("The terms are strings but the operation " + assertEquals("Both terms are strings but the operation " + "is not concatenation: not implemented", ((RosettaInterpreterErrorValue)val).getErrors() .get(0).getMessage()); @@ -141,7 +198,7 @@ public void stringConcatenationErrorTest() { public void wrongTypeLeftTest() { RosettaExpression expr = parser.parseExpression("True - \"World\""); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("Arithmetic Operation: Leftside is not of type Number/String", + assertEquals("Arithmetic Operation: Leftside is not of type Number/String/Date", ((RosettaInterpreterErrorValue)val) .getErrors().get(0).getMessage()); } @@ -150,7 +207,7 @@ public void wrongTypeLeftTest() { public void wrongTypeRightTestString() { RosettaExpression expr = parser.parseExpression("\"Hello \" + True"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + assertEquals("Arithmetic Operation: Rightside is not of type Number/String/Date", ((RosettaInterpreterErrorValue)val) .getErrors().get(0).getMessage()); } @@ -159,7 +216,7 @@ public void wrongTypeRightTestString() { public void wrongTypeRightTestInteger() { RosettaExpression expr = parser.parseExpression("2 + True"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + assertEquals("Arithmetic Operation: Rightside is not of type Number/String/Date", ((RosettaInterpreterErrorValue)val) .getErrors().get(0).getMessage()); } @@ -168,7 +225,7 @@ public void wrongTypeRightTestInteger() { public void wrongTypeRightTestNumber() { RosettaExpression expr = parser.parseExpression("2.5 + True"); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("Arithmetic Operation: Rightside is not of type Number/String", + assertEquals("Arithmetic Operation: Rightside is not of type Number/String/Date", ((RosettaInterpreterErrorValue)val) .getErrors().get(0).getMessage()); } @@ -178,7 +235,7 @@ public void leftsideErrorTest() { RosettaExpression expr = parser .parseExpression("\"Hello \" - \"World\" + \"World\""); RosettaInterpreterValue val = interpreter.interp(expr); - assertEquals("The terms are strings but the " + assertEquals("Both terms are strings but the " + "operation is not concatenation: not implemented", ((RosettaInterpreterErrorValue)val) .getErrors().get(0).getMessage()); @@ -191,11 +248,11 @@ public void complexTest() { RosettaInterpreterValue val = interpreter.interp(expr); List expected = List.of( new RosettaInterpreterError( - "The terms are strings but the operation " + "Both terms are strings but the operation " + "is not concatenation: not implemented"), new RosettaInterpreterError( "Arithmetic Operation: Rightside " - + "is not of type Number/String") + + "is not of type Number/String/Date") ); assertEquals(expected, ((RosettaInterpreterErrorValue)val) From 90a2fa469b94fcdd49d158ab72ac23c5e55ea0e0 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 11:45:57 +0200 Subject: [PATCH 183/236] Fixed checkstyle --- .../visitors/RosettaInterpreterListOperationsInterpreter.java | 1 - .../visitors/RosettaInterpreterListOperatorInterpreter.java | 1 - ...osettaInterpreterRosettaConditionalExpressionInterpreter.java | 1 - 3 files changed, 3 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 578bcec0d..ed2341479 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 4cc574cd8..5fcd1d0e3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -12,7 +12,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 4a273e152..e44e5ba4d 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; From 7bd9fc3f539667c5767a3e07472a55a51c1fe9f9 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Wed, 12 Jun 2024 11:51:15 +0200 Subject: [PATCH 184/236] Fixed checkstyle attempt#2 --- rosetta-interpreter/.project | 6 ++++++ .../RosettaInterpreterRosettaFeatureCallInterpreter.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rosetta-interpreter/.project b/rosetta-interpreter/.project index d53fdc8e9..acd4e0fa1 100644 --- a/rosetta-interpreter/.project +++ b/rosetta-interpreter/.project @@ -15,9 +15,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index 13f97587d..6797d46a7 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -38,7 +38,7 @@ public class RosettaInterpreterRosettaFeatureCallInterpreter extends RosettaInte public RosettaInterpreterValue interp(RosettaFeatureCall expr, RosettaInterpreterEnvironment env) { RosettaEnumValue enumVal; - if(expr.getFeature() instanceof RosettaEnumValueImpl) { + if (expr.getFeature() instanceof RosettaEnumValueImpl) { enumVal = (RosettaEnumValueImpl) expr.getFeature(); RosettaEnumeration enumeration = (RosettaEnumeration) ((RosettaSymbolReferenceImpl) expr.getReceiver()).getSymbol(); From 5209fcd519e8ceb7454f17bec830e9888a41a3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Wed, 12 Jun 2024 14:17:51 +0300 Subject: [PATCH 185/236] Fixed checkstyle and added supertype for data types --- .../RosettaInterpreterIntegerValue.java | 120 +++++++++--------- .../RosettaInterpreterTypedFeatureValue.java | 27 +++- .../values/RosettaInterpreterTypedValue.java | 48 ++++++- ...aInterpreterListOperationsInterpreter.java | 1 - ...ttaInterpreterListOperatorInterpreter.java | 1 - ...settaConstructorExpressionInterpreter.java | 16 ++- ...aInterpreterConstructorExpressionTest.java | 20 +++ .../RosettaInterpreterFeatureCallTest.java | 14 ++ 8 files changed, 172 insertions(+), 75 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java index bd9fd0dfc..c3edb3e43 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java @@ -1,60 +1,60 @@ -package com.regnosys.rosetta.interpreternew.values; - -import java.math.BigInteger; -import java.util.Objects; -import java.util.stream.Stream; - -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue - implements Comparable { - - private BigInteger value; - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; - return Objects.equals(value, other.value); - } - - public RosettaInterpreterIntegerValue(BigInteger value) { - super(); - this.value = value; - } - - public RosettaInterpreterIntegerValue(int value) { - super(); - this.value = BigInteger.valueOf(value); - } - - public BigInteger getValue() { return value; } - - @Override - public int compareTo(RosettaInterpreterIntegerValue o) { - return this.value.compareTo(o.value); - } - - @Override - public Stream toElementStream() { - return Stream.of(value); - } - - @Override - public Stream toValueStream() { - return Stream.of(this); - } -} +//package com.regnosys.rosetta.interpreternew.values; +// +//import java.math.BigInteger; +//import java.util.Objects; +//import java.util.stream.Stream; +// +//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +// +//public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue +// implements Comparable { +// +// private BigInteger value; +// +// @Override +// public int hashCode() { +// return Objects.hash(value); +// } +// +// @Override +// public boolean equals(Object obj) { +// if (this == obj) { +// return true; +// } +// if (obj == null) { +// return false; +// } +// if (getClass() != obj.getClass()) { +// return false; +// } +// RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; +// return Objects.equals(value, other.value); +// } +// +// public RosettaInterpreterIntegerValue(BigInteger value) { +// super(); +// this.value = value; +// } +// +// public RosettaInterpreterIntegerValue(int value) { +// super(); +// this.value = BigInteger.valueOf(value); +// } +// +// public BigInteger getValue() { return value; } +// +// @Override +// public int compareTo(RosettaInterpreterIntegerValue o) { +// return this.value.compareTo(o.value); +// } +// +// @Override +// public Stream toElementStream() { +// return Stream.of(value); +// } +// +// @Override +// public Stream toValueStream() { +// return Stream.of(this); +// } +//} diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java index 39f3958ad..a0109718e 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java @@ -10,12 +10,21 @@ public class RosettaInterpreterTypedFeatureValue extends RosettaInterpreterBaseV public String name; public RosettaInterpreterValue value; - //public RosettaCardinality card; + public RosettaCardinality card; - public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterValue value) { + /** + * Constructor for data-type feature value. + * + * @param name name value + * @param value value of feature + * @param card cardinality value + */ + public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterValue value, + RosettaCardinality card) { super(); this.name = name; this.value = value; + this.card = card; } public String getName() { @@ -26,9 +35,13 @@ public RosettaInterpreterValue getValue() { return value; } + public RosettaCardinality getCard() { + return card; + } + @Override public Stream toElementStream() { - return Stream.of(name, value); + return Stream.of(name, value, card); } @Override @@ -38,7 +51,7 @@ public Stream toValueStream() { @Override public int hashCode() { - return Objects.hash(name, value); + return Objects.hash(card, name, value); } @Override @@ -53,11 +66,13 @@ public boolean equals(Object obj) { return false; } RosettaInterpreterTypedFeatureValue other = (RosettaInterpreterTypedFeatureValue) obj; - return Objects.equals(name, other.name) && Objects.equals(value, other.value); + return Objects.equals(card, other.card) && Objects.equals(name, other.name) + && Objects.equals(value, other.value); } @Override public String toString() { - return "RosettaInterpreterTypedFeatureValue [name=" + name + ", value=" + value + "]"; + return "RosettaInterpreterTypedFeatureValue [name=" + name + ", value=" + value + + ", card=" + card + "]"; } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java index 7db7f6bb2..1462b667c 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -1,6 +1,5 @@ package com.regnosys.rosetta.interpreternew.values; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Stream; @@ -9,26 +8,63 @@ public class RosettaInterpreterTypedValue extends RosettaInterpreterBaseValue { + public String superType; public String name; public List attributes; + /** + * Constructor for data-type value with no super type. + * + * @param name name value + * @param attributes list of data-type feature values + */ public RosettaInterpreterTypedValue(String name, List attributes) { super(); + this.superType = null; this.name = name; this.attributes = attributes; } + /** + * Constructor for data-type value with super type. + * + * @param superType supertype class + * @param name name value + * @param attributes list of data-type feature values + */ + public RosettaInterpreterTypedValue(String superType, String name, + List attributes) { + super(); + this.superType = superType; + this.name = name; + this.attributes = attributes; + } + + public boolean hasSuperType() { + return superType == null; + } + + public String getSuperType() { + return superType; + } + public String getName() { return name; } + /** + * Getter for the attributes of a data-type. If it has a supertype, it return its attributes as well. + * + * @return a list of attributes, including the one from a supertype if it has one + */ public List getAttributes() { + // This will return all attributes, including the ones of the supertype return attributes; } @Override public Stream toElementStream() { - return Stream.of(name, attributes); + return Stream.of(superType, name, attributes); } @Override @@ -38,7 +74,7 @@ public Stream toValueStream() { @Override public int hashCode() { - return Objects.hash(attributes, name); + return Objects.hash(superType, attributes, name); } @Override @@ -53,11 +89,13 @@ public boolean equals(Object obj) { return false; } RosettaInterpreterTypedValue other = (RosettaInterpreterTypedValue) obj; - return Objects.equals(attributes, other.attributes) && Objects.equals(name, other.name); + return Objects.equals(attributes, other.attributes) && Objects.equals(name, other.name) + && Objects.equals(superType, other.superType); } @Override public String toString() { - return "RosettaInterpreterTypedValue [name=" + name + ", attributes=" + attributes + "]"; + return "RosettaInterpreterTypedValue [supertype=" + superType + ", name=" + + name + ", attributes=" + attributes + "]"; } } \ No newline at end of file diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 578bcec0d..ed2341479 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 4cc574cd8..5fcd1d0e3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -12,7 +12,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 3f9c3161c..a8b95924e 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -19,7 +19,10 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; +import com.regnosys.rosetta.rosetta.RosettaCardinality; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { @@ -93,11 +96,13 @@ public RosettaInterpreterBaseValue interp( break; } default: { - // check that the data type is defined before, if not return error List attributes = new ArrayList<>(); + // This for will take all the attributes of a data type, + // including the ones of the supertype for (ConstructorKeyValuePair pair : values) { String name = pair.getKey().getName(); + RosettaCardinality card = ((AttributeImpl) pair.getKey()).getCard(); RosettaInterpreterValue value = pair.getValue().accept(visitor, env); if (RosettaInterpreterErrorValue.errorsExist(value)) { @@ -115,7 +120,14 @@ public RosettaInterpreterBaseValue interp( List.of(newExpError, expError)); } - attributes.add(new RosettaInterpreterTypedFeatureValue(name, value)); + attributes.add(new RosettaInterpreterTypedFeatureValue(name, value, card)); + } + + if (((DataImpl) expr.getTypeCall().getType()).hasSuperType()) { + String superType = ((DataImpl) expr.getTypeCall().getType()) + .getSuperType().getName(); + + return new RosettaInterpreterTypedValue(superType, typeCall, attributes); } return new RosettaInterpreterTypedValue(typeCall, attributes); diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 7ec2ada6c..7713b2bde 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -235,6 +235,26 @@ public void testDataType() { .getValue()); } + @Test + public void testDataTypeExtends() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "type Age extends Person: age number (1..1)" + "func M: output: result Person (1..1) " + + "set result: Age { name: \"F\", age: 10 }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(2)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Person", result.getSuperType()); + assertEquals("Age", result.getName()); + assertEquals("name", result.getAttributes().get(0).getName()); + assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) + .getValue()); + assertEquals("age", result.getAttributes().get(1).getName()); + assertEquals(10, ((RosettaInterpreterNumberValue) result.getAttributes().get(1).getValue()) + .getValue().intValue()); + } + @Test public void testDataTypeError() { RosettaModel model = mh.parseRosetta("type Test: value boolean (1..1) " diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 476a8be87..249141912 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -179,4 +179,18 @@ public void testDataType() { assertEquals("F", ((RosettaInterpreterStringValue) result).getValue()); } + + @Test + public void testDataTypeExtends() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "type Age extends Person: age number (1..1) " + + "func M: output: result number (1..1) set result: " + + "Age { name: \"F\", age: 10 } -> age"); + + RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) + model.getElements().get(2)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(featureCall); + + assertEquals(10, ((RosettaInterpreterNumberValue) result).getValue().intValue()); + } } From 07341b4914d3825d0ca8dab59badeb9469ad7816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Thu, 13 Jun 2024 02:18:50 +0300 Subject: [PATCH 186/236] Added tests for value classes --- .../values/RosettaInterpreterTypedValue.java | 2 +- .../RosettaInterpreterDateTimeValueTest.java | 78 ++++++++++++++ .../RosettaInterpreterDateValueTest.java | 65 ++++++++++++ .../RosettaInterpreterTimeValueTest.java | 100 ++++++++++++++++++ ...settaInterpreterTypedFeatureValueTest.java | 69 ++++++++++++ .../RosettaInterpreterTypedValueTest.java | 77 ++++++++++++++ ...ettaInterpreterZonedDateTimeValueTest.java | 91 ++++++++++++++++ 7 files changed, 481 insertions(+), 1 deletion(-) create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateTimeValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTimeValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedFeatureValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterZonedDateTimeValueTest.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java index 1462b667c..741cd9365 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -41,7 +41,7 @@ public RosettaInterpreterTypedValue(String superType, String name, } public boolean hasSuperType() { - return superType == null; + return !(superType == null); } public String getSuperType() { diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateTimeValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateTimeValueTest.java new file mode 100644 index 000000000..389217630 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateTimeValueTest.java @@ -0,0 +1,78 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; + +public class RosettaInterpreterDateTimeValueTest { + + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); + RosettaInterpreterNumberValue day2 = new RosettaInterpreterNumberValue(2); + + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + RosettaInterpreterDateValue dateDay = new RosettaInterpreterDateValue(day2, month, year); + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + + RosettaInterpreterNumberValue hours2 = new RosettaInterpreterNumberValue(BigDecimal.valueOf(18)); + RosettaInterpreterTimeValue timeHours = new RosettaInterpreterTimeValue(hours2, minutes, seconds); + + RosettaInterpreterDateTimeValue dateTime = new RosettaInterpreterDateTimeValue(date, time); + RosettaInterpreterDateTimeValue dateTime2 = new RosettaInterpreterDateTimeValue(date, time); + RosettaInterpreterDateTimeValue dateTimeDate = new RosettaInterpreterDateTimeValue(dateDay, time); + RosettaInterpreterDateTimeValue dateTimeTime = new RosettaInterpreterDateTimeValue(date, timeHours); + + @Test + void hashTest() { + assertEquals(dateTime.hashCode(), dateTime2.hashCode()); + assertNotEquals(dateTime.hashCode(), dateTimeDate.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(dateTime.equals(dateTime)); + assertTrue(dateTime.equals(dateTime2)); + assertFalse(dateTime.equals(dateTimeDate)); + assertFalse(dateTime.equals(dateTimeTime)); + assertFalse(dateTime.equals(null)); + assertFalse(dateTime.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of(date, time), dateTime.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(dateTime).collect(Collectors.toList()); + assertEquals(stream, dateTime.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterDateTimeValue [date=RosettaInterpreterDateValue " + + "[day=RosettaInterpreterNumberValue [5], month=RosettaInterpreterNumberValue [7], " + + "year=RosettaInterpreterNumberValue [2024]], time=RosettaInterpreterTimeValue " + + "[hours=RosettaInterpreterNumberValue [5], minutes=RosettaInterpreterNumberValue " + + "[30], seconds=RosettaInterpreterNumberValue [28]]]", dateTime.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateValueTest.java new file mode 100644 index 000000000..e23b07a33 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterDateValueTest.java @@ -0,0 +1,65 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; + +public class RosettaInterpreterDateValueTest { + + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); + RosettaInterpreterNumberValue day2 = new RosettaInterpreterNumberValue(2); + RosettaInterpreterNumberValue month2 = new RosettaInterpreterNumberValue(1); + RosettaInterpreterNumberValue year2 = new RosettaInterpreterNumberValue(2020); + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + RosettaInterpreterDateValue date2 = new RosettaInterpreterDateValue(day, month, year); + RosettaInterpreterDateValue dateDay = new RosettaInterpreterDateValue(day2, month, year); + RosettaInterpreterDateValue dateMonth = new RosettaInterpreterDateValue(day, month2, year); + RosettaInterpreterDateValue dateYear = new RosettaInterpreterDateValue(day, month, year2); + + @Test + void hashTest() { + assertEquals(date.hashCode(), date2.hashCode()); + assertNotEquals(date.hashCode(), dateDay.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(date.equals(date)); + assertTrue(date.equals(date2)); + assertFalse(date.equals(dateDay)); + assertFalse(date.equals(dateMonth)); + assertFalse(date.equals(dateYear)); + assertFalse(date.equals(null)); + assertFalse(date.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of(day, month, year), date.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(date).collect(Collectors.toList()); + assertEquals(stream, date.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterDateValue [day=RosettaInterpreterNumberValue [5], " + + "month=RosettaInterpreterNumberValue [7], " + + "year=RosettaInterpreterNumberValue [2024]]", date.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTimeValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTimeValueTest.java new file mode 100644 index 000000000..4e1ef35e8 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTimeValueTest.java @@ -0,0 +1,100 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; + +public class RosettaInterpreterTimeValueTest { + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + RosettaInterpreterTimeValue time2 = new RosettaInterpreterTimeValue(hours, minutes, seconds); + + RosettaInterpreterNumberValue hoursError = new RosettaInterpreterNumberValue(BigDecimal.valueOf(88)); + RosettaInterpreterNumberValue hoursError2 = new RosettaInterpreterNumberValue(BigDecimal.valueOf(-2)); + RosettaInterpreterNumberValue minutesError = new RosettaInterpreterNumberValue(BigDecimal.valueOf(88)); + RosettaInterpreterNumberValue secondsError = new RosettaInterpreterNumberValue(BigDecimal.valueOf(88)); + RosettaInterpreterNumberValue minutesError2 = new RosettaInterpreterNumberValue(BigDecimal.valueOf(-2)); + RosettaInterpreterNumberValue secondsError2 = new RosettaInterpreterNumberValue(BigDecimal.valueOf(-2)); + + RosettaInterpreterTimeValue timeErrorHours = new RosettaInterpreterTimeValue(hoursError, minutes, seconds); + RosettaInterpreterTimeValue timeErrorHours2 = new RosettaInterpreterTimeValue(hoursError2, minutes, seconds); + RosettaInterpreterTimeValue timeErrorMinutes = new RosettaInterpreterTimeValue(hours, minutesError, seconds); + RosettaInterpreterTimeValue timeErrorSeconds = new RosettaInterpreterTimeValue(hours, minutes, secondsError); + RosettaInterpreterTimeValue timeErrorMinutes2 = new RosettaInterpreterTimeValue(hours, minutesError2, seconds); + RosettaInterpreterTimeValue timeErrorSeconds2 = new RosettaInterpreterTimeValue(hours, minutes, secondsError2); + + @Test + void getHoursTest() { + assertEquals(hours, time.getHours()); + } + + @Test + void getMinutesTest() { + assertEquals(minutes, time.getMinutes()); + } + + @Test + void getSecondsTest() { + assertEquals(seconds, time.getSeconds()); + } + + @Test + void validTest() { + assertFalse(timeErrorHours.valid()); + assertFalse(timeErrorHours2.valid()); + assertFalse(timeErrorMinutes.valid()); + assertFalse(timeErrorSeconds.valid()); + assertFalse(timeErrorMinutes2.valid()); + assertFalse(timeErrorSeconds2.valid()); + assertTrue(time.valid()); + } + + @Test + void hashTest() { + assertEquals(time.hashCode(), time2.hashCode()); + assertNotEquals(time.hashCode(), timeErrorHours.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(time.equals(time)); + assertTrue(time.equals(time2)); + assertFalse(time.equals(timeErrorHours)); + assertFalse(time.equals(timeErrorMinutes)); + assertFalse(time.equals(timeErrorSeconds)); + assertFalse(time.equals(null)); + assertFalse(time.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of(hours, minutes, seconds), time.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(time).collect(Collectors.toList()); + assertEquals(stream, time.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterTimeValue [hours=RosettaInterpreterNumberValue [5], " + + "minutes=RosettaInterpreterNumberValue [30], " + + "seconds=RosettaInterpreterNumberValue [28]]", time.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedFeatureValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedFeatureValueTest.java new file mode 100644 index 000000000..9aaf8515f --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedFeatureValueTest.java @@ -0,0 +1,69 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; + +public class RosettaInterpreterTypedFeatureValueTest { + + RosettaInterpreterStringValue value = new RosettaInterpreterStringValue("a"); + RosettaInterpreterStringValue value2 = new RosettaInterpreterStringValue("b"); + + RosettaInterpreterTypedFeatureValue attribute = new RosettaInterpreterTypedFeatureValue("name", value, null); + RosettaInterpreterTypedFeatureValue attribute2 = new RosettaInterpreterTypedFeatureValue("name", value, null); + RosettaInterpreterTypedFeatureValue attributeName = + new RosettaInterpreterTypedFeatureValue("nickname", value, null); + RosettaInterpreterTypedFeatureValue attributeValue = + new RosettaInterpreterTypedFeatureValue("name", value2, null); + + @Test + void getCardTest() { + assertNull(attribute.getCard()); + } + + @Test + void hashTest() { + assertEquals(attribute.hashCode(), attribute2.hashCode()); + assertNotEquals(attribute.hashCode(), attributeName.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(attribute.equals(attribute)); + assertTrue(attribute.equals(attribute2)); + assertFalse(attribute.equals(attributeName)); + assertFalse(attribute.equals(attributeValue)); + assertFalse(attribute.equals(null)); + assertFalse(attribute.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(Arrays.asList("name", value, null), + attribute.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(attribute).collect(Collectors.toList()); + assertEquals(stream, attribute.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterTypedFeatureValue [name=name, value=RosettaInterpreterStringValue " + + "[a], card=null]", attribute.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedValueTest.java new file mode 100644 index 000000000..edea0c4b3 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterTypedValueTest.java @@ -0,0 +1,77 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; + +public class RosettaInterpreterTypedValueTest { + + RosettaInterpreterStringValue value = new RosettaInterpreterStringValue("a"); + RosettaInterpreterTypedFeatureValue attribute = new RosettaInterpreterTypedFeatureValue("name", value, null); + RosettaInterpreterTypedFeatureValue attribute2 = new RosettaInterpreterTypedFeatureValue("name", value, null); + RosettaInterpreterTypedFeatureValue attributeName = + new RosettaInterpreterTypedFeatureValue("nickname", value, null); + + RosettaInterpreterTypedValue data = new RosettaInterpreterTypedValue("super", "data", List.of(attribute)); + RosettaInterpreterTypedValue data2 = new RosettaInterpreterTypedValue("super", "data", List.of(attribute2)); + RosettaInterpreterTypedValue dataSuper = + new RosettaInterpreterTypedValue("supernot", "data", List.of(attribute)); + RosettaInterpreterTypedValue dataName = + new RosettaInterpreterTypedValue("super", "datanot", List.of(attribute)); + RosettaInterpreterTypedValue dataAttribute = + new RosettaInterpreterTypedValue("super", "data", List.of(attributeName)); + RosettaInterpreterTypedValue dataNotSuper = new RosettaInterpreterTypedValue("data", List.of(attribute)); + + @Test + void hasSuperTypeTest() { + assertTrue(data.hasSuperType()); + assertFalse(dataNotSuper.hasSuperType()); + } + + @Test + void hashTest() { + assertEquals(data.hashCode(), data2.hashCode()); + assertNotEquals(data.hashCode(), dataName.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(data.equals(data)); + assertTrue(data.equals(data2)); + assertFalse(data.equals(dataSuper)); + assertFalse(data.equals(dataName)); + assertFalse(data.equals(dataAttribute)); + assertFalse(data.equals(null)); + assertFalse(data.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of("super", "data", List.of(attribute)), + data.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(data).collect(Collectors.toList()); + assertEquals(stream, data.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterTypedValue [supertype=super, name=data, " + + "attributes=[RosettaInterpreterTypedFeatureValue [name=name, " + + "value=RosettaInterpreterStringValue [a], card=null]]]", data.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterZonedDateTimeValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterZonedDateTimeValueTest.java new file mode 100644 index 000000000..7e4b3dde6 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterZonedDateTimeValueTest.java @@ -0,0 +1,91 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; + +public class RosettaInterpreterZonedDateTimeValueTest { + + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); + RosettaInterpreterNumberValue day2 = new RosettaInterpreterNumberValue(2); + + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + RosettaInterpreterDateValue dateDay = new RosettaInterpreterDateValue(day2, month, year); + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + + RosettaInterpreterNumberValue hours2 = new RosettaInterpreterNumberValue(BigDecimal.valueOf(18)); + RosettaInterpreterTimeValue timeHours = new RosettaInterpreterTimeValue(hours2, minutes, seconds); + + RosettaInterpreterStringValue zone = new RosettaInterpreterStringValue("CET"); + RosettaInterpreterStringValue zone2 = new RosettaInterpreterStringValue("CEST"); + + RosettaInterpreterZonedDateTimeValue zonedDateTime = + new RosettaInterpreterZonedDateTimeValue(date, time, zone); + RosettaInterpreterZonedDateTimeValue zonedDateTime2 = + new RosettaInterpreterZonedDateTimeValue(date, time, zone); + RosettaInterpreterZonedDateTimeValue zonedDateTimeDate = + new RosettaInterpreterZonedDateTimeValue(dateDay, time, zone); + RosettaInterpreterZonedDateTimeValue zonedDateTimeTime = + new RosettaInterpreterZonedDateTimeValue(date, timeHours, zone); + RosettaInterpreterZonedDateTimeValue zonedDateTimeZone = + new RosettaInterpreterZonedDateTimeValue(date, time, zone2); + + @Test + void hashTest() { + assertEquals(zonedDateTime.hashCode(), zonedDateTime2.hashCode()); + assertNotEquals(zonedDateTime.hashCode(), zonedDateTimeDate.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(zonedDateTime.equals(zonedDateTime)); + assertTrue(zonedDateTime.equals(zonedDateTime2)); + assertFalse(zonedDateTime.equals(zonedDateTimeDate)); + assertFalse(zonedDateTime.equals(zonedDateTimeTime)); + assertFalse(zonedDateTime.equals(zonedDateTimeZone)); + assertFalse(zonedDateTime.equals(null)); + assertFalse(zonedDateTime.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of(date, time, zone), zonedDateTime.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(zonedDateTime) + .collect(Collectors.toList()); + assertEquals(stream, zonedDateTime.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterZonedDateTimeValue [date=RosettaInterpreterDateValue " + + "[day=RosettaInterpreterNumberValue [5], month=RosettaInterpreterNumberValue [7], " + + "year=RosettaInterpreterNumberValue [2024]], time=RosettaInterpreterTimeValue " + + "[hours=RosettaInterpreterNumberValue [5], minutes=RosettaInterpreterNumberValue " + + "[30], seconds=RosettaInterpreterNumberValue [28]], " + + "timeZone=RosettaInterpreterStringValue [CET]]", zonedDateTime.toString()); + } +} From 6aa84bebdb2232618c031d740120be09e77c3652 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 13 Jun 2024 09:54:35 +0200 Subject: [PATCH 187/236] Fixed checkstyle #2 --- rosetta-interpreter/.project | 6 ++++++ ...taInterpreterRosettaArithmeticOperationsInterpreter.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rosetta-interpreter/.project b/rosetta-interpreter/.project index d53fdc8e9..acd4e0fa1 100644 --- a/rosetta-interpreter/.project +++ b/rosetta-interpreter/.project @@ -15,9 +15,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 26c80946a..776a4ee5e 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -102,7 +102,6 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterDateValue l = (RosettaInterpreterDateValue) leftInterpreted; RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; if (expr.getOperator().equals("-")) { - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); String dayL = l.getDay().getValue().bigDecimalValue().toBigInteger().toString(); if (dayL.length() == 1) { dayL = "0" + dayL; @@ -125,6 +124,8 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, String inputString1 = dayL + " " + monthL + " " + yearL; String inputString2 = dayR + " " + monthR + " " + yearR; + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); + LocalDateTime date1 = LocalDate.parse(inputString1, dtf).atStartOfDay(); LocalDateTime date2 = LocalDate.parse(inputString2, dtf).atStartOfDay(); long daysBetween = Duration.between(date1, date2).toDays(); From 8d91a44de30c49b5eeb322b9ac524028406e7144 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 13 Jun 2024 12:50:33 +0200 Subject: [PATCH 188/236] Added test for data types with optional attribute --- ...ettaInterpreterConstructorExpressionTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 7713b2bde..3b88407b0 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -235,6 +235,22 @@ public void testDataType() { .getValue()); } + @Test + public void test() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1)" + + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Person", result.getName()); + assertEquals("name", result.getAttributes().get(0).getName()); + assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) + .getValue()); + System.out.println(result.getAttributes().get(1).getValue()); + } + @Test public void testDataTypeExtends() { RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " From 0176022219884e2e1e0b1fa29db0cf6ff105a85d Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 13 Jun 2024 12:57:20 +0200 Subject: [PATCH 189/236] Changed test name --- .../RosettaInterpreterConstructorExpressionTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 3b88407b0..77f66603a 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -236,9 +236,9 @@ public void testDataType() { } @Test - public void test() { + public void testOptionalAttributeDataType() { RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty }"); + + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty}"); RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); From 876a831b7ac073272a4231c75c7fabdb2fef43cb Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 13 Jun 2024 13:00:08 +0200 Subject: [PATCH 190/236] c --- .../visitors/RosettaInterpreterListOperationsInterpreter.java | 1 - .../visitors/RosettaInterpreterListOperatorInterpreter.java | 1 - .../interpreternew/RosettaInterpreterFeatureCallTest.java | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index bf9bad5ce..3955e1c64 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 65577250c..1db27ca41 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -12,7 +12,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index db4b352af..95feb1a75 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -151,6 +151,7 @@ public void testZonedDateTimeTime() { assertEquals(time, result); } + @SuppressWarnings("unused") @Test public void testError() { RosettaExpression expr = parser.parseExpression( From b77df01b0dbba00ffdcd3df9b872ad371b97739a Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 13 Jun 2024 14:19:32 +0200 Subject: [PATCH 191/236] Removed test from ConstructorExpressionTest class --- ...ettaInterpreterConstructorExpressionTest.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 77f66603a..7713b2bde 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -235,22 +235,6 @@ public void testDataType() { .getValue()); } - @Test - public void testOptionalAttributeDataType() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty}"); - - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); - - assertEquals("Person", result.getName()); - assertEquals("name", result.getAttributes().get(0).getName()); - assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) - .getValue()); - System.out.println(result.getAttributes().get(1).getValue()); - } - @Test public void testDataTypeExtends() { RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " From c836c72e8a59129991fcaceff3f54b839cb57a69 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 13 Jun 2024 16:29:35 +0200 Subject: [PATCH 192/236] c2 --- .../interpreternew/values/RosettaInterpreterErrorValue.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java index 93364d8fc..6286208b3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterErrorValue.java @@ -145,7 +145,8 @@ public boolean equals(Object obj) { return false; } RosettaInterpreterErrorValue other = (RosettaInterpreterErrorValue) obj; - return ((List)errors).equals(((List)other.errors)); + return ((List)errors) + .equals(((List)other.errors)); } @Override From de3d1bf9515cfa4f999cfdc69a6cb4a5ddd778bc Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Thu, 13 Jun 2024 17:22:08 +0200 Subject: [PATCH 193/236] Support for 'choice' operation --- ...settaConstructorExpressionInterpreter.java | 75 +++++++++++++++++ ...aInterpreterConstructorExpressionTest.java | 80 +++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index a8b95924e..772e22411 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -2,6 +2,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.eclipse.emf.common.util.EList; @@ -10,6 +12,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -18,10 +21,15 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.ConstructorKeyValuePair; +import com.regnosys.rosetta.rosetta.expression.Necessity; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ChoiceOperationImpl; import com.regnosys.rosetta.rosetta.RosettaCardinality; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Attribute; +import com.regnosys.rosetta.rosetta.simple.Condition; import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.impl.ConditionImpl; import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { @@ -105,6 +113,7 @@ public RosettaInterpreterBaseValue interp( RosettaCardinality card = ((AttributeImpl) pair.getKey()).getCard(); RosettaInterpreterValue value = pair.getValue().accept(visitor, env); + if (RosettaInterpreterErrorValue.errorsExist(value)) { RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) value; @@ -123,6 +132,50 @@ public RosettaInterpreterBaseValue interp( attributes.add(new RosettaInterpreterTypedFeatureValue(name, value, card)); } + //check if attributes are correctly defined, considering the conditions + List conditions = ((DataImpl) expr.getTypeCall().getType()).getConditions(); + + for (Condition condInterface : conditions) { + ConditionImpl c = (ConditionImpl)condInterface; + if (c.getExpression().getClass().equals(ChoiceOperationImpl.class)) { + ChoiceOperationImpl choice = (ChoiceOperationImpl)c.getExpression(); + List choiceAttributesName = choice.getAttributes().stream() + .map(Attribute::getName) + .collect(Collectors.toList()); + + if (choice.getNecessity().equals(Necessity.REQUIRED)) { + //exactly one attribute allowed to be present + // => count non-empty, should be one + int nonEmptyCount = countPresentAttributes( + choiceAttributesName, + attributes); + if (nonEmptyCount != 1) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Choice condition not followed. " + + "Exactly one attribute should " + + "be defined.")); + } + } + + if (choice.getNecessity().equals(Necessity.OPTIONAL)) { + //at most one attribute allowed to be present + // => count non-empty, should be less/equal than one + int nonEmptyCount = countPresentAttributes( + choiceAttributesName, + attributes); + if (nonEmptyCount > 1) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Choice condition not followed. " + + "At most one attribute should " + + "be defined.")); + } + } + + } + } + if (((DataImpl) expr.getTypeCall().getType()).hasSuperType()) { String superType = ((DataImpl) expr.getTypeCall().getType()) .getSuperType().getName(); @@ -137,4 +190,26 @@ public RosettaInterpreterBaseValue interp( return new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Constructor Expressions: attribute type is not valid.")); } + + private int countPresentAttributes(List names, List attributes) { + int countEmpty = 0; + + + Map valueMap = attributes.stream() + .collect(Collectors.toMap( + RosettaInterpreterTypedFeatureValue::getName, + RosettaInterpreterTypedFeatureValue::getValue)); + + for (String name : names) { + RosettaInterpreterValue val = valueMap.get(name); + //attribute empty if it is ListValue with size 0 + if (val instanceof RosettaInterpreterListValue) { + if (((RosettaInterpreterListValue)val).getExpressions().size() == 0) { + countEmpty++; + } + } + } + + return attributes.size() - countEmpty; + } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 7713b2bde..117a40387 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -271,4 +271,84 @@ public void testDataTypeError() { assertEquals(RosettaInterpreterErrorValue.merge(errorValue, errorBool), result); } + + + @Test + public void testDataTypeRequiredChoiceError1() { + RosettaModel model = mh.parseRosetta("type Ob:" + + "one int (0..1) two int (0..1)" + + "condition Choice: required choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { one: 1, two: 2 }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Choice condition not followed. Exactly one attribute should be defined.")); + + assertEquals(expected, result); + } + + @Test + public void testDataTypeRequiredChoiceError2() { + RosettaModel model = mh.parseRosetta("type Ob:" + + "one int (0..1) two int (0..1)" + + "condition Choice: required choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { one: empty, two: empty }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Choice condition not followed. Exactly one attribute should be defined.")); + + assertEquals(expected, result); + } + + @Test + public void testDataTypeRequiredChoice() { + RosettaModel model = mh.parseRosetta("type Ob:" + + "one int (0..1) two int (0..1)" + + "condition Choice: required choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { one: empty, two: 2 }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Ob", result.getName()); + } + + @Test + public void testDataTypeOptionalChoice() { + RosettaModel model = mh.parseRosetta("type Ob:" + + "one int (0..1) two int (0..1)" + + "condition Choice: optional choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { one: empty, two: empty }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Ob", result.getName()); + } + + @Test + public void testDataTypeOptionalChoiceError() { + RosettaModel model = mh.parseRosetta("type Ob:" + + "one int (0..1) two int (0..*)" + + "condition Choice: optional choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { one: 1, two: [2,3] }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Choice condition not followed. At most one attribute should be defined.")); + + assertEquals(expected, result); + } } From 284830e8de9d3f1917b3959273800631ccca9082 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 13 Jun 2024 22:12:27 +0200 Subject: [PATCH 194/236] Quality of code changes --- ...osettaArithmeticOperationsInterpreter.java | 208 +++++++++++------- 1 file changed, 124 insertions(+), 84 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 776a4ee5e..f238f6517 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -40,102 +40,31 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); - //Check that the types are correct for the operations - if (!(leftInterpreted instanceof RosettaInterpreterNumberValue - || leftInterpreted instanceof RosettaInterpreterStringValue - || leftInterpreted instanceof RosettaInterpreterDateValue) - || !(rightInterpreted instanceof RosettaInterpreterNumberValue - || rightInterpreted instanceof RosettaInterpreterStringValue - || rightInterpreted instanceof RosettaInterpreterDateValue)) { - // Check for errors in the left or right side of the binary operation - RosettaInterpreterErrorValue leftErrors = - checkForErrors(leftInterpreted, "Leftside"); - RosettaInterpreterErrorValue rightErrors = - checkForErrors(rightInterpreted, "Rightside"); + // Check for errors in the left or right side of the binary operation + RosettaInterpreterErrorValue leftErrors = + checkForErrors(leftInterpreted, "Leftside"); + RosettaInterpreterErrorValue rightErrors = + checkForErrors(rightInterpreted, "Rightside"); + if (leftErrors.getErrors().size() + rightErrors.getErrors().size() > 0) { return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); - } + } //Interpret string concatenation if (leftInterpreted instanceof RosettaInterpreterStringValue && rightInterpreted instanceof RosettaInterpreterStringValue) { - String leftString = ((RosettaInterpreterStringValue) leftInterpreted) - .getValue(); - String rightString = ((RosettaInterpreterStringValue) rightInterpreted) - .getValue(); - if (expr.getOperator().equals("+")) { - return new RosettaInterpreterStringValue(leftString + rightString); - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Both terms are strings but the operation " - + "is not concatenation: not implemented")); - } + return interpretString(leftInterpreted, rightInterpreted, expr); + //Interpret number operations } else if (leftInterpreted instanceof RosettaInterpreterNumberValue && rightInterpreted instanceof RosettaInterpreterNumberValue) { - RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); - RosettaNumber rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); + return interpretNumber(leftInterpreted, rightInterpreted, expr); - if (expr.getOperator().equals("+")) { - return new RosettaInterpreterNumberValue((leftNumber - .add(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("-")) { - return new RosettaInterpreterNumberValue((leftNumber - .subtract(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("*")) { - return new RosettaInterpreterNumberValue((leftNumber - .multiply(rightNumber)).bigDecimalValue()); - } else { - // Division by 0 is not allowed - if (rightNumber.floatValue() == 0.0) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Division by 0 is not allowed")); - } - return new RosettaInterpreterNumberValue((leftNumber - .divide(rightNumber)).bigDecimalValue()); - } + //Interpret date subtraction } else if (leftInterpreted instanceof RosettaInterpreterDateValue && rightInterpreted instanceof RosettaInterpreterDateValue) { - RosettaInterpreterDateValue l = (RosettaInterpreterDateValue) leftInterpreted; - RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; - if (expr.getOperator().equals("-")) { - String dayL = l.getDay().getValue().bigDecimalValue().toBigInteger().toString(); - if (dayL.length() == 1) { - dayL = "0" + dayL; - } - String monthL = l.getMonth().getValue().bigDecimalValue().toBigInteger().toString(); - if (monthL.length() == 1) { - monthL = "0" + monthL; - } - String yearL = l.getYear().getValue().bigDecimalValue().toBigInteger().toString(); - String dayR = r.getDay().getValue().bigDecimalValue().toBigInteger().toString(); - if (dayR.length() == 1) { - dayR = "0" + dayR; - } - String monthR = r.getMonth().getValue().bigDecimalValue().toBigInteger().toString(); - if (monthR.length() == 1) { - monthR = "0" + monthR; - } - String yearR = r.getYear().getValue().bigDecimalValue().toBigInteger().toString(); - - String inputString1 = dayL + " " + monthL + " " + yearL; - String inputString2 = dayR + " " + monthR + " " + yearR; - - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); - - LocalDateTime date1 = LocalDate.parse(inputString1, dtf).atStartOfDay(); - LocalDateTime date2 = LocalDate.parse(inputString2, dtf).atStartOfDay(); - long daysBetween = Duration.between(date1, date2).toDays(); - return new RosettaInterpreterNumberValue(BigDecimal.valueOf(daysBetween)); - } else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Both terms are dates but the operation " - + "is not subtraction: not implemented")); - } + return interpretDate(leftInterpreted, rightInterpreted, expr); + } else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( @@ -143,6 +72,117 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, } } + /** + * Helper method that contains the code for interpreting string concatenation. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretString(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + String leftString = ((RosettaInterpreterStringValue) leftInterpreted) + .getValue(); + String rightString = ((RosettaInterpreterStringValue) rightInterpreted) + .getValue(); + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterStringValue(leftString + rightString); + } + else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Both terms are strings but the operation " + + "is not concatenation: not implemented")); + } + } + + /** + * Helper method that contains the code for interpreting number operations. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretNumber(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); + RosettaNumber rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); + + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterNumberValue((leftNumber + .add(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("-")) { + return new RosettaInterpreterNumberValue((leftNumber + .subtract(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("*")) { + return new RosettaInterpreterNumberValue((leftNumber + .multiply(rightNumber)).bigDecimalValue()); + } else { + // Division by 0 is not allowed + if (rightNumber.floatValue() == 0.0) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Division by 0 is not allowed")); + } + return new RosettaInterpreterNumberValue((leftNumber + .divide(rightNumber)).bigDecimalValue()); + } + } + + /** + * Helper method that contains the code for interpreting date subtraction. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretDate(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + RosettaInterpreterDateValue l = (RosettaInterpreterDateValue) leftInterpreted; + RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; + if (expr.getOperator().equals("-")) { + String dayL = appendZeroes(l.getDay()); + String monthL = appendZeroes(l.getMonth()); + String yearL = appendZeroes(l.getYear()); + String dayR = appendZeroes(r.getDay()); + String monthR = appendZeroes(r.getMonth()); + String yearR = appendZeroes(l.getYear()); + + String inputString1 = dayL + " " + monthL + " " + yearL; + String inputString2 = dayR + " " + monthR + " " + yearR; + + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); + + LocalDateTime date1 = LocalDate.parse(inputString1, dtf).atStartOfDay(); + LocalDateTime date2 = LocalDate.parse(inputString2, dtf).atStartOfDay(); + long daysBetween = Duration.between(date1, date2).toDays(); + return new RosettaInterpreterNumberValue(BigDecimal.valueOf(daysBetween)); + } else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Both terms are dates but the operation " + + "is not subtraction: not implemented")); + } + } + + /** + * Helper method that adds a 0 to a day/month string in case it does not have it, + * to correspond to the proper format. + * + * @param d The day/month value as a RosettaInterpreterNumberValue + * @return The (optionally) modified string value. + */ + private String appendZeroes(RosettaInterpreterNumberValue d) { + String result = d.getValue().bigDecimalValue().toBigInteger().toString(); + if (result.length() == 1) { + result = "0" + result; + } + return result; + } + /** * Helper method that takes an interpretedValue and a string, From 01130b46a5cd890a0e1f2055d6c334f1a401fbee Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 13 Jun 2024 22:16:05 +0200 Subject: [PATCH 195/236] C --- ...osettaInterpreterRosettaArithmeticOperationsInterpreter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index f238f6517..ce2912256 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -149,7 +149,7 @@ private RosettaInterpreterValue interpretDate(RosettaInterpreterValue leftInterp String yearL = appendZeroes(l.getYear()); String dayR = appendZeroes(r.getDay()); String monthR = appendZeroes(r.getMonth()); - String yearR = appendZeroes(l.getYear()); + String yearR = appendZeroes(r.getYear()); String inputString1 = dayL + " " + monthL + " " + yearL; String inputString2 = dayR + " " + monthR + " " + yearR; From 7d6a2f9aeb7214901d46166de96af54cc8adbd54 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 14 Jun 2024 11:53:36 +0200 Subject: [PATCH 196/236] Improved documentation --- README.md | 81 ++++++++++++++++++++++++++++++-------- img/Project_Structure.png | Bin 0 -> 333929 bytes 2 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 img/Project_Structure.png diff --git a/README.md b/README.md index 6fa52c52b..90f03940a 100644 --- a/README.md +++ b/README.md @@ -2,45 +2,92 @@ An interpreter for a subset of the Rune DSl. -For most practical information, refer to the [original readme file](README_project.md) +For more information, refer to the [original Rosetta readme file](README_project.md) -## Authors -- Jacek Kulik -- Antonio Lupu -- Maria Cristescu -- Bogdan Damian -- Diana Şutac +## How to build + +Refer to the main building instructions in the original readme. + +Additionally, open the `interpreternew` module. + +If the project still doesn't build try the following steps: +- Mark [xsemantics gen](rosetta-lang/target/xsemantics-gen/main/java/) as a source folder +- Close the projects: `com.regnosys.rosetta.ide`, `com.regnosys.rosetta.profiling`, `com.regnosys.rosetta.tools`, `rosetta-maven-plugin` +- Update the Maven project ## Project Structure -FIGURE HERE +![Class structure Diagram](img/Project_Structure.png) -Rune operations are defined in [xcore files](rosetta-lang/model/RosettaInterpreter.xcore) +Rune operations are defined in [xcore files in the model folder](rosetta-lang/model/). The constructs defined there get auto generated into the generated source folders. They correspond to the objects that the parser can return, and thus are essential for ensuring compatibility with it. It does have some limitations, such as the lack of the notion of many data types, like streams, so some general operations are defined outside those files if they concern more complicated Java constructs. All objects generated via xcore have som associated EObject methods required for them, that are used to get back the original semantics of how they were generated. Thus to implement those methods, the generated objects we make use of also implement `MinimalEObject` to get a base implementation of those methods, if nothing custom is required. -All interpretable operations implement an interp method which takes in an expression and an environment. +All interpretable operations implement an interp method which takes in a visitor and an environment. There is a visitor which accepts the expressions and passes them along to the correct concrete interpreter to perform their operations. +Each concrete interpreter in the [interpreters module](rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/) concerns the interpretation of a certain thematically linked part of Rune operations. For example the List Operators interpreter interprets list `exists`, `absent`, `first`, `only`, `last`, `distinct`, `reverse`, `sum` as they all apply an operation to a list of values and they are somewhat similar in their implementation pattern. + +The program flow starts in the [main interpreter file](rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java). It contains fields for the visitor and the environment and keeps track of them. When interrpetation is started, this class is used by calling its `interp` method. This starts the interpretation flow and keeps track of the environment + +## Error handling and preservation of semantics + +All the operations are implementations of `EObject` so they retain information about the original text they were generated from and all other metadata about the parsing process. Thus it is important to preserve that information through the interpretation process. + +When an error is encountered, it gets associated with an EObject, such that more diagnostic information can be retaing from it. Currently, the information that is given to the user is the position in the source code of the text that generated the error constructs, though in the future this functionality could be extended. + +Errors are stored as `RosettaInterpreterErrorValue`. When an interpretation function encounteres an error value, it should try to propagate that error further up in the computation. This can be achieved by scanning through all the inputs received, and if any errors are found, returning them. The `RosettaInterpreterErrorValue.errorsExist()` and `RosettaInterpreterErrorValue.merge()` methods can be used for those purposes. + +## Testing + +The benchmark for good testing coverage for this project is 100% branch coverage, and should be achieved wherever possible. + +Tests are created in the [interpreter test folder](rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/) + +Useful tools for the testing process: +- Expressionparser: allows for parsing a string representation of a Rune expression into a `RosettaExpression` +- ExpressionFactory: allows for directly instantiating an expression object +- ExpressionValidationHelper: allows for validating that a parsed expression is actually a valid Rune expression + +## Checkstyle + +The [checkstyle file](checkstyle-SP.xml) is enforced for the project. It is not a very strict checkstyle, but ensures some style guidelines and helps with readability of the codebase. + +## CI/CD Pipeline + +The [pipeline](.gitlab-ci.yml) runs on the repository after each pushed commit. + +It consists of three stages: +1. Build - ensure the codebase compiles and builds successfully +2. Test - run all the tests and ensure they all pass +3. Checkstyle - check all Interpreter source files and ensure they adhere to the checkstyle + ## How to extend ### New Expression The simplest extension is by adding new Rune constructs to interpret. The process for this is: 1. Define the interp method for this expression in [RosettaExpression.xcore](rosetta-lang/model/RosettaExpression.xcore) - 2. Create a new class inside [interpreternew.visitors](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/visitors/) OR use one of the already existing ones if it fits thematically - 3. Implement a new interp method in [RosettaInterpreterVisitor.java](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java) to accept the new expression + 2. Create a new class inside [interpreternew.visitors](rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/) OR use one of the already existing ones if it fits thematically + 3. Implement a new interp method in [RosettaInterpreterVisitor.java](rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java) to accept the new expression 4. Implement the interpretation of the expression - 5. Test the expression in [the testing module](rosetta-testing/src/test/java/com/regnosys/rosetta/interpreternew/visitors/) + 5. Test the expression in [the testing module](rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/visitors/) ### New Value Domain Type Right now this process doesn't have any additional steps, but this may change in the future. -1. Create a new class in [the value domain folder](rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/values/) -2. Optionally also test the class if it requires it +1. Create a new class in [the value domain folder](rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/) +2. Test the class if it requires it ### New Expression Function -Currently there is only the interpretation function defined for the expressions, but the visitor pattern allows for easily adding a new one. +Currently there is only the interpretation function defined for the expressions, but the visitor pattern allows for adding a new one. 1. Create a new main visitor (like RosettaTypeCheckVisitor) 2. Define accept methods for this visitor for all the expressions -3. Implement concrete acceptors in the new visitor or in new files stemming from it \ No newline at end of file +3. Implement concrete acceptors in the new visitor or in new files stemming from it + +## Authors +- Jacek Kulik +- Antonio Lupu +- Maria Cristescu +- Bogdan Damian +- Diana Şutac \ No newline at end of file diff --git a/img/Project_Structure.png b/img/Project_Structure.png new file mode 100644 index 0000000000000000000000000000000000000000..74939647ad57ab4c063f723217dca413e716bf7c GIT binary patch literal 333929 zcmeGEXH=6}_%{lxSVs}d3>a9`3;)dTRac`9#jxeu5ZGH zO;U^v?emtdoRg9;@r~2J**R)0z1F(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v$y(`vWz_LL#Tx0NqyTcvNpUs!?~^7U0s_yGOpl-NwaTDq>AzT) z%6a7%zFREH42Wg+^z4RyoG6$y)9M1Q_!1?AJ`I>OY6cDX{j;bzAOmv30vq*;|Gp1Q z*!W`^5_lP8RRqZ0c<|hKUE)Y@od88SDMi^ZK_O79Kd*r7eOclFT(c#C#B|QCBuPBS zPXQUQ_>A7r8jpwEyNki(aQBWHASdG|f)CT`YXPw|TQ1lrIfC#7$cd`TMdH6trG618 zQWbRpe2axBG$?>mlK0tY%@FbgO7HmRTTfv!;0KV?c-aeUz}yPN(qd?A1ojYKNvw(b z--8Jh*HYgnUcsw|P1Urinl@F_rfS+$O`BHJrq%Sf-8}DsC0FB&H+Z)Iy9p}zG~1EC zkx8%x#SH=|xyN3}!weovGGO6p9dq8XZY-mqEzcvInJ}k>z%B&I17c;V)Kqxa5JeD2 zRQdSB0Kby|rM{HFe69u7g$k`v-DUi18<`Mzy9{St1OQu?>&hfN+(7uy23K-{#Wna+ z_6*EcCP0?}YM2FBObrOghIGT5XB$0DI5dJ5kW$C*@==(fM&KIYko_AT>W4u5_Cgih zqyJC6{}b#OOMG;40Pa)$r&u5Zq$(g`9v(mbPra`LIB0u?Jsg&W|4)%n|3NW^C{~o_ VsoGuC#1`=H@ Date: Fri, 14 Jun 2024 13:13:30 +0300 Subject: [PATCH 197/236] Fixed some comments --- .../RosettaInterpreterIntegerValue.java | 60 ----------------- ...settaConstructorExpressionInterpreter.java | 65 ++++++++++++++----- ...aInterpreterConstructorExpressionTest.java | 33 ++++++++++ 3 files changed, 80 insertions(+), 78 deletions(-) delete mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java deleted file mode 100644 index c3edb3e43..000000000 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterIntegerValue.java +++ /dev/null @@ -1,60 +0,0 @@ -//package com.regnosys.rosetta.interpreternew.values; -// -//import java.math.BigInteger; -//import java.util.Objects; -//import java.util.stream.Stream; -// -//import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -// -//public class RosettaInterpreterIntegerValue extends RosettaInterpreterBaseValue -// implements Comparable { -// -// private BigInteger value; -// -// @Override -// public int hashCode() { -// return Objects.hash(value); -// } -// -// @Override -// public boolean equals(Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (getClass() != obj.getClass()) { -// return false; -// } -// RosettaInterpreterIntegerValue other = (RosettaInterpreterIntegerValue) obj; -// return Objects.equals(value, other.value); -// } -// -// public RosettaInterpreterIntegerValue(BigInteger value) { -// super(); -// this.value = value; -// } -// -// public RosettaInterpreterIntegerValue(int value) { -// super(); -// this.value = BigInteger.valueOf(value); -// } -// -// public BigInteger getValue() { return value; } -// -// @Override -// public int compareTo(RosettaInterpreterIntegerValue o) { -// return this.value.compareTo(o.value); -// } -// -// @Override -// public Stream toElementStream() { -// return Stream.of(value); -// } -// -// @Override -// public Stream toValueStream() { -// return Stream.of(this); -// } -//} diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index a8b95924e..f02829574 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -3,13 +3,17 @@ import java.util.ArrayList; import java.util.List; +import javax.inject.Inject; + import org.eclipse.emf.common.util.EList; +import com.regnosys.rosetta.RosettaExtensions; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -21,11 +25,14 @@ import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.RosettaCardinality; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.Attribute; import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; public class RosettaInterpreterRosettaConstructorExpressionInterpreter extends RosettaInterpreterConcreteInterpreter { + @Inject + RosettaExtensions ext = new RosettaExtensions(); + /** * Interpreter method for Constructor Expressions. * @@ -98,29 +105,51 @@ public RosettaInterpreterBaseValue interp( default: { List attributes = new ArrayList<>(); - // This for will take all the attributes of a data type, - // including the ones of the supertype - for (ConstructorKeyValuePair pair : values) { - String name = pair.getKey().getName(); - RosettaCardinality card = ((AttributeImpl) pair.getKey()).getCard(); - RosettaInterpreterValue value = pair.getValue().accept(visitor, env); + DataImpl data = (DataImpl) expr.getTypeCall().getType(); + // This retrieves all the attributes of a data type + List allAtt = ext.allNonOverridesAttributes(data); + + for (Attribute att : allAtt) { + String name = att.getName(); + RosettaCardinality card = att.getCard(); + boolean contains = false; - if (RosettaInterpreterErrorValue.errorsExist(value)) { - RosettaInterpreterErrorValue expError = - (RosettaInterpreterErrorValue) value; - RosettaInterpreterErrorValue newExpError = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError( + // Here I get the attributes from the constructor + for (ConstructorKeyValuePair pair : values) { + // Check if the attributes from the data type are in + // the list of the constructor attributes. If they are, + // assign them a value, else they are empty. This is needed + // for when '...' is used in the constructor. + if (name.equals(pair.getKey().getName())) { + RosettaInterpreterValue value = + pair.getValue().accept(visitor, env); + + if (RosettaInterpreterErrorValue.errorsExist(value)) { + RosettaInterpreterErrorValue expError = + (RosettaInterpreterErrorValue) value; + RosettaInterpreterErrorValue newExpError = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError( "Constructor Expression" + ": the attribute \"" + name + "\" is an " + "error value.")); - - return RosettaInterpreterErrorValue.merge( - List.of(newExpError, expError)); + + return RosettaInterpreterErrorValue.merge( + List.of(newExpError, expError)); + } + contains = true; + + attributes.add(new + RosettaInterpreterTypedFeatureValue(name, value, card)); + } + } + if (!contains) { + RosettaInterpreterListValue empty = + new RosettaInterpreterListValue(List.of()); + attributes.add(new + RosettaInterpreterTypedFeatureValue(name, empty, card)); } - - attributes.add(new RosettaInterpreterTypedFeatureValue(name, value, card)); } if (((DataImpl) expr.getTypeCall().getType()).hasSuperType()) { diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 7713b2bde..dad2d827d 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -17,6 +17,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -271,4 +272,36 @@ public void testDataTypeError() { assertEquals(RosettaInterpreterErrorValue.merge(errorValue, errorBool), result); } + + @Test + public void testDataTypeCardZero() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) age number (0..1) " + + "func M: output: result Person (1..1) set result: Person { name: \"F\", age: empty }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Person", result.getName()); + assertEquals("name", result.getAttributes().get(0).getName()); + assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) + .getValue()); + assertEquals(new RosettaInterpreterListValue(List.of()), result.getAttributes().get(1).getValue()); + } + + @Test + public void testDataTypeCardZero2() { + RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) age number (0..1) " + + "func M: output: result Person (1..1) set result: Person { name: \"F\", ... }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Person", result.getName()); + assertEquals("name", result.getAttributes().get(0).getName()); + assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) + .getValue()); + assertEquals(new RosettaInterpreterListValue(List.of()), result.getAttributes().get(1).getValue()); + } } From fa30fce2cf2bb2b07d1d43937be8335f6ca04c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 14 Jun 2024 13:43:27 +0300 Subject: [PATCH 198/236] Fixed tests --- .../values/RosettaInterpreterTypedValue.java | 6 ------ ...aInterpreterConstructorExpressionTest.java | 18 +++++++++-------- .../RosettaInterpreterEnumTest.java | 8 ++++---- .../RosettaInterpreterFeatureCallTest.java | 20 ++++++++++++++++--- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java index 741cd9365..af22c559b 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedValue.java @@ -52,13 +52,7 @@ public String getName() { return name; } - /** - * Getter for the attributes of a data-type. If it has a supertype, it return its attributes as well. - * - * @return a list of attributes, including the one from a supertype if it has one - */ public List getAttributes() { - // This will return all attributes, including the ones of the supertype return attributes; } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index dad2d827d..e3a463e75 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -43,7 +43,7 @@ public class RosettaInterpreterConstructorExpressionTest { RosettaInterpreterNew interpreter; @Inject - ModelHelper mh; + ModelHelper modelHelper; RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); @@ -223,7 +223,7 @@ public void testZonedDateTimeNotValidZone() { @Test public void testDataType() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + "func M: output: result Person (1..1) set result: Person { name: \"F\" }"); RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( @@ -238,7 +238,7 @@ public void testDataType() { @Test public void testDataTypeExtends() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + "type Age extends Person: age number (1..1)" + "func M: output: result Person (1..1) " + "set result: Age { name: \"F\", age: 10 }"); @@ -258,7 +258,7 @@ public void testDataTypeExtends() { @Test public void testDataTypeError() { - RosettaModel model = mh.parseRosetta("type Test: value boolean (1..1) " + RosettaModel model = modelHelper.parseRosetta("type Test: value boolean (1..1) " + "func M: output: result Test (1..1) set result: Test { value: 1 and True }"); RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( @@ -275,8 +275,9 @@ public void testDataTypeError() { @Test public void testDataTypeCardZero() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) age number (0..1) " - + "func M: output: result Person (1..1) set result: Person { name: \"F\", age: empty }"); + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "age number (0..1) func M: output: result Person (1..1) " + + "set result: Person { name: \"F\", age: empty }"); RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); @@ -291,8 +292,9 @@ public void testDataTypeCardZero() { @Test public void testDataTypeCardZero2() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) age number (0..1) " - + "func M: output: result Person (1..1) set result: Person { name: \"F\", ... }"); + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "age number (0..1) func M: output: result Person (1..1) " + + "set result: Person { name: \"F\", ... }"); RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java index cd38dab4a..d3d6b358a 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterEnumTest.java @@ -28,11 +28,11 @@ public class RosettaInterpreterEnumTest { RosettaInterpreterNew interpreter; @Inject - ModelHelper mh; + ModelHelper modelHelper; @Test public void enumAddsToEnvironmentTest() { - RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + " VALUE1 displayName \"VALUE1\"\r\n" + " VALUE2\r\n" + "\r\n" @@ -57,7 +57,7 @@ public void enumAddsToEnvironmentTest() { @Test public void enumRefTest() { - RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + " VALUE1 displayName \"VALUE1\"\r\n" + " VALUE2\r\n" + "\r\n" @@ -81,7 +81,7 @@ public void enumRefTest() { @Test public void combinedTest() { - RosettaModel model = mh.parseRosettaWithNoErrors("enum Foo:\r\n" + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + " VALUE1 displayName \"VALUE1\"\r\n" + " VALUE2\r\n" + "\r\n" diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index 249141912..cd4eea3ca 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -16,6 +16,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; @@ -39,7 +40,7 @@ public class RosettaInterpreterFeatureCallTest { RosettaInterpreterNew interpreter; @Inject - ModelHelper mh; + ModelHelper modelHelper; RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); @@ -170,7 +171,7 @@ public void testError() { @Test public void testDataType() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + "func M: output: result string (1..1) set result: Person { name: \"F\" } -> name"); RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) @@ -182,7 +183,7 @@ public void testDataType() { @Test public void testDataTypeExtends() { - RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + "type Age extends Person: age number (1..1) " + "func M: output: result number (1..1) set result: " + "Age { name: \"F\", age: 10 } -> age"); @@ -193,4 +194,17 @@ public void testDataTypeExtends() { assertEquals(10, ((RosettaInterpreterNumberValue) result).getValue().intValue()); } + + @Test + public void testDataTypeEmpty() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + + "age number (0..1) func M: output: result number (1..1) " + + "set result: Person { name: \"F\", ... } -> age"); + + RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) + model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(featureCall); + + assertEquals(new RosettaInterpreterListValue(List.of()), result); + } } From 6b9e578a7b0687a2b3bbc174581d105c54224eae Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 14 Jun 2024 12:44:32 +0200 Subject: [PATCH 199/236] Improved the code quality of the functions --- ...aInterpreterListOperationsInterpreter.java | 1 - ...ttaInterpreterListOperatorInterpreter.java | 1 - ...settaConditionalExpressionInterpreter.java | 1 - ...RosettaInterpreterVariableInterpreter.java | 260 +----------------- 4 files changed, 2 insertions(+), 261 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java index 578bcec0d..ed2341479 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperationsInterpreter.java @@ -10,7 +10,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.JoinOperation; import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java index 4cc574cd8..5fcd1d0e3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterListOperatorInterpreter.java @@ -12,7 +12,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.DistinctOperation; import com.regnosys.rosetta.rosetta.expression.FirstOperation; import com.regnosys.rosetta.rosetta.expression.LastOperation; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 4a273e152..e44e5ba4d 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -7,7 +7,6 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index 3dc54edf7..a8f1c06fe 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -1,31 +1,11 @@ package com.regnosys.rosetta.interpreternew.visitors; -import java.util.ArrayList; -import java.util.List; -//import java.util.Map; -import java.util.stream.Collectors; - import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; -//import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; -import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; -import com.regnosys.rosetta.rosetta.simple.Condition; -import com.regnosys.rosetta.rosetta.simple.Operation; -import com.regnosys.rosetta.rosetta.simple.ShortcutDeclaration; -import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; public class RosettaInterpreterVariableInterpreter { @@ -50,7 +30,8 @@ public RosettaInterpreterValue interp(RosettaSymbolReference exp, RosettaInterpreterBaseEnvironment env) { if (exp.getSymbol() instanceof FunctionImpl) { - return interp((FunctionImpl) exp.getSymbol(), exp.getRawArgs(), env); + return (new RosettaInterpreterFunctionInterpreter()) + .interp((FunctionImpl) exp.getSymbol(), exp.getRawArgs(), env); } return interp(exp.getSymbol().getName(), env); @@ -76,243 +57,6 @@ public RosettaInterpreterValue interp(String varName, return varValue; } - /** - * Interprets a function, returns the result. - * - * @param func The name of the function to interpret - * @param env RosettaInterpreterEnvironment that keeps track - * of the current state of the program - * @return If no errors are encountered, a RosettaInterpreterValue representing - * the value of the function. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterValue interp(FunctionImpl func, List args, - RosettaInterpreterBaseEnvironment env) { - - final FunctionImpl f = ((RosettaInterpreterFunctionValue) env.findValue(func.getName())) - .getFunction(); - - //interpret the raw arguments - List interpretedArgs = new ArrayList<>(); - for (RosettaExpression e : args) { - interpretedArgs.add(e.accept(visitor, env)); - } - - //check if there are any errors in interpreting the arguments. If so, return them - RosettaInterpreterErrorValue acc = new RosettaInterpreterErrorValue(); - for (RosettaInterpreterValue value : interpretedArgs) { - acc.addAllErrors(value); - } - if (acc.getErrors().size() > 0) { - return acc; - } - - //check that all argument/passed value correspond in type and cardinality - //if not, return errors pointing to each attribute reference where this is the case - int inputSize = f.getInputs().size(); - for (int i = 0 ; i < inputSize ; i++) { - acc.addAllErrors(checkPair((AttributeImpl) f.getInputs().get(i), - (RosettaInterpreterBaseValue) interpretedArgs.get(i))); - } - if (acc.getErrors().size() > 0) { - return acc; - } - - //create a copy of the enums and data types in the passed environment - //since those are the only "global" variables -// RosettaInterpreterEnvironment nv = copyDataTypesOnly(env); - //Create a new environment to use for evaluating the operations - RosettaInterpreterEnvironment nv = new RosettaInterpreterEnvironment(); - //add all the argument/value pairs to the NEW environment - for (int i = 0 ; i < inputSize ; i++) { - AttributeImpl attr = (AttributeImpl) f.getInputs().get(i); - RosettaInterpreterBaseValue value = (RosettaInterpreterBaseValue) interpretedArgs.get(i); - nv.addValue(attr.getName(), value); - } - - //check the pre-conditions of the function - List conditions = func.getConditions(); - for (Condition c : conditions) { - RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); - if (v instanceof RosettaInterpreterBooleanValue) { - if (((RosettaInterpreterBooleanValue) v).getValue() == false) { - acc.addError(new RosettaInterpreterError("Condition \"" - + c.getName() + "\" does not hold for this function call")); - } - } else { //must be an error if not a boolean value - acc.addAllErrors(v); - } - } - if (acc.getErrors().size() > 0) { - return acc; - } - - //Add all aliases to the environment, throw errors if any are found - List aliases = f.getShortcuts(); - for (ShortcutDeclaration alias : aliases) { - RosettaInterpreterBaseValue val = (RosettaInterpreterBaseValue) - alias.getExpression().accept(visitor, nv); - acc.addAllErrors(val); - nv.addValue(alias.getName(), val); - } if (acc.getErrors().size() > 0) { - return acc; - } - - - //compute the results of all operations in the function - List resultList = new ArrayList<>(); - for (Operation o : f.getOperations()) { - if (o.isAdd()) { - resultList.add(o.getExpression().accept(visitor, nv)); - } else { - resultList = ((RosettaInterpreterBaseValue) o.getExpression().accept(visitor, nv)) - .toValueStream().collect(Collectors.toList()); - } - } - - //check that the function operations yield no errors - for (RosettaInterpreterValue value : resultList) { - acc.addAllErrors(value); - } if (acc.getErrors().size() > 0) { - return acc; - } - - //check cardinality and type of output matches computed value - RosettaInterpreterBaseValue result; - int upperLimit = f.getOutput().getCard().isUnbounded() ? Integer.MAX_VALUE : - f.getOutput().getCard().getSup(); - int lowerLimit = f.getOutput().getCard().getInf(); - //make the result a single element or a list depending on its stated cardinality - if (upperLimit == 1 && lowerLimit == 1) { - result = (RosettaInterpreterBaseValue) resultList.get(0); - } else { - result = new RosettaInterpreterListValue(resultList); - } - acc.addAllErrors(checkPair((AttributeImpl) f.getOutput(), result)); - if (acc.getErrors().size() > 0) { - return acc; - } - - //check the post-conditions of the function - nv.addValue(f.getOutput().getName(), result); - conditions = func.getPostConditions(); - for (Condition c : conditions) { - RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); - if (v instanceof RosettaInterpreterBooleanValue) { - if (((RosettaInterpreterBooleanValue) v).getValue() == false) { - acc.addError(new RosettaInterpreterError("Condition \"" - + c.getName() + "\" does not hold for this function call")); - } - } else { //must be an error if not a boolean value - acc.addAllErrors(v); - } - } - if (acc.getErrors().size() > 0) { - return acc; - } - - - //if everything went well, return the result - return result; - } - - /** - * Subroutine for checking that the function call is valid based on cardinality and type checking. - * - * @param attr The attribute object that contains the pertinent information - * @param value The interpreted value that is passed to the function - * @return True if the type and cardinality of the attribute and value match, false otherwise - */ - public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) { - //This will consider only basic types, this will be changed after datatypes are done - String typeName = attr.getTypeCall().getType().getName(); - List vals = value.toValueStream() - .collect(Collectors.toList()); - - //check that the cardinality of the arg and the value match - int paramSize = vals.size(); - int lowerLimit = attr.getCard().getInf(); - if (paramSize < lowerLimit) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" has cardinality lower than the limit " - + lowerLimit)); - } - int upperLimit = attr.getCard().isUnbounded() ? Integer.MAX_VALUE : attr.getCard().getSup(); - if (paramSize > upperLimit) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" has cardinality higher than the limit " - + upperLimit)); - } - - //checking that the potential list of elements in arg and value are of the same type - switch (typeName) { - case "number": - for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterNumberValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" requires a number, but received a " - + val.getClass())); - } - } - break; - case "int": - for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterNumberValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" requires a number, but received a " - + val.getClass())); - } - } - break; - case "boolean": - for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterBooleanValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" requires a boolean, but received a " - + val.getClass())); - } - } - break; - case "string": - for (RosettaInterpreterValue val : vals) { - if (!(val instanceof RosettaInterpreterStringValue)) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError("The attribute \"" - + attr.getName() + "\" requires a string, but received a " - + val.getClass())); - } - } - break; - // this will be implemented after record types - // case "time": - // if (!(val instanceof RosettaInterpreterNumberValue - // || val instanceof RosettaInterpreterIntegerValue)) { - // return false; - // } - default: - } - //if all checks pass, return true - return new RosettaInterpreterErrorValue(); - - } - //This will be used once enum values and data types are implemented and merged - //For now, this branch knows nothing of such "global"ly available variables -// public RosettaInterpreterEnvironment copyDataTypesOnly(RosettaInterpreterEnvironment env) { -// RosettaInterpreterEnvironment result = new RosettaInterpreterEnvironment(); -// Map environment = env.getEnvironment(); -// for (Map.Entry entry : environment.entrySet()) { -// if (entry.getValue() instanceof RosettaInterpreterEnumValue) { -// result.addValue(entry.getKey(), entry.getValue()); -// } -// } -// return result; -// } } From 696a37de15b4345d6d28d60dacbbcb75861f9086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 14 Jun 2024 14:05:22 +0300 Subject: [PATCH 200/236] Fixed more comments from MR --- ...ettaInterpreterFeatureCallInterpreter.java | 60 ------------------- ...erpreterRosettaFeatureCallInterpreter.java | 28 ++++----- .../RosettaInterpreterFeatureCallTest.java | 3 + 3 files changed, 14 insertions(+), 77 deletions(-) delete mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java deleted file mode 100644 index 7906f77e1..000000000 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.regnosys.rosetta.interpreternew.visitors; - -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.rosetta.RosettaEnumValue; -import com.regnosys.rosetta.rosetta.RosettaEnumeration; -import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; -import com.regnosys.rosetta.rosetta.impl.RosettaEnumValueImpl; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -public class RosettaInterpreterFeatureCallInterpreter - extends RosettaInterpreterConcreteInterpreter { - - /** - * Based on what class the symbol reference belongs to, it chooses what method to send it to. - * - * @param expr The RosettaFeatureCall expression to redirect - * @param env The Environment - * @return If no errors are encountered, a RosettaInterpreterNumberValue or - * RosettaInterpreterStringValue representing - * the result of the arithmetic/concatenation operation. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterValue interp(RosettaFeatureCall expr, - RosettaInterpreterEnvironment env) { - RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) expr.getReceiver(); - RosettaEnumValue enumVal; - //if(expr.getFeature() instanceof RosettaEnumValueImpl) { - enumVal = (RosettaEnumValueImpl) expr.getFeature(); - RosettaEnumeration enumeration = (RosettaEnumeration) ref.getSymbol(); - return interpEnum(enumeration, enumVal, env); - //} - //else Here comes the DataType ref call implementation that will have a different interp method - - } - - /** - * Interprets an enum feature call. - * - * @param enumeration The RosettaEnumeration to interpret alongside - * @param val The enum value to interpret - * @param env The Environment - * @return If no errors are encountered, a RosettaInterpreterNumberValue or - * RosettaInterpreterStringValue representing - * the result of the arithmetic/concatenation operation. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, RosettaEnumValue val, - RosettaInterpreterEnvironment env) { - - return new RosettaInterpreterEnumElementValue(val.getEnumeration().getName(), - val.getName()); - - - } - -} diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index 14d04e9a1..a5ac9d51f 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -45,9 +45,8 @@ public RosettaInterpreterValue interp(RosettaFeatureCall expr, RosettaEnumeration enumeration = (RosettaEnumeration) ((RosettaSymbolReferenceImpl) expr.getReceiver()).getSymbol(); return interpEnum(enumeration, enumVal, env); - } - else { - return interpRecord(expr, env); + } else { + return interpType(expr, env); } } @@ -79,7 +78,7 @@ public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, Rosett * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interpRecord(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterBaseValue interpType(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { RosettaExpression receiver = exp.getReceiver(); RosettaInterpreterValue receiverValue = receiver.accept(visitor, env); @@ -110,15 +109,7 @@ public RosettaInterpreterBaseValue interpRecord(RosettaFeatureCall exp, RosettaI return ((RosettaInterpreterZonedDateTimeValue) receiverValue).getTimeZone(); } - } else if (RosettaInterpreterErrorValue.errorsExist(receiverValue)) { - RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) receiverValue; - RosettaInterpreterErrorValue newExpError = - new RosettaInterpreterErrorValue( - new RosettaInterpreterError("Feature calls: the " - + "receiver is an error value.")); - - return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); - } else { + } else if (receiverValue instanceof RosettaInterpreterTypedValue) { List attributes = ((RosettaInterpreterTypedValue) receiverValue).getAttributes(); @@ -128,11 +119,14 @@ public RosettaInterpreterBaseValue interpRecord(RosettaFeatureCall exp, RosettaI RosettaInterpreterTypedFeatureValue) att).getValue(); } } - } + + RosettaInterpreterErrorValue expError = (RosettaInterpreterErrorValue) receiverValue; + RosettaInterpreterErrorValue newExpError = + new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Feature calls: the " + + "receiver is an error value.")); - // statement never reached - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Feature calls: receiver doesn't exist.")); + return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index cd4eea3ca..265dcc473 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -174,6 +174,9 @@ public void testDataType() { RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) " + "func M: output: result string (1..1) set result: Person { name: \"F\" } -> name"); + System.out.println(((RosettaFeatureCallImpl) ((FunctionImpl) + model.getElements().get(1)).getOperations().get(0).getExpression()).getReceiver()); + RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); RosettaInterpreterValue result = interpreter.interp(featureCall); From b0cf787048c29e44834b783b12a227471be3c8b5 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 14 Jun 2024 13:18:42 +0200 Subject: [PATCH 201/236] Started working on only exists --- .../RosettaInterpreterVisitor.java | 7 + ...settaInterpreterOnlyExistsInterpreter.java | 28 ++++ ...aInterpreterOnlyExistsInterpreterTest.java | 133 ++++++++++++++++++ rosetta-lang/model/RosettaExpression.xcore | 3 + rosetta-lang/model/RosettaInterpreter.xcore | 2 + 5 files changed, 173 insertions(+) create mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 784573cec..ec66cb9a3 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -25,6 +25,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyExistsExpression; import com.regnosys.rosetta.rosetta.expression.RosettaPatternLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; @@ -34,6 +35,7 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterOnlyExistsInterpreter; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; @@ -230,5 +232,10 @@ public RosettaInterpreterValue interp(RosettaConstructorExpression exp, RosettaI public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterRosettaFeatureCallInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterOnlyExistsInterpreter().interp(exp, env); + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java new file mode 100644 index 000000000..0e9f817da --- /dev/null +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java @@ -0,0 +1,28 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.*; + +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyExistsExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; + +public class RosettaInterpreterOnlyExistsInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { + + List interpretedArgs = new ArrayList<>(); + + for(RosettaExpression expression : exp.getArgs()) { + RosettaInterpreterValue val = expression.accept(visitor, env); + interpretedArgs.add(val); + System.out.println(val); + System.out.println(); + } + + + return null; + } + + +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java new file mode 100644 index 000000000..32c28b602 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java @@ -0,0 +1,133 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.HashMap; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; +import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaOnlyExistsExpressionImpl; + + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterOnlyExistsInterpreterTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + @Inject + ModelHelper modelHelper; + @SuppressWarnings("unused") + private ExpressionFactory expFactory; + + @BeforeEach + public void setup() { + expFactory = ExpressionFactoryImpl.init(); + } + + @Test + public void testOptionalAttributeDataType() { +// RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1)" +// + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty}"); +// RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( +// FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); +// RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + +// Example from Data Types Class: +// RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " +// + "type Age extends Person: age number (1..1) " +// + "func M: output: result number (1..1) set result: " +// + "Age { name: \"F\", age: 10 } -> age"); +// RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) +// model.getElements().get(2)).getOperations().get(0).getExpression()); +// RosettaInterpreterValue result = interpreter.interp(featureCall); + + +// RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1) " +// + "func M: output: result boolean (1..1) alias person: Person { name: \"F\", height: empty} " +// + "set result: person -> name only exists"); +// String code = "type Foo:\n" + +// " bar Bar (0..*)\n" + +// " baz Baz (0..1)\n" + +// "\n" + +// "type Bar:\n" + +// " before number (0..1)\n" + +// " after number (0..1)\n" + +// " other number (0..1)\n" + +// " beforeList number (0..*)\n" + +// " afterList number (0..*)\n" + +// "\n" + +// "type Baz:\n" + +// " bazValue number (0..1)\n" + +// " other number (0..1)\n" + +// "\n" + +// "func OnlyExists:\n" + +// " inputs: foo Foo (1..1)\n" + +// " output: result boolean (1..1)\n" + +// " set result:\n" + +// " foo -> bar -> before only exists\n"; + + String code = "type Person:\n " + + " name string (0..1)\n" + + " age int (0..1)\n" + + "\n" + + "func M:\n" + + " output: result boolean (1..1)\n" + + " set result:\n" + + " Person { name: \"Name\", age: empty } -> name only exists\n"; + + + RosettaModel model = modelHelper.parseRosettaWithNoErrors(code); + RosettaOnlyExistsExpressionImpl onlyExistsExpression = ((RosettaOnlyExistsExpressionImpl) ((FunctionImpl) + model.getElements().get(1)).getOperations().get(0).getExpression()); + + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(onlyExistsExpression); + + + assertNotNull(result); + // Add "result" (which is the created object) into the environment +// RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(new HashMap<>()); +// env.addValue("person", result); +// RosettaExpression expr = parser.parseExpression("person -> name only-exists", +// List.of("person Person (1..1)")); + +// RosettaInterpreterValue val = interpreter.interp(expr); +// assertTrue(val instanceof RosettaInterpreterBooleanValue); +// RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; +// assertEquals(expected, castedVal); +// assertEquals("Person", result.getName()); +// assertEquals("name", result.getAttributes().get(0).getName()); +// assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) +// .getValue()); +// System.out.println(result.getAttributes().get(1).getValue()); + } +} diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 5cecb5872..84cbbf4f5 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -297,6 +297,9 @@ class JoinOperation extends RosettaBinaryOperation { class RosettaOnlyExistsExpression extends RosettaExpression { contains RosettaExpression[] args + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } /** diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index 905878008..c4c0f8c91 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -25,6 +25,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaExistsExpression import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation +import com.regnosys.rosetta.rosetta.expression.RosettaOnlyExistsExpression import com.regnosys.rosetta.rosetta.expression.SumOperation import com.regnosys.rosetta.rosetta.expression.FirstOperation import com.regnosys.rosetta.rosetta.expression.LastOperation @@ -63,6 +64,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (RosettaDisjointExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (JoinOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaExistsExpression exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaAbsentExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaOnlyElement exp, RosettaInterpreterBaseEnvironment env) From f62575a1c86129727ef5a148a339b7b2ec1425df Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Fri, 14 Jun 2024 14:13:31 +0200 Subject: [PATCH 202/236] Improved code quality for the function interpreter, added support for record types in function interpretation, and added support for copying the global variables (enum and data type declaration) from the environment when interpreting functions. Note: I miss 4 branches in testing because I could not figure out how to get dateTime and zonedDateTime to parse because the time having a variable in the environment just did not work for me --- ...ettaInterpreterFeatureCallInterpreter.java | 60 ------- ...settaConstructorExpressionInterpreter.java | 15 ++ ...RosettaInterpreterVariableInterpreter.java | 3 +- .../RosettaInterpreterFunctionTest.java | 152 ++++++++++++++++++ 4 files changed, 169 insertions(+), 61 deletions(-) delete mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java deleted file mode 100644 index 7906f77e1..000000000 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFeatureCallInterpreter.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.regnosys.rosetta.interpreternew.visitors; - -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.rosetta.RosettaEnumValue; -import com.regnosys.rosetta.rosetta.RosettaEnumeration; -import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; -import com.regnosys.rosetta.rosetta.impl.RosettaEnumValueImpl; -import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; - -public class RosettaInterpreterFeatureCallInterpreter - extends RosettaInterpreterConcreteInterpreter { - - /** - * Based on what class the symbol reference belongs to, it chooses what method to send it to. - * - * @param expr The RosettaFeatureCall expression to redirect - * @param env The Environment - * @return If no errors are encountered, a RosettaInterpreterNumberValue or - * RosettaInterpreterStringValue representing - * the result of the arithmetic/concatenation operation. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterValue interp(RosettaFeatureCall expr, - RosettaInterpreterEnvironment env) { - RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) expr.getReceiver(); - RosettaEnumValue enumVal; - //if(expr.getFeature() instanceof RosettaEnumValueImpl) { - enumVal = (RosettaEnumValueImpl) expr.getFeature(); - RosettaEnumeration enumeration = (RosettaEnumeration) ref.getSymbol(); - return interpEnum(enumeration, enumVal, env); - //} - //else Here comes the DataType ref call implementation that will have a different interp method - - } - - /** - * Interprets an enum feature call. - * - * @param enumeration The RosettaEnumeration to interpret alongside - * @param val The enum value to interpret - * @param env The Environment - * @return If no errors are encountered, a RosettaInterpreterNumberValue or - * RosettaInterpreterStringValue representing - * the result of the arithmetic/concatenation operation. - * If errors are encountered, a RosettaInterpreterErrorValue representing - * the error. - */ - public RosettaInterpreterValue interpEnum(RosettaEnumeration enumeration, RosettaEnumValue val, - RosettaInterpreterEnvironment env) { - - return new RosettaInterpreterEnumElementValue(val.getEnumeration().getName(), - val.getName()); - - - } - -} diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index d51fd43a4..85f8c2d51 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -31,6 +31,21 @@ public RosettaInterpreterBaseValue interp( EList values = expr.getValues(); switch (typeCall) { + case "time": { + RosettaInterpreterValue day = values.get(0).getValue().accept(visitor, env); + RosettaInterpreterValue month = values.get(1).getValue().accept(visitor, env); + RosettaInterpreterValue year = values.get(2).getValue().accept(visitor, env); + + if (day instanceof RosettaInterpreterNumberValue + && month instanceof RosettaInterpreterNumberValue + && year instanceof RosettaInterpreterNumberValue) { + return new RosettaInterpreterDateValue( + ((RosettaInterpreterNumberValue) day), + ((RosettaInterpreterNumberValue) month), + ((RosettaInterpreterNumberValue) year)); + } + break; + } case "date": { RosettaInterpreterValue day = values.get(0).getValue().accept(visitor, env); RosettaInterpreterValue month = values.get(1).getValue().accept(visitor, env); diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java index a8f1c06fe..e14cce2fd 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterVariableInterpreter.java @@ -3,6 +3,7 @@ import javax.inject.Inject; import com.regnosys.rosetta.interpreternew.RosettaInterpreterVisitor; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -27,7 +28,7 @@ public class RosettaInterpreterVariableInterpreter { * the error. */ public RosettaInterpreterValue interp(RosettaSymbolReference exp, - RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterEnvironment env) { if (exp.getSymbol() instanceof FunctionImpl) { return (new RosettaInterpreterFunctionInterpreter()) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java index c9ed63509..dfc7fe662 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java @@ -3,7 +3,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.inject.Inject; @@ -16,13 +18,16 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.RosettaEnumeration; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ModelHelper; @@ -37,6 +42,16 @@ public class RosettaInterpreterFunctionTest { @Inject ModelHelper mh; + RosettaInterpreterNumberValue day = new RosettaInterpreterNumberValue(5); + RosettaInterpreterNumberValue month = new RosettaInterpreterNumberValue(7); + RosettaInterpreterNumberValue year = new RosettaInterpreterNumberValue(2024); + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(day, month, year); + + RosettaInterpreterNumberValue hours = new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)); + RosettaInterpreterNumberValue minutes = new RosettaInterpreterNumberValue(BigDecimal.valueOf(30)); + RosettaInterpreterNumberValue seconds = new RosettaInterpreterNumberValue(BigDecimal.valueOf(28)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); + // private ExpressionFactory exFactory; // // @BeforeEach @@ -213,6 +228,84 @@ public void booleanMismatch() { assertEquals(expected, res); } + @Test + public void dateMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a date (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a date, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); + } + + @Test + public void dateTimeMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a dateTime (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a dateTime, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); + } + + @Test + public void zonedDateTimeMismatch() { + //Had to make this parse without errors, otherwise it would've checked the cardinality mismatch on its own + RosettaModel model = mh.parseRosetta( + "func Add:\r\n" + + " inputs:" + + " a zonedDateTime (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"a\" requires a zonedDateTime, but received a " + + (new RosettaInterpreterNumberValue(BigDecimal.valueOf(0))).getClass())); + assertEquals(expected, res); + } + @Test public void funcSimpleSetTest() { RosettaModel model = mh.parseRosettaWithNoErrors( @@ -237,6 +330,40 @@ public void funcSimpleSetTest() { assertEquals(expected, res); } + @Test + public void funcSimpleSetTestWithEnum() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "enum RoundingModeEnum: \r\n" + + " Down \r\n" + + " Up \r\n" + + "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0, 2.0)\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + Map nv = new HashMap(); + RosettaInterpreterEnvironment env2 = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterEnvironment env1 = + (RosettaInterpreterEnvironment) interpreter.interp((RosettaEnumeration) model + .getElements().get(0)); + nv.putAll(env2.getEnvironment()); + nv.putAll(env1.getEnvironment()); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(nv); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterNumberValue expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)); + assertEquals(expected, res); + } + @Test public void funcSimpleBooleanSetTest() { RosettaModel model = mh.parseRosettaWithNoErrors( @@ -261,6 +388,31 @@ public void funcSimpleBooleanSetTest() { assertEquals(expected, res); } + @Test + public void funcSimpleDateSetTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "func Add:\r\n" + + " inputs:" + + " a date (1..*)\r\n" + + " output: result date (1..*)\r\n" + + " set result:\r\n" + + " a\r\n" + + "func MyTest:\r\n" + + " output: result date (1..*)\r\n" + + " set result:\r\n" + + " Add(date { day: 1, month: 1, year: 1 })\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterNumberValue n = new RosettaInterpreterNumberValue(BigDecimal.valueOf(1)); + RosettaInterpreterListValue expected = new RosettaInterpreterListValue(List.of( + new RosettaInterpreterDateValue(n, n, n))); + assertEquals(expected, res); + } + @Test public void funcPreConditionTest() { RosettaModel model = mh.parseRosettaWithNoErrors( From d420634d859b0250ff49e6bf718c838cfe9ae851 Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sat, 15 Jun 2024 12:19:28 +0200 Subject: [PATCH 203/236] Extra test and javadoc --- ...terRosettaConstructorExpressionInterpreter.java | 6 ++++++ ...osettaInterpreterConstructorExpressionTest.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 476372452..1cfe84ef7 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -217,6 +217,12 @@ public RosettaInterpreterBaseValue interp( "Constructor Expressions: attribute type is not valid.")); } + /** + * Counts how many attributes mentioned in the first list are non-empty + * @param names - the names of the attributes that should be counted + * @param attributes - all the attributes of object + * @return the number of non-empty attributes + */ private int countPresentAttributes(List names, List attributes) { int countEmpty = 0; diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 5d7172372..3d6508101 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -385,4 +385,18 @@ public void testDataTypeOptionalChoiceError() { assertEquals(expected, result); } + + @Test + public void testDataTypeChoiceThreeDots() { + RosettaModel model = modelHelper.parseRosetta("type Ob:" + + "one int (0..1) two int (0..*)" + + "condition Choice: optional choice one, two " + + "func M: output: result Ob (1..1) set result: Ob { ... }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Ob", result.getName()); + } } From 8ab676d09b18639de8812e3f386038688926224c Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sat, 15 Jun 2024 12:34:41 +0200 Subject: [PATCH 204/236] Decrease method nesting --- ...settaConstructorExpressionInterpreter.java | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 1cfe84ef7..d455e2361 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -169,36 +169,15 @@ public RosettaInterpreterBaseValue interp( .map(Attribute::getName) .collect(Collectors.toList()); - if (choice.getNecessity().equals(Necessity.REQUIRED)) { - //exactly one attribute allowed to be present - // => count non-empty, should be one - int nonEmptyCount = countPresentAttributes( - choiceAttributesName, - attributes); - if (nonEmptyCount != 1) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Choice condition not followed. " - + "Exactly one attribute should " - + "be defined.")); - } - } - - if (choice.getNecessity().equals(Necessity.OPTIONAL)) { - //at most one attribute allowed to be present - // => count non-empty, should be less/equal than one - int nonEmptyCount = countPresentAttributes( - choiceAttributesName, - attributes); - if (nonEmptyCount > 1) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Choice condition not followed. " - + "At most one attribute should " - + "be defined.")); - } - } + String choiceError = verifyChoiceOperation( + choice.getNecessity(), + choiceAttributesName, + attributes); + if (choiceError != null) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError(choiceError)); + } } } @@ -216,9 +195,44 @@ public RosettaInterpreterBaseValue interp( return new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Constructor Expressions: attribute type is not valid.")); } + + /** + * Verify the Choice operation of this type. + * + * @param necessity - Necessity of choice operation + * @param choiceAttributesName - the names of the attributes choice applies to + * @param attributes - all the attributes of object + * @return Error message iff condition not met, else null + */ + private String verifyChoiceOperation(Necessity necessity, List choiceAttributesName, + List attributes) { + if (necessity.equals(Necessity.REQUIRED)) { + //exactly one attribute allowed to be present + // => count non-empty, should be one + int nonEmptyCount = countPresentAttributes( + choiceAttributesName, + attributes); + if (nonEmptyCount != 1) { + return "Choice condition not followed. Exactly one attribute should be defined."; + } + } + + if (necessity.equals(Necessity.OPTIONAL)) { + //at most one attribute allowed to be present + // => count non-empty, should be less/equal than one + int nonEmptyCount = countPresentAttributes( + choiceAttributesName, + attributes); + if (nonEmptyCount > 1) { + return "Choice condition not followed. At most one attribute should be defined."; + } + } + return null; + } /** - * Counts how many attributes mentioned in the first list are non-empty + * Counts how many attributes mentioned in the first list are non-empty. + * * @param names - the names of the attributes that should be counted * @param attributes - all the attributes of object * @return the number of non-empty attributes From fd4266387a394efcd34198d0c2ec9d68738e988e Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sat, 15 Jun 2024 13:58:01 +0200 Subject: [PATCH 205/236] Refactor method to separate condition verification --- ...settaConstructorExpressionInterpreter.java | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index d455e2361..42bc54b66 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -158,29 +158,16 @@ public RosettaInterpreterBaseValue interp( } } - //check if attributes are correctly defined, considering the conditions + //check conditions of type in separate method List conditions = ((DataImpl) expr.getTypeCall().getType()).getConditions(); - for (Condition condInterface : conditions) { - ConditionImpl c = (ConditionImpl)condInterface; - if (c.getExpression().getClass().equals(ChoiceOperationImpl.class)) { - ChoiceOperationImpl choice = (ChoiceOperationImpl)c.getExpression(); - List choiceAttributesName = choice.getAttributes().stream() - .map(Attribute::getName) - .collect(Collectors.toList()); - - String choiceError = verifyChoiceOperation( - choice.getNecessity(), - choiceAttributesName, - attributes); - - if (choiceError != null) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError(choiceError)); - } - } + String conditionsError = verifyConditions(conditions, attributes); + if (conditionsError != null) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError(conditionsError)); } + if (((DataImpl) expr.getTypeCall().getType()).hasSuperType()) { String superType = ((DataImpl) expr.getTypeCall().getType()) .getSuperType().getName(); @@ -196,6 +183,31 @@ public RosettaInterpreterBaseValue interp( "Constructor Expressions: attribute type is not valid.")); } + + /** + * Check all the conditions of the type. + * + * @param conditions - conditions set by type + * @param attr - list of attributes of type + * @return Error message iff conditions not met, else null + */ + private String verifyConditions(List conditions, List attr) { + for (Condition condInterface : conditions) { + ConditionImpl c = (ConditionImpl)condInterface; + if (c.getExpression().getClass().equals(ChoiceOperationImpl.class)) { + ChoiceOperationImpl choice = (ChoiceOperationImpl)c.getExpression(); + List choiceAttributesName = choice.getAttributes().stream() + .map(Attribute::getName) + .collect(Collectors.toList()); + + return verifyChoiceOperation(choice.getNecessity(), choiceAttributesName, attr); + } + } + + //if no errors up until this point, return null + return null; + } + /** * Verify the Choice operation of this type. * From 962cc660b03be4eeacb342f68db9e0fc038e7e86 Mon Sep 17 00:00:00 2001 From: Antonio Date: Sat, 15 Jun 2024 14:00:43 +0200 Subject: [PATCH 206/236] Implemented only-exists support --- ...settaInterpreterOnlyExistsInterpreter.java | 161 ++++++++++++++++-- 1 file changed, 146 insertions(+), 15 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java index 0e9f817da..cb2a580be 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java @@ -3,26 +3,157 @@ import java.util.*; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaFeatureCall; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyExistsExpression; +import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; public class RosettaInterpreterOnlyExistsInterpreter extends RosettaInterpreterConcreteInterpreter { + + /** + * Interprets a 'only exists' expression. + * + * @param exp the 'only exists' expression to interpret. + * @param env the environment containing variable bindings. + * @return a boolean value indicating if only the specified features exist. + */ + public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { + Set expectedFeatures = new HashSet<>(); - public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { - - List interpretedArgs = new ArrayList<>(); - - for(RosettaExpression expression : exp.getArgs()) { - RosettaInterpreterValue val = expression.accept(visitor, env); - interpretedArgs.add(val); - System.out.println(val); - System.out.println(); - } - - - return null; - } + for (RosettaExpression expression : exp.getArgs()) { + RosettaFeatureCall featureCall = (RosettaFeatureCall) expression; + + // Recursively get the receiver and get the final feature value + RosettaInterpreterValue finalAttribute = getAttributeUtil(featureCall, env); + if (finalAttribute == null) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "The final attribute was not found")); + } else if (finalAttribute instanceof RosettaInterpreterErrorValue) { + return finalAttribute; + } else if (!(finalAttribute instanceof RosettaInterpreterTypedFeatureValue)) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "The final attribute is not a feature")); + } + + // Add the feature name to the set of expected features + expectedFeatures.add(((RosettaInterpreterTypedFeatureValue)finalAttribute).getName()); + } - + // Get the variable (from the environment) that we need to check the attributes for + RosettaExpression firstExpression = exp.getArgs().get(0); + RosettaFeatureCall firstFeatureCall = (RosettaFeatureCall) firstExpression; + + RosettaInterpreterValue objectInstance = getReceiverUtil(firstFeatureCall.getReceiver(), env); + // Error handling + objectInstance = validateReceiver(objectInstance); + if (objectInstance instanceof RosettaInterpreterErrorValue) { + return objectInstance; + } + + // Check if the only non-null attributes are the expected features. + // We expect either to find an attribute from expectedFeatures that is declared + // or find one that is not in expectedFeatures and is not declared + List attributes = + ((RosettaInterpreterTypedValue) objectInstance).getAttributes(); + boolean onlyExpectedFeaturesExist = attributes.stream() + .allMatch(attr -> expectedFeatures.contains(attr.getName()) == isDeclared(attr)); + + return new RosettaInterpreterBooleanValue(onlyExpectedFeaturesExist); + } + + // Checks if an attribute is declared + private boolean isDeclared(RosettaInterpreterTypedFeatureValue attr) { + // Returns true if attribute is not a RosettaInterpreterListValue + // containing an empty list of expressions + if (attr.getValue() instanceof RosettaInterpreterListValue) { + return !((RosettaInterpreterListValue) attr.getValue()).getExpressions().isEmpty(); + } + + return true; // if it's not a RosettaInterpreterListValue it cannot possibly be "empty" + } + + + // This is just used to get the final attribute's name from a feature call. + // + // Example: + // For "(foo -> bar -> firstNumber, foo -> bar -> secondNumber) only exists" it will + // get "firstNumber" from the first element, and "secondNumber" from the second one. + // These will then be saved in the "expectedFeatures" set so we know which ones are + // supposed to be declared in the "bar" object. + private RosettaInterpreterValue getAttributeUtil(RosettaFeatureCall featureCall, + RosettaInterpreterBaseEnvironment env) { + // Recursively get the next receiver until the last one + // (foo -> bar -> baz -> attribute) would mean that the last receiver is "baz" + RosettaInterpreterValue receiver = getReceiverUtil(featureCall.getReceiver(), env); + // Error handling + receiver = validateReceiver(receiver); + if (receiver instanceof RosettaInterpreterErrorValue) { + return receiver; + } + + // Find the correct attribute in the receiver's attribute list + String featureName = featureCall.getFeature().getName(); + return ((RosettaInterpreterTypedValue)receiver).getAttributes().stream() + .filter(attr -> attr.getName().equals(featureName)) + .findFirst() + .orElse(null); + } + + + // Recursively gets the receiver value of a feature call. + // + // Example: + // For "foo -> bar -> baz -> attr only exists", it will recursively get the rightside + // of the "->", until it gets to the last receiver, which is "baz" in this case. + // "baz" will be used afterwards to check which attributes it contains that are/are not declared. + private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, RosettaInterpreterBaseEnvironment env) { + if (receiver instanceof RosettaSymbolReference) { + // Meaning we already got to the end, we don't have another feature call + RosettaSymbolReference ref = (RosettaSymbolReference) receiver; + String receiverSymbolName = ref.getSymbol().getName(); + return (RosettaInterpreterTypedValue) env.findValue(receiverSymbolName); + + } else if (receiver instanceof RosettaFeatureCall) { + // We need to recursively get the next receiver + RosettaFeatureCall featureCall = (RosettaFeatureCall) receiver; + RosettaInterpreterValue nextReceiver = getReceiverUtil(featureCall.getReceiver(), env); + // Error handling + nextReceiver = validateReceiver(nextReceiver); + if (nextReceiver instanceof RosettaInterpreterErrorValue) { + return nextReceiver; + } + + String featureName = featureCall.getFeature().getName(); + return ((RosettaInterpreterTypedValue) nextReceiver).getAttributes().stream() + .filter(attr -> attr.getName().equals(featureName)) + .map(RosettaInterpreterTypedFeatureValue::getValue) + .filter(value -> value instanceof RosettaInterpreterTypedValue) + .map(value -> (RosettaInterpreterTypedValue) value) + .findFirst().orElse(null); + } + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Receiver is not of correct type: only 'feature call'/'symbol reference' are accepted")); + } + + private RosettaInterpreterValue validateReceiver(RosettaInterpreterValue receiver) { + // Just error handling + if (receiver == null) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Receiver was not found")); + } else if (receiver instanceof RosettaInterpreterErrorValue) { + return receiver; + } else if (!(receiver instanceof RosettaInterpreterTypedValue)) { + return new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "Receiver is not of type RosettaInterpreterTypedValue")); + } + return receiver; + } } + From 5e51db1664f3d514c66635f1308e6af103cdbe05 Mon Sep 17 00:00:00 2001 From: Antonio Date: Sat, 15 Jun 2024 14:01:01 +0200 Subject: [PATCH 207/236] Added some tests for only exists --- ...aInterpreterOnlyExistsInterpreterTest.java | 242 +++++++++++++----- 1 file changed, 175 insertions(+), 67 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java index 32c28b602..65af66c95 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java @@ -48,86 +48,194 @@ public class RosettaInterpreterOnlyExistsInterpreterTest { @SuppressWarnings("unused") private ExpressionFactory expFactory; + private RosettaModel personModel; + private RosettaModel fooModel; + @BeforeEach public void setup() { expFactory = ExpressionFactoryImpl.init(); + personModel = modelHelper.parseRosettaWithNoIssues( + "type Person:\n" + + " name string (0..1)\n" + + " height int (0..1)" + ); + + fooModel = modelHelper.parseRosettaWithNoIssues( + "type Foo:\n" + + " bar Bar (0..*)\n" + + " baz Baz (0..1)\n" + + "\n" + + "type Bar:\n" + + " before number (0..1)\n" + + " after number (0..1)\n" + + " another number (0..1)\n" + + "\n" + + "type Baz:\n" + + " bazValue number (0..1)\n" + + " other number (0..1)\n" + ); } @Test - public void testOptionalAttributeDataType() { -// RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1)" -// + "func M: output: result Person (1..1) set result: Person { name: \"F\", height: empty}"); -// RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( -// FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); -// RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); - - -// Example from Data Types Class: -// RosettaModel model = mh.parseRosettaWithNoErrors("type Person: name string (1..1) " -// + "type Age extends Person: age number (1..1) " -// + "func M: output: result number (1..1) set result: " -// + "Age { name: \"F\", age: 10 } -> age"); -// RosettaFeatureCallImpl featureCall = ((RosettaFeatureCallImpl) ((FunctionImpl) -// model.getElements().get(2)).getOperations().get(0).getExpression()); -// RosettaInterpreterValue result = interpreter.interp(featureCall); + public void onlyExistsTrueTest() { + String onlyExistsStr = "person -> name only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + // Creating the environment (for the interpreter) that contains an instance of Person + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: empty}"); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("person", dataTypeInstance); -// RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person: name string (1..1) height number (0..1) " -// + "func M: output: result boolean (1..1) alias person: Person { name: \"F\", height: empty} " -// + "set result: person -> name only exists"); -// String code = "type Foo:\n" + -// " bar Bar (0..*)\n" + -// " baz Baz (0..1)\n" + -// "\n" + -// "type Bar:\n" + -// " before number (0..1)\n" + -// " after number (0..1)\n" + -// " other number (0..1)\n" + -// " beforeList number (0..*)\n" + -// " afterList number (0..*)\n" + -// "\n" + -// "type Baz:\n" + -// " bazValue number (0..1)\n" + -// " other number (0..1)\n" + -// "\n" + -// "func OnlyExists:\n" + -// " inputs: foo Foo (1..1)\n" + -// " output: result boolean (1..1)\n" + -// " set result:\n" + -// " foo -> bar -> before only exists\n"; + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertTrue(castedVal.getValue()); + } + + @Test + public void onlyExistsFalseTest() { + String onlyExistsStr = "person -> name only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); - String code = "type Person:\n " + - " name string (0..1)\n" + - " age int (0..1)\n" + - "\n" + - "func M:\n" + - " output: result boolean (1..1)\n" + - " set result:\n" + - " Person { name: \"Name\", age: empty } -> name only exists\n"; - + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: 180}"); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("person", dataTypeInstance); - RosettaModel model = modelHelper.parseRosettaWithNoErrors(code); - RosettaOnlyExistsExpressionImpl onlyExistsExpression = ((RosettaOnlyExistsExpressionImpl) ((FunctionImpl) - model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertFalse(castedVal.getValue()); + } + + @Test + public void onlyExistsMultipleFeaturesTrueTest() { + String onlyExistsStr = "(person -> name, person -> height) only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); - RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(onlyExistsExpression); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: 180}"); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("person", dataTypeInstance); + + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertTrue(castedVal.getValue()); + } + + @Test + public void onlyExistsMultipleFeaturesFalseTest() { + String onlyExistsStr = "(person -> name, person -> height) only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: empty}"); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("person", dataTypeInstance); + + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertFalse(castedVal.getValue()); + } + + @Test + public void onlyExistsComplexTrueTest() { + String onlyExistsStr = "foo -> bar -> before only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(fooModel), List.of("foo Foo (1..1)")); + + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: empty, another: empty }," + + " baz: Baz { bazValue: 1, other: empty } }" + ); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("foo", dataTypeInstance); + + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertTrue(castedVal.getValue()); + } + + @Test + public void onlyExistsComplexMultipleFeaturesTrueTest() { + String onlyExistsStr = "(foo -> bar -> before, foo -> bar -> another) only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(fooModel), List.of("foo Foo (1..1)")); + + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: empty, another: 50 }," + + " baz: Baz { bazValue: 1, other: empty } }" + ); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("foo", dataTypeInstance); + + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertTrue(castedVal.getValue()); + } + + @Test + public void onlyExistsComplexMultipleFeaturesFalseTest() { + String onlyExistsStr = "(foo -> bar -> before, foo -> bar -> another) only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(fooModel), List.of("foo Foo (1..1)")); - assertNotNull(result); - // Add "result" (which is the created object) into the environment -// RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(new HashMap<>()); -// env.addValue("person", result); -// RosettaExpression expr = parser.parseExpression("person -> name only-exists", -// List.of("person Person (1..1)")); + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: 25, another: 50 }," + + " baz: Baz { bazValue: 1, other: empty } }" + ); + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("foo", dataTypeInstance); -// RosettaInterpreterValue val = interpreter.interp(expr); -// assertTrue(val instanceof RosettaInterpreterBooleanValue); -// RosettaInterpreterNumberValue castedVal = (RosettaInterpreterNumberValue)val; -// assertEquals(expected, castedVal); -// assertEquals("Person", result.getName()); -// assertEquals("name", result.getAttributes().get(0).getName()); -// assertEquals("F", ((RosettaInterpreterStringValue) result.getAttributes().get(0).getValue()) -// .getValue()); -// System.out.println(result.getAttributes().get(1).getValue()); + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertFalse(castedVal.getValue()); } } From 6dccbfedbd70f5652d14f8ddbb7b3fee9bda9313 Mon Sep 17 00:00:00 2001 From: Antonio Date: Sat, 15 Jun 2024 17:45:55 +0200 Subject: [PATCH 208/236] Fixed checkstyle --- ...settaInterpreterOnlyExistsInterpreter.java | 15 +- ...aInterpreterOnlyExistsInterpreterTest.java | 168 ++++++++++-------- 2 files changed, 102 insertions(+), 81 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java index cb2a580be..5888d6bd2 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java @@ -32,10 +32,7 @@ public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaIn // Recursively get the receiver and get the final feature value RosettaInterpreterValue finalAttribute = getAttributeUtil(featureCall, env); - if (finalAttribute == null) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "The final attribute was not found")); - } else if (finalAttribute instanceof RosettaInterpreterErrorValue) { + if (finalAttribute instanceof RosettaInterpreterErrorValue) { return finalAttribute; } else if (!(finalAttribute instanceof RosettaInterpreterTypedFeatureValue)) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError( @@ -102,8 +99,7 @@ private RosettaInterpreterValue getAttributeUtil(RosettaFeatureCall featureCall, String featureName = featureCall.getFeature().getName(); return ((RosettaInterpreterTypedValue)receiver).getAttributes().stream() .filter(attr -> attr.getName().equals(featureName)) - .findFirst() - .orElse(null); + .findFirst().get(); } @@ -136,7 +132,7 @@ private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, Rose .map(RosettaInterpreterTypedFeatureValue::getValue) .filter(value -> value instanceof RosettaInterpreterTypedValue) .map(value -> (RosettaInterpreterTypedValue) value) - .findFirst().orElse(null); + .findFirst().get(); } return new RosettaInterpreterErrorValue(new RosettaInterpreterError( "Receiver is not of correct type: only 'feature call'/'symbol reference' are accepted")); @@ -144,10 +140,7 @@ private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, Rose private RosettaInterpreterValue validateReceiver(RosettaInterpreterValue receiver) { // Just error handling - if (receiver == null) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Receiver was not found")); - } else if (receiver instanceof RosettaInterpreterErrorValue) { + if (receiver instanceof RosettaInterpreterErrorValue) { return receiver; } else if (!(receiver instanceof RosettaInterpreterTypedValue)) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError( diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java index 65af66c95..34e64d241 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.*; -import java.util.HashMap; import java.util.List; import javax.inject.Inject; @@ -13,26 +12,19 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import com.regnosys.rosetta.interpreternew.RosettaInterpreterNew; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; import com.regnosys.rosetta.rosetta.expression.impl.RosettaConstructorExpressionImpl; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaFeatureCallImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; import com.regnosys.rosetta.tests.util.ModelHelper; -import com.regnosys.rosetta.rosetta.expression.impl.RosettaOnlyExistsExpressionImpl; @ExtendWith(InjectionExtension.class) @@ -52,27 +44,27 @@ public class RosettaInterpreterOnlyExistsInterpreterTest { private RosettaModel fooModel; @BeforeEach - public void setup() { + private void setup() { expFactory = ExpressionFactoryImpl.init(); personModel = modelHelper.parseRosettaWithNoIssues( - "type Person:\n" + - " name string (0..1)\n" + - " height int (0..1)" + "type Person:\n" + + " name string (0..1)\n" + + " height int (0..1)" ); - + fooModel = modelHelper.parseRosettaWithNoIssues( - "type Foo:\n" + - " bar Bar (0..*)\n" + - " baz Baz (0..1)\n" + - "\n" + - "type Bar:\n" + - " before number (0..1)\n" + - " after number (0..1)\n" + - " another number (0..1)\n" + - "\n" + - "type Baz:\n" + - " bazValue number (0..1)\n" + - " other number (0..1)\n" + "type Foo:\n" + + " bar Bar (0..*)\n" + + " baz Baz (0..1)\n" + + "\n" + + "type Bar:\n" + + " before number (0..1)\n" + + " after number (0..1)\n" + + " another number (0..1)\n" + + "\n" + + "type Baz:\n" + + " bazValue number (0..1)\n" + + " other number (0..1)\n" ); } @@ -80,15 +72,21 @@ public void setup() { public void onlyExistsTrueTest() { String onlyExistsStr = "person -> name only exists"; RosettaExpression onlyExistsExpression = - parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + parser.parseExpression(onlyExistsStr, + List.of(personModel), List.of("person Person (1..1)")); // Creating the environment (for the interpreter) that contains an instance of Person RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: empty}"); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaModel constructorModel = modelHelper + .parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) " + + "set result: Person { name: \"Simon\", height: empty}"); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(1)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("person", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -102,14 +100,20 @@ public void onlyExistsTrueTest() { public void onlyExistsFalseTest() { String onlyExistsStr = "person -> name only exists"; RosettaExpression onlyExistsExpression = - parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + parser.parseExpression(onlyExistsStr, + List.of(personModel), List.of("person Person (1..1)")); RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: 180}"); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaModel constructorModel = modelHelper + .parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) " + + "set result: Person { name: \"Simon\", height: 180}"); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(1)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("person", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -123,14 +127,20 @@ public void onlyExistsFalseTest() { public void onlyExistsMultipleFeaturesTrueTest() { String onlyExistsStr = "(person -> name, person -> height) only exists"; RosettaExpression onlyExistsExpression = - parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + parser.parseExpression(onlyExistsStr, + List.of(personModel), List.of("person Person (1..1)")); RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: 180}"); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaModel constructorModel = modelHelper + .parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) " + + "set result: Person { name: \"Simon\", height: 180}"); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(1)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("person", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -144,14 +154,20 @@ public void onlyExistsMultipleFeaturesTrueTest() { public void onlyExistsMultipleFeaturesFalseTest() { String onlyExistsStr = "(person -> name, person -> height) only exists"; RosettaExpression onlyExistsExpression = - parser.parseExpression(onlyExistsStr, List.of(personModel), List.of("person Person (1..1)")); + parser.parseExpression(onlyExistsStr, + List.of(personModel), List.of("person Person (1..1)")); RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); - RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" - + "func M: output: result Person (1..1) set result: Person { name: \"Simon\", height: empty}"); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(1)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaModel constructorModel = modelHelper + .parseRosettaWithNoErrors("type Person: name string (0..1) height number (0..1)" + + "func M: output: result Person (1..1) " + + "set result: Person { name: \"Simon\", height: empty}"); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(1)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("person", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -169,15 +185,19 @@ public void onlyExistsComplexTrueTest() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( - "type Foo: bar Bar (0..*) baz Baz (0..1)" + - "type Bar: before number (0..1) after number (0..1) another number (0..1)" + - "type Baz: bazValue number (0..1) other number (0..1)" + - "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: empty, another: empty }," + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: " + + "Foo { bar: Bar { before: 10, after: empty, another: empty }," + " baz: Baz { bazValue: 1, other: empty } }" ); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(3)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("foo", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -195,15 +215,19 @@ public void onlyExistsComplexMultipleFeaturesTrueTest() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( - "type Foo: bar Bar (0..*) baz Baz (0..1)" + - "type Bar: before number (0..1) after number (0..1) another number (0..1)" + - "type Baz: bazValue number (0..1) other number (0..1)" + - "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: empty, another: 50 }," + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: " + + "Foo { bar: Bar { before: 10, after: empty, another: 50 }," + " baz: Baz { bazValue: 1, other: empty } }" ); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(3)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("foo", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); @@ -221,15 +245,19 @@ public void onlyExistsComplexMultipleFeaturesFalseTest() { RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( - "type Foo: bar Bar (0..*) baz Baz (0..1)" + - "type Bar: before number (0..1) after number (0..1) another number (0..1)" + - "type Baz: bazValue number (0..1) other number (0..1)" + - "func M: output: result Foo (1..1) set result: Foo { bar: Bar { before: 10, after: 25, another: 50 }," + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: " + + "Foo { bar: Bar { before: 10, after: 25, another: 50 }," + " baz: Baz { bazValue: 1, other: empty } }" ); - RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( - FunctionImpl) constructorModel.getElements().get(3)).getOperations().get(0).getExpression()); - RosettaInterpreterTypedValue dataTypeInstance = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(3)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); env.addValue("foo", dataTypeInstance); RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); From c54114376d17d0cd7a957fb3d6fd3c751b712c29 Mon Sep 17 00:00:00 2001 From: Antonio Date: Sat, 15 Jun 2024 17:55:23 +0200 Subject: [PATCH 209/236] Removed error handling since it would not be reached --- ...settaInterpreterOnlyExistsInterpreter.java | 42 +------------------ ...aInterpreterOnlyExistsInterpreterTest.java | 31 ++++++++++++++ 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java index 5888d6bd2..ad8339515 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java @@ -10,8 +10,6 @@ import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; @@ -30,16 +28,8 @@ public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaIn for (RosettaExpression expression : exp.getArgs()) { RosettaFeatureCall featureCall = (RosettaFeatureCall) expression; - // Recursively get the receiver and get the final feature value - RosettaInterpreterValue finalAttribute = getAttributeUtil(featureCall, env); - if (finalAttribute instanceof RosettaInterpreterErrorValue) { - return finalAttribute; - } else if (!(finalAttribute instanceof RosettaInterpreterTypedFeatureValue)) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "The final attribute is not a feature")); - } - // Add the feature name to the set of expected features + RosettaInterpreterValue finalAttribute = getAttributeUtil(featureCall, env); expectedFeatures.add(((RosettaInterpreterTypedFeatureValue)finalAttribute).getName()); } @@ -48,11 +38,6 @@ public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaIn RosettaFeatureCall firstFeatureCall = (RosettaFeatureCall) firstExpression; RosettaInterpreterValue objectInstance = getReceiverUtil(firstFeatureCall.getReceiver(), env); - // Error handling - objectInstance = validateReceiver(objectInstance); - if (objectInstance instanceof RosettaInterpreterErrorValue) { - return objectInstance; - } // Check if the only non-null attributes are the expected features. // We expect either to find an attribute from expectedFeatures that is declared @@ -89,11 +74,6 @@ private RosettaInterpreterValue getAttributeUtil(RosettaFeatureCall featureCall, // Recursively get the next receiver until the last one // (foo -> bar -> baz -> attribute) would mean that the last receiver is "baz" RosettaInterpreterValue receiver = getReceiverUtil(featureCall.getReceiver(), env); - // Error handling - receiver = validateReceiver(receiver); - if (receiver instanceof RosettaInterpreterErrorValue) { - return receiver; - } // Find the correct attribute in the receiver's attribute list String featureName = featureCall.getFeature().getName(); @@ -116,15 +96,10 @@ private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, Rose String receiverSymbolName = ref.getSymbol().getName(); return (RosettaInterpreterTypedValue) env.findValue(receiverSymbolName); - } else if (receiver instanceof RosettaFeatureCall) { + } else { // We need to recursively get the next receiver RosettaFeatureCall featureCall = (RosettaFeatureCall) receiver; RosettaInterpreterValue nextReceiver = getReceiverUtil(featureCall.getReceiver(), env); - // Error handling - nextReceiver = validateReceiver(nextReceiver); - if (nextReceiver instanceof RosettaInterpreterErrorValue) { - return nextReceiver; - } String featureName = featureCall.getFeature().getName(); return ((RosettaInterpreterTypedValue) nextReceiver).getAttributes().stream() @@ -134,19 +109,6 @@ private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, Rose .map(value -> (RosettaInterpreterTypedValue) value) .findFirst().get(); } - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Receiver is not of correct type: only 'feature call'/'symbol reference' are accepted")); - } - - private RosettaInterpreterValue validateReceiver(RosettaInterpreterValue receiver) { - // Just error handling - if (receiver instanceof RosettaInterpreterErrorValue) { - return receiver; - } else if (!(receiver instanceof RosettaInterpreterTypedValue)) { - return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Receiver is not of type RosettaInterpreterTypedValue")); - } - return receiver; } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java index 34e64d241..5347cb7ca 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterOnlyExistsInterpreterTest.java @@ -266,4 +266,35 @@ public void onlyExistsComplexMultipleFeaturesFalseTest() { RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; assertFalse(castedVal.getValue()); } + + @Test + public void onlyExistsListWithMultipleElementsTest() { + String onlyExistsStr = "foo -> bar only exists"; + RosettaExpression onlyExistsExpression = + parser.parseExpression(onlyExistsStr, List.of(fooModel), List.of("foo Foo (1..1)")); + + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + RosettaModel constructorModel = modelHelper.parseRosettaWithNoErrors( + "type Foo: bar Bar (0..*) baz Baz (0..1)" + + "type Bar: before number (0..1) after number (0..1) another number (0..1)" + + "type Baz: bazValue number (0..1) other number (0..1)" + + "func M: output: result Foo (1..1) set result: " + + " Foo { bar: [Bar { before: 10, after: 25, another: 50 }, " + + " Bar { before: 0, after: 0, another: 0 } ]," + + " baz: Baz { bazValue: 1, other: empty } }" + ); + RosettaConstructorExpressionImpl constructor = + ((RosettaConstructorExpressionImpl) ((FunctionImpl) + constructorModel.getElements().get(3)) + .getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue dataTypeInstance = + (RosettaInterpreterTypedValue) interpreter.interp(constructor); + env.addValue("foo", dataTypeInstance); + + RosettaInterpreterValue val = interpreter.interp(onlyExistsExpression, env); + System.out.println(val); + assertTrue(val instanceof RosettaInterpreterBooleanValue); + RosettaInterpreterBooleanValue castedVal = (RosettaInterpreterBooleanValue)val; + assertFalse(castedVal.getValue()); + } } From f1d17fa3563f0ccf4e7ad3cb52cb4563cfdf59ed Mon Sep 17 00:00:00 2001 From: Maria Cristescu Date: Sun, 16 Jun 2024 11:07:14 +0200 Subject: [PATCH 210/236] Add support for one-of operation --- ...settaConstructorExpressionInterpreter.java | 13 +++++ ...aInterpreterConstructorExpressionTest.java | 48 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 42bc54b66..1d7764c2f 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -27,6 +27,7 @@ import com.regnosys.rosetta.rosetta.expression.Necessity; import com.regnosys.rosetta.rosetta.expression.RosettaConstructorExpression; import com.regnosys.rosetta.rosetta.expression.impl.ChoiceOperationImpl; +import com.regnosys.rosetta.rosetta.expression.impl.OneOfOperationImpl; import com.regnosys.rosetta.rosetta.RosettaCardinality; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.simple.Attribute; @@ -202,6 +203,18 @@ private String verifyConditions(List conditions, List allAttributesNames = attr.stream() + .map(RosettaInterpreterTypedFeatureValue::getName) + .collect(Collectors.toList()); + + int nonEmptyCount = countPresentAttributes(allAttributesNames, attr); + if (nonEmptyCount != 1) { + return "One-of condition not followed. " + + "Exactly one attribute should be defined."; + } + + } } //if no errors up until this point, return null diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index 3d6508101..ab23e629c 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -399,4 +399,52 @@ public void testDataTypeChoiceThreeDots() { assertEquals("Ob", result.getName()); } + + @Test + public void testDataTypeOneOfGood() { + RosettaModel model = modelHelper.parseRosetta("type Ob:" + + "one int (0..1) two int (0..*)" + + "condition: one-of " + + "func M: output: result Ob (1..1) set result: Ob { one: 1 }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterTypedValue result = (RosettaInterpreterTypedValue) interpreter.interp(constructor); + + assertEquals("Ob", result.getName()); + } + + @Test + public void testDataTypeOneOfBad() { + RosettaModel model = modelHelper.parseRosetta("type Ob:" + + "one int (0..1) two int (0..*)" + + "condition: one-of " + + "func M: output: result Ob (1..1) set result: Ob { ... }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "One-of condition not followed. Exactly one attribute should be defined.")); + + assertEquals(expected, result); + } + + @Test + public void testDataTypeOneOfNonOptional() { + RosettaModel model = modelHelper.parseRosetta("type Ob:" + + "one int (0..1) two int (0..*) three int (1..1) four int (1..*)" + + "condition: one-of " + + "func M: output: result Ob (1..1) set result: Ob { three: 3, four: [4,5] }"); + + RosettaConstructorExpressionImpl constructor = ((RosettaConstructorExpressionImpl) (( + FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression()); + RosettaInterpreterValue result = interpreter.interp(constructor); + + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( + "One-of condition not followed. Exactly one attribute should be defined.")); + + assertEquals(expected, result); + } } From 8de5d5e15ebc4b761551ac4a4d5b4260989a0f9f Mon Sep 17 00:00:00 2001 From: Antonio Date: Sun, 16 Jun 2024 15:53:19 +0200 Subject: [PATCH 211/236] Changed comments explaining the methods into JavaDoc --- ...settaInterpreterOnlyExistsInterpreter.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java index ad8339515..e464dc993 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterOnlyExistsInterpreter.java @@ -61,14 +61,18 @@ private boolean isDeclared(RosettaInterpreterTypedFeatureValue attr) { return true; // if it's not a RosettaInterpreterListValue it cannot possibly be "empty" } - - // This is just used to get the final attribute's name from a feature call. - // - // Example: - // For "(foo -> bar -> firstNumber, foo -> bar -> secondNumber) only exists" it will - // get "firstNumber" from the first element, and "secondNumber" from the second one. - // These will then be saved in the "expectedFeatures" set so we know which ones are - // supposed to be declared in the "bar" object. + /** + * This is just used to get the final attribute's name from a feature call. + * Example: + * For "(foo -> bar -> firstNumber, foo -> bar -> secondNumber) only exists" it will + * get "firstNumber" from the first element, and "secondNumber" from the second one. + * These will then be saved in the "expectedFeatures" set so we know which ones are + * supposed to be declared in the "bar" object. + * + * @param featureCall The feature call that contains the attribute at the end + * @param env The Current environment + * @return The wanted attribute value + */ private RosettaInterpreterValue getAttributeUtil(RosettaFeatureCall featureCall, RosettaInterpreterBaseEnvironment env) { // Recursively get the next receiver until the last one @@ -81,14 +85,18 @@ private RosettaInterpreterValue getAttributeUtil(RosettaFeatureCall featureCall, .filter(attr -> attr.getName().equals(featureName)) .findFirst().get(); } - - - // Recursively gets the receiver value of a feature call. - // - // Example: - // For "foo -> bar -> baz -> attr only exists", it will recursively get the rightside - // of the "->", until it gets to the last receiver, which is "baz" in this case. - // "baz" will be used afterwards to check which attributes it contains that are/are not declared. + + /** + * Recursively gets the receiver value of a feature call. + * Example: + * For "foo -> bar -> baz -> attr only exists", it will recursively get the rightside + * of the "->", until it gets to the last receiver, which is "baz" in this case. + * "baz" will be used afterwards to check which attributes it contains that are/are not declared. + * + * @param receiver The receiver of the feature call + * @param env The current environment + * @return The last receiver of the nested feature call + */ private RosettaInterpreterValue getReceiverUtil(RosettaExpression receiver, RosettaInterpreterBaseEnvironment env) { if (receiver instanceof RosettaSymbolReference) { // Meaning we already got to the end, we don't have another feature call From 967552b3c7f74178fd10fd4f53bfc273e7dd7fb2 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Sun, 16 Jun 2024 20:02:41 +0200 Subject: [PATCH 212/236] Added the missing file --- ...RosettaInterpreterFunctionInterpreter.java | 374 ++++++++++++++++++ 1 file changed, 374 insertions(+) create mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java new file mode 100644 index 000000000..b8b892f48 --- /dev/null +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java @@ -0,0 +1,374 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterFunctionValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Condition; +import com.regnosys.rosetta.rosetta.simple.Operation; +import com.regnosys.rosetta.rosetta.simple.ShortcutDeclaration; +import com.regnosys.rosetta.rosetta.simple.impl.AttributeImpl; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; + + +public class RosettaInterpreterFunctionInterpreter + extends RosettaInterpreterConcreteInterpreter { + + /** + * Interprets a function, returns the result. + * + * @param func The name of the function to interpret + * @param env RosettaInterpreterEnvironment that keeps track + * of the current state of the program + * @return If no errors are encountered, a RosettaInterpreterValue representing + * the value of the function. + * If errors are encountered, a RosettaInterpreterErrorValue representing + * the error. + */ + public RosettaInterpreterValue interp(FunctionImpl func, List args, + RosettaInterpreterEnvironment env) { + + final FunctionImpl f = ((RosettaInterpreterFunctionValue) env.findValue(func.getName())) + .getFunction(); + RosettaInterpreterErrorValue acc = new RosettaInterpreterErrorValue(); + List interpretedArgs = new ArrayList<>(); + RosettaInterpreterEnvironment nv = copyDataTypesOnly(env); + + acc = processInputs(f, args, env, interpretedArgs, acc, nv); + if (acc.getErrors().size() > 0) { + return acc; + } + + //check the pre-conditions of the function + List conditions = func.getConditions(); + acc = processConditions(conditions, acc, nv); + if (acc.getErrors().size() > 0) { + return acc; + } + + //Add all aliases to the environment, throw errors if any are found + List aliases = f.getShortcuts(); + acc = processAliases(aliases, acc, nv); + if (acc.getErrors().size() > 0) { + return acc; + } + + + //compute the results of all operations in the function + RosettaInterpreterValue result; + result = processOperations(f, args, acc, nv); + if (result instanceof RosettaInterpreterErrorValue) { + return result; + } + + //check the post-conditions of the function + nv.addValue(f.getOutput().getName(), result); + conditions = func.getPostConditions(); + acc = processConditions(conditions, acc, nv); + if (acc.getErrors().size() > 0) { + return acc; + } + + + //if everything went well, return the result + return result; + } + + /** + * Subroutine for processing the inputs. + * + * + * @param f The function we are interpreting + * @param args The raw arguments + * @param env The original environment + * @param interpretedArgs The interpreted arguments + * @param acc Error accumulator + * @param nv The new, local, environment + * @return The error accumulator, since all correct operations do not require a return value + */ + public RosettaInterpreterErrorValue processInputs(FunctionImpl f, List args, + RosettaInterpreterBaseEnvironment env, List interpretedArgs, + RosettaInterpreterErrorValue acc, RosettaInterpreterBaseEnvironment nv) { + + //interpret the raw arguments + for (RosettaExpression e : args) { + interpretedArgs.add(e.accept(visitor, env)); + } + + //check if there are any errors in interpreting the arguments. If so, return them + for (RosettaInterpreterValue value : interpretedArgs) { + acc.addAllErrors(value); + } + if (acc.getErrors().size() > 0) { + return acc; + } + + //check that all argument/passed value correspond in type and cardinality + //if not, return errors pointing to each attribute reference where this is the case + int inputSize = f.getInputs().size(); + for (int i = 0 ; i < inputSize ; i++) { + acc.addAllErrors(checkPair((AttributeImpl) f.getInputs().get(i), + (RosettaInterpreterBaseValue) interpretedArgs.get(i))); + } + if (acc.getErrors().size() > 0) { + return acc; + } + + //create a copy of the enums and data types in the passed environment + //since those are the only "global" variables +// RosettaInterpreterEnvironment nv = copyDataTypesOnly(env); + //add all the argument/value pairs to the NEW environment + for (int i = 0 ; i < inputSize ; i++) { + AttributeImpl attr = (AttributeImpl) f.getInputs().get(i); + RosettaInterpreterBaseValue value = (RosettaInterpreterBaseValue) interpretedArgs.get(i); + nv.addValue(attr.getName(), value); + } + return acc; + + } + + /** + * Subroutine for processing conditions. + * + * + * @param conditions The list of conditions to check + * @param acc Error accumulator + * @param nv The new, local, environment + * @return The error accumulator, since all correct operations do not require a return value + */ + public RosettaInterpreterErrorValue processConditions(List conditions, + RosettaInterpreterErrorValue acc, RosettaInterpreterBaseEnvironment nv) { + + for (Condition c : conditions) { + RosettaInterpreterValue v = c.getExpression().accept(visitor, nv); + if (v instanceof RosettaInterpreterBooleanValue) { + if (((RosettaInterpreterBooleanValue) v).getValue() == false) { + acc.addError(new RosettaInterpreterError("Condition \"" + + c.getName() + "\" does not hold for this function call")); + } + } else { //must be an error if not a boolean value + acc.addAllErrors(v); + } + } + return acc; + } + + /** + * Subroutine for processing aliases. + * + * + * @param aliases The list of aliases to interpret + * @param acc Error accumulator + * @param nv The new, local, environment + * @return The error accumulator, since all correct operations do not require a return value + */ + public RosettaInterpreterErrorValue processAliases(List aliases, + RosettaInterpreterErrorValue acc, RosettaInterpreterBaseEnvironment nv) { + + for (ShortcutDeclaration alias : aliases) { + RosettaInterpreterBaseValue val = (RosettaInterpreterBaseValue) + alias.getExpression().accept(visitor, nv); + acc.addAllErrors(val); + nv.addValue(alias.getName(), val); + } + return acc; + } + + /** + * Subroutine for processing operations. + * + * + * @param f The function we are interpreting + * @param args The raw arguments + * @param acc Error accumulator + * @param nv The new, local, environment + * @return The error accumulator if there are any errors, and the result value otherwise + */ + public RosettaInterpreterValue processOperations(FunctionImpl f, List args, + RosettaInterpreterErrorValue acc, RosettaInterpreterBaseEnvironment nv) { + + + List resultList = new ArrayList<>();; + + for (Operation o : f.getOperations()) { + if (o.isAdd()) { + resultList.add(o.getExpression().accept(visitor, nv)); + } else { + resultList = ((RosettaInterpreterBaseValue) o.getExpression().accept(visitor, nv)) + .toValueStream().collect(Collectors.toList()); + } + } + + //check that the function operations yield no errors + for (RosettaInterpreterValue value : resultList) { + acc.addAllErrors(value); + } if (acc.getErrors().size() > 0) { + return acc; + } + + //check cardinality and type of output matches computed value + RosettaInterpreterBaseValue result; + int upperLimit = f.getOutput().getCard().isUnbounded() ? Integer.MAX_VALUE : + f.getOutput().getCard().getSup(); + int lowerLimit = f.getOutput().getCard().getInf(); + //make the result a single element or a list depending on its stated cardinality + if (upperLimit == 1 && lowerLimit == 1) { + result = (RosettaInterpreterBaseValue) resultList.get(0); + } else { + result = new RosettaInterpreterListValue(resultList); + } + acc.addAllErrors(checkPair((AttributeImpl) f.getOutput(), result)); + if (acc.getErrors().size() > 0) { + return acc; + } else { + return result; + } + } + + + + /** + * Subroutine for checking that the function call is valid based on cardinality and type checking. + * + * @param attr The attribute object that contains the pertinent information + * @param value The interpreted value that is passed to the function + * @return True if the type and cardinality of the attribute and value match, false otherwise + */ + public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpreterBaseValue value) { + //This will consider only basic types, this will be changed after datatypes are done + String typeName = attr.getTypeCall().getType().getName(); + List vals = value.toValueStream() + .collect(Collectors.toList()); + + //check that the cardinality of the arg and the value match + int paramSize = vals.size(); + int lowerLimit = attr.getCard().getInf(); + if (paramSize < lowerLimit) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" has cardinality lower than the limit " + + lowerLimit)); + } + int upperLimit = attr.getCard().isUnbounded() ? Integer.MAX_VALUE : attr.getCard().getSup(); + if (paramSize > upperLimit) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" has cardinality higher than the limit " + + upperLimit)); + } + + //checking that the potential list of elements in arg and value are of the same type + switch (typeName) { + case "number": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterNumberValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a number, but received a " + + val.getClass())); + } + } + break; + case "int": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterNumberValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a number, but received a " + + val.getClass())); + } + } + break; + case "boolean": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterBooleanValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a boolean, but received a " + + val.getClass())); + } + } + break; + case "string": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterStringValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a string, but received a " + + val.getClass())); + } + } + break; + case "date": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterDateValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a date, but received a " + + val.getClass())); + } + } + break; + case "dateTime": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterDateTimeValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a dateTime, but received a " + + val.getClass())); + } + } + break; + case "zonedDateTime": + for (RosettaInterpreterValue val : vals) { + if (!(val instanceof RosettaInterpreterZonedDateTimeValue)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError("The attribute \"" + + attr.getName() + "\" requires a zonedDateTime, but received a " + + val.getClass())); + } + } + break; + default: + } + //if all checks pass, return true + return new RosettaInterpreterErrorValue(); + + } + + /** + * Subroutine for copying data type/enum declarations from the old environment. + * + * @param env Old environment + * @return new environment that contains the filtered values from the old one + */ + public RosettaInterpreterEnvironment copyDataTypesOnly(RosettaInterpreterEnvironment env) { + RosettaInterpreterEnvironment result = new RosettaInterpreterEnvironment(); + Map environment = env.getEnvironment(); + for (Map.Entry entry : environment.entrySet()) { + if (entry.getValue() instanceof RosettaInterpreterEnumValue) { + result.addValue(entry.getKey(), entry.getValue()); + } + } + return result; + } + +} From bc2b5ce6d3ac5c55838581fdef5f7c03bcdf723c Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Sun, 16 Jun 2024 20:28:47 +0200 Subject: [PATCH 213/236] Fixes --- ...rRosettaArithmeticOperationsInterpreter.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index ce2912256..398bf6fdf 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -7,6 +7,8 @@ import java.time.format.DateTimeFormatter; import java.util.List; +import org.eclipse.emf.ecore.EObject; + import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -43,13 +45,14 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, // Check for errors in the left or right side of the binary operation RosettaInterpreterErrorValue leftErrors = - checkForErrors(leftInterpreted, "Leftside"); + checkForErrors(leftInterpreted, "Leftside", expr); RosettaInterpreterErrorValue rightErrors = - checkForErrors(rightInterpreted, "Rightside"); + checkForErrors(rightInterpreted, "Rightside", expr); if (leftErrors.getErrors().size() + rightErrors.getErrors().size() > 0) { return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); } + //Interpret string concatenation if (leftInterpreted instanceof RosettaInterpreterStringValue && rightInterpreted instanceof RosettaInterpreterStringValue) { @@ -121,7 +124,7 @@ private RosettaInterpreterValue interpretNumber(RosettaInterpreterValue leftInte .multiply(rightNumber)).bigDecimalValue()); } else { // Division by 0 is not allowed - if (rightNumber.floatValue() == 0.0) { + if (rightNumber.bigDecimalValue() == BigDecimal.valueOf(0.0)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Division by 0 is not allowed")); @@ -196,12 +199,12 @@ private String appendZeroes(RosettaInterpreterNumberValue d) { * if the interpretedValue does not cause an error */ private RosettaInterpreterErrorValue checkForErrors( - RosettaInterpreterValue interpretedValue, String side) { + RosettaInterpreterValue interpretedValue, String side, + EObject associatedObject) { if (interpretedValue instanceof RosettaInterpreterNumberValue || interpretedValue instanceof RosettaInterpreterStringValue || interpretedValue instanceof RosettaInterpreterDateValue) { - // If the value satisfies the type conditions, we return an empty - // error value so that the merger has two error values to merge + // If the value satisfies the type conditions, return an empty error return new RosettaInterpreterErrorValue(); } @@ -214,7 +217,7 @@ else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Arithmetic Operation: " + side - + " is not of type Number/String/Date")); + + " is not of type Number/String/Date", associatedObject)); } } } From 161d146a9c0b8d04c02efb2693649467f11d5997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Mon, 17 Jun 2024 23:14:44 +0300 Subject: [PATCH 214/236] Added functionality for conditions on data types --- ...settaConstructorExpressionInterpreter.java | 14 +++++++-- ...aInterpreterConstructorExpressionTest.java | 31 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 1d7764c2f..d9bde59a2 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -11,6 +11,7 @@ import com.regnosys.rosetta.RosettaExtensions; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; @@ -149,6 +150,7 @@ public RosettaInterpreterBaseValue interp( attributes.add(new RosettaInterpreterTypedFeatureValue(name, value, card)); + env.addValue(name, value); } } if (!contains) { @@ -156,13 +158,14 @@ public RosettaInterpreterBaseValue interp( new RosettaInterpreterListValue(List.of()); attributes.add(new RosettaInterpreterTypedFeatureValue(name, empty, card)); + env.addValue(name, empty); } } //check conditions of type in separate method List conditions = ((DataImpl) expr.getTypeCall().getType()).getConditions(); - String conditionsError = verifyConditions(conditions, attributes); + String conditionsError = verifyConditions(conditions, attributes, env); if (conditionsError != null) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError(conditionsError)); @@ -192,7 +195,8 @@ public RosettaInterpreterBaseValue interp( * @param attr - list of attributes of type * @return Error message iff conditions not met, else null */ - private String verifyConditions(List conditions, List attr) { + private String verifyConditions(List conditions, List attr, + RosettaInterpreterBaseEnvironment env) { for (Condition condInterface : conditions) { ConditionImpl c = (ConditionImpl)condInterface; if (c.getExpression().getClass().equals(ChoiceOperationImpl.class)) { @@ -214,6 +218,12 @@ private String verifyConditions(List conditions, List Date: Tue, 18 Jun 2024 00:50:57 +0300 Subject: [PATCH 215/236] Added support for some parse operations --- .../RosettaInterpreterVisitor.java | 32 +++++++- ...aInterpreterParseOperationInterpreter.java | 79 +++++++++++++++++++ .../RosettaInterpreterParseOperationTest.java | 65 +++++++++++++++ rosetta-lang/model/RosettaExpression.xcore | 16 ++++ rosetta-lang/model/RosettaInterpreter.xcore | 12 ++- 5 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index e7bc8a5a2..5ec1ad80b 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -31,12 +31,17 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.expression.SumOperation; +import com.regnosys.rosetta.rosetta.expression.ToEnumOperation; +import com.regnosys.rosetta.rosetta.expression.ToIntOperation; +import com.regnosys.rosetta.rosetta.expression.ToNumberOperation; +import com.regnosys.rosetta.rosetta.expression.ToStringOperation; +import com.regnosys.rosetta.rosetta.expression.ToTimeOperation; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEmptyError; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterOnlyExistsInterpreter; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterParseOperationInterpreter; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEnumerationInterpreter; @@ -247,5 +252,30 @@ public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreter public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterOnlyExistsInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(ToStringOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToNumberOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToIntOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToTimeOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToEnumOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java new file mode 100644 index 000000000..d33a5e8fd --- /dev/null +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java @@ -0,0 +1,79 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.math.BigDecimal; +import java.util.List; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.ToEnumOperation; +import com.regnosys.rosetta.rosetta.expression.ToIntOperation; +import com.regnosys.rosetta.rosetta.expression.ToNumberOperation; +import com.regnosys.rosetta.rosetta.expression.ToStringOperation; +import com.regnosys.rosetta.rosetta.expression.ToTimeOperation; +import com.regnosys.rosetta.rosetta.expression.impl.RosettaStringLiteralImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; + +public class RosettaInterpreterParseOperationInterpreter extends RosettaInterpreterConcreteInterpreter { + + public RosettaInterpreterBaseValue interp(ToStringOperation expr, RosettaInterpreterBaseEnvironment env) { + return null; + + } + + public RosettaInterpreterBaseValue interp(ToNumberOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = expr.getArgument(); + + if (argument instanceof RosettaStringLiteralImpl) { + String string = ((RosettaStringLiteralImpl) argument).getValue(); + BigDecimal number; + + try { + number = new BigDecimal(string); + } catch (NumberFormatException e) { + number = null; + } + + if (number != null) { + return new RosettaInterpreterNumberValue(number); + } + } + return new RosettaInterpreterListValue(List.of()); + } + + public RosettaInterpreterBaseValue interp(ToIntOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = expr.getArgument(); + + if (argument instanceof RosettaStringLiteralImpl) { + String string = ((RosettaStringLiteralImpl) argument).getValue(); + int number; + + try { + number = new BigDecimal(string).intValueExact(); + } catch (ArithmeticException e) { + number = Integer.MIN_VALUE; + } + + if (number != Integer.MIN_VALUE) { + return new RosettaInterpreterNumberValue(number); + } + } + return new RosettaInterpreterListValue(List.of()); + + } + + public RosettaInterpreterBaseValue interp(ToTimeOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = expr.getArgument(); + + return new RosettaInterpreterListValue(List.of()); + + } + + public RosettaInterpreterBaseValue interp(ToEnumOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = expr.getArgument(); + + return new RosettaInterpreterListValue(List.of()); + + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java new file mode 100644 index 000000000..25a127b7d --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java @@ -0,0 +1,65 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ToNumberOperationImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterParseOperationTest { + + @Inject + private ExpressionParser parser; + + @Inject + RosettaInterpreterNew interpreter; + + RosettaInterpreterListValue empty = new RosettaInterpreterListValue(List.of()); + + @Test + void toNumberStringTest() { + RosettaExpression expr = parser.parseExpression("\"3.4\" to-number"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(3.4), result); + } + + @Test + void toNumberError() { + RosettaExpression expr = parser.parseExpression("\"bla\" to-number"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toIntStringTest() { + RosettaExpression expr = parser.parseExpression("\"3\" to-int"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterNumberValue(3), result); + } + + @Test + void toIntError() { + RosettaExpression expr = parser.parseExpression("\"3.4\" to-int"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } +} diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index 84cbbf4f5..af11670f5 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -417,22 +417,38 @@ class ChoiceOperation extends RosettaUnaryOperation { } class ToStringOperation extends RosettaUnaryOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } interface ParseOperation extends RosettaUnaryOperation { } class ToNumberOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToIntOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToTimeOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToEnumOperation extends ParseOperation { refers RosettaEnumeration enumeration + + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToDateOperation extends ParseOperation { diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index da53fd18f..f5b2a613b 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -35,6 +35,11 @@ import com.regnosys.rosetta.rosetta.expression.LastOperation import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement +import com.regnosys.rosetta.rosetta.expression.ToStringOperation +import com.regnosys.rosetta.rosetta.expression.ToNumberOperation +import com.regnosys.rosetta.rosetta.expression.ToIntOperation +import com.regnosys.rosetta.rosetta.expression.ToTimeOperation +import com.regnosys.rosetta.rosetta.expression.ToEnumOperation class RosettaInterpreterBaseError{ String message @@ -78,6 +83,11 @@ interface InterpreterVisitor { op RosettaInterpreterBaseEnvironment interp (RosettaEnumeration exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) - op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToStringOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToNumberOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToIntOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToTimeOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToEnumOperation exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file From 603c9efea72f9f5b7918db6b22cac8689abe6ac1 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 18 Jun 2024 09:44:27 +0200 Subject: [PATCH 216/236] removed supposedly previousely removed error constructor --- .vscode/settings.json | 3 +++ .../values/RosettaInterpreterError.java | 21 +++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..8f2b7113d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "disabled" +} \ No newline at end of file diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index f7f0049f3..dd24e7511 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -12,32 +12,25 @@ public class RosettaInterpreterError extends MinimalEObjectImpl implements RosettaInterpreterBaseError { private String errorMessage; private EObject associatedObject; - - public RosettaInterpreterError(String errorMessage) { - super(); - this.errorMessage = errorMessage; - } @Override public int hashCode() { - return Objects.hash(errorMessage); + return Objects.hash(associatedObject, errorMessage); } @Override public boolean equals(Object obj) { - if (this == obj) { + if (this == obj) return true; - } - if (obj == null) { + if (obj == null) return false; - } - if (getClass() != obj.getClass()) { + if (getClass() != obj.getClass()) return false; - } RosettaInterpreterError other = (RosettaInterpreterError) obj; - return Objects.equals(errorMessage, other.errorMessage); + return Objects.equals(associatedObject, other.associatedObject) + && Objects.equals(errorMessage, other.errorMessage); } - + public RosettaInterpreterError(String errorMessage, EObject obj) { this.associatedObject = obj; this.errorMessage = errorMessage; From 3ee3ef3b1b6b7ed50114491c33a37bb243abbbcf Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 18 Jun 2024 09:45:17 +0200 Subject: [PATCH 217/236] checkstyle fix --- .../interpreternew/values/RosettaInterpreterError.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index dd24e7511..1416221cf 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -20,12 +20,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RosettaInterpreterError other = (RosettaInterpreterError) obj; return Objects.equals(associatedObject, other.associatedObject) && Objects.equals(errorMessage, other.errorMessage); From 41b0c65eebff03c77d56a955680cacb23c483e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Tue, 18 Jun 2024 13:23:02 +0300 Subject: [PATCH 218/236] Added support for all operations --- .../RosettaInterpreterVisitor.java | 18 + ...aInterpreterParseOperationInterpreter.java | 267 ++++++++++++++- .../RosettaInterpreterParseOperationTest.java | 315 +++++++++++++++++- rosetta-lang/model/RosettaExpression.xcore | 9 + rosetta-lang/model/RosettaInterpreter.xcore | 6 + 5 files changed, 601 insertions(+), 14 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index 5ec1ad80b..f3531ceb1 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -31,11 +31,14 @@ import com.regnosys.rosetta.rosetta.expression.RosettaStringLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference; import com.regnosys.rosetta.rosetta.expression.SumOperation; +import com.regnosys.rosetta.rosetta.expression.ToDateOperation; +import com.regnosys.rosetta.rosetta.expression.ToDateTimeOperation; import com.regnosys.rosetta.rosetta.expression.ToEnumOperation; import com.regnosys.rosetta.rosetta.expression.ToIntOperation; import com.regnosys.rosetta.rosetta.expression.ToNumberOperation; import com.regnosys.rosetta.rosetta.expression.ToStringOperation; import com.regnosys.rosetta.rosetta.expression.ToTimeOperation; +import com.regnosys.rosetta.rosetta.expression.ToZonedDateTimeOperation; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEmptyError; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; @@ -277,5 +280,20 @@ public RosettaInterpreterValue interp(ToTimeOperation exp, RosettaInterpreterBas public RosettaInterpreterValue interp(ToEnumOperation exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterValue interp(ToDateOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToDateTimeOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } + + @Override + public RosettaInterpreterValue interp(ToZonedDateTimeOperation exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterParseOperationInterpreter().interp(exp, env); + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java index d33a5e8fd..6ca3d6854 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java @@ -4,44 +4,74 @@ import java.util.List; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.ToDateOperation; +import com.regnosys.rosetta.rosetta.expression.ToDateTimeOperation; import com.regnosys.rosetta.rosetta.expression.ToEnumOperation; import com.regnosys.rosetta.rosetta.expression.ToIntOperation; import com.regnosys.rosetta.rosetta.expression.ToNumberOperation; import com.regnosys.rosetta.rosetta.expression.ToStringOperation; import com.regnosys.rosetta.rosetta.expression.ToTimeOperation; +import com.regnosys.rosetta.rosetta.expression.ToZonedDateTimeOperation; import com.regnosys.rosetta.rosetta.expression.impl.RosettaStringLiteralImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; public class RosettaInterpreterParseOperationInterpreter extends RosettaInterpreterConcreteInterpreter { + /** + * Interpreter method for to-string operation. + * + * @param expr ToStringOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ public RosettaInterpreterBaseValue interp(ToStringOperation expr, RosettaInterpreterBaseEnvironment env) { - return null; + RosettaExpression argument = expr.getArgument(); + RosettaInterpreterValue result = argument.accept(visitor, env); + + if (result instanceof RosettaInterpreterEnumElementValue) { + return new RosettaInterpreterStringValue((( + RosettaInterpreterEnumElementValue) result).getValue()); + } + + return new RosettaInterpreterListValue(List.of()); } + /** + * Interpreter method for to-number operation. + * + * @param expr ToNumberOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ public RosettaInterpreterBaseValue interp(ToNumberOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); if (argument instanceof RosettaStringLiteralImpl) { String string = ((RosettaStringLiteralImpl) argument).getValue(); - BigDecimal number; - - try { - number = new BigDecimal(string); - } catch (NumberFormatException e) { - number = null; - } - - if (number != null) { - return new RosettaInterpreterNumberValue(number); - } + return checkString(string); } return new RosettaInterpreterListValue(List.of()); } + /** + * Interpreter method for to-int operation. + * + * @param expr ToIntOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ public RosettaInterpreterBaseValue interp(ToIntOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); @@ -63,17 +93,228 @@ public RosettaInterpreterBaseValue interp(ToIntOperation expr, RosettaInterprete } + /** + * Interpreter method for to-time operation. + * + * @param expr ToTimeOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ public RosettaInterpreterBaseValue interp(ToTimeOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); + if (argument instanceof RosettaStringLiteralImpl) { + return createTime(((RosettaStringLiteralImpl) argument).getValue()); + } + return new RosettaInterpreterListValue(List.of()); + + } + + /** + * Interpreter method for to-enum operation. + * + * @param expr ToEnumOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ + public RosettaInterpreterValue interp(ToEnumOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaInterpreterValue argument = expr.getArgument().accept(visitor, env); + String enumName = expr.getEnumeration().getName(); + String argumentValue = ((RosettaInterpreterStringValue) argument).getValue(); + + RosettaInterpreterValue enumValue = env.findValue(enumName); + + List values = ((RosettaInterpreterEnumValue) enumValue).getValues(); + + for (RosettaInterpreterValue value : values) { + String name = ((RosettaInterpreterEnumElementValue) value).getValue(); + + + if (name.equals(argumentValue)) { + return value; + } + } + + + return new RosettaInterpreterListValue(List.of()); + + } + + /** + * Interpreter method for to-date operation. + * + * @param expr ToDateOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ + public RosettaInterpreterBaseValue interp(ToDateOperation expr, RosettaInterpreterBaseEnvironment env) { + RosettaExpression argument = expr.getArgument(); + + if (argument instanceof RosettaStringLiteralImpl) { + return createDate(((RosettaStringLiteralImpl) argument).getValue()); + } return new RosettaInterpreterListValue(List.of()); } - public RosettaInterpreterBaseValue interp(ToEnumOperation expr, RosettaInterpreterBaseEnvironment env) { + /** + * Interpreter method for to-date-time operation. + * + * @param expr TodateTimeOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ + public RosettaInterpreterBaseValue interp(ToDateTimeOperation expr, RosettaInterpreterBaseEnvironment env) { + // 2024-06-18T01:24:14 + + RosettaExpression argument = expr.getArgument(); + + if (argument instanceof RosettaStringLiteralImpl) { + String string = ((RosettaStringLiteralImpl) argument).getValue(); + String[] parts = string.split("T"); + + if (parts.length != 2) { + return new RosettaInterpreterListValue(List.of()); + } + + RosettaInterpreterValue date = createDate(parts[0]); + RosettaInterpreterValue time = createTime(parts[1]); + + if (date instanceof RosettaInterpreterDateValue + && time instanceof RosettaInterpreterTimeValue) { + return new RosettaInterpreterDateTimeValue((RosettaInterpreterDateValue) date, + (RosettaInterpreterTimeValue) time); + } + } + + return new RosettaInterpreterListValue(List.of()); + } + + /** + * Interpreter method for to-zoned-date-time operation. + * + * @param expr ToZonedDateTimeOperation to be interpreted + * @param env the environment used + * @return the interpreted value + */ + public RosettaInterpreterBaseValue interp(ToZonedDateTimeOperation expr, + RosettaInterpreterBaseEnvironment env) { + // 2024-06-18T01:24:14−07:00 + RosettaExpression argument = expr.getArgument(); + if (argument instanceof RosettaStringLiteralImpl) { + String string = ((RosettaStringLiteralImpl) argument).getValue(); + String[] parts = string.split("T"); + + if (parts.length != 2) { + return new RosettaInterpreterListValue(List.of()); + } + + int timezoneStartIndex = Math.max(parts[1].lastIndexOf('+'), parts[1].lastIndexOf('-')); + + if (timezoneStartIndex == -1) { + return new RosettaInterpreterListValue(List.of()); + } + + String timeString = parts[1].substring(0, timezoneStartIndex); + String timezoneString = "UTC" + parts[1].substring(timezoneStartIndex); + + RosettaInterpreterValue date = createDate(parts[0]); + RosettaInterpreterValue time = createTime(timeString); + + if (date instanceof RosettaInterpreterDateValue + && time instanceof RosettaInterpreterTimeValue) { + return new RosettaInterpreterZonedDateTimeValue((RosettaInterpreterDateValue) date, + (RosettaInterpreterTimeValue) time, + new RosettaInterpreterStringValue(timezoneString)); + } + } + + return new RosettaInterpreterListValue(List.of()); + } + + /** + * Checks if a string can be transformed into a number. + * If yes, returns the interpreted number, else returns empty. + * + * @param string string to be checked + * @return the interpreted value + */ + public RosettaInterpreterBaseValue checkString(String string) { + BigDecimal number; + + try { + number = new BigDecimal(string); + } catch (NumberFormatException e) { + number = null; + } + + if (number != null) { + return new RosettaInterpreterNumberValue(number); + } + return new RosettaInterpreterListValue(List.of()); + } + + /** + * Transforms a string into a time value. If not possible, + * returns empty. + * + * @param string string to be transformed + * @return the interpreted value + */ + public RosettaInterpreterBaseValue createTime(String string) { + String[] strings = string.split(":"); + if (strings.length != 3) { + return new RosettaInterpreterListValue(List.of()); + } + + RosettaInterpreterValue hours = checkString(strings[0]); + RosettaInterpreterValue minutes = checkString(strings[1]); + RosettaInterpreterValue seconds = checkString(strings[2]); + + if (hours instanceof RosettaInterpreterNumberValue + && minutes instanceof RosettaInterpreterNumberValue + && seconds instanceof RosettaInterpreterNumberValue) { + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue( + (RosettaInterpreterNumberValue) hours, + (RosettaInterpreterNumberValue) minutes, + (RosettaInterpreterNumberValue) seconds); + + if (time.valid()) { + return time; + } + } + return new RosettaInterpreterListValue(List.of()); + } + + /** + * Transforms a string into a date value. If not possible, + * returns empty. + * + * @param string string to be transformed + * @return the interpreted value + */ + public RosettaInterpreterBaseValue createDate(String string) { + String[] strings = string.split("-"); + + if (strings.length != 3) { + return new RosettaInterpreterListValue(List.of()); + } + + RosettaInterpreterValue day = checkString(strings[2]); + RosettaInterpreterValue month = checkString(strings[1]); + RosettaInterpreterValue year = checkString(strings[0]); + + if (day instanceof RosettaInterpreterNumberValue + && month instanceof RosettaInterpreterNumberValue + && year instanceof RosettaInterpreterNumberValue) { + return new RosettaInterpreterDateValue((RosettaInterpreterNumberValue) day, + (RosettaInterpreterNumberValue) month, + (RosettaInterpreterNumberValue) year); + } + return new RosettaInterpreterListValue(List.of()); } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java index 25a127b7d..ec165fc0e 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterParseOperationTest.java @@ -11,13 +11,23 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; +import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; -import com.regnosys.rosetta.rosetta.expression.impl.ToNumberOperationImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.tests.util.ModelHelper; @ExtendWith(InjectionExtension.class) @InjectWith(RosettaInjectorProvider.class) @@ -29,7 +39,46 @@ public class RosettaInterpreterParseOperationTest { @Inject RosettaInterpreterNew interpreter; + @Inject + ModelHelper modelHelper; + RosettaInterpreterListValue empty = new RosettaInterpreterListValue(List.of()); + RosettaInterpreterDateValue date = new RosettaInterpreterDateValue(new RosettaInterpreterNumberValue(18), + new RosettaInterpreterNumberValue(6), new RosettaInterpreterNumberValue(2024)); + RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(new RosettaInterpreterNumberValue(17), + new RosettaInterpreterNumberValue(5), new RosettaInterpreterNumberValue(28)); + + @Test + void toStringTest() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALUE1 displayName \"Value 1\"\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " Foo -> VALUE1 to-string"); + RosettaInterpreterEnvironment expectedEnv = + new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Foo", + new RosettaInterpreterEnumValue("Foo", + List.of(new RosettaInterpreterEnumElementValue( + "Foo", "VALUE1"),new RosettaInterpreterEnumElementValue( + "Foo", "VALUE2")))); + RosettaExpression operation = ((FunctionImpl) model.getElements().get(1)).getOperations() + .get(0).getExpression(); + RosettaInterpreterStringValue result = (RosettaInterpreterStringValue) + interpreter.interp(operation, expectedEnv); + assertEquals(new RosettaInterpreterStringValue("VALUE1"), result); + } + + @Test + void toSringError() { + RosettaExpression expr = parser.parseExpression("3.4 to-string"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } @Test void toNumberStringTest() { @@ -47,6 +96,14 @@ void toNumberError() { assertEquals(empty, result); } + @Test + void toNumberNotStringError() { + RosettaExpression expr = parser.parseExpression("3 to-number"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + @Test void toIntStringTest() { RosettaExpression expr = parser.parseExpression("\"3\" to-int"); @@ -62,4 +119,260 @@ void toIntError() { assertEquals(empty, result); } + + @Test + void toIntNotStringError() { + RosettaExpression expr = parser.parseExpression("3.4 to-int"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toEnumTest() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALUE1\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result Foo (1..1)\r\n" + + " set result:\r\n" + + " \"VALUE1\" to-enum Foo"); + RosettaInterpreterEnvironment expectedEnv = + new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Foo", + new RosettaInterpreterEnumValue("Foo", + List.of(new RosettaInterpreterEnumElementValue( + "Foo", "VALUE1"),new RosettaInterpreterEnumElementValue( + "Foo", "VALUE2")))); + RosettaExpression operation = ((FunctionImpl) model.getElements().get(1)).getOperations() + .get(0).getExpression(); + RosettaInterpreterEnumElementValue result = (RosettaInterpreterEnumElementValue) + interpreter.interp(operation, expectedEnv); + assertEquals(new RosettaInterpreterEnumElementValue("Foo", "VALUE1"), result); + } + + @Test + void toEnumError() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("enum Foo:\r\n" + + " VALUE1\r\n" + + " VALUE2\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " output: result Foo (1..1)\r\n" + + " set result:\r\n" + + " \"VALUE3\" to-enum Foo"); + RosettaInterpreterEnvironment expectedEnv = + new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Foo", + new RosettaInterpreterEnumValue("Foo", + List.of(new RosettaInterpreterEnumElementValue( + "Foo", "VALUE1"),new RosettaInterpreterEnumElementValue( + "Foo", "VALUE2")))); + RosettaExpression operation = ((FunctionImpl) model.getElements().get(1)).getOperations() + .get(0).getExpression(); + RosettaInterpreterValue result = interpreter.interp(operation, expectedEnv); + assertEquals(empty, result); + } + + @Test + void toTimeStringTest() { + RosettaExpression expr = parser.parseExpression("\"17:05:28\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(time, result); + } + + @Test + void toTimeError() { + RosettaExpression expr = parser.parseExpression("\"3.4\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeNotStringError() { + RosettaExpression expr = parser.parseExpression("3.4 to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeErrorNotValid() { + RosettaExpression expr = parser.parseExpression("\"17:82:03\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeErrorWrongString() { + RosettaExpression expr = parser.parseExpression("\"17:28:03:59\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeWrongHoursError() { + RosettaExpression expr = parser.parseExpression("\"val:05:28\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeWrongMinutesTest() { + RosettaExpression expr = parser.parseExpression("\"17:05s:28\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toTimeWrongSecondsTest() { + RosettaExpression expr = parser.parseExpression("\"17:05:2a8\" to-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateStringTest() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18\" to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(date, result); + } + + @Test + void toDateError() { + RosettaExpression expr = parser.parseExpression("\"3.4\" to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateWrongDayError() { + RosettaExpression expr = parser.parseExpression("\"2024-06-day\" to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateWrongMonthError() { + RosettaExpression expr = parser.parseExpression("\"2024-0m6-18\" to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateWrongYearError() { + RosettaExpression expr = parser.parseExpression("\"20year24-06-18\" to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateNotStringError() { + RosettaExpression expr = parser.parseExpression("3 to-date"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateTimeStringTest() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18T17:05:28\" to-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterDateTimeValue(date, time), result); + } + + @Test + void toDateTimeError() { + RosettaExpression expr = parser.parseExpression("\"3.4\" to-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateTimeNotStringError() { + RosettaExpression expr = parser.parseExpression("3.4 to-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateTimeNotDateError() { + RosettaExpression expr = parser.parseExpression("\"2024-18T17:05:28\"to-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toDateTimeNotTimeError() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18T17\" to-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toZonedDateTimeStringTest() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18T17:05:28-07:00\" to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(new RosettaInterpreterZonedDateTimeValue(date, time, + new RosettaInterpreterStringValue("UTC-07:00")), result); + } + + @Test + void toZonedDateTimeError1() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18T17:05:28\" to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toZonedDateTimeError2() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18\" to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toZonedDateTimeNotStringError() { + RosettaExpression expr = parser.parseExpression("3 to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toZonedDateTimeNotDateError() { + RosettaExpression expr = parser.parseExpression("\"18T17:05:28-07:00\" to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } + + @Test + void toZonedDateTimeNotTimeError() { + RosettaExpression expr = parser.parseExpression("\"2024-06-18T17:28-07:00\" to-zoned-date-time"); + RosettaInterpreterValue result = interpreter.interp(expr); + + assertEquals(empty, result); + } } diff --git a/rosetta-lang/model/RosettaExpression.xcore b/rosetta-lang/model/RosettaExpression.xcore index af11670f5..a18f0ec37 100644 --- a/rosetta-lang/model/RosettaExpression.xcore +++ b/rosetta-lang/model/RosettaExpression.xcore @@ -452,12 +452,21 @@ class ToEnumOperation extends ParseOperation { } class ToDateOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToDateTimeOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class ToZonedDateTimeOperation extends ParseOperation { + op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } /** diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index f5b2a613b..42f3efb99 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -40,6 +40,9 @@ import com.regnosys.rosetta.rosetta.expression.ToNumberOperation import com.regnosys.rosetta.rosetta.expression.ToIntOperation import com.regnosys.rosetta.rosetta.expression.ToTimeOperation import com.regnosys.rosetta.rosetta.expression.ToEnumOperation +import com.regnosys.rosetta.rosetta.expression.ToDateOperation +import com.regnosys.rosetta.rosetta.expression.ToDateTimeOperation +import com.regnosys.rosetta.rosetta.expression.ToZonedDateTimeOperation class RosettaInterpreterBaseError{ String message @@ -89,5 +92,8 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (ToIntOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ToTimeOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (ToEnumOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToDateOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToDateTimeOperation exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterValue interp (ToZonedDateTimeOperation exp, RosettaInterpreterBaseEnvironment env) } \ No newline at end of file From 603a393abf22fbbb748329bd0f681782bb3dda88 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 18 Jun 2024 12:26:38 +0200 Subject: [PATCH 219/236] initial comparison test --- rosetta-interpreter/.project | 6 +++ ...ettaInterpreterCompilerComparisonTest.java | 38 +++++++++++++++++++ ...taInterpreterCompilerComparisonTest2.xtend | 25 ++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend diff --git a/rosetta-interpreter/.project b/rosetta-interpreter/.project index acd4e0fa1..a9093cfab 100644 --- a/rosetta-interpreter/.project +++ b/rosetta-interpreter/.project @@ -5,6 +5,11 @@ + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.jdt.core.javabuilder @@ -25,5 +30,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature net.sf.eclipsecs.core.CheckstyleNature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java new file mode 100644 index 000000000..2ec8748d9 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java @@ -0,0 +1,38 @@ +package com.regnosys.rosetta.interpreternew; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterCompilerComparisonTest { + + @Inject + private ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; + + @SuppressWarnings("unused") + private ExpressionFactory exFactory; + + @BeforeEach + public void setup() { + exFactory = ExpressionFactoryImpl.init(); + } + + @Test + void SimpleTest() { + + + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend new file mode 100644 index 000000000..cf54b2a9a --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -0,0 +1,25 @@ +package com.regnosys.rosetta.interpreternew + +import org.junit.jupiter.api.^extension.ExtendWith +import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import com.regnosys.rosetta.tests.RosettaInjectorProvider +import org.junit.jupiter.api.Test +import javax.inject.Inject +import com.regnosys.rosetta.tests.util.CodeGeneratorTestHelper + +import static com.google.common.collect.ImmutableMap.* +import static org.junit.jupiter.api.Assertions.* + +@ExtendWith(InjectionExtension) +@InjectWith(RosettaInjectorProvider) +class RosettaInterpreterCompilerComparisonTest2 { + @Inject extension CodeGeneratorTestHelper + + @Test + def simpleTest(){ + val code = ''' + 2 + '''.generateCode + } +} \ No newline at end of file From b2284f101eec321dd553bec7cc3a8fac2baccb6f Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 18 Jun 2024 12:55:06 +0200 Subject: [PATCH 220/236] Added value tests for enums --- .../RosettaInterpreterEnumElementValue.java | 12 ++-- .../values/RosettaInterpreterEnumValue.java | 4 +- ...osettaInterpreterEnumElementValueTest.java | 63 ++++++++++++++++++ .../RosettaInterpreterEnumValueTest.java | 66 +++++++++++++++++++ 4 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumElementValueTest.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumValueTest.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java index 269e14184..9a55915cf 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumElementValue.java @@ -21,15 +21,19 @@ public RosettaInterpreterEnumElementValue(String n, String v) { this.enumName = n; this.value = v; } + + public String getValue() { return value; } + + public String getEnumName() { return enumName; } @Override public int hashCode() { - return Objects.hash(value); + return Objects.hash(enumName, value); } @Override public String toString() { - return "RosettaInterpreterEnumElementValue [value=" + value + "]"; + return "RosettaInterpreterEnumElementValue [value = " + value + "]"; } @Override @@ -47,10 +51,6 @@ public boolean equals(Object obj) { return Objects.equals(value, other.value) && Objects.equals(enumName, other.enumName); } - public String getValue() { return value; } - - public String getEnumName() { return enumName; } - @Override public Stream toElementStream() { return Stream.of(value); diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java index 9a7929d7c..fcbb5a3c5 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterEnumValue.java @@ -48,7 +48,7 @@ public int hashCode() { @Override public String toString() { - return "RosettaInterpreterListValue [name = " + name + ", values=" + values.toString() + "]"; + return "RosettaInterpreterListValue [name = " + name + ", values = " + values.toString() + "]"; } @Override @@ -73,6 +73,6 @@ public Stream toElementStream() { @Override public Stream toValueStream() { - return values.stream(); + return Stream.of(this); } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumElementValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumElementValueTest.java new file mode 100644 index 000000000..ff99d9759 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumElementValueTest.java @@ -0,0 +1,63 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; + +public class RosettaInterpreterEnumElementValueTest { + + RosettaInterpreterEnumElementValue attribute = + new RosettaInterpreterEnumElementValue("a", "b"); + RosettaInterpreterEnumElementValue attribute2 = + new RosettaInterpreterEnumElementValue("a", "b"); + RosettaInterpreterEnumElementValue attributeFirst = + new RosettaInterpreterEnumElementValue("a", "c"); + RosettaInterpreterEnumElementValue attributeSecond = + new RosettaInterpreterEnumElementValue("c", "b"); + + @Test + void hashTest() { + assertEquals(attribute.hashCode(), attribute2.hashCode()); + assertNotEquals(attribute.hashCode(), attributeFirst.hashCode()); + assertNotEquals(attribute.hashCode(), attributeSecond.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(attribute.equals(attribute)); + assertTrue(attribute.equals(attribute2)); + assertFalse(attribute.equals(attributeFirst)); + assertFalse(attribute.equals(attributeSecond)); + assertFalse(attribute.equals(null)); + assertFalse(attribute.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(Arrays.asList("b"), + attribute.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = + Stream.of(attribute).collect(Collectors.toList()); + assertEquals(stream, attribute.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterEnumElementValue [value = " + + "b]", attribute.toString()); + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumValueTest.java new file mode 100644 index 000000000..d74f4fbb7 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterEnumValueTest.java @@ -0,0 +1,66 @@ +package com.regnosys.rosetta.interpreternew.value; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; + +public class RosettaInterpreterEnumValueTest { + + RosettaInterpreterStringValue value = new RosettaInterpreterStringValue("a"); + + RosettaInterpreterEnumElementValue attribute = new RosettaInterpreterEnumElementValue("E", "Value1"); + RosettaInterpreterEnumElementValue attribute2 = new RosettaInterpreterEnumElementValue("E", "Value1"); + RosettaInterpreterEnumElementValue attributeName = + new RosettaInterpreterEnumElementValue("E", "Value2"); + + RosettaInterpreterEnumValue data = new RosettaInterpreterEnumValue("E", List.of(attribute)); + RosettaInterpreterEnumValue data2 = new RosettaInterpreterEnumValue("E", List.of(attribute2)); + + RosettaInterpreterEnumValue dataName = + new RosettaInterpreterEnumValue("F", List.of(attribute)); + RosettaInterpreterEnumValue dataAttribute = + new RosettaInterpreterEnumValue("E", List.of(attributeName)); + + @Test + void hashTest() { + assertEquals(data.hashCode(), data2.hashCode()); + } + + @Test + void equalsTest() { + assertTrue(data.equals(data)); + assertTrue(data.equals(data2)); + assertFalse(data.equals(dataName)); + assertFalse(data.equals(dataAttribute)); + assertFalse(data.equals(null)); + assertFalse(data.equals(3)); + } + + @Test + void streamElementTest() { + assertEquals(List.of(attribute), + data.toElementStream().collect(Collectors.toList())); + } + + @Test + void streamValueTest() { + List stream = Stream.of(data).collect(Collectors.toList()); + assertEquals(stream, data.toValueStream().collect(Collectors.toList())); + } + + @Test + void toStringTest() { + assertEquals("RosettaInterpreterListValue [name = E, values = [" + + "RosettaInterpreterEnumElementValue [value = Value1]]]", data.toString()); + } +} From b467d8ebd30204d09bd258d3d7d84c143949849b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Tue, 18 Jun 2024 14:26:23 +0300 Subject: [PATCH 221/236] Added support for data type declarations --- .../interpreternew/RosettaInterpreterNew.java | 15 +++ .../RosettaInterpreterVisitor.java | 9 +- .../RosettaInterpreterDataInterpreter.java | 47 ++++++++ .../RosettaInterpreterDataTest.java | 108 ++++++++++++++++++ rosetta-lang/model/RosettaInterpreter.xcore | 2 + rosetta-lang/model/RosettaSimple.xcore | 6 + 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterDataInterpreter.java create mode 100644 rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterDataTest.java diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index 012d12910..159d48ca1 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -8,6 +8,7 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Data; public class RosettaInterpreterNew { @@ -66,4 +67,18 @@ public RosettaInterpreterEnvironment interp(RosettaEnumeration expression) { return environment; } + + /** + * Main interpret function for handling data declaration. + * + * @param expression the expression to be interpreted + * @return value of RosettaExpression otherwise exception + */ + public RosettaInterpreterEnvironment interp(Data expression, + RosettaInterpreterBaseEnvironment env) { + + environment = (RosettaInterpreterEnvironment) expression.accept(visitor, env); + + return environment; + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java index e7bc8a5a2..f9e300609 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterVisitor.java @@ -24,6 +24,7 @@ import com.regnosys.rosetta.rosetta.expression.RosettaIntLiteral; import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Data; import com.regnosys.rosetta.rosetta.expression.RosettaNumberLiteral; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement; import com.regnosys.rosetta.rosetta.expression.RosettaOnlyExistsExpression; @@ -36,9 +37,9 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterLogicalOperationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterOnlyExistsInterpreter; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterComparisonOperationInterpreter; +import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterDataInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterEnumerationInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterListLiteralInterpreter; import com.regnosys.rosetta.interpreternew.visitors.RosettaInterpreterRosettaArithmeticOperationsInterpreter; @@ -247,5 +248,11 @@ public RosettaInterpreterValue interp(RosettaFeatureCall exp, RosettaInterpreter public RosettaInterpreterValue interp(RosettaOnlyExistsExpression exp, RosettaInterpreterBaseEnvironment env) { return new RosettaInterpreterOnlyExistsInterpreter().interp(exp, env); } + + @Override + public RosettaInterpreterBaseEnvironment interp(Data exp, RosettaInterpreterBaseEnvironment env) { + return new RosettaInterpreterDataInterpreter().interp(exp, + (RosettaInterpreterEnvironment) env); + } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterDataInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterDataInterpreter.java new file mode 100644 index 000000000..f898990b8 --- /dev/null +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterDataInterpreter.java @@ -0,0 +1,47 @@ +package com.regnosys.rosetta.interpreternew.visitors; + +import java.util.ArrayList; +import java.util.List; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; +import com.regnosys.rosetta.rosetta.RosettaCardinality; +import com.regnosys.rosetta.rosetta.simple.Attribute; +import com.regnosys.rosetta.rosetta.simple.Data; + +public class RosettaInterpreterDataInterpreter +extends RosettaInterpreterConcreteInterpreter { + + /** + * Interprets the definition of a data type, + * then adds the data type to the environment. + * + * @param exp the data type to be interpreted + * @return the new environment after adding the data type to it + */ + public RosettaInterpreterEnvironment interp(Data exp, + RosettaInterpreterEnvironment env) { + String name = exp.getName(); + String superType; + if (exp.hasSuperType()) { + superType = exp.getSuperType().getName(); + } else { + superType = null; + } + List attributes = new ArrayList<>(); + + for (Attribute att : exp.getAttributes()) { + String attName = att.getName(); + RosettaCardinality card = att.getCard(); + + RosettaInterpreterListValue empty = new RosettaInterpreterListValue(List.of()); + + attributes.add(new RosettaInterpreterTypedFeatureValue(attName, empty, card)); + } + + env.addValue(name, new RosettaInterpreterTypedValue(superType, name, attributes)); + return env; + } +} diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterDataTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterDataTest.java new file mode 100644 index 000000000..ae9229f49 --- /dev/null +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterDataTest.java @@ -0,0 +1,108 @@ +package com.regnosys.rosetta.interpreternew; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; +import com.regnosys.rosetta.rosetta.RosettaCardinality; +import com.regnosys.rosetta.rosetta.RosettaModel; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.rosetta.simple.Data; +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ModelHelper; + +@ExtendWith(InjectionExtension.class) +@InjectWith(RosettaInjectorProvider.class) +public class RosettaInterpreterDataTest { + + @Inject + RosettaInterpreterNew interpreter; + + @Inject + ModelHelper modelHelper; + + RosettaInterpreterListValue empty = new RosettaInterpreterListValue(List.of()); + + @Test + public void dataAddedToEnvTest() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person:\r\n" + + " name string (1..1)\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " inputs: p Person (1..1)" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " p -> name"); + + Data dataType = (Data) model.getElements().get(0); + RosettaCardinality card = ((Data) model.getElements().get(0)).getAttributes().get(0).getCard(); + + RosettaInterpreterEnvironment expectedEnv = new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Person", new RosettaInterpreterTypedValue("Person", + List.of(new RosettaInterpreterTypedFeatureValue("name", empty, card)))); + RosettaInterpreterEnvironment actualEnv = new RosettaInterpreterEnvironment(); + + RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(dataType, actualEnv); + assertEquals((RosettaInterpreterEnvironment) env, (RosettaInterpreterEnvironment) expectedEnv); + } + + @Test + public void dataRefTest() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person:\r\n" + + " name string (1..1)\r\n" + + "\r\n" + + "func MyTest:\r\n" + + " inputs: p Person (1..1)" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " p -> name"); + + RosettaExpression refCall = ((FunctionImpl) model.getElements().get(1)).getOperations().get(0).getExpression(); + RosettaCardinality card = ((Data) model.getElements().get(0)).getAttributes().get(0).getCard(); + + RosettaInterpreterEnvironment env = new RosettaInterpreterEnvironment(); + env.addValue("p", new RosettaInterpreterTypedValue("Person", + List.of(new RosettaInterpreterTypedFeatureValue("name", empty, card)))); + + RosettaInterpreterValue value = interpreter.interp(refCall, env); + assertEquals(value, empty); + } + + @Test + public void dataAddedToEnvSupertypeTest() { + RosettaModel model = modelHelper.parseRosettaWithNoErrors("type Person:\r\n" + + " name string (1..1)\r\n" + + "type Age extends Person:\r\n" + + " age number (1..1)" + + "\r\n" + + "func MyTest:\r\n" + + " inputs: p Age (1..1)" + + " output: result string (1..1)\r\n" + + " set result:\r\n" + + " p -> name"); + + Data dataType = (Data) model.getElements().get(1); + RosettaCardinality card = ((Data) model.getElements().get(1)).getAttributes().get(0).getCard(); + + RosettaInterpreterEnvironment expectedEnv = new RosettaInterpreterEnvironment(); + expectedEnv.addValue("Age", new RosettaInterpreterTypedValue("Person", "Age", + List.of(new RosettaInterpreterTypedFeatureValue("age", empty, card)))); + RosettaInterpreterEnvironment actualEnv = new RosettaInterpreterEnvironment(); + + RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(dataType, actualEnv); + assertEquals((RosettaInterpreterEnvironment) env, (RosettaInterpreterEnvironment) expectedEnv); + } +} diff --git a/rosetta-lang/model/RosettaInterpreter.xcore b/rosetta-lang/model/RosettaInterpreter.xcore index da53fd18f..8e5887e82 100644 --- a/rosetta-lang/model/RosettaInterpreter.xcore +++ b/rosetta-lang/model/RosettaInterpreter.xcore @@ -35,6 +35,7 @@ import com.regnosys.rosetta.rosetta.expression.LastOperation import com.regnosys.rosetta.rosetta.expression.DistinctOperation import com.regnosys.rosetta.rosetta.expression.ReverseOperation import com.regnosys.rosetta.rosetta.expression.RosettaOnlyElement +import com.regnosys.rosetta.rosetta.simple.Data class RosettaInterpreterBaseError{ String message @@ -77,6 +78,7 @@ interface InterpreterVisitor { op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterBaseEnvironment interp (RosettaEnumeration exp, RosettaInterpreterBaseEnvironment env) + op RosettaInterpreterBaseEnvironment interp (Data exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaConstructorExpression exp, RosettaInterpreterBaseEnvironment env) op RosettaInterpreterValue interp (RosettaFeatureCall exp, RosettaInterpreterBaseEnvironment env) diff --git a/rosetta-lang/model/RosettaSimple.xcore b/rosetta-lang/model/RosettaSimple.xcore index 47b534f8c..3bf158a08 100644 --- a/rosetta-lang/model/RosettaSimple.xcore +++ b/rosetta-lang/model/RosettaSimple.xcore @@ -21,6 +21,8 @@ import org.eclipse.emf.common.util.BasicEList import com.regnosys.rosetta.rosetta.expression.RosettaExpression import com.regnosys.rosetta.rosetta.RosettaAttributeReferenceSegment import com.regnosys.rosetta.rosetta.RosettaCardinality +import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment abstract class RootElement extends RosettaRootElement, RosettaNamed, RosettaDefinable, Annotated { } @@ -68,6 +70,10 @@ class Data extends RosettaType, RootElement, References { op boolean hasSuperType() { return superType !== null } + + op RosettaInterpreterBaseEnvironment accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) { + v.interp(this,nv) + } } class Function extends RootElement, RosettaNamed, RosettaCallableWithArgs, References { From 2f5c45945d10d3034fe491661221900b27a5a50d Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Tue, 18 Jun 2024 13:47:37 +0200 Subject: [PATCH 222/236] Added data feature modification in functions + enum value tests --- rosetta-interpreter/.project | 4 +- .../RosettaInterpreterFunctionValue.java | 9 +- .../RosettaInterpreterTypedFeatureValue.java | 28 ++++ ...RosettaInterpreterFunctionInterpreter.java | 55 +++++++- .../RosettaInterpreterFunctionTest.java | 127 +++++++++++++++++- 5 files changed, 208 insertions(+), 15 deletions(-) diff --git a/rosetta-interpreter/.project b/rosetta-interpreter/.project index acd4e0fa1..0c6d0c76d 100644 --- a/rosetta-interpreter/.project +++ b/rosetta-interpreter/.project @@ -11,12 +11,12 @@ - org.eclipse.m2e.core.maven2Builder + net.sf.eclipsecs.core.CheckstyleBuilder - net.sf.eclipsecs.core.CheckstyleBuilder + org.eclipse.m2e.core.maven2Builder diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java index 849f9cefe..8011f5275 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterFunctionValue.java @@ -20,6 +20,10 @@ public RosettaInterpreterFunctionValue(FunctionImpl f) { function = f; } + public FunctionImpl getFunction() { + return function; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -45,11 +49,6 @@ public int hashCode() { return Objects.hash(function); } - public FunctionImpl getFunction() { - return function; - } - - @Override public Stream toElementStream() { diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java index a0109718e..0b4d603d9 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterTypedFeatureValue.java @@ -26,6 +26,30 @@ public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterValue this.value = value; this.card = card; } + + /** + * Constructor for data-type feature value. + * + * @param name name value + */ + public RosettaInterpreterTypedFeatureValue(String name) { + super(); + this.name = name; + this.value = null; + this.card = null; + } + + /** + * Constructor for data-type feature value. + * + * @param name name value + * @param value value of feature + */ + public RosettaInterpreterTypedFeatureValue(String name, RosettaInterpreterValue value) { + super(); + this.name = name; + this.value = value; + } public String getName() { return name; @@ -34,6 +58,10 @@ public String getName() { public RosettaInterpreterValue getValue() { return value; } + + public void setValue(RosettaInterpreterValue value) { + this.value = value; + } public RosettaCardinality getCard() { return card; diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java index b8b892f48..e5cdd6799 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java @@ -18,6 +18,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterListValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterZonedDateTimeValue; import com.regnosys.rosetta.rosetta.expression.RosettaExpression; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterBaseEnvironment; @@ -74,7 +76,12 @@ public RosettaInterpreterValue interp(FunctionImpl func, List //compute the results of all operations in the function RosettaInterpreterValue result; - result = processOperations(f, args, acc, nv); + if (nv.findValue(f.getOutput().getTypeCall().getType().getName()) + instanceof RosettaInterpreterTypedValue) { + result = processOperationsTyped(f, acc, nv); + } else { + result = processOperations(f, acc, nv); + } if (result instanceof RosettaInterpreterErrorValue) { return result; } @@ -197,12 +204,11 @@ public RosettaInterpreterErrorValue processAliases(List ali * * * @param f The function we are interpreting - * @param args The raw arguments * @param acc Error accumulator * @param nv The new, local, environment * @return The error accumulator if there are any errors, and the result value otherwise */ - public RosettaInterpreterValue processOperations(FunctionImpl f, List args, + public RosettaInterpreterValue processOperations(FunctionImpl f, RosettaInterpreterErrorValue acc, RosettaInterpreterBaseEnvironment nv) { @@ -210,6 +216,7 @@ public RosettaInterpreterValue processOperations(FunctionImpl f, List 0) { + return acc; + } else { + return result; + } + } /** * Subroutine for checking that the function call is valid based on cardinality and type checking. @@ -364,7 +408,8 @@ public RosettaInterpreterEnvironment copyDataTypesOnly(RosettaInterpreterEnviron RosettaInterpreterEnvironment result = new RosettaInterpreterEnvironment(); Map environment = env.getEnvironment(); for (Map.Entry entry : environment.entrySet()) { - if (entry.getValue() instanceof RosettaInterpreterEnumValue) { + if (entry.getValue() instanceof RosettaInterpreterEnumValue + || entry.getValue() instanceof RosettaInterpreterTypedValue) { result.addValue(entry.getKey(), entry.getValue()); } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java index dfc7fe662..9cf338499 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java @@ -24,6 +24,8 @@ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterStringValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTimeValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedFeatureValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterTypedValue; import com.regnosys.rosetta.rosetta.RosettaModel; import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; @@ -330,6 +332,124 @@ public void funcSimpleSetTest() { assertEquals(expected, res); } + @Test + public void funcSimpleSetFeatureTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "type A:" + + " a int (1..1)" + + "func Add:\r\n" + + " output: result A (1..1)\r\n" + + " set result -> a:\r\n" + + " 5\r\n" + + "func MyTest:\r\n" + + " output: result A (1..1)\r\n" + + " set result:\r\n" + + " Add()\r\n"); + RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a"))); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + env.addValue("A", v); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a", + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5))))); + assertEquals(expected, res); + } + + @Test + public void funcSimpleSetFeatureErrorTest() { + RosettaModel model = mh.parseRosetta( + "type A:" + + " a int (1..1)" + + "func Add:\r\n" + + " output: result A (1..1)\r\n" + + " set result -> a:\r\n" + + " 5 + True\r\n" + + "func MyTest:\r\n" + + " output: result A (1..1)\r\n" + + " set result:\r\n" + + " Add()\r\n"); + RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a"))); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + env.addValue("A", v); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( + new RosettaInterpreterError("Arithmetic Operation: Rightside" + + " is not of type Number/String/Date", + function.getOperations().get(0).getExpression())); + assertEquals(expected, res); + } + + @Test + public void funcSimpleSetFeatureData() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "type A:" + + " a int (1..1)" + + "func Add:\r\n" + + " output: result A (1..1)\r\n" + + " set result:\r\n" + + " A { a: 5 }\r\n" + + "func MyTest:\r\n" + + " output: result A (1..1)\r\n" + + " set result:\r\n" + + " Add()\r\n"); + RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a"))); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + env.addValue("A", v); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a", + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)), + ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()))); + assertEquals(expected, res); + } + + @Test + public void funcSimpleSetFeatureDataSecond() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "type A:" + + " a int (1..1)" + + " b int (1..1)" + + "func Add:\r\n" + + " output: result A (1..1)\r\n" + + " set result -> b:\r\n" + + " 5\r\n" + + "func MyTest:\r\n" + + " output: result A (1..1)\r\n" + + " set result:\r\n" + + " Add()\r\n"); + RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a"), + new RosettaInterpreterTypedFeatureValue("b"))); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + env.addValue("A", v); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", + List.of(new RosettaInterpreterTypedFeatureValue("a"), + new RosettaInterpreterTypedFeatureValue("b", + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)), + ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()))); + assertEquals(expected, res); + } + @Test public void funcSimpleSetTestWithEnum() { RosettaModel model = mh.parseRosettaWithNoErrors( @@ -567,7 +687,7 @@ public void funcOperationError() { RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Arithmetic Operation: Rightside" - + " is not of type Number/String")); + + " is not of type Number/String/Date", function.getOperations().get(0))); assertEquals(expected, res); } @@ -592,7 +712,7 @@ public void funcArgumentInterpretError() { RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Arithmetic Operation: Rightside" - + " is not of type Number/String")); + + " is not of type Number/String/Date", ref.getArgs().get(0))); assertEquals(expected, res); } @@ -696,7 +816,8 @@ public void aliasErrorTest() { RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Arithmetic Operation: Rightside" - + " is not of type Number/String")); + + " is not of type Number/String/Date", function.getShortcuts() + .get(0).getExpression())); assertEquals(expected, res); } From 2dbf6815a7c3709753f729670675809fefba5bbc Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 18 Jun 2024 17:37:33 +0200 Subject: [PATCH 223/236] implemented simple test of somewhat comparison (i dont have functions so i cannot actually do it fully) --- rosetta-interpreter/.project | 4 +- ...taInterpreterCompilerComparisonTest2.xtend | 117 +++++++++++++++++- 2 files changed, 116 insertions(+), 5 deletions(-) diff --git a/rosetta-interpreter/.project b/rosetta-interpreter/.project index a9093cfab..9215ddf5c 100644 --- a/rosetta-interpreter/.project +++ b/rosetta-interpreter/.project @@ -16,12 +16,12 @@ - org.eclipse.m2e.core.maven2Builder + net.sf.eclipsecs.core.CheckstyleBuilder - net.sf.eclipsecs.core.CheckstyleBuilder + org.eclipse.m2e.core.maven2Builder diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index cf54b2a9a..8983f7616 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -10,16 +10,127 @@ import com.regnosys.rosetta.tests.util.CodeGeneratorTestHelper import static com.google.common.collect.ImmutableMap.* import static org.junit.jupiter.api.Assertions.* +import com.google.inject.AbstractModule +import com.google.inject.Guice +import com.google.inject.Injector +import com.regnosys.rosetta.rosetta.RosettaModel +import com.regnosys.rosetta.rosetta.simple.Function +import com.regnosys.rosetta.tests.util.CodeGeneratorTestHelper +import com.regnosys.rosetta.tests.util.ModelHelper +import com.rosetta.model.lib.functions.ConditionValidator +import com.rosetta.model.lib.functions.DefaultConditionValidator +import com.rosetta.model.lib.functions.ModelObjectValidator +import com.rosetta.model.lib.functions.NoOpModelObjectValidator +import com.rosetta.model.lib.functions.RosettaFunction +import java.util.Map +import java.util.function.Consumer +import org.eclipse.xtext.xbase.testing.RegisteringFileSystemAccess + +import static org.junit.jupiter.api.Assertions.* +import com.regnosys.rosetta.generator.java.RosettaJavaPackages.RootPackage +import java.lang.reflect.InvocationTargetException +import javax.inject.Inject +import com.regnosys.rosetta.generator.java.function.FunctionGenerator +import com.regnosys.rosetta.rosetta.expression.RosettaExpression +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue +import com.regnosys.rosetta.tests.util.ExpressionParser +import static org.junit.jupiter.api.Assertions.*; + +import javax.inject.Inject; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.extensions.InjectionExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBooleanValue; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; +import com.regnosys.rosetta.rosetta.expression.ExpressionFactory; +import com.regnosys.rosetta.rosetta.expression.RosettaExpression; +import com.regnosys.rosetta.rosetta.expression.impl.ExpressionFactoryImpl; +import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; +import com.regnosys.rosetta.tests.RosettaInjectorProvider; +import com.regnosys.rosetta.tests.util.ExpressionParser; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue @ExtendWith(InjectionExtension) @InjectWith(RosettaInjectorProvider) class RosettaInterpreterCompilerComparisonTest2 { + @Inject extension CodeGeneratorTestHelper + @Inject extension FunctionGeneratorHelper + + @Inject + ExpressionParser parser; + @Inject + RosettaInterpreterNew interpreter; @Test - def simpleTest(){ - val code = ''' - 2 + def void simpleTest() { + val model = ''' + func Foo: + output: b int (1..1) + set b: 5 '''.generateCode + val classes = model.compileToClasses + val foo = classes.createFunc('Foo') + val output = foo.invokeFunc(Integer) + + val expr = parser.parseExpression("5") + val value = interpreter.interp(expr) + assertEquals(value, new RosettaInterpreterNumberValue(output)) + } +} + +// I couldn't get a way to import this so I just put it here?????? +class FunctionGeneratorHelper { + + @Inject FunctionGenerator generator + @Inject extension ModelHelper + @Inject extension CodeGeneratorTestHelper + @Inject RegisteringFileSystemAccess fsa + + final Injector injector + + new() { + injector = Guice.createInjector(new AbstractModule() { + override protected configure() { + bind(ConditionValidator).toInstance(new DefaultConditionValidator) + bind(ModelObjectValidator).toInstance(new NoOpModelObjectValidator) + } + }) + } + + def createFunc(Map> classes, String funcName) { + injector.getInstance(classes.get(rootPackage.functions + '.' + funcName)) as RosettaFunction + } + + def invokeFunc(RosettaFunction func, Class resultClass, Object... inputs) { + val evaluateMethod = func.class.getMatchingMethod("evaluate", inputs.map[it?.class]) + try { + evaluateMethod.invoke(func, inputs) as T + } catch (InvocationTargetException e) { + throw e.cause + } + } + + def void assertToGeneratedFunction(CharSequence actualModel, CharSequence expected) throws AssertionError { + actualModel.assertToGenerated(expected, [ + generator.generate(new RootPackage(it), fsa, it.elements.filter(Function).filter[operations.nullOrEmpty].head, "test") + ]) + } + + def void assertToGeneratedCalculation(CharSequence actualModel, CharSequence expected) throws AssertionError { + actualModel.assertToGenerated(expected, [ + generator.generate(new RootPackage(it), fsa, it.elements.filter(Function).filter[!operations.nullOrEmpty].head, "test") + ]) + } + + def protected void assertToGenerated(CharSequence actualModel, CharSequence expected, + Consumer genCall) throws AssertionError { + val model = actualModel.parseRosettaWithNoErrors + genCall.accept(model) + assertEquals(expected.toString, fsa.textFiles.entrySet.head.value) } } \ No newline at end of file From 1adfc508c8589223bee5c5385b5cc085d62c70e6 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Tue, 18 Jun 2024 17:39:28 +0200 Subject: [PATCH 224/236] added explanatory comments --- .../RosettaInterpreterCompilerComparisonTest2.xtend | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index 8983f7616..dd00da195 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -73,12 +73,23 @@ class RosettaInterpreterCompilerComparisonTest2 { output: b int (1..1) set b: 5 '''.generateCode + + // Biggest problem I see is that there's no just way to run a piece of code + // from the code text itself + // You need to tell it specifically what function its supposed to be + // creating, running and getting output from + // Though I guess it could be standardised by calling all functions + // the same and passing some arguments? val classes = model.compileToClasses val foo = classes.createFunc('Foo') val output = foo.invokeFunc(Integer) val expr = parser.parseExpression("5") val value = interpreter.interp(expr) + + // If actually doing this then better approach would be + // To have like a helper method that converts a primitive type + // Into some value domain type to avoid having to manually set it assertEquals(value, new RosettaInterpreterNumberValue(output)) } } From 0f2f3f8e24dbc8869e4f045d755ca47bf0b98233 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 09:37:47 +0200 Subject: [PATCH 225/236] more test comment --- .../RosettaInterpreterCompilerComparisonTest2.xtend | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index dd00da195..311832ceb 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -80,6 +80,8 @@ class RosettaInterpreterCompilerComparisonTest2 { // creating, running and getting output from // Though I guess it could be standardised by calling all functions // the same and passing some arguments? + // This would require writing a lot of code manually and testing it for + // both runtime options val classes = model.compileToClasses val foo = classes.createFunc('Foo') val output = foo.invokeFunc(Integer) From 89bc28b89862651087667a585fd780f5f6ea4377 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 10:09:22 +0200 Subject: [PATCH 226/236] fixed error tests and handling sort of --- .../values/RosettaInterpreterError.java | 3 +-- ...osettaArithmeticOperationsInterpreter.java | 4 ++-- ...settaConditionalExpressionInterpreter.java | 2 +- ...settaConstructorExpressionInterpreter.java | 11 +++++----- ...erpreterRosettaFeatureCallInterpreter.java | 2 +- ...taInterpreterArithmeticOperationsTest.java | 2 +- .../RosettaInterpreterComparisonTest.java | 16 +++++++------- ...aInterpreterConditionalExpressionTest.java | 2 +- ...aInterpreterConstructorExpressionTest.java | 21 +++++++++++-------- .../RosettaInterpreterFeatureCallTest.java | 4 ++-- .../value/RosettaInterpreterErrorTest.java | 16 +++++++------- .../RosettaInterpreterErrorValueTest.java | 4 ++-- 12 files changed, 44 insertions(+), 43 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java index 1416221cf..17aca84ae 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/values/RosettaInterpreterError.java @@ -30,8 +30,7 @@ public boolean equals(Object obj) { return false; } RosettaInterpreterError other = (RosettaInterpreterError) obj; - return Objects.equals(associatedObject, other.associatedObject) - && Objects.equals(errorMessage, other.errorMessage); + return Objects.equals(errorMessage, other.errorMessage); } public RosettaInterpreterError(String errorMessage, EObject obj) { diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index 22adc213d..f06d04d46 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -95,7 +95,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, if (rightNumber.floatValue() == 0.0) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Division by 0 is not allowed")); + "Division by 0 is not allowed", expr)); } return new RosettaInterpreterNumberValue((leftNumber .divide(rightNumber)).bigDecimalValue()); @@ -103,7 +103,7 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, } else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "The terms of the operation are neither both strings nor both numbers")); + "The terms of the operation are neither both strings nor both numbers", expr)); } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java index 7a0564a66..b730baadc 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConditionalExpressionInterpreter.java @@ -86,7 +86,7 @@ public RosettaInterpreterBaseValue interp(RosettaConditionalExpression expr, // Else branch should be evaluated but it does not exist return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "Else branch should be evaluated but does not exist")); + "Else branch should be evaluated but does not exist", expr)); } } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java index 1d7764c2f..eab76274b 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaConstructorExpressionInterpreter.java @@ -78,7 +78,7 @@ public RosettaInterpreterBaseValue interp( if (!check) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: time isn't valid.")); + "Constructor Expressions: time isn't valid.", expr)); } else { return new RosettaInterpreterDateTimeValue( ((RosettaInterpreterDateValue) date), @@ -99,7 +99,7 @@ public RosettaInterpreterBaseValue interp( if (!check) { return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: time isn't valid.")); + "Constructor Expressions: time isn't valid.", expr)); } else { return new RosettaInterpreterZonedDateTimeValue( ((RosettaInterpreterDateValue) date), @@ -140,7 +140,8 @@ public RosettaInterpreterBaseValue interp( "Constructor Expression" + ": the attribute \"" + name + "\" is an " - + "error value.")); + + "error value.", + expr)); return RosettaInterpreterErrorValue.merge( List.of(newExpError, expError)); @@ -165,7 +166,7 @@ public RosettaInterpreterBaseValue interp( String conditionsError = verifyConditions(conditions, attributes); if (conditionsError != null) { return new RosettaInterpreterErrorValue( - new RosettaInterpreterError(conditionsError)); + new RosettaInterpreterError(conditionsError, expr)); } @@ -181,7 +182,7 @@ public RosettaInterpreterBaseValue interp( } return new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: attribute type is not valid.")); + "Constructor Expressions: attribute type is not valid.", expr)); } diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java index a5ac9d51f..da5fd6315 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaFeatureCallInterpreter.java @@ -125,7 +125,7 @@ public RosettaInterpreterBaseValue interpType(RosettaFeatureCall exp, RosettaInt RosettaInterpreterErrorValue newExpError = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Feature calls: the " - + "receiver is an error value.")); + + "receiver is an error value.", exp)); return RosettaInterpreterErrorValue.merge(List.of(newExpError, expError)); } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java index bbb84d0ce..d27273d32 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterArithmeticOperationsTest.java @@ -94,7 +94,7 @@ public void divisionByZeroTest() { RosettaInterpreterValue val = interpreter.interp(expr); List expected = List.of( new RosettaInterpreterError( - "Division by 0 is not allowed")); + "Division by 0 is not allowed", expr)); assertEquals(expected, ((RosettaInterpreterErrorValue)val).getErrors()); diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java index 12081f52d..a7ae06d6a 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterComparisonTest.java @@ -161,14 +161,12 @@ public void errorThrownAllElementsTest() { @Test void badOperatorTest() { - RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "operator not suppported")); - RosettaBooleanLiteral ex = exFactory.createRosettaBooleanLiteral(); ex.setValue(true); RosettaExpression expr = createComparisonOperation("><", ex,ex, CardinalityModifier.NONE); - + RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "operator not suppported", expr)); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; @@ -180,11 +178,11 @@ void badOperatorTest() { @Test void wrongListLengthAnyTest() { + RosettaExpression expr = parser.parseExpression("[1] any < 3"); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ANY\" keyword " - + "to compare two elements")); - RosettaExpression expr = parser.parseExpression("[1] any < 3"); + + "to compare two elements", expr)); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; assertEquals(expectedError.getErrors(), @@ -197,11 +195,11 @@ void wrongListLengthAnyTest() { @Test void wrongListLengthAllTest() { + RosettaExpression expr = parser.parseExpression("[1] all <= 3"); RosettaInterpreterErrorValue expectedError = new RosettaInterpreterErrorValue( new RosettaInterpreterError( "cannot use \"ALL\" keyword " - + "to compare two elements")); - RosettaExpression expr = parser.parseExpression("[1] all <= 3"); + + "to compare two elements", expr)); RosettaInterpreterValue val = interpreter.interp(expr); RosettaInterpreterErrorValue errorVal = (RosettaInterpreterErrorValue) val; assertEquals(expectedError.getErrors(), diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java index af19ab0d3..6cc06941c 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConditionalExpressionTest.java @@ -206,7 +206,7 @@ public void noElseTest() { RosettaExpression expr = parser.parseExpression("if False then 1.2"); RosettaInterpreterValue result = interpreter.interp(expr); RosettaInterpreterError expected = new RosettaInterpreterError( - "Else branch should be evaluated but does not exist"); + "Else branch should be evaluated but does not exist", expr); assertEquals(expected, ((RosettaInterpreterErrorValue)result).getErrors().get(0)); } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java index ab23e629c..695360bdf 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterConstructorExpressionTest.java @@ -59,9 +59,9 @@ public class RosettaInterpreterConstructorExpressionTest { RosettaInterpreterTimeValue timeError = new RosettaInterpreterTimeValue(hoursError, minutes, seconds); RosettaInterpreterErrorValue error = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: time isn't valid.")); + "Constructor Expressions: time isn't valid.", null)); RosettaInterpreterErrorValue errorAtt = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expressions: attribute type is not valid.")); + "Constructor Expressions: attribute type is not valid.", null)); @Test public void testDate() { @@ -266,9 +266,9 @@ public void testDataTypeError() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue errorBool = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Logical Operation: Leftside is not of type Boolean")); + "Logical Operation: Leftside is not of type Boolean", null)); RosettaInterpreterErrorValue errorValue = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Constructor Expression: the attribute \"value\" is an error value.")); + "Constructor Expression: the attribute \"value\" is an error value.", null)); assertEquals(RosettaInterpreterErrorValue.merge(errorValue, errorBool), result); } @@ -319,7 +319,8 @@ public void testDataTypeRequiredChoiceError1() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Choice condition not followed. Exactly one attribute should be defined.")); + "Choice condition not followed." + + " Exactly one attribute should be defined.", null)); assertEquals(expected, result); } @@ -336,7 +337,8 @@ public void testDataTypeRequiredChoiceError2() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Choice condition not followed. Exactly one attribute should be defined.")); + "Choice condition not followed." + + " Exactly one attribute should be defined.", null)); assertEquals(expected, result); } @@ -381,7 +383,8 @@ public void testDataTypeOptionalChoiceError() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Choice condition not followed. At most one attribute should be defined.")); + "Choice condition not followed." + + " At most one attribute should be defined.", null)); assertEquals(expected, result); } @@ -426,7 +429,7 @@ public void testDataTypeOneOfBad() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "One-of condition not followed. Exactly one attribute should be defined.")); + "One-of condition not followed. Exactly one attribute should be defined.", null)); assertEquals(expected, result); } @@ -443,7 +446,7 @@ public void testDataTypeOneOfNonOptional() { RosettaInterpreterValue result = interpreter.interp(constructor); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "One-of condition not followed. Exactly one attribute should be defined.")); + "One-of condition not followed. Exactly one attribute should be defined.", null)); assertEquals(expected, result); } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java index bd2d0b5b1..5e0baff00 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFeatureCallTest.java @@ -53,9 +53,9 @@ public class RosettaInterpreterFeatureCallTest { RosettaInterpreterTimeValue time = new RosettaInterpreterTimeValue(hours, minutes, seconds); RosettaInterpreterErrorValue error1 = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "Feature calls: the receiver is an error value.")); + "Feature calls: the receiver is an error value.", null)); RosettaInterpreterErrorValue error2 = new RosettaInterpreterErrorValue(new RosettaInterpreterError( - "dates does not exist in the environment")); + "dates does not exist in the environment", null)); @Test public void testDateDay() { diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java index af35256ed..13d08a950 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorTest.java @@ -13,9 +13,9 @@ public class RosettaInterpreterErrorTest { @Test void hashTest() { - RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); - RosettaInterpreterError e2 = new RosettaInterpreterError("error1"); - RosettaInterpreterError e3 = new RosettaInterpreterError("error3"); + RosettaInterpreterError e1 = new RosettaInterpreterError("error1", null); + RosettaInterpreterError e2 = new RosettaInterpreterError("error1", null); + RosettaInterpreterError e3 = new RosettaInterpreterError("error3", null); assertEquals(e1.hashCode(), e2.hashCode()); assertNotEquals(e1.hashCode(), e3.hashCode()); @@ -23,8 +23,8 @@ void hashTest() { @Test void equalsGoodWeatherTest() { - RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); - RosettaInterpreterError e2 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e1 = new RosettaInterpreterError("error1", null); + RosettaInterpreterError e2 = new RosettaInterpreterError("error1", null); assertTrue(e1.equals(e1)); assertTrue(e1.equals(e2)); @@ -32,8 +32,8 @@ void equalsGoodWeatherTest() { @Test void equalsBadWeatherTest() { - RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); - RosettaInterpreterError e2 = new RosettaInterpreterError("error2"); + RosettaInterpreterError e1 = new RosettaInterpreterError("error1", null); + RosettaInterpreterError e2 = new RosettaInterpreterError("error2", null); assertFalse(e1.equals(e2)); assertFalse(e1.equals(null)); @@ -42,7 +42,7 @@ void equalsBadWeatherTest() { @Test void toStringTest() { - RosettaInterpreterError e1 = new RosettaInterpreterError("error1"); + RosettaInterpreterError e1 = new RosettaInterpreterError("error1", null); assertEquals("error1", e1.toString()); } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java index 4e3fbdac1..9f2adc382 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/value/RosettaInterpreterErrorValueTest.java @@ -68,8 +68,8 @@ void setup() { vb2 = new RosettaInterpreterBooleanValue(false); vals = new ArrayList<>(List.of(v1,v2,v3,vb1,vb2)); exFactory = ExpressionFactoryImpl.init(); - b1 = new RosettaInterpreterError("b1"); - b2 = new RosettaInterpreterError("b2"); + b1 = new RosettaInterpreterError("b1", null); + b2 = new RosettaInterpreterError("b2", null); baseErr = new ArrayList<>(List.of(b1,b2)); } From 0f88678abb364f15aee412a1dc9fc34ee7a514b9 Mon Sep 17 00:00:00 2001 From: Bogdan Damian Date: Thu, 20 Jun 2024 10:49:20 +0200 Subject: [PATCH 227/236] Incorporated the data changes to the functions tests --- .../interpreternew/RosettaInterpreterNew.java | 14 ++++ .../RosettaInterpreterFunctionTest.java | 74 +++++++++++++++---- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java index e3425d5a0..ecd32aeb5 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java @@ -104,4 +104,18 @@ public RosettaInterpreterEnvironment interp(Data expression, return environment; } + + /** + * Simple example interpret function to allow for better understanding + * of the development workflow. It is used in testing for simplification. + * + * @param expression the expression to be interpreted + * @return value of RosettaIntLiteral otherwise exception + */ + public RosettaInterpreterEnvironment interp(Data expression) { + + environment = (RosettaInterpreterEnvironment) expression.accept(visitor, environment); + + return environment; + } } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java index 9cf338499..a19f82138 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterFunctionTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,6 +31,7 @@ import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl; import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.rosetta.RosettaEnumeration; +import com.regnosys.rosetta.rosetta.simple.impl.DataImpl; import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ModelHelper; @@ -345,18 +347,60 @@ public void funcSimpleSetFeatureTest() { + " output: result A (1..1)\r\n" + " set result:\r\n" + " Add()\r\n"); - RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", - List.of(new RosettaInterpreterTypedFeatureValue("a"))); FunctionImpl function = (FunctionImpl) model.getElements().get(1); + DataImpl data = (DataImpl) model.getElements().get(0); RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); - env.addValue("A", v); + env = (RosettaInterpreterEnvironment) interpreter.interp(data); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", List.of(new RosettaInterpreterTypedFeatureValue("a", - new RosettaInterpreterNumberValue(BigDecimal.valueOf(5))))); + new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)), + ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()))); + assertEquals(expected, res); + } + + @Test + public void funcSimpleSetComplexFeatureTest() { + RosettaModel model = mh.parseRosettaWithNoErrors( + "type Date:" + + " day int (1..1)" + + " month int (1..1)" + + " year int (1..1)" + + "func FindMyBday:\r\n" + + " output: result Date (1..1)\r\n" + + " set result:\r\n" + + " Date { day: 0, month: 0, year: 0 }\r\n" + + " set result -> day:\r\n" + + " 17\r\n" + + " set result -> month:\r\n" + + " 9\r\n" + + " set result -> year:\r\n" + + " 2003\r\n" + + "func MyTest:\r\n" + + " output: result Date (1..1)\r\n" + + " set result:\r\n" + + " FindMyBday()\r\n"); + FunctionImpl function = (FunctionImpl) model.getElements().get(1); + DataImpl data = (DataImpl) model.getElements().get(0); + RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) + ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); + RosettaInterpreterEnvironment env = + (RosettaInterpreterEnvironment) interpreter.interp(function); + env = (RosettaInterpreterEnvironment) interpreter.interp(data); + RosettaInterpreterValue res = interpreter.interp(ref, env); + RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("Date", + List.of(new RosettaInterpreterTypedFeatureValue("day", + new RosettaInterpreterNumberValue(17), + ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()), + new RosettaInterpreterTypedFeatureValue("month", + new RosettaInterpreterNumberValue(BigDecimal.valueOf(9)), + ((RosettaInterpreterTypedValue) res).getAttributes().get(1).getCard()), + new RosettaInterpreterTypedFeatureValue("year", + new RosettaInterpreterNumberValue(BigDecimal.valueOf(2003)), + ((RosettaInterpreterTypedValue) res).getAttributes().get(2).getCard()))); assertEquals(expected, res); } @@ -373,14 +417,13 @@ public void funcSimpleSetFeatureErrorTest() { + " output: result A (1..1)\r\n" + " set result:\r\n" + " Add()\r\n"); - RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", - List.of(new RosettaInterpreterTypedFeatureValue("a"))); FunctionImpl function = (FunctionImpl) model.getElements().get(1); + DataImpl data = (DataImpl) model.getElements().get(0); RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); - env.addValue("A", v); + env = (RosettaInterpreterEnvironment) interpreter.interp(data); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterErrorValue expected = new RosettaInterpreterErrorValue( new RosettaInterpreterError("Arithmetic Operation: Rightside" @@ -402,14 +445,13 @@ public void funcSimpleSetFeatureData() { + " output: result A (1..1)\r\n" + " set result:\r\n" + " Add()\r\n"); - RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", - List.of(new RosettaInterpreterTypedFeatureValue("a"))); FunctionImpl function = (FunctionImpl) model.getElements().get(1); + DataImpl data = (DataImpl) model.getElements().get(0); RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); - env.addValue("A", v); + env = (RosettaInterpreterEnvironment) interpreter.interp(data); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", List.of(new RosettaInterpreterTypedFeatureValue("a", @@ -432,21 +474,21 @@ public void funcSimpleSetFeatureDataSecond() { + " output: result A (1..1)\r\n" + " set result:\r\n" + " Add()\r\n"); - RosettaInterpreterTypedValue v = new RosettaInterpreterTypedValue("A", - List.of(new RosettaInterpreterTypedFeatureValue("a"), - new RosettaInterpreterTypedFeatureValue("b"))); FunctionImpl function = (FunctionImpl) model.getElements().get(1); + DataImpl data = (DataImpl) model.getElements().get(0); RosettaSymbolReferenceImpl ref = (RosettaSymbolReferenceImpl) ((FunctionImpl)model.getElements().get(2)).getOperations().get(0).getExpression(); RosettaInterpreterEnvironment env = (RosettaInterpreterEnvironment) interpreter.interp(function); - env.addValue("A", v); + env = (RosettaInterpreterEnvironment) interpreter.interp(data); RosettaInterpreterValue res = interpreter.interp(ref, env); RosettaInterpreterTypedValue expected = new RosettaInterpreterTypedValue("A", - List.of(new RosettaInterpreterTypedFeatureValue("a"), + List.of(new RosettaInterpreterTypedFeatureValue("a", + new RosettaInterpreterListValue(new ArrayList<>()), + ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()), new RosettaInterpreterTypedFeatureValue("b", new RosettaInterpreterNumberValue(BigDecimal.valueOf(5)), - ((RosettaInterpreterTypedValue) res).getAttributes().get(0).getCard()))); + ((RosettaInterpreterTypedValue) res).getAttributes().get(1).getCard()))); assertEquals(expected, res); } From fe14b001f71c587abb0d1818bde8f021b06c2a48 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 11:11:51 +0200 Subject: [PATCH 228/236] failed attempt at further tests --- ...ettaInterpreterCompilerComparisonTest.java | 2 +- ...taInterpreterCompilerComparisonTest2.xtend | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java index 2ec8748d9..9e6861c56 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java @@ -31,7 +31,7 @@ public void setup() { } @Test - void SimpleTest() { + void simpleTest() { } diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index 311832ceb..8b1a6fc74 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -53,6 +53,11 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue; import com.regnosys.rosetta.tests.RosettaInjectorProvider; import com.regnosys.rosetta.tests.util.ExpressionParser; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue +import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment +import java.math.BigDecimal +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue +import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl @ExtendWith(InjectionExtension) @InjectWith(RosettaInjectorProvider) @@ -66,8 +71,11 @@ class RosettaInterpreterCompilerComparisonTest2 { @Inject RosettaInterpreterNew interpreter; + @Inject + ModelHelper mh; + @Test - def void simpleTest() { + def void simpleTest2() { val model = ''' func Foo: output: b int (1..1) @@ -92,7 +100,37 @@ class RosettaInterpreterCompilerComparisonTest2 { // If actually doing this then better approach would be // To have like a helper method that converts a primitive type // Into some value domain type to avoid having to manually set it - assertEquals(value, new RosettaInterpreterNumberValue(output)) + assertEquals(value, new RosettaInterpreterNumberValue(output + 1)) + assertTrue(false) + } + + @Test + def void simpleTest() { + val code = "func Add:\r\n" + + " inputs:" + + " a number (1..1)\r\n" + + " b int (1..1)\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " a + b\r\n" + + "func MyTest:\r\n" + + " output: result number (1..1)\r\n" + + " set result:\r\n" + + " Add(1.0, 2.0)\r\n" + val model = mh.parseRosettaWithNoErrors(code) + val function = model.getElements().get(0) as FunctionImpl + val ref = (model.getElements().get(1) as FunctionImpl).getOperations().get(0).getExpression() as RosettaSymbolReferenceImpl + val env = interpreter.interp(function) as RosettaInterpreterEnvironment + val res = interpreter.interp(ref, env) + val expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)) + + val classes = code.generateCode.compileToClasses + val myTest = classes.createFunc('MyTest') + val output = myTest.invokeFunc(Double) + println(output) + + assertEquals(expected, 2) + assertTrue(false) } } From 78b02d7681e616895f531c001329710a8cd18391 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 11:16:20 +0200 Subject: [PATCH 229/236] fix arithmetic --- ...osettaArithmeticOperationsInterpreter.java | 206 ++++++++++++------ 1 file changed, 142 insertions(+), 64 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java index f06d04d46..4db887723 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterRosettaArithmeticOperationsInterpreter.java @@ -1,9 +1,14 @@ package com.regnosys.rosetta.interpreternew.visitors; -import java.util.List; +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import org.eclipse.emf.ecore.EObject; +import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterError; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterErrorValue; @@ -36,77 +41,150 @@ public RosettaInterpreterValue interp(ArithmeticOperation expr, RosettaInterpreterValue leftInterpreted = left.accept(visitor, env); RosettaInterpreterValue rightInterpreted = right.accept(visitor, env); - if (!(leftInterpreted instanceof RosettaInterpreterNumberValue - || leftInterpreted instanceof RosettaInterpreterStringValue) - || !(rightInterpreted instanceof RosettaInterpreterNumberValue - || rightInterpreted instanceof RosettaInterpreterStringValue)) { - - // Check for errors in the left or right side of the binary operation - RosettaInterpreterErrorValue leftErrors = - checkForErrors(leftInterpreted, "Leftside", expr); - RosettaInterpreterErrorValue rightErrors = - checkForErrors(rightInterpreted, "Rightside", expr); - return RosettaInterpreterErrorValue.merge(List.of(leftErrors, rightErrors)); - } - boolean sameType = - (leftInterpreted instanceof RosettaInterpreterStringValue - && rightInterpreted instanceof RosettaInterpreterStringValue) - || (!(leftInterpreted instanceof RosettaInterpreterStringValue) - && !(rightInterpreted instanceof RosettaInterpreterStringValue)); - if (!sameType) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "The terms of the operation " - + "are neither both strings nor both numbers", expr)); - } - + // Check for errors in the left or right side of the binary operation + RosettaInterpreterErrorValue leftErrors = + checkForErrors(leftInterpreted, "Leftside", expr); + RosettaInterpreterErrorValue rightErrors = + checkForErrors(rightInterpreted, "Rightside", expr); + if (leftErrors.getErrors().size() + rightErrors.getErrors().size() > 0) { + return RosettaInterpreterErrorValue.merge(leftErrors, rightErrors); + } + + + //Interpret string concatenation if (leftInterpreted instanceof RosettaInterpreterStringValue && rightInterpreted instanceof RosettaInterpreterStringValue) { - String leftString = ((RosettaInterpreterStringValue) leftInterpreted) - .getValue(); - String rightString = ((RosettaInterpreterStringValue) rightInterpreted) - .getValue(); - if (expr.getOperator().equals("+")) { - return new RosettaInterpreterStringValue(leftString + rightString); - } - else { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "The terms are strings but the operation " - + "is not concatenation: not implemented", expr)); - } + return interpretString(leftInterpreted, rightInterpreted, expr); + + //Interpret number operations } else if (leftInterpreted instanceof RosettaInterpreterNumberValue && rightInterpreted instanceof RosettaInterpreterNumberValue) { - RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); - RosettaNumber rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); + return interpretNumber(leftInterpreted, rightInterpreted, expr); + + //Interpret date subtraction + } else if (leftInterpreted instanceof RosettaInterpreterDateValue + && rightInterpreted instanceof RosettaInterpreterDateValue) { + return interpretDate(leftInterpreted, rightInterpreted, expr); - if (expr.getOperator().equals("+")) { - return new RosettaInterpreterNumberValue((leftNumber - .add(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("-")) { - return new RosettaInterpreterNumberValue((leftNumber - .subtract(rightNumber)).bigDecimalValue()); - } else if (expr.getOperator().equals("*")) { - return new RosettaInterpreterNumberValue((leftNumber - .multiply(rightNumber)).bigDecimalValue()); - } else { - // Division by 0 is not allowed - if (rightNumber.floatValue() == 0.0) { - return new RosettaInterpreterErrorValue( - new RosettaInterpreterError( - "Division by 0 is not allowed", expr)); - } - return new RosettaInterpreterNumberValue((leftNumber - .divide(rightNumber)).bigDecimalValue()); - } } else { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( - "The terms of the operation are neither both strings nor both numbers", expr)); + "The terms of the operation are not both strings or both numbers or both dates", expr)); } } + /** + * Helper method that contains the code for interpreting string concatenation. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretString(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + String leftString = ((RosettaInterpreterStringValue) leftInterpreted) + .getValue(); + String rightString = ((RosettaInterpreterStringValue) rightInterpreted) + .getValue(); + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterStringValue(leftString + rightString); + } + else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Both terms are strings but the operation " + + "is not concatenation: not implemented", expr)); + } + } + + /** + * Helper method that contains the code for interpreting number operations. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretNumber(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + RosettaNumber leftNumber = ((RosettaInterpreterNumberValue) leftInterpreted).getValue(); + RosettaNumber rightNumber = ((RosettaInterpreterNumberValue) rightInterpreted).getValue(); + + if (expr.getOperator().equals("+")) { + return new RosettaInterpreterNumberValue((leftNumber + .add(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("-")) { + return new RosettaInterpreterNumberValue((leftNumber + .subtract(rightNumber)).bigDecimalValue()); + } else if (expr.getOperator().equals("*")) { + return new RosettaInterpreterNumberValue((leftNumber + .multiply(rightNumber)).bigDecimalValue()); + } else { + // Division by 0 is not allowed + if (rightNumber.bigDecimalValue() == BigDecimal.valueOf(0)) { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Division by 0 is not allowed", expr)); + } + return new RosettaInterpreterNumberValue((leftNumber + .divide(rightNumber)).bigDecimalValue()); + } + } + + /** + * Helper method that contains the code for interpreting date subtraction. + * + * @param leftInterpreted the left term + * @param rightInterpreted the right term + * @param expr the arithmetic operation + * @return The interpreted result + */ + private RosettaInterpreterValue interpretDate(RosettaInterpreterValue leftInterpreted, + RosettaInterpreterValue rightInterpreted, ArithmeticOperation expr) { + RosettaInterpreterDateValue l = (RosettaInterpreterDateValue) leftInterpreted; + RosettaInterpreterDateValue r = (RosettaInterpreterDateValue) rightInterpreted; + if (expr.getOperator().equals("-")) { + String dayL = appendZeroes(l.getDay()); + String monthL = appendZeroes(l.getMonth()); + String yearL = appendZeroes(l.getYear()); + String dayR = appendZeroes(r.getDay()); + String monthR = appendZeroes(r.getMonth()); + String yearR = appendZeroes(r.getYear()); + + String inputString1 = dayL + " " + monthL + " " + yearL; + String inputString2 = dayR + " " + monthR + " " + yearR; + + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd MM yyyy"); + + LocalDateTime date1 = LocalDate.parse(inputString1, dtf).atStartOfDay(); + LocalDateTime date2 = LocalDate.parse(inputString2, dtf).atStartOfDay(); + long daysBetween = Duration.between(date1, date2).toDays(); + return new RosettaInterpreterNumberValue(BigDecimal.valueOf(daysBetween)); + } else { + return new RosettaInterpreterErrorValue( + new RosettaInterpreterError( + "Both terms are dates but the operation " + + "is not subtraction: not implemented", expr)); + } + } + + /** + * Helper method that adds a 0 to a day/month string in case it does not have it, + * to correspond to the proper format. + * + * @param d The day/month value as a RosettaInterpreterNumberValue + * @return The (optionally) modified string value. + */ + private String appendZeroes(RosettaInterpreterNumberValue d) { + String result = d.getValue().bigDecimalValue().toBigInteger().toString(); + if (result.length() == 1) { + result = "0" + result; + } + return result; + } + /** * Helper method that takes an interpretedValue and a string, @@ -123,9 +201,9 @@ private RosettaInterpreterErrorValue checkForErrors( RosettaInterpreterValue interpretedValue, String side, EObject associatedObject) { if (interpretedValue instanceof RosettaInterpreterNumberValue - || interpretedValue instanceof RosettaInterpreterStringValue) { - // If the value satisfies the type conditions, we return an empty - // error value so that the merger has two error values to merge + || interpretedValue instanceof RosettaInterpreterStringValue + || interpretedValue instanceof RosettaInterpreterDateValue) { + // If the value satisfies the type conditions, return an empty error return new RosettaInterpreterErrorValue(); } @@ -138,7 +216,7 @@ else if (RosettaInterpreterErrorValue.errorsExist(interpretedValue)) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError( "Arithmetic Operation: " + side - + " is not of type Number/String", associatedObject)); + + " is not of type Number/String/Date", associatedObject)); } } } From f58c36902d9ba0c2525fa83988bcb5999cb7197b Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 11:26:18 +0200 Subject: [PATCH 230/236] ? --- .../RosettaInterpreterCompilerComparisonTest2.xtend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index 8b1a6fc74..bb16bdf98 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -100,7 +100,7 @@ class RosettaInterpreterCompilerComparisonTest2 { // If actually doing this then better approach would be // To have like a helper method that converts a primitive type // Into some value domain type to avoid having to manually set it - assertEquals(value, new RosettaInterpreterNumberValue(output + 1)) + assertEquals(value, new RosettaInterpreterNumberValue(output)) assertTrue(false) } @@ -126,7 +126,7 @@ class RosettaInterpreterCompilerComparisonTest2 { val classes = code.generateCode.compileToClasses val myTest = classes.createFunc('MyTest') - val output = myTest.invokeFunc(Double) + val output = myTest.invokeFunc(BigDecimal) println(output) assertEquals(expected, 2) From dbcbf295b17cbd91d4265c1987d05828ff238a7e Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 11:26:57 +0200 Subject: [PATCH 231/236] fix checkstyle --- .../visitors/RosettaInterpreterFunctionInterpreter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java index 9e34969a3..c0fae989f 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java @@ -169,7 +169,9 @@ public RosettaInterpreterErrorValue processConditions(List conditions if (v instanceof RosettaInterpreterBooleanValue) { if (((RosettaInterpreterBooleanValue) v).getValue() == false) { acc.addError(new RosettaInterpreterError("Condition \"" - + c.getName() + "\" does not hold for this function call", null)); + + c.getName() + "\" " + + "does not hold" + + " for this function call", null)); } } else { //must be an error if not a boolean value acc.addAllErrors(v); From 16b2e97d2907eb9250184943585a191e424ee8d9 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Thu, 20 Jun 2024 13:44:54 +0200 Subject: [PATCH 232/236] final stand --- .../RosettaInterpreterCompilerComparisonTest2.xtend | 2 -- 1 file changed, 2 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index bb16bdf98..9547b9ae2 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -101,7 +101,6 @@ class RosettaInterpreterCompilerComparisonTest2 { // To have like a helper method that converts a primitive type // Into some value domain type to avoid having to manually set it assertEquals(value, new RosettaInterpreterNumberValue(output)) - assertTrue(false) } @Test @@ -130,7 +129,6 @@ class RosettaInterpreterCompilerComparisonTest2 { println(output) assertEquals(expected, 2) - assertTrue(false) } } From 529c5b65df00d3b35f5b9f45c28faed00e4856c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20=C5=9Eutac?= Date: Fri, 21 Jun 2024 11:59:58 +0300 Subject: [PATCH 233/236] Changer the InterpreterBaseValue to just InterpreterValue --- ...aInterpreterParseOperationInterpreter.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java index 6ca3d6854..2d8262845 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterParseOperationInterpreter.java @@ -3,7 +3,6 @@ import java.math.BigDecimal; import java.util.List; -import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterBaseValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateTimeValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterDateValue; import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnumElementValue; @@ -35,7 +34,7 @@ public class RosettaInterpreterParseOperationInterpreter extends RosettaInterpre * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToStringOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToStringOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); RosettaInterpreterValue result = argument.accept(visitor, env); @@ -55,7 +54,7 @@ public RosettaInterpreterBaseValue interp(ToStringOperation expr, RosettaInterpr * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToNumberOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToNumberOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); if (argument instanceof RosettaStringLiteralImpl) { @@ -72,7 +71,7 @@ public RosettaInterpreterBaseValue interp(ToNumberOperation expr, RosettaInterpr * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToIntOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToIntOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); if (argument instanceof RosettaStringLiteralImpl) { @@ -100,7 +99,7 @@ public RosettaInterpreterBaseValue interp(ToIntOperation expr, RosettaInterprete * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToTimeOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToTimeOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); if (argument instanceof RosettaStringLiteralImpl) { @@ -147,7 +146,7 @@ public RosettaInterpreterValue interp(ToEnumOperation expr, RosettaInterpreterBa * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToDateOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToDateOperation expr, RosettaInterpreterBaseEnvironment env) { RosettaExpression argument = expr.getArgument(); if (argument instanceof RosettaStringLiteralImpl) { @@ -164,7 +163,7 @@ public RosettaInterpreterBaseValue interp(ToDateOperation expr, RosettaInterpret * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToDateTimeOperation expr, RosettaInterpreterBaseEnvironment env) { + public RosettaInterpreterValue interp(ToDateTimeOperation expr, RosettaInterpreterBaseEnvironment env) { // 2024-06-18T01:24:14 RosettaExpression argument = expr.getArgument(); @@ -197,7 +196,7 @@ public RosettaInterpreterBaseValue interp(ToDateTimeOperation expr, RosettaInter * @param env the environment used * @return the interpreted value */ - public RosettaInterpreterBaseValue interp(ToZonedDateTimeOperation expr, + public RosettaInterpreterValue interp(ToZonedDateTimeOperation expr, RosettaInterpreterBaseEnvironment env) { // 2024-06-18T01:24:14−07:00 @@ -241,7 +240,7 @@ public RosettaInterpreterBaseValue interp(ToZonedDateTimeOperation expr, * @param string string to be checked * @return the interpreted value */ - public RosettaInterpreterBaseValue checkString(String string) { + public RosettaInterpreterValue checkString(String string) { BigDecimal number; try { @@ -264,7 +263,7 @@ public RosettaInterpreterBaseValue checkString(String string) { * @param string string to be transformed * @return the interpreted value */ - public RosettaInterpreterBaseValue createTime(String string) { + public RosettaInterpreterValue createTime(String string) { String[] strings = string.split(":"); if (strings.length != 3) { @@ -297,7 +296,7 @@ public RosettaInterpreterBaseValue createTime(String string) { * @param string string to be transformed * @return the interpreted value */ - public RosettaInterpreterBaseValue createDate(String string) { + public RosettaInterpreterValue createDate(String string) { String[] strings = string.split("-"); if (strings.length != 3) { From d29e997ff5e1e92c490f8e723c43c18833d50bbb Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 21 Jun 2024 15:11:16 +0200 Subject: [PATCH 234/236] fix not null any longer --- ...RosettaInterpreterFunctionInterpreter.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java index c0fae989f..1db9b9430 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java @@ -171,7 +171,7 @@ public RosettaInterpreterErrorValue processConditions(List conditions acc.addError(new RosettaInterpreterError("Condition \"" + c.getName() + "\" " + "does not hold" - + " for this function call", null)); + + " for this function call", c.getExpression())); } } else { //must be an error if not a boolean value acc.addAllErrors(v); @@ -311,14 +311,14 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" has cardinality lower than the limit " - + lowerLimit, null)); + + lowerLimit, attr)); } int upperLimit = attr.getCard().isUnbounded() ? Integer.MAX_VALUE : attr.getCard().getSup(); if (paramSize > upperLimit) { return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" has cardinality higher than the limit " - + upperLimit, null)); + + upperLimit, attr)); } //checking that the potential list of elements in arg and value are of the same type @@ -329,7 +329,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a number, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -339,7 +339,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a number, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -349,7 +349,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a boolean, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -359,7 +359,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a string, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -369,7 +369,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a date, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -379,7 +379,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a dateTime, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; @@ -389,7 +389,7 @@ public RosettaInterpreterErrorValue checkPair(AttributeImpl attr, RosettaInterpr return new RosettaInterpreterErrorValue( new RosettaInterpreterError("The attribute \"" + attr.getName() + "\" requires a zonedDateTime, but received a " - + val.getClass(), null)); + + val.getClass(), attr)); } } break; From 9530faf196ba67fbf867408db85d85348bdf3cdd Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 21 Jun 2024 15:18:48 +0200 Subject: [PATCH 235/236] fix checkstyle --- .../visitors/RosettaInterpreterFunctionInterpreter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java index 1db9b9430..0af5d5da8 100644 --- a/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java +++ b/rosetta-interpreter/src/main/java/com/regnosys/rosetta/interpreternew/visitors/RosettaInterpreterFunctionInterpreter.java @@ -171,7 +171,9 @@ public RosettaInterpreterErrorValue processConditions(List conditions acc.addError(new RosettaInterpreterError("Condition \"" + c.getName() + "\" " + "does not hold" - + " for this function call", c.getExpression())); + + " for this" + + " function" + + " call", c.getExpression())); } } else { //must be an error if not a boolean value acc.addAllErrors(v); From 82cd826f0bafce3c4b4827b17908579d3eee1f72 Mon Sep 17 00:00:00 2001 From: Jacek Kulik Date: Fri, 21 Jun 2024 16:55:01 +0200 Subject: [PATCH 236/236] testing more --- .../RosettaInterpreterCompilerComparisonTest2.xtend | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend index 9547b9ae2..582827f45 100644 --- a/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend +++ b/rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend @@ -121,14 +121,13 @@ class RosettaInterpreterCompilerComparisonTest2 { val ref = (model.getElements().get(1) as FunctionImpl).getOperations().get(0).getExpression() as RosettaSymbolReferenceImpl val env = interpreter.interp(function) as RosettaInterpreterEnvironment val res = interpreter.interp(ref, env) - val expected = new RosettaInterpreterNumberValue(BigDecimal.valueOf(3)) val classes = code.generateCode.compileToClasses val myTest = classes.createFunc('MyTest') val output = myTest.invokeFunc(BigDecimal) println(output) - assertEquals(expected, 2) + assertEquals(res, new RosettaInterpreterNumberValue(output)) } }