Skip to content

Commit fe14b00

Browse files
committed
failed attempt at further tests
1 parent 00d9e6a commit fe14b00

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void setup() {
3131
}
3232

3333
@Test
34-
void SimpleTest() {
34+
void simpleTest() {
3535

3636

3737
}

rosetta-interpreter/src/test/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterCompilerComparisonTest2.xtend

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue;
5353
import com.regnosys.rosetta.tests.RosettaInjectorProvider;
5454
import com.regnosys.rosetta.tests.util.ExpressionParser;
5555
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
5661

5762
@ExtendWith(InjectionExtension)
5863
@InjectWith(RosettaInjectorProvider)
@@ -66,8 +71,11 @@ class RosettaInterpreterCompilerComparisonTest2 {
6671
@Inject
6772
RosettaInterpreterNew interpreter;
6873

74+
@Inject
75+
ModelHelper mh;
76+
6977
@Test
70-
def void simpleTest() {
78+
def void simpleTest2() {
7179
val model = '''
7280
func Foo:
7381
output: b int (1..1)
@@ -92,7 +100,37 @@ class RosettaInterpreterCompilerComparisonTest2 {
92100
// If actually doing this then better approach would be
93101
// To have like a helper method that converts a primitive type
94102
// 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)
96134
}
97135
}
98136

0 commit comments

Comments
 (0)