summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Graham <julian.graham@aya.yale.edu>2010-08-08 20:23:14 -0400
committerJulian Graham <julian.graham@aya.yale.edu>2010-08-08 20:23:14 -0400
commit802b47bdc6232f3726860ce8ae17e4b422061620 (patch)
tree13bd2c834594b75ae454371660b8461cf5a24318
parentb24b7deb000ee4108c5e3a0a2cb3d7494973a7a4 (diff)
downloadguile-802b47bdc6232f3726860ce8ae17e4b422061620.tar.gz
Explicit definitions for `memp' and `assp' in `(rnrs list)'; the predicate
argument to Guile's `member' and `assoc' functions has a different expected arity. * module/rnrs/lists.scm (memp, assp): Wrap the predicate function with a two-argument wrapper before calling Guile's underlying implemenation. * test-suite/Makefile.am: Add test-suite/tests/r6rs-lists.test to SCM_TESTS. * test-suite/tests/r6rs-lists.test: New file.
-rw-r--r--module/rnrs/lists.scm4
-rw-r--r--test-suite/Makefile.am1
-rw-r--r--test-suite/tests/r6rs-lists.test32
3 files changed, 35 insertions, 2 deletions
diff --git a/module/rnrs/lists.scm b/module/rnrs/lists.scm
index c9d913b29..812ce5f98 100644
--- a/module/rnrs/lists.scm
+++ b/module/rnrs/lists.scm
@@ -44,6 +44,6 @@
(define (remv obj list) (remp (lambda (elt) (eqv? obj elt)) list))
(define (remq obj list) (remp (lambda (elt) (eq? obj elt)) list))
- (define (memp pred list) (memp-internal #f list pred))
- (define (assp pred list) (assp-internal #f list pred))
+ (define (memp pred list) (memp-internal #f list (lambda (x y) (pred y))))
+ (define (assp pred list) (assp-internal #f list (lambda (x y) (pred y))))
)
diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am
index 078df792f..eab1cd5f0 100644
--- a/test-suite/Makefile.am
+++ b/test-suite/Makefile.am
@@ -88,6 +88,7 @@ SCM_TESTS = tests/00-initial-env.test \
tests/r6rs-exceptions.test \
tests/r6rs-files.test \
tests/r6rs-hashtables.test \
+ tests/r6rs-lists.test \
tests/r6rs-ports.test \
tests/r6rs-records-inspection.test \
tests/r6rs-records-procedural.test \
diff --git a/test-suite/tests/r6rs-lists.test b/test-suite/tests/r6rs-lists.test
new file mode 100644
index 000000000..ba645ed01
--- /dev/null
+++ b/test-suite/tests/r6rs-lists.test
@@ -0,0 +1,32 @@
+;;; r6rs-lists.test --- Test suite for R6RS (rnrs lists)
+
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 3 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+(define-module (test-suite test-r6rs-lists)
+ :use-module ((rnrs lists) :version (6))
+ :use-module (test-suite lib))
+
+(with-test-prefix "memp"
+ (pass-if "memp simple"
+ (equal? (memp even? '(3 1 4 1 5 9 2 6 5)) '(4 1 5 9 2 6 5))))
+
+(with-test-prefix "assp"
+ (pass-if "assp simple"
+ (let ((d '((3 a) (1 b) (4 c))))
+ (equal? (assp even? d) '(4 c)))))
+