more working

This commit is contained in:
Jesse Bannon 2024-06-03 11:55:25 -07:00
parent 13a37b6453
commit 734d4c8a16
3 changed files with 8 additions and 1 deletions

View file

@ -64,6 +64,6 @@ class ConditionalFunctions:
otherwise returns ``else_arg``.
"""
maybe_true_value = maybe_true_arg.value()
if bool(maybe_true_value):
if bool(maybe_true_value.value):
return maybe_true_value
return else_arg.value()

View file

@ -229,6 +229,8 @@ class BuiltInFunction(Function, BuiltInFunctionType):
assert isinstance(lambda_array, Array)
if len(lambda_array.value) == 0:
return Array(value=[])
if len(lambda_array.value) == 1:
return lambda_array.value[0]

View file

@ -15,6 +15,11 @@ class TestLambdaFunction:
{"%times_two": "{%mul($0, 2)}", "wip": "{%array_apply([1, 2, 3], %times_two)}"}
).resolve() == ScriptOutput({"wip": Array([Integer(2), Integer(4), Integer(6)])})
def test_lambda_with_custom_function_empty_input(self):
assert Script(
{"%times_two": "{%mul($0, 2)}", "wip": "{%array_apply([], %times_two)}"}
).resolve() == ScriptOutput({"wip": Array([])})
def test_conditional_lambda_with_custom_functions(self):
assert Script(
{