3 (deftestsuite test-case-generation
() ())
4 (deftestsuite test-case-generation-simple
(test-case-generation) ())
6 ;;; ---------------------------------------------------------------------------
7 ;;; test-process-cases-form
8 ;;; ---------------------------------------------------------------------------
10 (deftestsuite test-process-cases-form
() ())
11 (deftestsuite test-vars-from-assignment
(test-process-cases-form) ())
13 (addtest (test-vars-from-assignment)
15 (ensure-same (vars-from-assignment '((:B
((A .
1) (B .
3)) ((A .
2) (B .
4)))))
18 (addtest (test-vars-from-assignment)
20 (ensure-same (vars-from-assignment (list '(c '(a b
)) '(d (list 'x
'y
))))
23 (addtest (test-vars-from-assignment)
25 (ensure-same (vars-from-assignment '((:B
((A .
1) (B .
3)) ((A .
2) (B .
4)))
26 (:B
((C . A
) (D . X
)) ((C . B
) (D . Y
)))))
29 ;;; ---------------------------------------------------------------------------
31 (deftestsuite test-values-from-assignment
(test-process-cases-form) ())
33 (addtest (test-values-from-assignment)
35 (ensure-same (values-from-assignment '((:B
((A .
1) (B .
3)) ((A .
2) (B .
4)))))
38 (addtest (test-values-from-assignment)
40 (ensure-same (values-from-assignment (list '(c '(a b
)) '(d (list 'x
'y
))))
43 (addtest (test-values-from-assignment)
45 (ensure-same (values-from-assignment '((:B
((A .
1) (B .
3)) ((A .
2) (B .
4)))
46 (:B
((C . A
) (D . X
)) ((C . B
) (D . Y
)))))
47 '((1 2) (3 4) (a b
) (x y
))))
49 ;;; ---------------------------------------------------------------------------
51 (deftestsuite test-standardize-cases-form
(test-process-cases-form)
54 (addtest (test-standardize-cases-form)
57 (standardize-cases-form '((q '(a b
))))
58 '(:cross
(q '(a b
)))))
60 ;;; ---------------------------------------------------------------------------
62 (addtest (test-standardize-cases-form)
65 (standardize-cases-form '((:map
(a '(1 2 3 4 5)) (b '(9 8 7 6 5)))))
66 '(:map
(a '(1 2 3 4 5)) (b '(9 8 7 6 5)))))
68 ;;; ---------------------------------------------------------------------------
70 (addtest (test-standardize-cases-form)
73 (standardize-cases-form '((q '(a b
)) (b '(1 2))))
74 '(:cross
(q '(a b
)) (b '(1 2)))))
76 ;;; ---------------------------------------------------------------------------
78 (addtest (test-process-cases-form)
81 (process-cases-form :map
'(c '(a b
)))
82 '(:b
((c . a
)) ((c . b
)))
85 ;;; ---------------------------------------------------------------------------
87 (addtest (test-process-cases-form)
90 (process-cases-form :map
'(c '(a b
)) '(d (list 'x
'y
)))
91 '(:b
((c . a
) (d . x
)) ((c . b
) (d . y
)))
94 (addtest (test-process-cases-form)
97 (process-cases-form :map
98 (process-cases-form :map
'(a '(1 2)) '(b '(3 4)))
99 (process-cases-form :map
'(c '(a b
)) '(d '(x y
))))
100 '(:b
((a .
1) (b .
3) (c . a
) (d . x
))
101 ((a .
2) (b .
4) (c . b
) (d . y
)))
104 (addtest (test-process-cases-form)
107 (process-cases-form :map
108 '(:b
((a .
1) (b .
3)) ((a .
2) (b .
4)))
109 '(:b
((c . a
) (d . x
)) ((c . b
) (d . y
))))
110 '(:b
((a .
1) (b .
3) (c . a
) (d . x
))
111 ((a .
2) (b .
4) (c . b
) (d . y
)))
114 (addtest (test-process-cases-form)
117 (process-cases-form :cross
'(c '(a b
)))
118 '(:b
((c . a
)) ((c . b
)))
121 (addtest (test-process-cases-form)
124 (process-cases-form :cross
'(c '(a b
)) '(d (list 'x
'y
)))
132 (addtest (test-process-cases-form)
135 (process-cases-form :cross
136 '(:b
((a .
1) (b .
3)) ((a .
2) (b .
4)))
137 '(:b
((c . a
) (d . x
)) ((c . b
) (d . y
))))
139 ((A .
1) (B .
3) (C . A
) (D . X
)) ((A .
1) (B .
3) (C . A
) (D . Y
))
140 ((A .
1) (B .
3) (C . B
) (D . X
)) ((A .
1) (B .
3) (C . B
) (D . Y
))
141 ((A .
1) (B .
4) (C . A
) (D . X
)) ((A .
1) (B .
4) (C . A
) (D . Y
))
142 ((A .
1) (B .
4) (C . B
) (D . X
)) ((A .
1) (B .
4) (C . B
) (D . Y
))
143 ((A .
2) (B .
3) (C . A
) (D . X
)) ((A .
2) (B .
3) (C . A
) (D . Y
))
144 ((A .
2) (B .
3) (C . B
) (D . X
)) ((A .
2) (B .
3) (C . B
) (D . Y
))
145 ((A .
2) (B .
4) (C . A
) (D . X
)) ((A .
2) (B .
4) (C . A
) (D . Y
))
146 ((A .
2) (B .
4) (C . B
) (D . X
)) ((A .
2) (B .
4) (C . B
) (D . Y
)))
149 (addtest (test-process-cases-form)
152 (process-cases-form :cross
153 (process-cases-form :map
'(a '(1 2)) '(b '(3 4)))
154 (process-cases-form :map
'(c '(a b
)) '(d '(x y
))))
156 ((A .
1) (B .
3) (C . A
) (D . X
)) ((A .
1) (B .
3) (C . A
) (D . Y
))
157 ((A .
1) (B .
3) (C . B
) (D . X
)) ((A .
1) (B .
3) (C . B
) (D . Y
))
158 ((A .
1) (B .
4) (C . A
) (D . X
)) ((A .
1) (B .
4) (C . A
) (D . Y
))
159 ((A .
1) (B .
4) (C . B
) (D . X
)) ((A .
1) (B .
4) (C . B
) (D . Y
))
160 ((A .
2) (B .
3) (C . A
) (D . X
)) ((A .
2) (B .
3) (C . A
) (D . Y
))
161 ((A .
2) (B .
3) (C . B
) (D . X
)) ((A .
2) (B .
3) (C . B
) (D . Y
))
162 ((A .
2) (B .
4) (C . A
) (D . X
)) ((A .
2) (B .
4) (C . A
) (D . Y
))
163 ((A .
2) (B .
4) (C . B
) (D . X
)) ((A .
2) (B .
4) (C . B
) (D . Y
)))
167 ;;; ---------------------------------------------------------------------------
168 ;;; some simple "real" tests
169 ;;; ---------------------------------------------------------------------------
171 (deftestsuite test-addition
()
173 (:cases
(:map
(a '(1 2 3 4 5))
175 (:test
((ensure-same (+ a b
) 10 :test
'=))))
177 (deftestsuite test-addition
()
179 (:cases
(a '(1 2 3 4 5))
181 (:test
((ensure-same (+ a b
) (+ b a
) :test
'=))))
183 ;;; ---------------------------------------------------------------------------
185 ;;; ---------------------------------------------------------------------------
187 (deftestsuite test-case-generation-simple-helper
()
189 (:cases
(a '(1 2 3)))
190 (:test
(test-1 (push a
*test-scratchpad
*))))
192 (addtest (test-case-generation-simple)
193 single-var-three-cases
194 (let ((tr (run-test (test-case-generation-simple-helper) test-1
)))
195 (ensure-same (length (tests-run tr
)) 3)
196 (ensure-same *test-scratchpad
* '(3 2 1))))
198 ;;; ---------------------------------------------------------------------------
200 (deftestsuite test-case-generation-simple-helper-2
(test-case-generation-simple-helper)
203 (:test
(test-1 (push a
*test-scratchpad
*)
204 (push b
*test-scratchpad
*))))
206 (addtest (test-case-generation-simple)
207 single-var-with-superclass
208 (let ((tr (run-test (test-case-generation-simple-helper-2) test-1
)))
209 (ensure-same (length (tests-run tr
)) 6)
210 (ensure-same *test-scratchpad
* '(1 4 1 5 2 4 2 5 3 4 3 5))))
212 ;;; ---------------------------------------------------------------------------
214 (deftestsuite test-case-generation-simple-helper-3
()
218 (:test
(test-1 (push (list a b
) *test-scratchpad
*))))
220 (addtest (test-case-generation-simple)
221 two-vars-cross-product
222 (let ((tr (run-test (test-case-generation-simple-helper-3) test-1
)))
223 (ensure-same (length (tests-run tr
)) 6)
224 (ensure-same *test-scratchpad
* '((1 4) (1 5) (2 4) (2 5) (3 4) (3 5)))))
226 ;;; ---------------------------------------------------------------------------
228 (deftestsuite test-case-generation-simple-helper-4
()
230 (:cases
(:map
(a (1 2 3))
232 (:test
(test-1 (push (list a b
) *test-scratchpad
*))))
234 (addtest (test-case-generation-simple)
236 (let ((tr (run-test (test-case-generation-simple-helper) test-1
)))
237 (ensure-same (length (tests-run tr
)) 3)
238 (ensure-same *test-scratchpad
* '(3 2 1))))
240 ;;; ---------------------------------------------------------------------------
242 (defun random-integers (count)
243 (loop repeat count collect
244 (variates:integer-random variates
:*random-generator
* -
9 10)))
246 (deftestsuite test-case-generation-simple-helper-5
()
248 (:cases
(a (random-integers 3))
249 (b (random-integers 2)))
250 (:test
(test-1 (push (list a b
) *test-scratchpad
*))))
252 (addtest (test-case-generation-simple)
253 two-vars-cross-product-run-time
254 (let ((tr (run-test (test-case-generation-simple-helper-5) test-1
)))
255 (ensure-same (length (tests-run tr
)) 6)))
257 ;;; ---------------------------------------------------------------------------
259 ;;; ---------------------------------------------------------------------------
261 (deftestsuite test-case-generation-helper-1
()
263 (:cases
(a :exemplars-of fixnum
))
264 (:test
(test-1 (push (list a
) *test-scratchpad
*))))
266 ;;; ---------------------------------------------------------------------------
268 (deftestsuite test-case-generation-helper-2
()
270 (:cases
(a :samples-from standard-normal
))
271 (:test
(test-1 (push (list a
) *test-scratchpad
*))))
273 ;;; ---------------------------------------------------------------------------
275 (deftestsuite test-case-generation-helper-3
()
277 (:cases
(a :samples-from fixnum
))
278 (:test
(test-1 (push (list a
) *test-scratchpad
*))))