1
;;; Copyright (c) 2003-2011 uim Project http://code.google.com/p/uim/
3
;;; All rights reserved.
5
;;; Redistribution and use in source and binary forms, with or without
6
;;; modification, are permitted provided that the following conditions
8
;;; 1. Redistributions of source code must retain the above copyright
9
;;; notice, this list of conditions and the following disclaimer.
10
;;; 2. Redistributions in binary form must reproduce the above copyright
11
;;; notice, this list of conditions and the following disclaimer in the
12
;;; documentation and/or other materials provided with the distribution.
13
;;; 3. Neither the name of authors nor the names of its contributors
14
;;; may be used to endorse or promote products derived from this software
15
;;; without specific prior written permission.
17
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18
;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
21
;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
;; These tests are passed at revision 6605 (new repository)
32
(define-module test.util.test-r5rs
33
(use test.unit.test-case)
35
(select-module test.util.test-r5rs)
39
(uim '(define lst '(1 "2" three (4) 5 six "7" (8 8) -9))))
45
(assert-uim-equal "else"
49
((eq? 'second 'twelve)
51
((string=? "third" "thirty")
59
((eq? 'second 'twelve)
61
((string=? "third" "third")
65
(assert-uim-false '(cond
68
((eq? 'second 'twelve)
70
((string=? "third" "thirty")
76
(define (test-boolean?)
77
(assert-uim-true '(boolean? #f))
78
(assert-uim-true '(boolean? #t))
79
(assert-uim-false '(boolean? "foo"))
80
(assert-uim-false '(boolean? 'foo))
81
(assert-uim-false '(boolean? -1))
82
(assert-uim-false '(boolean? 0))
85
;;(assert-uim-true '(boolean? 1)) ; Siod specific
87
(assert-uim-false '(boolean? 1))
89
(assert-uim-false '(boolean? 10))
90
;;(assert-uim-true '(boolean? ())) ; SIOD specific
91
(assert-uim-false '(boolean? ())) ; SigScheme
92
(assert-uim-false '(boolean? '(1 "2" 'three)))
93
(assert-uim-false '(boolean? 'nil))
94
(assert-uim-false '(symbol-bound? 'nil))
97
(define (test-integer?)
98
(assert-uim-false '(integer? #f))
99
(assert-uim-false '(integer? "foo"))
100
(assert-uim-false '(integer? 'foo))
101
(assert-uim-true '(integer? -1))
102
(assert-uim-true '(integer? 0))
103
(assert-uim-true '(integer? 1))
104
(assert-uim-true '(integer? 2))
105
(assert-uim-true '(integer? 10))
106
(assert-uim-false '(integer? ()))
107
(assert-uim-false '(integer? '(1 "2" 'three)))
111
;;(assert-uim-true '(list? #f)) ; SIOD specific
112
(assert-uim-false '(list? #f)) ; SigScheme
113
(assert-uim-false '(list? "foo"))
114
(assert-uim-false '(list? 'foo))
115
(assert-uim-false '(list? -1))
116
(assert-uim-false '(list? 0))
117
(assert-uim-false '(list? 1))
118
(assert-uim-false '(list? 2))
119
(assert-uim-false '(list? 10))
120
(assert-uim-true '(list? ()))
121
(assert-uim-true '(list? '(1)))
122
(assert-uim-true '(list? '(1 "2")))
123
(assert-uim-true '(list? '(1 "2" 'three)))
127
(assert-uim-error '(zero? #f))
128
(assert-uim-error '(zero? "foo"))
129
(assert-uim-error '(zero? 'foo))
130
(assert-uim-false '(zero? -2))
131
(assert-uim-false '(zero? -1))
132
(assert-uim-true '(zero? 0))
133
(assert-uim-false '(zero? 1))
134
(assert-uim-false '(zero? 2))
135
(assert-uim-false '(zero? 10))
136
(assert-uim-error '(zero? ()))
137
(assert-uim-error '(zero? '(1)))
138
(assert-uim-error '(zero? '(1 "2")))
139
(assert-uim-error '(zero? '(1 "2" 'three)))
142
(define (test-positive?)
143
(assert-uim-error '(positive? #f))
144
(assert-uim-error '(positive? "foo"))
145
(assert-uim-error '(positive? 'foo))
146
(assert-uim-false '(positive? -2))
147
(assert-uim-false '(positive? -1))
148
(assert-uim-false '(positive? 0))
149
(assert-uim-true '(positive? 1))
150
(assert-uim-true '(positive? 2))
151
(assert-uim-true '(positive? 10))
152
(assert-uim-error '(positive? ()))
153
(assert-uim-error '(positive? '(1)))
154
(assert-uim-error '(positive? '(1 "2")))
155
(assert-uim-error '(positive? '(1 "2" 'three)))
158
(define (test-negative?)
159
(assert-uim-error '(negative? #f))
160
(assert-uim-error '(negative? "foo"))
161
(assert-uim-error '(negative? 'foo))
162
(assert-uim-true '(negative? -2))
163
(assert-uim-true '(negative? -1))
164
(assert-uim-false '(negative? 0))
165
(assert-uim-false '(negative? 1))
166
(assert-uim-false '(negative? 2))
167
(assert-uim-false '(negative? 10))
168
(assert-uim-error '(negative? ()))
169
(assert-uim-error '(negative? '(1)))
170
(assert-uim-error '(negative? '(1 "2")))
171
(assert-uim-error '(negative? '(1 "2" 'three)))
174
(define (test-string->symbol)
175
(assert-uim-equal 'foo1
176
'(string->symbol "foo1"))
177
(assert-uim-equal 'Foo1
178
'(string->symbol "Foo1"))
179
(assert-uim-equal 'FOO1
180
'(string->symbol "FOO1"))
181
(assert-uim-equal '1foo
182
'(string->symbol "1foo"))
183
(assert-uim-equal '1Foo
184
'(string->symbol "1Foo"))
185
(assert-uim-equal '1FOO
186
'(string->symbol "1FOO"))
190
(assert-uim-equal '()
192
(assert-uim-equal (uim '(list #f))
195
;; these two tests fail due to bug #617 'boolean value
196
;; representation is inconsistent'
197
(assert-uim-equal (uim '(list #f #t))
199
(assert-uim-equal (uim '(list #f #t #f))
200
'(map not '(#t #f #t)))
202
(assert-uim-equal '()
206
(assert-uim-equal '(5)
210
(assert-uim-equal '(5 7)
214
(assert-uim-equal '(5 7 9)
218
(assert-uim-equal '()
223
(assert-uim-equal '(12)
228
(assert-uim-equal '(12 15)
233
(assert-uim-equal '(12 15 18)
238
(assert-uim-equal '()
244
(assert-uim-equal '(22)
250
(assert-uim-equal '(22 26)
256
(assert-uim-equal '(22 26 30)
264
(define (test-for-each)
267
(for-each (lambda (x)
274
(for-each (lambda (x)
276
(set! sum (+ sum x)))
281
(for-each (lambda (x y)
289
(for-each (lambda (x y)
291
(set! sum (+ sum x y)))
297
(define (test-list-tail)
298
(assert-uim-equal '(1 "2" three (4) 5 six "7" (8 8) -9)
300
(assert-uim-equal '("2" three (4) 5 six "7" (8 8) -9)
302
(assert-uim-equal '(three (4) 5 six "7" (8 8) -9)
304
(assert-uim-equal '((4) 5 six "7" (8 8) -9)
306
(assert-uim-equal '(-9)
308
(assert-uim-equal '()
310
(assert-uim-error '(list-tail lst 10))
311
(assert-uim-error '(list-tail lst -1))
314
(provide "test/util/test-r5rs")