test new syntax

pull/6/head
Matthew Butterick 7 years ago
parent a5ba1f7fdf
commit 867b84f16e

@ -0,0 +1,16 @@
#lang brag
;; Simple baby example of JSON structure
json ::= number | string
| array
| object
number ::= NUMBER
string ::= STRING
array ::= "[" [json ("," json)*] "]"
object ::= "{" [kvpair ("," kvpair)*] "}"
kvpair ::= ID ":" json

@ -1,33 +1,30 @@
#lang racket/base #lang racket/base
(require brag/examples/baby-json (require brag/examples/baby-json
(prefix-in alt: brag/examples/baby-json-alt)
brag/support brag/support
rackunit) rackunit)
(check-equal? (let ([str (list "{"
(syntax->datum (token 'ID "message")
(parse (list "{" ":"
(token 'ID "message") (token 'STRING "'hello world'")
":" "}")]
(token 'STRING "'hello world'") [result '(json (object "{"
"}"))) (kvpair "message" ":" (json (string "'hello world'")))
'(json (object "{" "}"))])
(kvpair "message" ":" (json (string "'hello world'"))) (check-equal? (parse-to-datum str) result)
"}"))) (check-equal? (alt:parse-to-datum str) result))
(check-equal? (let ([str "[[[{}]],[],[[{}]]]"]
(syntax->datum [result '(json
(parse "[[[{}]],[],[[{}]]]")) (array
'(json "["
(array (json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
"[" ","
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]")) (json (array "[" "]"))
"," ","
(json (array "[" "]")) (json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
"," "]"))])
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]")) (check-equal? (parse-to-datum str) result)
"]"))) (check-equal? (alt:parse-to-datum str) result))
Loading…
Cancel
Save