HS: cookie API (+3 tests, partial)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Three-part change: (a) tests/hs-run-filtered.js gets a per-test __hsCookieStore Map, a globalThis.cookies Proxy, and a document.cookie getter/setter that reads/writes the store. Per-test reset clears the store. (b) generate-sx-tests.py declares cookies in the test header and emits hand-rolled deftests for basic set / update / length-when-empty (the three tractable tests). (c) regenerated spec/tests/test-hyperscript-behavioral.sx via mcp_hs_test.regen. No .sx edits — `set cookies.foo to 'bar'` already compiles to (dom-set-prop cookies "foo" "bar") which routes through host-set!. Suite hs-upstream-expressions/cookies: 0/5 → 3/5. Smoke 0-195 unchanged at 170/195. Remaining `basic clear` (needs hs-method-call host-call dispatch) and `iterate` (needs hs-for-each host-array recognition) need runtime.sx edits — deferred to a future sx-tree worktree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
;; references them (e.g. `window.tmp`) can resolve through the host.
|
||||
(define window (host-global "window"))
|
||||
(define document (host-global "document"))
|
||||
(define cookies (host-global "cookies"))
|
||||
|
||||
(define hs-test-el
|
||||
(fn (tag hs-src)
|
||||
@@ -4885,13 +4886,21 @@
|
||||
(deftest "basic clear cookie values work"
|
||||
(error "SKIP (untranslated): basic clear cookie values work"))
|
||||
(deftest "basic set cookie values work"
|
||||
(error "SKIP (untranslated): basic set cookie values work"))
|
||||
(hs-cleanup!)
|
||||
(assert (nil? (eval-hs "cookies.foo")))
|
||||
(eval-hs "set cookies.foo to 'bar'")
|
||||
(assert= (eval-hs "cookies.foo") "bar"))
|
||||
(deftest "iterate cookies values work"
|
||||
(error "SKIP (untranslated): iterate cookies values work"))
|
||||
(deftest "length is 0 when no cookies are set"
|
||||
(error "SKIP (untranslated): length is 0 when no cookies are set"))
|
||||
(hs-cleanup!)
|
||||
(assert= (eval-hs "cookies.length") 0))
|
||||
(deftest "update cookie values work"
|
||||
(error "SKIP (untranslated): update cookie values work"))
|
||||
(hs-cleanup!)
|
||||
(eval-hs "set cookies.foo to 'bar'")
|
||||
(assert= (eval-hs "cookies.foo") "bar")
|
||||
(eval-hs "set cookies.foo to 'doh'")
|
||||
(assert= (eval-hs "cookies.foo") "doh"))
|
||||
)
|
||||
|
||||
;; ── expressions/dom-scope (20 tests) ──
|
||||
|
||||
Reference in New Issue
Block a user