summaryrefslogtreecommitdiffstats
path: root/tests/common.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-02 07:43:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-02 07:43:21 -0700
commiteb5b89cc8a58c35eba829254af82d3aa78399649 (patch)
tree232003b5ce34bf33dd62feffc2686964b45ca5c7 /tests/common.tl
parent9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a (diff)
downloadtxr-eb5b89cc8a58c35eba829254af82d3aa78399649.tar.gz
txr-eb5b89cc8a58c35eba829254af82d3aa78399649.tar.bz2
txr-eb5b89cc8a58c35eba829254af82d3aa78399649.zip
Adding struct tests.
* tests/common.tl (vtest): New macro based on test. Evaluates the expected expression. (test): Becomes a wrapper for vtest which quotes the expected expression. (stest): New macro for string-based comparison of output. * tests/012/struct.expected: New file. * tests/012/struct.tl: New file.
Diffstat (limited to 'tests/common.tl')
-rw-r--r--tests/common.tl16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/common.tl b/tests/common.tl
index f4ad7351..301a5402 100644
--- a/tests/common.tl
+++ b/tests/common.tl
@@ -2,12 +2,20 @@
^(catch ,expr
(error (cond) :error)))
-(defmacro test (:env env expr expected)
+(defmacro vtest (:env env expr expected)
(catch
- (let ((expr-expn (macroexpand expr env)))
- ^(ifa (not (equal (error-to-sym ,expr-expn) ',expected))
+ (let ((expr-expn (macroexpand expr env))
+ (expval (gensym)))
+ ^(let ((,expval ,expected))
+ (ifa (not (equal (error-to-sym ,expr-expn) ,expval))
(error "test case ~s failed: produced ~s; expected ~s"
- ',expr it ',expected)))
+ ',expr it ,expval))))
(error (exc)
(unless (eq expected :error)
(error "test case ~s failed to expand: expected is ~s" expr expected)))))
+
+(defmacro test (expr expected)
+ ^(vtest ,expr ',expected))
+
+(defmacro stest (expr expected)
+ ^(vtest ,^(tostring ,expr) ,expected))