diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-18 10:51:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-18 10:51:15 -0800 |
commit | 6d2bc0b88c6f0060bce5c79ee5879cf4ce77a35f (patch) | |
tree | e99dd6f7fec514671f6815db79971eec0641b059 /tests/009/json.txr | |
parent | f55237951cd029bdfe40346c52060a8ed59bb49e (diff) | |
download | txr-6d2bc0b88c6f0060bce5c79ee5879cf4ce77a35f.tar.gz txr-6d2bc0b88c6f0060bce5c79ee5879cf4ce77a35f.tar.bz2 txr-6d2bc0b88c6f0060bce5c79ee5879cf4ce77a35f.zip |
Added a JSON parsing test case. This flushed out a bug which crashed
the garbage collector (uninitialized fields in function objects).
* Makefile: Defined TXR_ARGS and TXR_OPTS for new test case.
* hash.c (hash_begin): Construction of cobj modified to obey
the correct procedure described in HACKING.
* lib.c (func_n3, func_n4): These functions neglected to initialize
the env member of the function structure.
* tests/009/json.expected: New file.
* tests/009/json.txr: New file.
* tests/009/webapp.json: New file.
Diffstat (limited to 'tests/009/json.txr')
-rw-r--r-- | tests/009/json.txr | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/009/json.txr b/tests/009/json.txr new file mode 100644 index 00000000..bf5530d4 --- /dev/null +++ b/tests/009/json.txr @@ -0,0 +1,57 @@ +@(define value (v))@\ + @(cases)@\ + @(string v)@(or)@(num v)@(or)@(object v)@(or)@\ + @(keyword v)@(or)@(array v)@\ + @(end)@\ +@(end) +@(define ws)@/[\n\t ]*/@(end) +@(define string (g))@\ + @(local s hex)@\ + @(ws)@\ + "@(coll :gap 0 :vars (s))@\ + @(cases)@\ + \"@(bind s """)@(or)@\ + \\@(bind s "\\\\")@(or)@\ + \/@(bind s "\\/")@(or)@\ + \b@(bind s "")@(or)@\ + \f@(bind s "")@(or)@\ + \n@(bind s " ")@(or)@\ + \r@(bind s " ")@(or)@\ + \t@(bind s "	")@(or)@\ + \u@{hex /[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]/}@\ + @(bind s `&#x@hex;`)@(or)@\ + @{s /[^"\\]*/}@(filter :to_html s)@\ + @(end)@\ + @(until)"@\ + @(end)"@\ + @(ws)@\ + @(cat s "")@\ + @(filter :from_html s)@\ + @(bind g ("S" s))@\ +@(end) +@(define num (v))@\ + @(local n)@\ + @(ws)@{n /-?[0-9]+((\.[0-9]+)?([Ee][+\-]?[0-9]+)?)?/}@(ws)@\ + @(bind v ("N" n))@\ +@(end) +@(define keyword (v))@\ + @(local k)@\ + @(all)@(ws)@{k /true|false|null/}@(trailer)@/[^A-Za-z0-9_]/@(end)@(ws)@\ + @(bind v ("K" k))@\ +@(end) +@(define object (v))@\ + @(local p e pair)@\ + @(ws){@(ws)@(coll :gap 0 :vars (pair))@\ + @(string p):@(value e)@/,?/@\ + @(bind pair (p e))@\ + @(until)}@\ + @(end)}@(ws)@\ + @(bind v ("O" pair))@\ +@(end) +@(define array (v))@\ + @(local e)@\ + @(ws)[@(ws)@(coll :gap 0 :var (e))@(value e)@/,?/@(until)]@(end)]@(ws)@\ + @(bind v ("A" e))@\ +@(end) +@(freeform) +@(maybe)@(value v)@(end)@badsyntax |