1
;; Filename : test-srfi2.scm
2
;; About : unit test for the SRFI-2 'and-let*'
4
;; Copyright (C) 2005-2006 Kazuki Ohta <mover AT hct.zaq.ne.jp>
5
;; Copyright (c) 2007 SigScheme Project <uim AT freedesktop.org>
7
;; All rights reserved.
9
;; Redistribution and use in source and binary forms, with or without
10
;; modification, are permitted provided that the following conditions
13
;; 1. Redistributions of source code must retain the above copyright
14
;; notice, this list of conditions and the following disclaimer.
15
;; 2. Redistributions in binary form must reproduce the above copyright
16
;; notice, this list of conditions and the following disclaimer in the
17
;; documentation and/or other materials provided with the distribution.
18
;; 3. Neither the name of authors nor the names of its contributors
19
;; may be used to endorse or promote products derived from this software
20
;; without specific prior written permission.
22
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
23
;; IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24
;; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25
;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
26
;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27
;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
(load "./test/unittest.scm")
38
(if (not (provided? "srfi-2"))
39
(test-skip "SRFI-2 is not enabled"))
43
;; (and-let* <claws> <body>)
45
;; <claws> ::= '() | (cons <claw> <claws>)
46
;; <claw> ::= (<variable> <expression>) | (<expression>)
52
(tn "and-let* invalid form")
53
(assert-error (tn) (lambda () (and-let* ((#t) . #t) #t)))
54
(assert-error (tn) (lambda () (and-let* ((foo #t) . #t) #t)))
57
(assert-true "and-let* test 1" (and-let* () #t))
58
(assert-true "and-let* test 2" (and-let* () #t #t))
59
(assert-true "and-let* test 3" (and-let* () #t #t #t))
60
(assert-false "and-let* test 4" (and-let* () #f))
61
(assert-false "and-let* test 5" (and-let* () #t #f))
62
(assert-false "and-let* test 6" (and-let* () #t #t #f))
63
(assert-false "and-let* test 7" (and-let* ((false (< 2 1)))
65
(assert-false "and-let* test 8" (and-let* ((true (< 1 2))
68
(assert-true "and-let* test 9" (and-let* ((one 1)
72
(assert-false "and-let* test 10" (and-let* ((one 1)
77
;; <bound-variable> style claw
78
(assert-true "and-let* #11" (and-let* (true)
80
(assert-true "and-let* #12" (and-let* (even?)
82
(assert-false "and-let* #13" (and-let* (false)
84
(assert-true "and-let* #14" (and-let* (even?
87
(assert-false "and-let* #15" (and-let* (even?
92
;; (<expression>) style claw
93
(assert-true "and-let* #16" (and-let* ((#t))
95
(assert-false "and-let* #17" (and-let* ((#f))
97
(assert-true "and-let* #18" (and-let* (((integer? 1)))
99
(assert-false "and-let* #19" (and-let* (((integer? #t)))
101
(assert-true "and-let* #20" (and-let* (((integer? 1))
104
(assert-false "and-let* #21" (and-let* (((integer? 1))
108
;; procedure itself as value
109
(assert-true "and-let* #22" (and-let* ((even?))
113
(assert-true "and-let* #23" (and-let* (true
117
(assert-true "and-let* #24" (and-let* (true
124
(assert-false "and-let* #25" (and-let* (true
131
(assert-false "and-let* #26" (and-let* (true