2 (rl3 web rpc json test)
4 (require "json-writer.scm"
5 (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8))
6 (planet "test.ss" ("schematics" "schemeunit.plt" 2 8)))
8 (define json-object-write
11 (test-equal? "Empty Object" (json-write '()) "{}")
12 (test-equal? "Simple types" (json-write `(("a" . 1) ("b" . "c") ("d" . #t) ("e" . #f) ("g" . ,(void))))
13 "{\"a\":1,\"b\":\"c\",\"d\":true,\"e\":false,\"g\":null}")
14 (test-equal? "Nested Json" (json-write `(,(cons "a" (list "a" "b" 3)) ,(cons "b" (list (cons "d" "ray")))))
15 "{\"a\":[\"a\",\"b\",3],\"b\":{\"d\":\"ray\"}}")))
17 (define json-array-write
20 (test-equal? "Empty Array" (json-write json-empty-array) "[]")
21 (test-equal? "Simple array types" (json-write `("a" 1 #t #f ,(void)))
22 "[\"a\",1,true,false,null]")
23 (test-equal? "Nested array" (json-write `("a" ,(list 1 2 3)))
27 (test-suite "JSON Writer Tests"