HS parser/compiler/mock: fix 31 test failures across 7 issues

Parser:
- Relax (number? v) to v in parse-one-transition so (expr)unit works
- Add (match-kw "then") before parse-cmd-list in parse-for-cmd
- Handle "indexed by" syntax alongside "index" in for loops
- Add "indexed" to hs-keywords to prevent unit-suffix consumption

Compiler:
- Use map-indexed instead of for-each for indexed for-loops

Test generator:
- Preserve \" escapes in process_hs_val via placeholder/restore

Mock DOM:
- Coerce insertAdjacentHTML values via dom_stringify (match browser)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 20:46:01 +00:00
parent 3ba819d9ae
commit be84246961
6 changed files with 379 additions and 76 deletions

View File

@@ -1985,9 +1985,10 @@ let run_spec_tests env test_files =
Hashtbl.replace r "right" (Number 100.0); Hashtbl.replace r "bottom" (Number 100.0);
Dict r
| "insertAdjacentHTML" ->
(* Simplified: just append text to innerHTML *)
(* Simplified: coerce value to string and append to innerHTML *)
(match rest with
| [String _pos; String html] ->
| [String _pos; value] ->
let html = match dom_stringify value with String s -> s | _ -> "" in
let cur = match Hashtbl.find_opt d "innerHTML" with Some (String s) -> s | _ -> "" in
Hashtbl.replace d "innerHTML" (String (cur ^ html)); Nil
| _ -> Nil)