HS: possessive expression via its (+1 test)
Two generator changes: (a) `parse_run_locals` for Pattern 2
(`var R = await run(...)`) now recognises `result: <literal>` in the
opts dict and binds it to `it` so `run("its foo", {result: {foo: "foo"}})`
produces `(eval-hs-locals "its foo" (list (list (quote it) {:foo "foo"})))`.
Also adds the same extraction to Pattern 1 (`expect(run(...)).toBe(...)`).
(b) `_hs-wrap-body` emitted by the generator no longer shadows `it` to
nil — it only binds `event` — so eval-hs-locals's outer `it` binding is
visible inside the wrapped body. `eval-hs` still binds `it` nil at its
own `fn` wrapper so nothing regresses.
Suite hs-upstream-expressions/possessiveExpression: 22/23 → 23/23.
Smoke 0-195: 162/195 unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,8 +27,10 @@
|
||||
;; bare expressions (e.g. `foo.foo`) get the expression value back.
|
||||
(define _hs-wrap-body
|
||||
(fn (sx)
|
||||
;; Wrap body to capture return via `it`. `event` default is always nil.
|
||||
;; `it` is NOT shadowed here — callers (eval-hs-locals) may pre-bind it.
|
||||
(list (quote let)
|
||||
(list (list (quote it) nil) (list (quote event) nil))
|
||||
(list (list (quote event) nil))
|
||||
(list (quote let)
|
||||
(list (list (quote _ret) sx))
|
||||
(list (quote if) (list (quote nil?) (quote _ret)) (quote it) (quote _ret))))))
|
||||
@@ -5679,7 +5681,7 @@
|
||||
(dom-append (dom-body) _el-pDiv)
|
||||
))
|
||||
(deftest "can access its properties"
|
||||
(assert= (eval-hs "its foo") "foo")
|
||||
(assert= (eval-hs-locals "its foo" (list (list (quote it) {:foo "foo"}))) "foo")
|
||||
)
|
||||
(deftest "can access multiple basic attributes"
|
||||
(hs-cleanup!)
|
||||
|
||||
Reference in New Issue
Block a user