Skip to content

Commit

Permalink
Fixed (finos#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCockx authored Aug 10, 2023
1 parent 8b77c52 commit 7ff0b1e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public void setDerivedState(EObject obj) {
this.setDefaultElseToEmpty((RosettaConditionalExpression)obj);
} else if (obj instanceof JoinOperation) {
this.setDefaultJoinSeparator((JoinOperation)obj);
} else if (obj instanceof HasGeneratedInput) {
}
if (obj instanceof HasGeneratedInput) {
this.setDefaultInput((HasGeneratedInput)obj);
}
}
Expand All @@ -63,7 +64,8 @@ public void removeDerivedState(EObject obj) {
this.discardDefaultElse((RosettaConditionalExpression)obj);
} else if (obj instanceof JoinOperation) {
this.discardDefaultJoinSeparator((JoinOperation)obj);
} else if (obj instanceof HasGeneratedInput) {
}
if (obj instanceof HasGeneratedInput) {
this.discardDefaultInput((HasGeneratedInput)obj);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ExpressionGenerator extends RosettaExpressionSwitch<StringConcatenationCli
if (expr.evaluatesToComparisonResult) {
'''((«ComparisonResult»)«expr.javaCode(scope)»).asMapper()'''
} else {
'''((MapperS<«typeProvider.getRType(expr).toJavaReferenceType»>)«expr.javaCode(scope)»)'''
'''((«MapperS»<«typeProvider.getRType(expr).toJavaReferenceType»>)«expr.javaCode(scope)»)'''
}
} else if (expr.evaluatesToComparisonResult && !multi) {
'''«expr.javaCode(scope)».asMapper()'''
Expand Down Expand Up @@ -751,17 +751,17 @@ class ExpressionGenerator extends RosettaExpressionSwitch<StringConcatenationCli
if (expr.argument.isOutputListOfLists) {
if (isBodyMulti) {
'''
«expr.argument.ensureMapperJavaCode(context, false
«expr.argument.ensureMapperJavaCode(context, true
.mapListToList(«funcExpr»)'''
} else {
'''
«expr.argument.ensureMapperJavaCode(context, false
«expr.argument.ensureMapperJavaCode(context, true
.mapListToItem(«funcExpr»)'''
}
} else {
if (isBodyMulti) {
'''
«expr.argument.ensureMapperJavaCode(context, false
«expr.argument.ensureMapperJavaCode(context, true
.mapItemToList(«funcExpr»)'''
} else {
buildSingleItemListOperationOptionalBody(expr, "mapItem", context)
Expand Down Expand Up @@ -873,7 +873,7 @@ class ExpressionGenerator extends RosettaExpressionSwitch<StringConcatenationCli
override protected caseThenOperation(ThenOperation expr, JavaScope context) {
val funcExpr = expr.function.inlineFunction(context, false, true)
'''
«expr.argument.ensureMapperJavaCode(context, false
«expr.argument.ensureMapperJavaCode(context, cardinalityProvider.isMulti(expr.argument)
.apply(«funcExpr»)'''
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ class FunctionGeneratorTest {
@Inject extension ModelHelper
@Inject extension ValidationTestHelper

@Test
def void conditionalThenJoin() {
val code = '''
func A:
output:
result string (1..1)
set result:
if True
then ["Foo", "Bar"]
else "Bar"
then join ", "
'''.generateCode
val classes = code.compileToClasses

val a = classes.createFunc("A");
assertEquals("Foo, Bar", a.invokeFunc(String))
}

@Test
def void canPassEmptyToFunctionThatExpectsList() {
val code = '''
Expand Down

0 comments on commit 7ff0b1e

Please sign in to comment.