diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index b0d6fcf1..d01289a5 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -1555,7 +1555,7 @@ (fn () (let - ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr))))) + ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show") (= (tp-val) "on"))) (list (quote me))) (true (parse-expr))))) (let ((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (do (adv!) (cond ((at-end?) s) ((= (tp-type) "colon") (do (adv!) (let ((v (tp-val))) (do (adv!) (str s ":" v))))) ((= (tp-type) "local") (let ((v (tp-val))) (do (adv!) (str s ":" v)))) (true s))))) "display"))) (let @@ -1566,7 +1566,7 @@ (fn () (let - ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr))))) + ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show") (= (tp-val) "on"))) (list (quote me))) (true (parse-expr))))) (let ((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (do (adv!) (cond ((at-end?) s) ((= (tp-type) "colon") (do (adv!) (let ((v (tp-val))) (do (adv!) (str s ":" v))))) ((= (tp-type) "local") (let ((v (tp-val))) (do (adv!) (str s ":" v)))) (true s))))) "display"))) (let diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index e17bc9de..78dea311 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -2120,6 +2120,7 @@ ((fn-val (host-get obj method))) (cond ((and fn-val (callable? fn-val)) (apply fn-val args)) + (fn-val (apply host-call (cons obj (cons method args)))) (true nil))))))) (define hs-beep (fn (v) v)) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index b0d6fcf1..d01289a5 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -1555,7 +1555,7 @@ (fn () (let - ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr))))) + ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show") (= (tp-val) "on"))) (list (quote me))) (true (parse-expr))))) (let ((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (do (adv!) (cond ((at-end?) s) ((= (tp-type) "colon") (do (adv!) (let ((v (tp-val))) (do (adv!) (str s ":" v))))) ((= (tp-type) "local") (let ((v (tp-val))) (do (adv!) (str s ":" v)))) (true s))))) "display"))) (let @@ -1566,7 +1566,7 @@ (fn () (let - ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr))))) + ((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show") (= (tp-val) "on"))) (list (quote me))) (true (parse-expr))))) (let ((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (do (adv!) (cond ((at-end?) s) ((= (tp-type) "colon") (do (adv!) (let ((v (tp-val))) (do (adv!) (str s ":" v))))) ((= (tp-type) "local") (let ((v (tp-val))) (do (adv!) (str s ":" v)))) (true s))))) "display"))) (let diff --git a/shared/static/wasm/sx/hs-runtime.sx b/shared/static/wasm/sx/hs-runtime.sx index e17bc9de..78dea311 100644 --- a/shared/static/wasm/sx/hs-runtime.sx +++ b/shared/static/wasm/sx/hs-runtime.sx @@ -2120,6 +2120,7 @@ ((fn-val (host-get obj method))) (cond ((and fn-val (callable? fn-val)) (apply fn-val args)) + (fn-val (apply host-call (cons obj (cons method args)))) (true nil))))))) (define hs-beep (fn (v) v)) diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index d652ed6e..f0206746 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -20,7 +20,11 @@ (define hs-cleanup! (fn () - (dom-set-inner-html (dom-body) ""))) + (begin + (dom-set-inner-html (dom-body) "") + ;; Reset global runtime state that prior tests may have set. + (hs-set-default-hide-strategy! nil) + (hs-set-log-all! false)))) ;; Evaluate a hyperscript expression and return either the expression ;; value or `it` (whichever is non-nil). Multi-statement scripts that @@ -4929,7 +4933,11 @@ ;; ── expressions/cookies (5 tests) ── (defsuite "hs-upstream-expressions/cookies" (deftest "basic clear cookie values work" - (error "SKIP (untranslated): basic clear cookie values work")) + (hs-cleanup!) + (eval-hs "set cookies.foo to 'bar'") + (assert= (eval-hs "cookies.foo") "bar") + (eval-hs "call cookies.clear('foo')") + (assert (nil? (eval-hs "cookies.foo")))) (deftest "basic set cookie values work" (hs-cleanup!) (assert (nil? (eval-hs "cookies.foo"))) diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index 3b715c0e..e3a032b1 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -1869,6 +1869,15 @@ def generate_eval_only_test(test, idx): f' (hs-cleanup!)\n' f' (assert= (eval-hs "cookies.length") 0))' ) + if test['name'] == 'basic clear cookie values work': + return ( + f' (deftest "{safe_name}"\n' + f' (hs-cleanup!)\n' + f' (eval-hs "set cookies.foo to \'bar\'")\n' + f' (assert= (eval-hs "cookies.foo") "bar")\n' + f' (eval-hs "call cookies.clear(\'foo\')")\n' + f' (assert (nil? (eval-hs "cookies.foo"))))' + ) # Special case: cluster-29 init events. The two tractable tests both attach # listeners to a wa container, set its innerHTML to a hyperscript fragment, @@ -2763,7 +2772,11 @@ output.append(' el)))') output.append('') output.append('(define hs-cleanup!') output.append(' (fn ()') -output.append(' (dom-set-inner-html (dom-body) "")))') +output.append(' (begin') +output.append(' (dom-set-inner-html (dom-body) "")') +output.append(' ;; Reset global runtime state that prior tests may have set.') +output.append(' (hs-set-default-hide-strategy! nil)') +output.append(' (hs-set-log-all! false))))') output.append('') output.append(';; Evaluate a hyperscript expression and return either the expression') output.append(';; value or `it` (whichever is non-nil). Multi-statement scripts that')