summaryrefslogtreecommitdiffstats
path: root/tests/common.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-25 20:21:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-25 20:21:35 -0700
commita0b712ca37537ca6067d8cd40bd1c232cb437cee (patch)
tree3516f01b0c843220691051f0e4f67c54a781669d /tests/common.tl
parent37af727ac31be5890c0ee4e8a0fa3fcd1f559586 (diff)
downloadtxr-a0b712ca37537ca6067d8cd40bd1c232cb437cee.tar.gz
txr-a0b712ca37537ca6067d8cd40bd1c232cb437cee.tar.bz2
txr-a0b712ca37537ca6067d8cd40bd1c232cb437cee.zip
tests: fix vtest being hindrance to error finding.
* tests/common.tl (vtest): Only if the expected expression is :error or (quote :error) do we wrap the expansion and evaluation of the test expression with exception handling, because only then do we expect an error. When the test expression is anything else, we don't intercept any errors, and so problems in test cases are easier to debug now. * tests/012/struct.tl: In one case we must initialize the *gensym-counter* to 4 to compensate for the change in vtest to get the same gensym numbers in the output.
Diffstat (limited to 'tests/common.tl')
-rw-r--r--tests/common.tl21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/common.tl b/tests/common.tl
index 157cd7e1..9f7e6eb3 100644
--- a/tests/common.tl
+++ b/tests/common.tl
@@ -3,16 +3,19 @@
(error (cond) :error)))
(defmacro vtest (:env env expr expected)
- (catch
- (let ((expr-expn (expand expr env))
- (expval (gensym)))
- ^(let ((,expval ,expected))
- (ifa (not (equal (error-to-sym ,expr-expn) ,expval))
+ (if (mequal expected :error '':error)
+ (catch
+ (let ((expr-expn (expand expr env)))
+ ^(ifa (not (equal (error-to-sym ,expr-expn) :error))
(error "test case ~s failed: produced ~s; expected ~s"
- ',expr it ,expval))))
- (error (exc)
- (unless (eq (eval expected) :error)
- (error "test case ~s failed to expand: expected is ~s" expr expected)))))
+ ',expr it :error)))
+ (error (exc)))
+ (let ((expr-expn (expand expr env))
+ (expval (gensym)))
+ ^(let ((,expval ,expected))
+ (ifa (not (equal ,expr-expn ,expval))
+ (error "test case ~s failed: produced ~s; expected ~s"
+ ',expr it ,expval))))))
(defmacro test (expr expected)
^(vtest ,expr ',expected))