From 8b972483aed0f256b322b570669486643b292d75 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 26 Apr 2026 21:01:46 +0000 Subject: [PATCH] =?UTF-8?q?HS:=20fix=20null=E2=86=92nil=20in=20behavioral?= =?UTF-8?q?=20tests=20+=20globalFunction=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SX uses nil (not null) as the null value; null is an undefined symbol that caused _run-test-thunk to throw before the guard could catch it. Also adds globalFunction mock for call-cluster tests. Co-Authored-By: Claude Sonnet 4.6 --- spec/tests/test-hyperscript-behavioral.sx | 4 ++-- tests/hs-run-filtered.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index a5106fbf..2075fbe4 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -1172,7 +1172,7 @@ )) (deftest "can call global javascript functions" (hs-cleanup!) - (host-set! (host-global "window") "calledWith" null) + (host-set! (host-global "window") "calledWith" nil) (let ((_el-div (dom-create-element "div"))) (dom-set-attr _el-div "_" "on click call globalFunction(\"foo\")") (dom-append (dom-body) _el-div) @@ -1246,7 +1246,7 @@ (defsuite "hs-upstream-core/bootstrap" (deftest "can call functions" (hs-cleanup!) - (host-set! (host-global "window") "calledWith" null) + (host-set! (host-global "window") "calledWith" nil) (let ((_el-div (dom-create-element "div"))) (dom-set-attr _el-div "_" "on click call globalFunction(\"foo\")") (dom-append (dom-body) _el-div) diff --git a/tests/hs-run-filtered.js b/tests/hs-run-filtered.js index 39681186..d00f7e39 100755 --- a/tests/hs-run-filtered.js +++ b/tests/hs-run-filtered.js @@ -396,6 +396,9 @@ globalThis.prompt = function(_msg){ globalThis.Event=Ev; globalThis.CustomEvent=Ev; globalThis.NodeList=Array; globalThis.HTMLCollection=Array; globalThis.getComputedStyle=(e)=>e?e.style:{}; globalThis.requestAnimationFrame=(f)=>{f();return 0;}; globalThis.cancelAnimationFrame=()=>{}; +// cluster-36b: globalFunction mock for "can call functions" test. +// The test calls globalFunction("foo") via hyperscript and checks window.calledWith. +globalThis.globalFunction = function(x) { globalThis.calledWith = x; }; // HsMutationObserver — cluster-32 mutation mock. Maintains a global // registry; setAttribute/appendChild/removeChild/_setInnerHTML hooks below // fire matching observers synchronously. A re-entry guard