diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-08 21:16:11 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-08 21:16:11 -0800 |
commit | f85a58da998088496c3cb0d3370a35934646ade9 (patch) | |
tree | ed74d14093785f22f28faeb12740cbc781b6d54f /tests | |
parent | 82cfcfdd91fb1cd8356fd6aaa537d329ecc3b78f (diff) | |
download | txr-f85a58da998088496c3cb0d3370a35934646ade9.tar.gz txr-f85a58da998088496c3cb0d3370a35934646ade9.tar.bz2 txr-f85a58da998088496c3cb0d3370a35934646ade9.zip |
match: remove bad restriction from @(sme) and @(end).
The end pattern in @(sme) and @(end) does not have to be a
list pattern, dotted or otherwise. It should support any
pattern whatsoever for a single object, which should match the
terminating atom. The documentation says that, though not very
clearly; it is reworded also.
* stdlib/match.tl (check-end): Remove this function, since
the end pattern can be any pattern.
(pat-len): Bugfix: we are using the meq function incorrectly.
The object being compared against several alternatives
must be the leftmost argument of meq. This bug prevents a
pattern like @(evenp @x) to be correctly considered of
length zero.
(sme, end): Remove calls to check-end, and just refer to
original end variable.
* tests/011/patmatch.tl: New tests.
* txr.1: clarify that the end pattern may be any pattern,
which can match just the terminating atom or a possibly
dotted suffix.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/011/patmatch.tl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index bb67e32e..6d071f3d 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -602,6 +602,16 @@ (match @gs 0 gs) :error (match @gs :gs gs) :gs) +(mtest + (match @(end @x) '(1 . 2) x) 2 + (match @(end @(evenp @x)) '(1 . 2) x) 2 + (match @(end (@z . @x)) '(1 . 2) (list z x)) (1 2) + (match @(end (@z . @(evenp @x))) '(1 . 2) (list z x)) (1 2)) + +(mtest + (match @(sme (@a) (@b) @x) '(0 1 . 2) (list a b x)) (0 1 2) + (match @(sme (@a) (@b) @(evenp @x)) '(0 1 . 2) (list a b x)) (0 1 2)) + (compile-only (eval-only (with-compile-opts (nil unused) |