HS: as Date/Set/Map return real JS host objects (+4 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s

- hs-coerce "Date": new case returns (host-new "Date" value)
- hs-coerce "Set": creates real JS Set via host-new + for-each add (was SX list)
- hs-coerce "Map": creates real JS Map via host-new + for-each set (was SX list)
- hs-make "Set"/"Map": use host-new instead of (list)/(dict)
- hs-add-to!, hs-remove-from!, hs-empty-like, hs-append: handle real JS Sets
- hs-run-filtered.js: add hs-is-set? and hs-is-map? natives
- generator: MANUAL_TEST_BODIES for converts-as-Date (×2), as-Set, as-Map
asExpression suite: 36/42 (was 32/42)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 10:04:51 +00:00
parent e9ddf31181
commit 6a40e991b3
4 changed files with 64 additions and 25 deletions

View File

@@ -3724,7 +3724,9 @@
(deftest "can accept custom dynamic conversions"
(error "SKIP (untranslated): can accept custom dynamic conversions"))
(deftest "can use the a modifier if you like"
(error "SKIP (untranslated): can use the a modifier if you like"))
(let ((_result (eval-hs "1 as a Date")))
(assert= (host-call _result "getTime") 1))
)
(deftest "can use the an modifier if you'd like"
(assert= (host-get (eval-hs "'{\"foo\":\"bar\"}' as an Object") "foo") "bar")
)
@@ -3828,7 +3830,10 @@
(assert= (eval-hs "[1,2,3] as Reversed") (list 3 2 1))
)
(deftest "converts array as Set"
(error "SKIP (untranslated): converts array as Set"))
(let ((_result (eval-hs "[1,2,2,3] as Set")))
(assert (hs-is-set? _result))
(assert= (host-get _result "size") 3))
)
(deftest "converts array as Unique"
(assert= (eval-hs "[1,2,2,3,3] as Unique") (list 1 2 3))
)
@@ -3881,7 +3886,11 @@
(assert= (eval-hs "{a:1, b:2} as Keys") (list "a" "b"))
)
(deftest "converts object as Map"
(error "SKIP (untranslated): converts object as Map"))
(let ((_result (eval-hs "{a:1, b:2} as Map")))
(assert (hs-is-map? _result))
(assert= (host-call _result "get" "a") 1)
(assert= (host-get _result "size") 2))
)
(deftest "converts radio buttons into a Value correctly"
(let ((_node (dom-create-element "form")))
(dom-set-inner-html _node "<div> <input type=\"radio\" name=\"gender\" value=\"Male\" checked> <input type=\"radio\" name=\"gender\" value=\"Female\"> <input type=\"radio\" name=\"gender\" value=\"Other\"> </div>")
@@ -3901,7 +3910,9 @@
(assert= (eval-hs "'hello' as Boolean") true)
)
(deftest "converts value as Date"
(error "SKIP (untranslated): converts value as Date"))
(let ((_result (eval-hs "1 as Date")))
(assert= (host-call _result "getTime") 1))
)
(deftest "converts value as Fixed"
(assert= (eval-hs "'10.4' as Fixed") "10")
(assert= (eval-hs "'10.4899' as Fixed:2") "10.49")