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,24 +1,23 @@
#lang racket/base
(require brag/examples/baby-json
(prefix-in alt: brag/examples/baby-json-alt)
brag/support
rackunit)
(check-equal?
(syntax->datum
(parse (list "{"
(let ([str (list "{"
(token 'ID "message")
":"
(token 'STRING "'hello world'")
"}")))
'(json (object "{"
"}")]
[result '(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?
(syntax->datum
(parse "[[[{}]],[],[[{}]]]"))
'(json
(let ([str "[[[{}]],[],[[{}]]]"]
[result '(json
(array
"["
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
@ -26,8 +25,6 @@
(json (array "[" "]"))
","
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
"]")))
"]"))])
(check-equal? (parse-to-datum str) result)
(check-equal? (alt:parse-to-datum str) result))
Loading…
Cancel
Save