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,33 +1,30 @@
#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 "{"
(token 'ID "message")
":"
(token 'STRING "'hello world'")
"}")))
'(json (object "{"
(kvpair "message" ":" (json (string "'hello world'")))
"}")))
(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))
(check-equal?
(syntax->datum
(parse "[[[{}]],[],[[{}]]]"))
'(json
(array
"["
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
","
(json (array "[" "]"))
","
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
"]")))
(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))
Loading…
Cancel
Save