diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-04-23 02:20:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-04-23 02:20:59 -0700 |
commit | f248e5ab1e0633c96c048116ba74305ec9664998 (patch) | |
tree | 4ccc84f323901a10cd69476a8acb02f69d65a68e /tests | |
parent | 1e43bc3bc6158a918736adf96792815afba268da (diff) | |
download | txr-f248e5ab1e0633c96c048116ba74305ec9664998.tar.gz txr-f248e5ab1e0633c96c048116ba74305ec9664998.tar.bz2 txr-f248e5ab1e0633c96c048116ba74305ec9664998.zip |
ifa: fix broken/invalid test case.
* tests/012/ifa.tl: The "ambiguous" test case is not ambiguous
at all. The reason it was yielding :error previously was not
due to the ifa macro identifying an ambiguity but due to the
funcion < not accepting nil arguments. Since < now does accept
nil arguments, this test broke. Fixing this test, and adding
one that tests for the ambiguous case: multiple it-candidates
being rejected by ifa at expansion time.
* tests/common.tl (vtest): This macro requires maintenance. To
test for expansion-time failure, we must use expand, not just
macroexpand. In this case, the (ifa ...) macro call is wrapped
in a (let ...) so macroexpand won't do it. Secondly, the
expected value is an quote expression that must be evaluated
if we need its value in vtest itself. Otherwise it won't
compare equal to :error, since it is actually (quote :error).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/012/ifa.tl | 7 | ||||
-rw-r--r-- | tests/common.tl | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/tests/012/ifa.tl b/tests/012/ifa.tl index d669244d..45a2939b 100644 --- a/tests/012/ifa.tl +++ b/tests/012/ifa.tl @@ -10,8 +10,11 @@ (isqrt it))) 7) -;; ambiguous: is "it" x or is "it" y? -(test (let (x y) (ifa (> x y) (print it))) :error) +;; no it-candidates: "it" is leftmost arg x. +(test (let ((x 1) (y 0)) (ifa (> x y) it)) 1) + +;; multiple it-candidates: error +(test (let (x y) (ifa (> (* x x) (* y y)) it)) :error) ;; "it" is (+ 3 (* 2 x)) (test (let ((x 5)) diff --git a/tests/common.tl b/tests/common.tl index 3cd5df63..3eef8d31 100644 --- a/tests/common.tl +++ b/tests/common.tl @@ -4,14 +4,14 @@ (defmacro vtest (:env env expr expected) (catch - (let ((expr-expn (macroexpand expr env)) + (let ((expr-expn (expand 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 ,expval)))) (error (exc) - (unless (eq expected :error) + (unless (eq (eval expected) :error) (error "test case ~s failed to expand: expected is ~s" expr expected))))) (defmacro test (expr expected) |