Skip to content

Commit d852cf5

Browse files
committed
test: add test for capture of deferred
1 parent 2faaab0 commit d852cf5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

koerce/tests/test_patterns.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,19 @@ def test_capture():
520520
assert ctx == {"result": 12}
521521

522522

523+
def test_capture_with_deferred():
524+
ctx = {}
525+
526+
x = Deferred(Variable("x"))
527+
p = Capture(x, InstanceOf(float))
528+
529+
assert p.apply(1, context=ctx) is NoMatch
530+
assert ctx == {}
531+
532+
assert p.apply(1.0, ctx) == 1.0
533+
assert ctx == {"x": 1.0}
534+
535+
523536
def test_none_of():
524537
def negative(x):
525538
return x < 0

0 commit comments

Comments
 (0)