summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2004-01-21 00:45:48 +0000
committerMarius Vollmer <mvo@zagadka.de>2004-01-21 00:45:48 +0000
commit012a3a7537d305b5ce2f95f3337978facac8634f (patch)
tree2ceacab8f3420b005986fd49f6aad2c11724c749
parent7eec4c37c73ef3e1a855655d9bbcaf790a919416 (diff)
downloadguile-012a3a7537d305b5ce2f95f3337978facac8634f.tar.gz
* tests/srfi-26.test: New.
* Makefile.am (SCM_TESTS): Added it.
-rw-r--r--test-suite/Makefile.am1
-rw-r--r--test-suite/tests/srfi-26.test74
2 files changed, 75 insertions, 0 deletions
diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am
index 241f66d0b..ad232bd6b 100644
--- a/test-suite/Makefile.am
+++ b/test-suite/Makefile.am
@@ -61,6 +61,7 @@ SCM_TESTS = tests/alist.test \
tests/srfi-13.test \
tests/srfi-14.test \
tests/srfi-19.test \
+ tests/srfi-26.test \
tests/srfi-34.test \
tests/srfi-4.test \
tests/srfi-9.test \
diff --git a/test-suite/tests/srfi-26.test b/test-suite/tests/srfi-26.test
new file mode 100644
index 000000000..2ebe5de03
--- /dev/null
+++ b/test-suite/tests/srfi-26.test
@@ -0,0 +1,74 @@
+; CONFIDENCE TEST FOR IMPLEMENTATION OF SRFI-26
+; =============================================
+;
+; Sebastian.Egner@philips.com, 3-Jun-2002.
+;
+; This file checks a few assertions about the implementation.
+; If you run it and no error message is issued, the implementation
+; is correct on the cases that have been tested.
+;
+; compliance:
+; Scheme R5RS with
+; SRFI-23: error
+;
+; loading this file into Scheme 48 0.57 after 'cut.scm' has been loaded:
+; ,open srfi-23
+; ,load check.scm
+
+; (check expr)
+; evals expr and issues an error if it is not #t.
+
+(define-module (test-srfi-26)
+ #:use-module (test-suite lib)
+ #:use-module (srfi srfi-26))
+
+(define (check expr)
+ (pass-if "cut/cute" (eval expr (interaction-environment))))
+
+; (check-all)
+; runs several tests on cut and reports.
+
+(define (check-all)
+ (for-each
+ check
+ '( ; cuts
+ (equal? ((cut list)) '())
+ (equal? ((cut list <...>)) '())
+ (equal? ((cut list 1)) '(1))
+ (equal? ((cut list <>) 1) '(1))
+ (equal? ((cut list <...>) 1) '(1))
+ (equal? ((cut list 1 2)) '(1 2))
+ (equal? ((cut list 1 <>) 2) '(1 2))
+ (equal? ((cut list 1 <...>) 2) '(1 2))
+ (equal? ((cut list 1 <...>) 2 3 4) '(1 2 3 4))
+ (equal? ((cut list 1 <> 3 <>) 2 4) '(1 2 3 4))
+ (equal? ((cut list 1 <> 3 <...>) 2 4 5 6) '(1 2 3 4 5 6))
+ (equal? (let* ((x 'wrong) (y (cut list x))) (set! x 'ok) (y)) '(ok))
+ (equal?
+ (let ((a 0))
+ (map (cut + (begin (set! a (+ a 1)) a) <>)
+ '(1 2))
+ a)
+ 2)
+ ; cutes
+ (equal? ((cute list)) '())
+ (equal? ((cute list <...>)) '())
+ (equal? ((cute list 1)) '(1))
+ (equal? ((cute list <>) 1) '(1))
+ (equal? ((cute list <...>) 1) '(1))
+ (equal? ((cute list 1 2)) '(1 2))
+ (equal? ((cute list 1 <>) 2) '(1 2))
+ (equal? ((cute list 1 <...>) 2) '(1 2))
+ (equal? ((cute list 1 <...>) 2 3 4) '(1 2 3 4))
+ (equal? ((cute list 1 <> 3 <>) 2 4) '(1 2 3 4))
+ (equal? ((cute list 1 <> 3 <...>) 2 4 5 6) '(1 2 3 4 5 6))
+ (equal?
+ (let ((a 0))
+ (map (cute + (begin (set! a (+ a 1)) a) <>)
+ '(1 2))
+ a)
+ 1))))
+
+; run the checks when loading
+(with-test-prefix "SRFI-26"
+ (check-all))