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
commita0b712ca37537ca6067d8cd40bd1c232cb437cee (patch)
tree3516f01b0c843220691051f0e4f67c54a781669d
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.
-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"]