You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
Racket
30 lines
1.0 KiB
Racket
#lang racket/base
|
|
(require yaragg/examples/baby-json
|
|
(prefix-in alt: yaragg/examples/baby-json-alt)
|
|
yaragg/support
|
|
rackunit)
|
|
|
|
(let ([str (list "{"
|
|
(token 'ID "message")
|
|
":"
|
|
(token 'STRING "'hello world'")
|
|
"}")]
|
|
[result '(json (object "{"
|
|
(kvpair "message" ":" (json (string "'hello world'")))
|
|
"}"))])
|
|
(check-equal? (parse-to-datum str) result)
|
|
(check-equal? (alt:parse-to-datum str) result))
|
|
|
|
|
|
(let ([str "[[[{}]],[],[[{}]]]"]
|
|
[result '(json
|
|
(array
|
|
"["
|
|
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
|
|
","
|
|
(json (array "[" "]"))
|
|
","
|
|
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
|
|
"]"))])
|
|
(check-equal? (parse-to-datum str) result)
|
|
(check-equal? (alt:parse-to-datum str) result)) |