HS: hs-strip-order-deep + dict equality in assert-equal (+1 test)

hs-make-object appends _order for consistent key iteration (needed by
repeat-in loops). But assert-equal (equal?) sees _order as a real key,
breaking arrayLiteral "arrays containing objects work".

Add hs-strip-order-deep to runtime.sx that recursively strips _order
from dicts. Update emit_eval in the generator to wrap deep-dict evals
with hs-strip-order-deep so assert-equal comparisons ignore _order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 05:00:40 +00:00
parent 7190a8b1d2
commit 6d534e8c42
3 changed files with 25 additions and 5 deletions

View File

@@ -2386,6 +2386,26 @@
pairs)
d))))
(define
hs-strip-order-deep
(fn
(val)
(cond
((dict? val)
(let
((d (dict)))
(do
(for-each
(fn
(k)
(when
(not (= k "_order"))
(dict-set! d k (hs-strip-order-deep (get val k)))))
(filter (fn (k) (not (= k "_order"))) (keys val)))
d)))
((list? val) (map hs-strip-order-deep val))
(true val))))
(define
hs-method-call
(fn
@@ -2709,6 +2729,8 @@
(host-set! (host-get el "__hs_vars") name val)
(when changed (hs-dom-fire-watchers! el name val))))))
;; ── SourceInfo API ────────────────────────────────────────────────
(define
hs-dom-resolve-start
(fn
@@ -2728,8 +2750,6 @@
(if match (dom-parent match) nil)))
(true el))))))
;; ── SourceInfo API ────────────────────────────────────────────────
(define
hs-dom-walk
(fn

View File

@@ -3695,7 +3695,7 @@
(assert= (eval-hs "[1 + 1, 2 * 3, 10 - 5]") (list 2 6 5))
)
(deftest "arrays containing objects work"
(assert-equal (list {:a 1} {:b 2}) (eval-hs "[{a: 1}, {b: 2}]"))
(assert-equal (list {:a 1} {:b 2}) (hs-strip-order-deep (eval-hs "[{a: 1}, {b: 2}]")))
)
(deftest "deeply nested array literals work"
(assert= (eval-hs "[[[1]], [[2, 3]]]") (list (list (list 1)) (list (list 2 3))))

View File

@@ -2570,10 +2570,10 @@ def generate_eval_only_test(test, idx):
f'(list (quote {n}) {v})' for n, v in pairs
) + ')'
if use_deep:
return f' (assert-equal {expected_sx} (eval-hs-locals "{hs_expr}" {locals_sx}))'
return f' (assert-equal {expected_sx} (hs-strip-order-deep (eval-hs-locals "{hs_expr}" {locals_sx})))'
return f' (assert= (eval-hs-locals "{hs_expr}" {locals_sx}) {expected_sx})'
if use_deep:
return f' (assert-equal {expected_sx} (eval-hs "{hs_expr}"))'
return f' (assert-equal {expected_sx} (hs-strip-order-deep (eval-hs "{hs_expr}")))'
return f' (assert= (eval-hs "{hs_expr}") {expected_sx})'
# Shared sub-pattern for run() call with optional String.raw and extra args: