diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index 19732286..1cfe27d5 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -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!) diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index a4bef01b..168e4da6 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -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: }` + 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: ` (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)