test new syntax

pull/6/head
Matthew Butterick 6 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,24 +1,23 @@
#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
(parse (list "{"
(token 'ID "message") (token 'ID "message")
":" ":"
(token 'STRING "'hello world'") (token 'STRING "'hello world'")
"}"))) "}")]
'(json (object "{" [result '(json (object "{"
(kvpair "message" ":" (json (string "'hello world'"))) (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 "[[[{}]],[],[[{}]]]"))
'(json
(array (array
"[" "["
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]")) (json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
@ -26,8 +25,6 @@
(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