From b2ae80fb21ef1c72dcdc1c01522bcbe625258376 Mon Sep 17 00:00:00 2001 From: giles Date: Wed, 22 Apr 2026 22:13:19 +0000 Subject: [PATCH] HS test generator: accept ES6 shorthand `{foo}` in run() locals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several upstream regex-pick tests use JS ES6 shorthand to pass a local declared earlier in the test body, e.g. const haystack = "..." await run(\`pick match of "\\\\d+" from haystack ...\`, {locals: {haystack}}); The generator's `(\\w+)\\s*:\\s*...` locals regex only matched explicit `key: value` entries, so `{haystack}` produced zero local_pairs and the HS script failed with "Undefined symbol: haystack". Now a second pass scans for bare identifiers in the locals object and resolves each against a preceding `const NAME = VALUE;` in the test body. Net test-count is unchanged (the affected regex tests still fail — now with TIMEOUT in the regex engine rather than Undefined-symbol, so this just moves them closer to real coverage). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/playwright/generate-sx-tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index 0fcae83e..16d18dda 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -1125,6 +1125,21 @@ def generate_eval_only_test(test, idx): lname = lm.group(1) lval = js_val_to_sx(lm.group(2).strip().rstrip(',')) local_pairs.append((lname, lval)) + # Also accept ES6 shorthand `{foo}` (= `{foo: foo}`): for every + # bare identifier in locals_str not already captured, look up + # `const = ;` earlier in the test body. + taken = {n for n, _ in local_pairs} + for sh in re.finditer(r'(?