diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-05-31 23:21:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-05-31 23:21:20 -0700 |
commit | f311b6ca089954675e745ad9212209ca8cf23be2 (patch) | |
tree | db61d4698f4485b87f0e5cc19b2da300acf8e14a /tests/common.tl | |
parent | 5d02e6e736d419c0abc271b6049814598cdc3cb9 (diff) | |
download | txr-f311b6ca089954675e745ad9212209ca8cf23be2.tar.gz txr-f311b6ca089954675e745ad9212209ca8cf23be2.tar.bz2 txr-f311b6ca089954675e745ad9212209ca8cf23be2.zip |
json: wrap up: test cases, fixes, tweaks.
* /share/txr/stdlib/getput.tl (get-jsons): If the s parameter
is a string, convert it to a byte input stream so that.
(put-jsons): Add missing t return value.
(file-put-json, file-append-json, file-put-jsons,
file-append-jsons, command-put-jsons, command-put-jsons): Add
missing object argument to all these functions, and a missing
"w" open-file mode to several of them.
* stream.c (mkstemp_wrap): Calculate length of suff the
defaulted argument, not the raw suffix argument.
* test/010/json.tl: New file, providing tests that touch every
area of the new JSON functionality.
* tests/common.tl (mstest, with-temp-file): New macros.
* txr.1: Document that get-jsons takes a source which could be
a string.
Diffstat (limited to 'tests/common.tl')
-rw-r--r-- | tests/common.tl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/common.tl b/tests/common.tl index 9f7e6eb3..f89d6ed8 100644 --- a/tests/common.tl +++ b/tests/common.tl @@ -26,6 +26,9 @@ (defmacro mtest (. pairs) ^(progn ,*(mapcar (op cons 'test) (tuples 2 pairs)))) +(defmacro mstest (. pairs) + ^(progn ,*(mapcar (op cons 'stest) (tuples 2 pairs)))) + (defun os-symbol () (if (ignerr (dlsym (dlopen "libandroid.so") "AAsset_close")) :android @@ -50,3 +53,11 @@ (let ,bindings (expand '(progn ,*body) ,env)))) (,invoke)))) + +(defmacro with-temp-file ((name-var stream-var prefix) . body) + ^(let* ((,stream-var (mkstemp ,prefix)) + (,name-var (stream-get-prop ,stream-var :name))) + (unwind-protect + (progn ,*body) + (close-stream ,stream-var) + (remove-path ,name-var)))) |