[BUGFIX] Fix lambda variable dependency issue
This commit is contained in:
parent
1abe2a44f5
commit
0b0f5320d4
1 changed files with 22 additions and 0 deletions
|
|
@ -62,6 +62,28 @@ class TestArrayFunctions:
|
|||
output = single_variable_output("{%array_apply(['a', 'b', 'c'], %capitalize)}")
|
||||
assert output == ["A", "B", "C"]
|
||||
|
||||
def test_array_apply_custom_function(self):
|
||||
output = (
|
||||
Script(
|
||||
{
|
||||
"the_array": "{ ['a', 'B', 'c', 'D'] }",
|
||||
"output": "{ %array_apply(the_array, %custom_cap) }",
|
||||
"should_lower": "{%bool(True)}",
|
||||
"%custom_cap": """{
|
||||
%if(
|
||||
%bool(should_lower),
|
||||
%lower($0),
|
||||
%upper($0)
|
||||
)
|
||||
}""",
|
||||
}
|
||||
)
|
||||
.resolve(update=True)
|
||||
.get("output")
|
||||
.native
|
||||
)
|
||||
assert output == ['a', 'b', 'c', 'd']
|
||||
|
||||
def test_array_reduce(self):
|
||||
output = single_variable_output("{%array_reduce([1, 2, 3, 4], %add)}")
|
||||
assert output == 10
|
||||
|
|
|
|||
Loading…
Reference in a new issue