nendo 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- encoding: utf-8 -*-
3
- #
4
- # syntax_spec.rb - "RSpec file for nendo language (nendo.test framework part)"
5
- #
6
- # Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
7
- #
8
- # Redistribution and use in source and binary forms, with or without
9
- # modification, are permitted provided that the following conditions
10
- # are met:
11
- #
12
- # 1. Redistributions of source code must retain the above copyright
13
- # notice, this list of conditions and the following disclaimer.
14
- #
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
- #
19
- # 3. Neither the name of the authors nor the names of its contributors
20
- # may be used to endorse or promote products derived from this
21
- # software without specific prior written permission.
22
- #
23
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29
- # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
- # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- #
35
- require 'nendo'
36
- include Nendo
37
- require 'timeout'
38
-
39
- describe Nendo, "when use NendoTestError " do
40
- before do
41
- @nendoError1 = NendoTestError.new
42
- @runtimeError = RuntimeError.new
43
- @argumentError = ArgumentError.new
44
- @nendoError2 = NendoTestError.new( @runtimeError.class )
45
- end
46
-
47
- it "should" do
48
- @nendoError1.type.should == RuntimeError
49
- @nendoError1.type = @runtimeError.class
50
- @nendoError1.type.should == RuntimeError
51
- @nendoError1.type = RuntimeError
52
- @nendoError1.type.should == RuntimeError
53
- @nendoError1.type = Timeout::Error
54
- @nendoError1.type.should == Timeout::Error
55
- @nendoError2.type.should == RuntimeError
56
- end
57
- end
58
-
59
-
60
- describe Nendo, "when use test function " do
61
- before do
62
- @nendo = Nendo::Core.new()
63
- @nendo.loadInitFile
64
- @nendo.evalStr( "(use nendo.test)" )
65
- end
66
-
67
- it "should" do
68
- @nendo.evalStr( '(test-section "(test)")' ).should == '"(test)"'
69
-
70
- @nendo.evalStr( '(test "true false" #t (lambda () #t))' ).should == '#t'
71
- @nendo.evalStr( '(test "true false" #f (lambda () #f))' ).should == '#t'
72
- @nendo.evalStr( '(test "number" 0 (lambda () 0))' ).should == '#t'
73
- @nendo.evalStr( '(test "number" 0 (lambda () 1))' ).should == '#f'
74
- @nendo.evalStr( '(test "string" "ab" (lambda () (+ "a" "b")))' ).should == '#t'
75
- end
76
- end
77
-
78
- describe Nendo, "when use test* function " do
79
- before do
80
- @nendo = Nendo::Core.new()
81
- @nendo.loadInitFile
82
- @nendo.evalStr( "(use nendo.test)" )
83
- end
84
-
85
- it "should" do
86
- @nendo.evalStr( '(test-section "(test*)")' ).should == '"(test*)"'
87
-
88
- @nendo.evalStr( '(test* "true false" #t #t)' ).should == '#t'
89
- @nendo.evalStr( '(test* "true false" #f #f)' ).should == '#t'
90
- @nendo.evalStr( '(test* "number" 0 0)' ).should == '#t'
91
- @nendo.evalStr( '(test* "number" 0 1)' ).should == '#f'
92
- @nendo.evalStr( '(test* "string" "ab" (+ "a" "b"))' ).should == '#t'
93
- @nendo.evalStr( <<EOS
94
- (test* "eq?" '(a b) '(a b) eq?)
95
- EOS
96
- ).should == '#f'
97
-
98
- @nendo.evalStr( <<EOS
99
- (test* "eqv?" '(a b) '(a b) eqv?)
100
- EOS
101
- ).should == '#f'
102
-
103
- @nendo.evalStr( <<EOS
104
- (test* "equal?" '(a b) '(a b) )
105
- EOS
106
- ).should == '#t'
107
-
108
- end
109
- end
110
-
111
-
112
- describe Nendo, "when test framework handle exception " do
113
- before do
114
- @nendo = Nendo::Core.new()
115
- @nendo.loadInitFile
116
- @nendo.evalStr( "(use nendo.test)" )
117
- end
118
-
119
- it "should" do
120
- @nendo.evalStr( '(test-section "exceptions")' ).should == '"exceptions"'
121
-
122
- @nendo.evalStr( '(. (test-error ) class)' ).should == 'Nendo::NendoTestError'
123
- @nendo.evalStr( '(. (test-error RuntimeError) class)' ).should == 'Nendo::NendoTestError'
124
-
125
- @nendo.evalStr( '(. (test-error RuntimeError) type)' ).should == 'RuntimeError'
126
- @nendo.evalStr( '(. (test-error ArgumentError) type)' ).should == 'ArgumentError'
127
- @nendo.evalStr( '(. (test-error SyntaxError) type)' ).should == 'SyntaxError'
128
-
129
- @nendo.evalStr( '(test-error? (test-error)) ' ).should == '#t'
130
- @nendo.evalStr( '(test-error? (test-error RuntimeError)) ' ).should == '#t'
131
- @nendo.evalStr( '(test-error? (test-error ArgumentError)) ' ).should == '#t'
132
- @nendo.evalStr( '(test-error? (test-error SyntaxError)) ' ).should == '#t'
133
-
134
- @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error RuntimeError ))' ).should == '#t'
135
- @nendo.evalStr( '(test-check 1 (test-error RuntimeError ))' ).should == '#f'
136
- @nendo.evalStr( '(test-check (test-error RuntimeError) 1 )' ).should == '#f'
137
- @nendo.evalStr( '(test-check 1 1 )' ).should == '#t'
138
- @nendo.evalStr( '(test-check 1 2 )' ).should == '#f'
139
- @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error ArgumentError))' ).should == '#f'
140
- @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error SyntaxError ))' ).should == '#f'
141
- @nendo.evalStr( '(test-check (test-error ArgumentError) (test-error RuntimeError ))' ).should == '#f'
142
- @nendo.evalStr( '(test-check (test-error SyntaxError) (test-error RuntimeError ))' ).should == '#f'
143
-
144
- @nendo.evalStr( '(test* "exception" (test-error TypeError) (+ 1.1 "str"))' ).should == '#t'
145
- @nendo.evalStr( '(test* "exception" (test-error RuntimeError) (+ 1.1 "str"))' ).should == '#f'
146
- @nendo.evalStr( '(test* "exception" (test-error TypeError) (error "[RuntimeError]"))' ).should == '#f'
147
- @nendo.evalStr( '(test* "exception" (test-error RuntimeError) (error "[RuntimeError]"))' ).should == '#t'
148
- @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise RuntimeError "[RuntimeError]"))' ).should == '#f'
149
- @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise ArgumentError "[ArgumentError]"))' ).should == '#t'
150
- @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise TypeError "[TypeError]"))' ).should == '#f'
151
- @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise NoMethodError "[NoMethodError]"))' ).should == '#f'
152
- end
153
- end
@@ -1,24 +0,0 @@
1
- ;;-*- mode: nendo; syntax: scheme -*-;;
2
- ;; test for text.* ( ported from Gauche by kiyoka )
3
-
4
- (use nendo.test)
5
- (test-start "text utilities")
6
-
7
- ;;===================================================================
8
- ;;-------------------------------------------------------------------
9
- (test-section "tree")
10
- (use text.tree)
11
- (test-module 'text.tree)
12
-
13
- (test* "tree->string" "" (tree->string '()))
14
- (test* "tree->string" "" (tree->string ""))
15
- (test* "tree->string" "ab" (tree->string "ab"))
16
- (test* "tree->string" "ab" (tree->string 'ab))
17
- (test* "tree->string" "ab" (tree->string '(a . b)))
18
- (test* "tree->string" "ab" (tree->string '(a b)))
19
- (test* "tree->string" "Ab" (tree->string '(:A . :b)))
20
- (test* "tree->string" "ab" (tree->string '((((() ())) . a) ((((b)))))))
21
-
22
-
23
- ;;===================================================================
24
- (test-end)
@@ -1,383 +0,0 @@
1
- ;;-*- mode: nendo; syntax: scheme -*-;;
2
- ;;
3
- ;; util-combinations-test.nnd - test suite for util.combinations
4
- ;;
5
- ;; Copyright (c) 2000-2010 Shiro Kawai <shiro@acm.org>
6
- ;;
7
- ;; Redistribution and use in source and binary forms, with or without
8
- ;; modification, are permitted provided that the following conditions
9
- ;; are met:
10
- ;;
11
- ;; 1. Redistributions of source code must retain the above copyright
12
- ;; notice, this list of conditions and the following disclaimer.
13
- ;;
14
- ;; 2. Redistributions in binary form must reproduce the above copyright
15
- ;; notice, this list of conditions and the following disclaimer in the
16
- ;; documentation and/or other materials provided with the distribution.
17
- ;;
18
- ;; 3. Neither the name of the authors nor the names of its contributors
19
- ;; may be used to endorse or promote products derived from this
20
- ;; software without specific prior written permission.
21
- ;;
22
- ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
- ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
- ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
- ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28
- ;; TO, 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.
33
-
34
-
35
- (use nendo.test)
36
- (use util.match)
37
- (test-start "util.combination")
38
-
39
- ;;===================================================================
40
- ;;-------------------------------------------------------------------
41
-
42
-
43
- (test-section "util.combinations")
44
- (use util.combinations)
45
-
46
- (test* "permutations (boundary)" '(())
47
- (permutations '()))
48
- (test* "permutations (boundary)" '((a))
49
- (permutations '(a)))
50
- (test* "permutations" '((a b) (b a))
51
- (permutations '(a b)))
52
- (test* "permutations" '((a a) (a a))
53
- (permutations '(a a)))
54
- (test* "permutations" '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
55
- (permutations '(a b c)))
56
- (test* "permutations" '((a b c d) (a b d c) (a c b d) (a c d b)
57
- (a d b c) (a d c b) (b a c d) (b a d c)
58
- (b c a d) (b c d a) (b d a c) (b d c a)
59
- (c a b d) (c a d b) (c b a d) (c b d a)
60
- (c d a b) (c d b a) (d a b c) (d a c b)
61
- (d b a c) (d b c a) (d c a b) (d c b a))
62
- (permutations '(a b c d)))
63
-
64
- (test* "permutations* (boundary)" '(())
65
- (permutations* '()))
66
- (test* "permutations* (boundary)" '((a))
67
- (permutations* '(a)))
68
- (test* "permutations*" '((a b) (b a))
69
- (permutations* '(a b)))
70
- (test* "permutations*" '((a a))
71
- (permutations* '(a a)))
72
- (test* "permutations*" '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
73
- (permutations* '(a b c)))
74
- (test* "permutations*" '((a a b) (a b a) (b a a))
75
- (permutations* '(a a b)))
76
- (test* "permutations*" '((a b a) (a a b) (b a a))
77
- (permutations* '(a b a)))
78
- (test* "permutations*" '((b a a) (a b a) (a a b))
79
- (permutations* '(b a a)))
80
- (test* "permutations*" '((a a a))
81
- (permutations* '(a a a)))
82
- (test* "permutations*" '((a b c d) (a b d c) (a c b d) (a c d b)
83
- (a d b c) (a d c b) (b a c d) (b a d c)
84
- (b c a d) (b c d a) (b d a c) (b d c a)
85
- (c a b d) (c a d b) (c b a d) (c b d a)
86
- (c d a b) (c d b a) (d a b c) (d a c b)
87
- (d b a c) (d b c a) (d c a b) (d c b a))
88
- (permutations* '(a b c d)))
89
- (test* "permutations*" '((a a b c) (a a c b) (a b a c) (a b c a)
90
- (a c a b) (a c b a) (b a a c) (b a c a)
91
- (b c a a) (c a a b) (c a b a) (c b a a))
92
- (permutations* '(a a b c)))
93
- (test* "permutations*" '((a b a c) (a b c a) (a a b c) (a a c b)
94
- (a c b a) (a c a b) (b a a c) (b a c a)
95
- (b c a a) (c a b a) (c a a b) (c b a a))
96
- (permutations* '(a b a c)))
97
- (test* "permutations*" '((a b c a) (a b a c) (a c b a) (a c a b)
98
- (a a b c) (a a c b) (b a c a) (b a a c)
99
- (b c a a) (c a b a) (c a a b) (c b a a))
100
- (permutations* '(a b c a)))
101
- (test* "permutations*" '((a b a b) (a b b a) (a a b b)
102
- (b a a b) (b a b a) (b b a a))
103
- (permutations* '(a b a b)))
104
- (test* "permutations*" '((a a a b) (a a b a) (a b a a) (b a a a))
105
- (permutations* '(a a a b)))
106
- (test* "permutations*" '((a b a a) (a a b a) (a a a b) (b a a a))
107
- (permutations* '(a b a a)))
108
- (test* "permutations*" '((a a a a))
109
- (permutations* '(a a a a)))
110
-
111
- (test* "permutations*" '(("a" "b" "b" "a") ("a" "b" "a" "b") ("a" "a" "b" "b")
112
- ("b" "a" "b" "a") ("b" "a" "a" "b") ("b" "b" "a" "a"))
113
- (permutations* '("a" "b" "b" "a") string=?))
114
-
115
- (test* "permutations-for-each"
116
- '()
117
- (let1 r '()
118
- (permutations-for-each (lambda (p) (push! r p)) '())
119
- (reverse r)))
120
- (test* "permutations-for-each"
121
- '((a))
122
- (let1 r '()
123
- (permutations-for-each (lambda (p) (push! r p)) '(a))
124
- (reverse r)))
125
- (test* "permutations-for-each"
126
- '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
127
- (let1 r '()
128
- (permutations-for-each (lambda (p) (push! r p)) '(a b c))
129
- (reverse r)))
130
- (test* "permutations-for-each"
131
- '((a b c d) (a b d c) (a c b d) (a c d b)
132
- (a d b c) (a d c b) (b a c d) (b a d c)
133
- (b c a d) (b c d a) (b d a c) (b d c a)
134
- (c a b d) (c a d b) (c b a d) (c b d a)
135
- (c d a b) (c d b a) (d a b c) (d a c b)
136
- (d b a c) (d b c a) (d c a b) (d c b a))
137
- (let1 r '()
138
- (permutations-for-each (lambda (p) (push! r p)) '(a b c d))
139
- (reverse r)))
140
- (test* "permutations-for-each"
141
- (let* ((set '(a b c d e))
142
- (all-patterns
143
- (append-map
144
- (lambda (v1)
145
- (append-map
146
- (lambda (v2)
147
- (append-map
148
- (lambda (v3)
149
- (append-map
150
- (lambda (v4)
151
- (map
152
- (lambda (v5)
153
- (list v1 v2 v3 v4 v5))
154
- set))
155
- set))
156
- set))
157
- set))
158
- set)))
159
- (filter
160
- (lambda (x)
161
- (eq? (length x)
162
- (length (delete-duplicates x))))
163
- all-patterns))
164
- (let1 r '()
165
- (permutations-for-each (lambda (p) (push! r p)) '(a b c d e))
166
- (reverse r)))
167
- (test* "permutations*-for-each"
168
- '()
169
- (let1 r '()
170
- (permutations*-for-each (lambda (p) (push! r p)) '())
171
- (reverse r)))
172
- (test* "permutations*-for-each"
173
- '((a))
174
- (let1 r '()
175
- (permutations*-for-each (lambda (p) (push! r p)) '(a))
176
- (reverse r)))
177
- (test* "permutations*-for-each"
178
- '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
179
- (let1 r '()
180
- (permutations*-for-each (lambda (p) (push! r p)) '(a b c))
181
- (reverse r)))
182
- (test* "permutations*-for-each"
183
- '((a a b) (a b a) (b a a))
184
- (let1 r '()
185
- (permutations*-for-each (lambda (p) (push! r p)) '(a a b))
186
- (reverse r)))
187
- (test* "permutations*-for-each"
188
- '((a a a))
189
- (let1 r '()
190
- (permutations*-for-each (lambda (p) (push! r p)) '(a a a))
191
- (reverse r)))
192
- (test* "permutations*-for-each"
193
- '(("a" "a" "b") ("a" "b" "a") ("b" "a" "a"))
194
- (let1 r '()
195
- (permutations*-for-each (lambda (p) (push! r p)) '("a" "a" "b")
196
- string=?)
197
- (reverse r)))
198
-
199
- (test* "combinations" '(())
200
- (combinations '() 0))
201
- (test* "combinations" '((a))
202
- (combinations '(a) 1))
203
- (test* "combinations" '((a) (b) (c) (d))
204
- (combinations '(a b c d) 1))
205
- (test* "combinations" '((a b) (a c) (b c))
206
- (combinations '(a b c) 2))
207
- (test* "combinations" '((a b c))
208
- (combinations '(a b c) 3))
209
- (test* "combinations" '((a b c) (a b d) (a c d) (b c d))
210
- (combinations '(a b c d) 3))
211
-
212
- (test* "combinations*" '(())
213
- (combinations* '() 0))
214
- (test* "combinations*" '((a))
215
- (combinations* '(a) 1))
216
- (test* "combinations*" '((a) (b) (c) (d))
217
- (combinations* '(a b c d) 1))
218
- (test* "combinations*" '((a b) (a c) (b c))
219
- (combinations* '(a b c) 2))
220
- (test* "combinations*" '((a b c))
221
- (combinations* '(a b c) 3))
222
- (test* "combinations*" '((a b c) (a b d) (a c d) (b c d))
223
- (combinations* '(a b c d) 3))
224
- (test* "combinations*" '((a) (b))
225
- (combinations* '(a a b) 1))
226
- (test* "combinations*" '((a a) (a b))
227
- (combinations* '(a a b) 2))
228
- (test* "combinations*" '((a a b))
229
- (combinations* '(a a b) 3))
230
- (test* "combinations*" '((a b) (a a))
231
- (combinations* '(a b a a) 2))
232
- (test* "combinations*" '((a b a) (a a a))
233
- (combinations* '(a b a a) 3))
234
- (test* "combinations*" '((a b b) (a b a))
235
- (combinations* '(a b b a) 3))
236
- (test* "combinations*" '(("a" "b" "b") ("a" "b" "a"))
237
- (combinations* '("a" "b" "b" "a") 3 string=?))
238
-
239
- (test* "combinations-for-each" '(())
240
- (let1 r '()
241
- (combinations-for-each (lambda (c) (push! r c)) '() 0)
242
- (reverse! r)))
243
- (test* "combinations-for-each" '((a))
244
- (let1 r '()
245
- (combinations-for-each (lambda (c) (push! r c)) '(a) 1)
246
- (reverse! r)))
247
- (test* "combinations-for-each" '((a) (b) (c) (d))
248
- (let1 r '()
249
- (combinations-for-each (lambda (c) (push! r c)) '(a b c d) 1)
250
- (reverse! r)))
251
- (test* "combinations-for-each" '((a b) (a c) (b c))
252
- (let1 r '()
253
- (combinations-for-each (lambda (c) (push! r c)) '(a b c) 2)
254
- (reverse! r)))
255
- (test* "combinations-for-each" '((a b c))
256
- (let1 r '()
257
- (combinations-for-each (lambda (c) (push! r c)) '(a b c) 3)
258
- (reverse! r)))
259
- (test* "combinations-for-each" '((a b c) (a b d) (a c d) (b c d))
260
- (let1 r '()
261
- (combinations-for-each (lambda (c) (push! r c)) '(a b c d) 3)
262
- (reverse! r)))
263
-
264
- (test* "combinations*-for-each" '(())
265
- (let1 r '()
266
- (combinations*-for-each (lambda (c) (push! r c)) '() 0)
267
- (reverse! r)))
268
- (test* "combinations*-for-each" '((a))
269
- (let1 r '()
270
- (combinations*-for-each (lambda (c) (push! r c)) '(a) 1)
271
- (reverse! r)))
272
- (test* "combinations*-for-each" '((a) (b) (c) (d))
273
- (let1 r '()
274
- (combinations*-for-each (lambda (c) (push! r c)) '(a b c d) 1)
275
- (reverse! r)))
276
- (test* "combinations*-for-each" '((a b) (a c) (b c))
277
- (let1 r '()
278
- (combinations*-for-each (lambda (c) (push! r c)) '(a b c) 2)
279
- (reverse! r)))
280
- (test* "combinations*-for-each" '((a b c))
281
- (let1 r '()
282
- (combinations*-for-each (lambda (c) (push! r c)) '(a b c) 3)
283
- (reverse! r)))
284
- (test* "combinations*-for-each" '((a b c) (a b d) (a c d) (b c d))
285
- (let1 r '()
286
- (combinations*-for-each (lambda (c) (push! r c)) '(a b c d) 3)
287
- (reverse! r)))
288
- (test* "combinations*-for-each" '((a) (b))
289
- (let1 r '()
290
- (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 1)
291
- (reverse! r)))
292
- (test* "combinations*-for-each" '((a a) (a b))
293
- (let1 r '()
294
- (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 2)
295
- (reverse! r)))
296
- (test* "combinations*-for-each" '((a a b))
297
- (let1 r '()
298
- (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 3)
299
- (reverse! r)))
300
- (test* "combinations*-for-each" '((a b) (a a))
301
- (let1 r '()
302
- (combinations*-for-each (lambda (c) (push! r c)) '(a b a a) 2)
303
- (reverse! r)))
304
- (test* "combinations*-for-each" '((a b a) (a a a))
305
- (let1 r '()
306
- (combinations*-for-each (lambda (c) (push! r c)) '(a b a a) 3)
307
- (reverse! r)))
308
- (test* "combinations*-for-each" '((a b b) (a b a))
309
- (let1 r '()
310
- (combinations*-for-each (lambda (c) (push! r c)) '(a b b a) 3)
311
- (reverse! r)))
312
- (test* "combinations*-for-each" '(("a" "b" "b") ("a" "b" "a"))
313
- (let1 r '()
314
- (combinations*-for-each (lambda (c) (push! r c)) '("a" "b" "b" "a") 3
315
- string=?)
316
- (reverse! r)))
317
-
318
- (test* "power-set-binary" '(())
319
- (power-set-binary '()))
320
- (test* "power-set-binary" '(() (a))
321
- (power-set-binary '(a)))
322
- (test* "power-set-binary" '(() (c) (b) (b c) (a) (a c) (a b) (a b c))
323
- (power-set-binary '(a b c)))
324
-
325
- (test* "power-set" '(())
326
- (power-set '()))
327
- (test* "power-set" '(() (a))
328
- (power-set '(a)))
329
- (test* "power-set" '(() (a) (b) (c) (a b) (a c) (b c) (a b c))
330
- (power-set '(a b c)))
331
-
332
- (test* "power-set*" '(())
333
- (power-set* '()))
334
- (test* "power-set*" '(() (a))
335
- (power-set* '(a)))
336
- (test* "power-set*" '(() (a) (b) (a a) (a b) (a a b))
337
- (power-set* '(a a b)))
338
- (test* "power-set*" '(() ("a") ("b") ("a" "a") ("a" "b") ("a" "a" "b"))
339
- (power-set* '("a" "a" "b") string=?))
340
-
341
- (test* "power-set-for-each" '(())
342
- (let1 r '()
343
- (power-set-for-each (lambda (s) (push! r s)) '())
344
- (reverse! r)))
345
- (test* "power-set-for-each" '(() (a))
346
- (let1 r '()
347
- (power-set-for-each (lambda (s) (push! r s)) '(a))
348
- (reverse! r)))
349
- (test* "power-set-for-each" '(() (a) (b) (c) (a b) (a c) (b c) (a b c))
350
- (let1 r '()
351
- (power-set-for-each (lambda (s) (push! r s)) '(a b c))
352
- (reverse! r)))
353
-
354
- (test* "power-set*-for-each" '(())
355
- (let1 r '()
356
- (power-set*-for-each (lambda (s) (push! r s)) '())
357
- (reverse! r)))
358
- (test* "power-set*-for-each" '(() (a))
359
- (let1 r '()
360
- (power-set*-for-each (lambda (s) (push! r s)) '(a))
361
- (reverse! r)))
362
- (test* "power-set*-for-each" '(() (a) (b) (a a) (a b) (a a b))
363
- (let1 r '()
364
- (power-set*-for-each (lambda (s) (push! r s)) '(a a b))
365
- (reverse! r)))
366
- (test* "power-set*-for-each" '(() ("a") ("b") ("a" "a") ("a" "b") ("a" "a" "b"))
367
- (let1 r '()
368
- (power-set*-for-each (lambda (s) (push! r s)) '("a" "a" "b")
369
- string=?)
370
- (reverse! r)))
371
-
372
- (test* "cartesian-product" '((a 0) (a 1) (b 0) (b 1) (c 0) (c 1))
373
- (cartesian-product '((a b c) (0 1))))
374
- (test* "cartesian-product" '((a 0 0) (a 0 1) (a 1 0) (a 1 1)
375
- (b 0 0) (b 0 1) (b 1 0) (b 1 1))
376
- (cartesian-product '((a b) (0 1) (0 1))))
377
- (test* "cartesian-product-right" '((a 0) (b 0) (c 0) (a 1) (b 1) (c 1))
378
- (cartesian-product-right '((a b c) (0 1))))
379
-
380
-
381
-
382
- ;;===================================================================
383
- (test-end)