diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-05 19:30:28 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-05 19:30:28 -0800 |
commit | d02854155e915e28740605a7302faaaff1128622 (patch) | |
tree | cf078bfe40a321df8450b6b9c2ab512f35ae6d86 /tests/011/patmatch.tl | |
parent | 00a793530e0386cfbe29670a8224f5e82897b283 (diff) | |
download | txr-d02854155e915e28740605a7302faaaff1128622.tar.gz txr-d02854155e915e28740605a7302faaaff1128622.tar.bz2 txr-d02854155e915e28740605a7302faaaff1128622.zip |
matcher: rearrange match order of @(with).
The @(with side-pat expr main-pat) syntax becomes
@(with main-pat side-pat expr), which is more useful.
Also, the main-pat can be omitted.
* share/txr/stdlib/match.tl (compile-with-match): Recognize
two forms of the syntax: two argument form with main-pat
omitted and the full form. In the full form, main-pat is
on the left now and processed first, so we have to rearrange
the compilation and integration order.
* tests/011/patmatch.tl: Existing tests updated. Two-argument
test added.
* txr.1: Updated.
Diffstat (limited to 'tests/011/patmatch.tl')
-rw-r--r-- | tests/011/patmatch.tl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 5dd735b9..fe82d28c 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -120,14 +120,19 @@ (test (when-match (@a @(as a @(or x @a))) '(#1=(1 2 #1# 3) #1#) :yes) :yes) -(test (when-match (@(with x 42 @a) @b @c) '(1 2 3) (list a b c x)) +(test (when-match (@(with @a x 42) @b @c) '(1 2 3) (list a b c x)) (1 2 3 42)) (test (let ((o 3)) - (when-match (@(evenp x) @(with @(oddp y) o @z)) '(4 6) + (when-match (@(evenp x) @(with @z @(oddp y) o)) '(4 6) (list x y z))) (4 3 6)) +(test (let ((o 3)) + (when-match (@(evenp x) @(with @(oddp y) o)) '(4 6) + (list x y))) + (4 3)) + (defstruct node () left right) |