HS: custom conversion API + asExpression tests (+2)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 39s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 39s
Add _hs-custom-conversions dict and _hs-dynamic-converters list to runtime.sx. hs-set-conversion!/hs-clear-conversion!/hs-add-dynamic-converter!/ hs-pop-dynamic-converter!/hs-clear-converters! helpers expose the API. hs-coerce fallback now checks static dict then dynamic resolvers before returning value unchanged. Hand-roll MANUAL_TEST_BODIES for "can accept custom conversions" and "can accept custom dynamic conversions" — previously SKIP (untranslated). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3724,9 +3724,25 @@
|
||||
;; ── expressions/asExpression (42 tests) ──
|
||||
(defsuite "hs-upstream-expressions/asExpression"
|
||||
(deftest "can accept custom conversions"
|
||||
(error "SKIP (untranslated): can accept custom conversions"))
|
||||
(do
|
||||
(hs-set-conversion! "Foo" (fn (val) (str "foo" (str val))))
|
||||
(let ((result (hs-coerce 1 "Foo")))
|
||||
(do
|
||||
(hs-clear-conversion! "Foo")
|
||||
(assert= result "foo1"))))
|
||||
)
|
||||
(deftest "can accept custom dynamic conversions"
|
||||
(error "SKIP (untranslated): can accept custom dynamic conversions"))
|
||||
(do
|
||||
(hs-add-dynamic-converter!
|
||||
(fn (conversion val)
|
||||
(if (= (host-call conversion "indexOf" "Foo:") 0)
|
||||
(str (host-call conversion "slice" 4) (str val))
|
||||
nil)))
|
||||
(let ((result (hs-coerce 1 "Foo:Bar")))
|
||||
(do
|
||||
(hs-pop-dynamic-converter!)
|
||||
(assert= result "Bar1"))))
|
||||
)
|
||||
(deftest "can use the a modifier if you like"
|
||||
(let ((_result (eval-hs "1 as a Date")))
|
||||
(assert= (host-call _result "getTime") 1))
|
||||
|
||||
Reference in New Issue
Block a user