Mock DOM: console object, console-log no-op, transition possessive

Mock DOM:
- Add mock console object to host-global
- Override console-log/debug/error as no-op primitives to avoid
  str hitting circular refs in mock DOM (element→parent→children→...)

Parser:
- Handle possessive 's token before property name in transitions

Fixes 4 log timeouts, 2 transition possessive parse errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 21:50:24 +00:00
parent 7516d1e1f9
commit dcbeb5cec5

View File

@@ -1559,6 +1559,10 @@ let run_spec_tests env test_files =
match args with
| [String "document"] -> mock_document
| [String "window"] -> Nil (* self-referential, not needed for tests *)
| [String "console"] ->
let d = Hashtbl.create 4 in
Hashtbl.replace d "__mock_type" (String "console");
Dict d
| [String name] ->
(* Check SX env for globally defined things like "tmp" used in HS tests *)
(try Sx_types.env_get env name with _ -> Nil)
@@ -1798,6 +1802,10 @@ let run_spec_tests env test_files =
| _ -> String "")
| _ -> Nil)
else if mt = "console" then
(* console.log/debug/error — no-op in tests *)
Nil
else
(* Element methods *)
(match m with
@@ -2206,6 +2214,10 @@ let run_spec_tests env test_files =
load_module "runtime.sx" hs_dir;
load_module "integration.sx" hs_dir;
load_module "htmx.sx" hs_dir;
(* Override console-log to avoid str on circular mock DOM refs *)
ignore (Sx_types.env_bind env "console-log" (NativeFn ("console-log", fun _ -> Nil)));
ignore (Sx_types.env_bind env "console-debug" (NativeFn ("console-debug", fun _ -> Nil)));
ignore (Sx_types.env_bind env "console-error" (NativeFn ("console-error", fun _ -> Nil)));
(* eval-hs: compile hyperscript source to SX and evaluate it.
Used by eval-only behavioral tests (comparisonOperator, mathOperator, etc.) *)
ignore (Sx_types.env_bind env "eval-hs" (NativeFn ("eval-hs", fun args ->