Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Mar 2, 2024
1 parent 7045486 commit 777afca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions coconut/tests/src/cocotest/agnostic/suite.coco
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ forward 2""") == 900
assert first_false_and_last_true([3, 2, 1, 0, "11", "1", ""]) == (0, "1")
assert ret_args_kwargs ↤** dict(a=1) == ((), dict(a=1))
assert ret_args_kwargs ↤**? None is None
assert [1, 2, 3] |> reduce_with_init$(+) == 6 == (1, 2, 3) |> iter |> reduce_with_init$((+), init=0)

with process_map.multiple_sequential_calls(): # type: ignore
assert process_map(tuple <.. (|>)$(to_sort), qsorts) |> list == [to_sort |> sorted |> tuple] * len(qsorts)
Expand Down
4 changes: 3 additions & 1 deletion coconut/tests/src/cocotest/agnostic/util.coco
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ sum_evens = (
)


# n-ary reduction
# reduction
def binary_reduce(binop, it) = (
it
|> reiterable
Expand All @@ -1703,6 +1703,8 @@ def nary_reduce(n, op, it) = (

binary_reduce_ = nary_reduce$(2)

match def reduce_with_init(f, xs, init=type(xs[0])()) = reduce(f, xs, init)


# last/end
import operator
Expand Down

0 comments on commit 777afca

Please sign in to comment.