summaryrefslogtreecommitdiff
path: root/test-suite/tests/match.test
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-09-27 22:50:36 +0200
committerLudovic Courtès <ludo@gnu.org>2010-09-27 22:50:36 +0200
commit1ffed5aa95d66123a552fa3513373e78a1679287 (patch)
tree12a9bb1c445b5d3d63b5ee98221ce502437df8ff /test-suite/tests/match.test
parent56ec46a7c3f8761b3e1f4fb2f957882636fbaaee (diff)
downloadguile-1ffed5aa95d66123a552fa3513373e78a1679287.tar.gz
Add support for `..1' to `match'.
Patch accepted upstream: <http://lists.gnu.org/archive/html/guile-devel/2010-09/threads.html#00114>. * module/ice-9/match.upstream.scm (match-two): Add support for `..1'. * test-suite/tests/match.test ("matches")["list ..1", "list ..1, with predicate"]: New tests. ("doesn't match")["list ..1", "list ..1, with predicate"]: New tests.
Diffstat (limited to 'test-suite/tests/match.test')
-rw-r--r--test-suite/tests/match.test23
1 files changed, 22 insertions, 1 deletions
diff --git a/test-suite/tests/match.test b/test-suite/tests/match.test
index 70a15ec3c..d1432d8af 100644
--- a/test-suite/tests/match.test
+++ b/test-suite/tests/match.test
@@ -67,6 +67,16 @@
((x . rest)
(and (eq? x 'a) (equal? rest '(b c)))))))
+ (pass-if "list ..1"
+ (match '(a b c)
+ ((x ..1)
+ (equal? x '(a b c)))))
+
+ (pass-if "list ..1, with predicate"
+ (match '(a b c)
+ (((and x (? symbol?)) ..1)
+ (equal? x '(a b c)))))
+
(pass-if "tree"
(let ((tree '(one (two 2) (three 3 (and 4 (and 5))))))
(match tree
@@ -79,4 +89,15 @@
(pass-if-exception "tree"
exception:match-error
(match '(a (b c))
- ((foo (bar)) #t))))
+ ((foo (bar)) #t)))
+
+ (pass-if-exception "list ..1"
+ exception:match-error
+ (match '()
+ ((x ..1) #f)))
+
+ (pass-if-exception "list ..1, with predicate"
+ exception:match-error
+ (match '(a 0)
+ (((and x (? symbol?)) ..1)
+ (equal? x '(a b c))))))