summaryrefslogtreecommitdiffstats
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
commit2a149715dab99d4e4e8e75cb6c114a8fd4f5247a (patch)
tree3516f01b0c843220691051f0e4f67c54a781669d
parentd4825b785b76e817d0926e81c273979bb1e1061c (diff)
downloadtxr-2a149715dab99d4e4e8e75cb6c114a8fd4f5247a.tar.gz
txr-2a149715dab99d4e4e8e75cb6c114a8fd4f5247a.tar.bz2
txr-2a149715dab99d4e4e8e75cb6c114a8fd4f5247a.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.
-rw-r--r--tests/012/struct.tl2
-rw-r--r--tests/common.tl21
-rw-r--r--txr.14
3 files changed, 15 insertions, 12 deletions
diff --git a/tests/012/struct.tl b/tests/012/struct.tl
index 88f37e4d..57234913 100644
--- a/tests/012/struct.tl
+++ b/tests/012/struct.tl
@@ -62,7 +62,7 @@
(test (new foo) #S(foo a 42))
-(set *gensym-counter* 0)
+(set *gensym-counter* 4)
(stest (expand '(defstruct (boa x y) nil
(x 0) (y 0)))
"(sys:make-struct-type 'boa '() '()\n \
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))
diff --git a/txr.1 b/txr.1
index 65e52bce..8952d3d2 100644
--- a/txr.1
+++ b/txr.1
@@ -33969,8 +33969,8 @@ being the first four elements of an infinite repetition of
.verb
;; change characters between angle brackets to upper case.
[window-map 1 nil (lambda (x y z)
- (if (and (eq x #\<)
- (eq z #\>))
+ (if (and (eq x #\e<)
+ (eq z #\e>))
(chr-toupper y)
y))
"ab<c>de<f>g"]