forked from finos/rune-dsl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STORY-1740: omit implicit parameter in operations and function calls (f…
…inos#457) * Addressed antrl warnings * Made left operand syntactically optional; cleaned up AST * Refactored implicit variable AST * Fixed tests * Added parsing tests * Added scoping test for function symbols * Adjusted Xsemantics validation filter for generated input * Restored test * Added validation * Added validation redirection test * Fixed scoping and condition code generator * Corrected UI test * Removed plugin.xml_gen from source control * Corrected condition test * Fixed invalid cardinality warnings * Added attributes of implicit variable to scope * Fixed code generator for attributes of implicit variable * Added validation tests * Added test for nested item references * Cleaned Co-authored-by: Hugo Hills <39260692+hugohills-regnosys@users.noreply.github.com>
- Loading branch information
1 parent
6f894db
commit 04b3b3d
Showing
43 changed files
with
1,298 additions
and
970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ build.acceleo | |
.metadata/ | ||
*.class | ||
.DS_Store | ||
plugin.xml_gen | ||
|
||
**/.settings | ||
**/src-gen/ | ||
|
68 changes: 68 additions & 0 deletions
68
...etta.tests/src/com/regnosys/rosetta/generator/java/condition/ConditionGeneratorTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.regnosys.rosetta.generator.java.condition | ||
|
||
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.* | ||
import com.regnosys.rosetta.generator.java.rule.ConditionTestHelper | ||
|
||
@ExtendWith(InjectionExtension) | ||
@InjectWith(RosettaInjectorProvider) | ||
class ConditionGeneratorTest { | ||
@Inject extension CodeGeneratorTestHelper | ||
@Inject extension ConditionTestHelper | ||
|
||
@Test | ||
def void omittedParameterInConditionTest() { | ||
val code = ''' | ||
namespace com.rosetta.test.model | ||
version "${project.version}" | ||
type Foo: | ||
a int (0..1) | ||
condition C: | ||
FooIsValid | ||
func FooIsValid: | ||
inputs: foo Foo (1..1) | ||
output: result boolean (1..1) | ||
set result: | ||
foo -> a exists | ||
'''.generateCode | ||
val classes = code.compileToClasses | ||
|
||
val foo1 = classes.createInstanceUsingBuilder('Foo', of('a', 42)) | ||
assertTrue(classes.runDataRule(foo1, 'FooC').isSuccess) | ||
|
||
val foo2 = classes.createInstanceUsingBuilder('Foo', of()) | ||
assertFalse(classes.runDataRule(foo2, 'FooC').isSuccess) | ||
} | ||
|
||
@Test | ||
def void useImplicitVariableInConditionTest() { | ||
val code = ''' | ||
namespace com.rosetta.test.model | ||
version "${project.version}" | ||
type Foo: | ||
a int (0..1) | ||
condition C: | ||
it -> a exists and [it, it] any = it | ||
'''.generateCode | ||
val classes = code.compileToClasses | ||
|
||
val foo1 = classes.createInstanceUsingBuilder('Foo', of('a', 42)) | ||
assertTrue(classes.runDataRule(foo1, 'FooC').isSuccess) | ||
|
||
val foo2 = classes.createInstanceUsingBuilder('Foo', of()) | ||
assertFalse(classes.runDataRule(foo2, 'FooC').isSuccess) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.