Skip to content

Commit 655a116

Browse files
committed
fix unit test coverage
1 parent 9ea4798 commit 655a116

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

unpythonic/test/test_fun.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,24 @@ def t():
168168
a = curry(add)
169169
test[curry(a) is a] # curry wrappers should not stack
170170

171-
with testset("top-level curry context handling"):
171+
# Curry passes through extra args on the right, like in Haskell. Each
172+
# call consumes args up to the maximum arity of the function being
173+
# called. If the return value is callable, it is the next function
174+
# to be (implicitly curried and then) called.
175+
@curry
176+
def f(x): # note f takes only one arg
177+
return lambda y: x * y
178+
test[f(2, 21) == 42]
179+
180+
# Curry raises by default when the top-level curry context exits with
181+
# args remaining. This is so that providing too many args will still
182+
# raise `TypeError`.
172183
def double(x):
173184
return 2 * x
174-
# curry raises by default when top-level curry context exits with args remaining:
175185
with test_raises(TypeError, "leftover args should not be allowed by default"):
176186
curry(double, 2, "foo")
177-
# to disable the error, use this trick to explicitly state your intent:
187+
188+
# To disable the error, use this trick to explicitly state you want to do so:
178189
with test("leftover args should be allowed with manually created surrounding context"):
179190
with dyn.let(curry_context=["whatever"]): # any human-readable label is fine.
180191
curry(double, 2, "foo") == (4, "foo")

0 commit comments

Comments
 (0)