HS test generator: pattern 2 captures me: from run() opts — +1 possessiveExpression
Pattern 2's `parse_run_locals` only looked for `, {locals: {...}}`. Tests
that pass `me:` directly (e.g. `run("my foo", { me: { foo: "foo" } })`)
got an empty locals list, so `my foo` lost its receiver and returned
nothing. Now `me:` (object/array/string/number literal) is also bound
as a local on top of any `locals: {}`.
possessiveExpression 18/23 → 19/23 ("can access my properties").
"can access its properties" still fails because the upstream test passes
`result:` rather than `it:` — appears to be an upstream typo we'd need
the runtime to special-case to fix.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5707,7 +5707,7 @@
|
||||
(dom-append (dom-body) _el-pDiv)
|
||||
))
|
||||
(deftest "can access my properties"
|
||||
(assert= (eval-hs "my foo") "foo")
|
||||
(assert= (eval-hs-locals "my foo" (list (list (quote me) {:foo "foo"}))) "foo")
|
||||
)
|
||||
(deftest "can access my style"
|
||||
(hs-cleanup!)
|
||||
|
||||
@@ -1366,13 +1366,20 @@ def generate_eval_only_test(test, idx):
|
||||
))
|
||||
|
||||
def parse_run_locals(rm):
|
||||
"""If the run() match has `, {locals: {...}}` in its args,
|
||||
return (name, sx_value) pairs; else []."""
|
||||
"""If the run() match has `, {locals: {...}}` or `{ me: <X> }`
|
||||
in its args, return (name, sx_value) pairs; else []."""
|
||||
# Args between the closing HS-source quote and run's `)`.
|
||||
args_str = body[rm.end(2) + 1:rm.end() - 1]
|
||||
pairs = []
|
||||
# `me: <literal>` (object/array/string/number) bound as local.
|
||||
me_m = re.search(
|
||||
r'\bme:\s*(\{[^}]*\}|\[[^\]]*\]|"[^"]*"|\'[^\']*\'|\d+(?:\.\d+)?)',
|
||||
args_str)
|
||||
if me_m:
|
||||
pairs.append(('me', js_val_to_sx(me_m.group(1))))
|
||||
lm = re.search(r'locals:\s*\{', args_str)
|
||||
if not lm:
|
||||
return []
|
||||
return pairs
|
||||
# Balanced-brace from after `locals: {`.
|
||||
start = rm.end(2) + 1 + lm.end()
|
||||
d, in_str, end = 1, None, -1
|
||||
@@ -1393,8 +1400,7 @@ def generate_eval_only_test(test, idx):
|
||||
end = i
|
||||
break
|
||||
if end < 0:
|
||||
return []
|
||||
pairs = []
|
||||
return pairs
|
||||
for kv in split_top_level(body[start:end]):
|
||||
kv = kv.strip()
|
||||
km = re.match(r'^(\w+)\s*:\s*(.+)$', kv, re.DOTALL)
|
||||
|
||||
Reference in New Issue
Block a user