@@ -53,6 +53,11 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue;
53
53
import com.regnosys.rosetta.tests.RosettaInjectorProvider ;
54
54
import com.regnosys.rosetta.tests.util.ExpressionParser ;
55
55
import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue
56
+ import com.regnosys.rosetta.rosetta.simple.impl.FunctionImpl
57
+ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment
58
+ import java.math.BigDecimal
59
+ import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterNumberValue
60
+ import com.regnosys.rosetta.rosetta.expression.impl.RosettaSymbolReferenceImpl
56
61
57
62
@ExtendWith (InjectionExtension )
58
63
@InjectWith (RosettaInjectorProvider )
@@ -66,8 +71,11 @@ class RosettaInterpreterCompilerComparisonTest2 {
66
71
@Inject
67
72
RosettaInterpreterNew interpreter;
68
73
74
+ @Inject
75
+ ModelHelper mh;
76
+
69
77
@Test
70
- def void simpleTest () {
78
+ def void simpleTest2 () {
71
79
val model = ' ' '
72
80
func Foo:
73
81
output: b int (1..1)
@@ -92,7 +100,37 @@ class RosettaInterpreterCompilerComparisonTest2 {
92
100
// If actually doing this then better approach would be
93
101
// To have like a helper method that converts a primitive type
94
102
// Into some value domain type to avoid having to manually set it
95
- assertEquals(value, new RosettaInterpreterNumberValue (output))
103
+ assertEquals(value, new RosettaInterpreterNumberValue (output + 1 ))
104
+ assertTrue(false )
105
+ }
106
+
107
+ @Test
108
+ def void simpleTest () {
109
+ val code = " func Add:\r\n "
110
+ + " inputs:"
111
+ + " a number (1..1)\r\n "
112
+ + " b int (1..1)\r\n "
113
+ + " output: result number (1..1)\r\n "
114
+ + " set result:\r\n "
115
+ + " a + b\r\n "
116
+ + " func MyTest:\r\n "
117
+ + " output: result number (1..1)\r\n "
118
+ + " set result:\r\n "
119
+ + " Add(1.0, 2.0)\r\n "
120
+ val model = mh. parseRosettaWithNoErrors(code)
121
+ val function = model. getElements(). get(0 ) as FunctionImpl
122
+ val ref = (model. getElements(). get(1 ) as FunctionImpl ). getOperations(). get(0 ). getExpression() as RosettaSymbolReferenceImpl
123
+ val env = interpreter. interp(function) as RosettaInterpreterEnvironment
124
+ val res = interpreter. interp(ref, env)
125
+ val expected = new RosettaInterpreterNumberValue (BigDecimal . valueOf(3 ))
126
+
127
+ val classes = code. generateCode. compileToClasses
128
+ val myTest = classes. createFunc(' MyTest' )
129
+ val output = myTest. invokeFunc(Double )
130
+ println(output)
131
+
132
+ assertEquals(expected, 2 )
133
+ assertTrue(false )
96
134
}
97
135
}
98
136
0 commit comments