ddat interop with dat js
cable interop with cabal js
ddat's frontend = dat-thang
cable fe = cable-thang
dillo support based on cel's dillo-dat
bootstrap node
xplatform support

Signed-off-by: divo <418@cryspace.space>
This commit is contained in:
divorce committed 2026-10-19 00:17:02 -04:00
1 parent f0f91540be
commit b735900f2e
323 files changed
+134347 -343

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
(define sample
(dat:json-parse
"{\"title\":\"dat \\\"thang\\\"\",\"items\":[true,false,null,-2,1.25e2],\"line\":\"a\\nb\"}"))
(unless (equal? (dat:json-object-ref sample "title") "dat \"thang\"")
(error 'test-failed "JSON strings and escaped quotes"))
(unless (equal? (dat:json-object-ref sample "items")
'(json:array #t #f json:null -2 125.0))
(error 'test-failed "JSON arrays, literals, and numbers"))
(unless (equal? (dat:json-object-ref sample "line") "a\nb")
(error 'test-failed "JSON escaped newline"))
(unless (equal? (dat:json-parse "\"\\uD83D\\uDE00\"")
(list->string (map integer->char '(#xf0 #x9f #x98 #x80))))
(error 'test-failed "JSON UTF-16 surrogate pair"))
(unless (json:number-token? "-0.4E+3")
(error 'test-failed "valid JSON number"))
(when (json:number-token? "+1")
(error 'test-failed "reject Scheme-only number spelling"))
(let* ((wire '(json:object ("type" . "chat/text")
("content" . (json:object ("channel" . "general")
("text" . "hello\n🐬")))
("timestamp" . 42)))
(encoded (dat:json-stringify wire))
(decoded (dat:json-parse encoded)))
(unless (equal? (dat:json-object-ref decoded "type") "chat/text")
(error 'test-failed "S-expression JSON adapter object roundtrip"))
(unless (equal? (dat:json-object-ref
(dat:json-object-ref decoded "content") "text") "hello\n🐬")
(error 'test-failed "S-expression JSON adapter escaped Unicode string")))
(let ((caught #f))
(catch #t
(lambda () (dat:json-parse "[1,]"))
(lambda args (set! caught #t)))
(unless caught (error 'test-failed "reject trailing array comma")))
(display "S7 JSON/S-expression adapter: PASS\n")