more working
This commit is contained in:
parent
13a37b6453
commit
734d4c8a16
3 changed files with 8 additions and 1 deletions
|
|
@ -64,6 +64,6 @@ class ConditionalFunctions:
|
||||||
otherwise returns ``else_arg``.
|
otherwise returns ``else_arg``.
|
||||||
"""
|
"""
|
||||||
maybe_true_value = maybe_true_arg.value()
|
maybe_true_value = maybe_true_arg.value()
|
||||||
if bool(maybe_true_value):
|
if bool(maybe_true_value.value):
|
||||||
return maybe_true_value
|
return maybe_true_value
|
||||||
return else_arg.value()
|
return else_arg.value()
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,8 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
|
|
||||||
assert isinstance(lambda_array, Array)
|
assert isinstance(lambda_array, Array)
|
||||||
|
|
||||||
|
if len(lambda_array.value) == 0:
|
||||||
|
return Array(value=[])
|
||||||
if len(lambda_array.value) == 1:
|
if len(lambda_array.value) == 1:
|
||||||
return lambda_array.value[0]
|
return lambda_array.value[0]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ class TestLambdaFunction:
|
||||||
{"%times_two": "{%mul($0, 2)}", "wip": "{%array_apply([1, 2, 3], %times_two)}"}
|
{"%times_two": "{%mul($0, 2)}", "wip": "{%array_apply([1, 2, 3], %times_two)}"}
|
||||||
).resolve() == ScriptOutput({"wip": Array([Integer(2), Integer(4), Integer(6)])})
|
).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):
|
def test_conditional_lambda_with_custom_functions(self):
|
||||||
assert Script(
|
assert Script(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue