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:
@@ -326,6 +326,27 @@ MANUAL_TEST_BODIES = {
|
||||
' (list (list (quote record) record)))',
|
||||
' "<div age=\\"21\\" style=\\"color:bleaux\\">John Connor</div>"))',
|
||||
],
|
||||
# asExpression: custom conversions — set/clear via hs-set-conversion! + hs-add-dynamic-converter!
|
||||
"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"))))',
|
||||
],
|
||||
"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"))))',
|
||||
],
|
||||
# asExpression: Date/Set/Map need real JS host objects
|
||||
"converts value as Date": [
|
||||
' (let ((_result (eval-hs "1 as Date")))',
|
||||
|
||||
Reference in New Issue
Block a user