Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Bug fix

* Cleaned
  • Loading branch information
SimonCockx authored Aug 30, 2023
1 parent 97c368f commit 06d734d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ public boolean isIdentity() {
}

/**
* Map a single value into an item of a list based on the given mapping function.
* Map a single value to a single value.
*
* @param <F>
* @param mappingFunc
* @return mapped list
*/
public <F> MapperS<F> mapSingleToItem(Function<MapperS<T>, MapperS<F>> mappingFunc) {
if (item.getMappedObject() == null) {
return MapperS.ofNull();
}
return mappingFunc.apply(this);
}

Expand All @@ -175,6 +178,9 @@ public <F> MapperS<F> mapSingleToItem(Function<MapperS<T>, MapperS<F>> mappingFu
* @return mapped list
*/
public <F> MapperC<F> mapSingleToList(Function<MapperS<T>, MapperC<F>> mappingFunc) {
if (item.getMappedObject() == null) {
return MapperC.ofNull();
}
return mappingFunc.apply(this);
}

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

@Test
def void singularExtractWithEmptyValueReturnsEmpty() {
val code = '''
func A:
inputs:
input int (0..1)
output:
result boolean (0..1)
set result:
input
extract
if item = 0
then True
else False
'''.generateCode
val classes = code.compileToClasses

val a = classes.createFunc("A");
assertEquals(null, a.invokeFunc(String, #[null]))
}

def void testDispatchFunction() {
val code = '''
enum DayCountFractionEnum:
Expand Down

0 comments on commit 06d734d

Please sign in to comment.