Skip to content

Commit 32dd44c

Browse files
Technologicatclaude
andcommitted
testing_testingtools: split the[] cases inside expect[] runtime test
Earlier commit's "implicit-LHS" case had an explicit `the[]` in it, which actually disables implicit-LHS injection — comment contradicted the test. Split into two cases that each exercise the path the comment claims: one without any `the[]` for implicit-LHS, one with explicit `the[]` for the override path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f437223 commit 32dd44c

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

unpythonic/syntax/tests/testing_testingtools.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ def counter():
113113

114114
# `expect[]` inside a `with test:` block — the runtime dispatch path.
115115
# We test that the value of the expression inside `expect[expr]` is what
116-
# gets asserted, and that the implicit LHS `the[]` capture on a `Compare`
117-
# still works (same rule as for the deprecated `return expr` form).
116+
# gets asserted, and that both `the[]` capture rules (implicit LHS on a
117+
# `Compare`, explicit) still apply, the same as they did for the
118+
# deprecated `return expr` form.
118119
tests_failed << 0
119120
tests_errored << 0
120121
tests_run << 0
@@ -130,11 +131,16 @@ def counter():
130131
log = []
131132
log.append("ran")
132133
with test:
133-
# Implicit-LHS `the[]` injection works inside `expect[expr]` when
134-
# `expr` is a Compare.
134+
# Implicit-LHS capture: no explicit `the[]` anywhere in the block,
135+
# and `expect[]` wraps a `Compare`, so the LHS is captured for
136+
# failure reporting. (Effect is only visible on failure.)
135137
c = 0
136-
expect[the[c] == 0] # passes; would report c on failure
137-
assert tests_run == 4
138+
expect[c == 0]
139+
with test:
140+
# Explicit `the[]` inside `expect[]` overrides implicit-LHS.
141+
items = ["a", "b"]
142+
expect["a" in the[items]]
143+
assert tests_run == 5
138144
assert tests_failed == 1
139145
assert tests_errored == 0
140146

0 commit comments

Comments
 (0)