clucumber 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +4 -9
- data/lib/clucumber/clucumber-bootstrap.lisp +32 -0
- data/lib/clucumber/vendor/cl-interpol/alias.lisp +55 -0
- data/lib/clucumber/vendor/cl-interpol/cl-interpol.asd +56 -0
- data/lib/clucumber/vendor/cl-interpol/load.lisp +53 -0
- data/lib/clucumber/vendor/cl-interpol/packages.lisp +40 -0
- data/lib/clucumber/vendor/cl-interpol/read.lisp +716 -0
- data/lib/clucumber/vendor/cl-interpol/specials.lisp +113 -0
- data/lib/clucumber/vendor/cl-interpol/test/packages.lisp +34 -0
- data/lib/clucumber/vendor/cl-interpol/test/tests.lisp +128 -0
- data/lib/clucumber/vendor/cl-interpol/test.lisp +177 -0
- data/lib/clucumber/vendor/cl-interpol/test2.lisp +6254 -0
- data/lib/clucumber/vendor/cl-interpol/unicode.lisp +13912 -0
- data/lib/clucumber/vendor/cl-interpol/util.lisp +122 -0
- data/lib/clucumber/vendor/cl-ppcre/api.lisp +1262 -0
- data/lib/clucumber/vendor/cl-ppcre/charmap.lisp +152 -0
- data/lib/clucumber/vendor/cl-ppcre/charset.lisp +242 -0
- data/lib/clucumber/vendor/cl-ppcre/chartest.lisp +98 -0
- data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-test.asd +34 -0
- data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/packages.lisp +38 -0
- data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/resolver.lisp +61 -0
- data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode.asd +58 -0
- data/lib/clucumber/vendor/cl-ppcre/cl-ppcre.asd +79 -0
- data/lib/clucumber/vendor/cl-ppcre/closures.lisp +471 -0
- data/lib/clucumber/vendor/cl-ppcre/convert.lisp +875 -0
- data/lib/clucumber/vendor/cl-ppcre/errors.lisp +84 -0
- data/lib/clucumber/vendor/cl-ppcre/lexer.lisp +737 -0
- data/lib/clucumber/vendor/cl-ppcre/lispworks-defsystem.lisp +57 -0
- data/lib/clucumber/vendor/cl-ppcre/load.lisp +67 -0
- data/lib/clucumber/vendor/cl-ppcre/optimize.lisp +578 -0
- data/lib/clucumber/vendor/cl-ppcre/packages.lisp +68 -0
- data/lib/clucumber/vendor/cl-ppcre/parser.lisp +319 -0
- data/lib/clucumber/vendor/cl-ppcre/ppcre-tests.lisp +269 -0
- data/lib/clucumber/vendor/cl-ppcre/regex-class-util.lisp +555 -0
- data/lib/clucumber/vendor/cl-ppcre/regex-class.lisp +259 -0
- data/lib/clucumber/vendor/cl-ppcre/repetition-closures.lisp +833 -0
- data/lib/clucumber/vendor/cl-ppcre/scanner.lisp +506 -0
- data/lib/clucumber/vendor/cl-ppcre/specials.lisp +172 -0
- data/lib/clucumber/vendor/cl-ppcre/test/packages.lisp +37 -0
- data/lib/clucumber/vendor/cl-ppcre/test/perl-tests.lisp +150 -0
- data/lib/clucumber/vendor/cl-ppcre/test/tests.lisp +159 -0
- data/lib/clucumber/vendor/cl-ppcre/test/unicode-tests.lisp +80 -0
- data/lib/clucumber/vendor/cl-ppcre/util.lisp +201 -0
- data/lib/clucumber/vendor/cl-unicode/alias.lisp +135 -0
- data/lib/clucumber/vendor/cl-unicode/api.lisp +412 -0
- data/lib/clucumber/vendor/cl-unicode/build/char-info.lisp +133 -0
- data/lib/clucumber/vendor/cl-unicode/build/dump.lisp +239 -0
- data/lib/clucumber/vendor/cl-unicode/build/read.lisp +280 -0
- data/lib/clucumber/vendor/cl-unicode/build/util.lisp +182 -0
- data/lib/clucumber/vendor/cl-unicode/cl-unicode.asd +90 -0
- data/lib/clucumber/vendor/cl-unicode/conditions.lisp +54 -0
- data/lib/clucumber/vendor/cl-unicode/derived.lisp +120 -0
- data/lib/clucumber/vendor/cl-unicode/hash-tables.lisp +20 -0
- data/lib/clucumber/vendor/cl-unicode/lists.lisp +10 -0
- data/lib/clucumber/vendor/cl-unicode/methods.lisp +15 -0
- data/lib/clucumber/vendor/cl-unicode/packages.lisp +76 -0
- data/lib/clucumber/vendor/cl-unicode/specials.lisp +135 -0
- data/lib/clucumber/vendor/cl-unicode/test/packages.lisp +34 -0
- data/lib/clucumber/vendor/cl-unicode/test/tests.lisp +150 -0
- data/lib/clucumber/vendor/cl-unicode/test-functions.lisp +94 -0
- data/lib/clucumber/vendor/cl-unicode/util.lisp +274 -0
- data/lib/clucumber/vendor/lift/compare/fiveam-tests.lisp +14 -0
- data/lib/clucumber/vendor/lift/compare/lift-tests.lisp +13 -0
- data/lib/clucumber/vendor/lift/compare/rt-tests.lisp +16 -0
- data/lib/clucumber/vendor/lift/compare/xlunit-tests.lisp +15 -0
- data/lib/clucumber/vendor/lift/dev/changes.lisp +61 -0
- data/lib/clucumber/vendor/lift/dev/config.lisp +354 -0
- data/lib/clucumber/vendor/lift/dev/copy-file.lisp +117 -0
- data/lib/clucumber/vendor/lift/dev/introspection.lisp +232 -0
- data/lib/clucumber/vendor/lift/dev/lift-interface.lisp +56 -0
- data/lib/clucumber/vendor/lift/dev/lift-notes.lisp +202 -0
- data/lib/clucumber/vendor/lift/dev/lift-randomized.lisp +45 -0
- data/lib/clucumber/vendor/lift/dev/lift.lisp +2383 -0
- data/lib/clucumber/vendor/lift/dev/macros.lisp +229 -0
- data/lib/clucumber/vendor/lift/dev/measuring.lisp +156 -0
- data/lib/clucumber/vendor/lift/dev/packages.lisp +161 -0
- data/lib/clucumber/vendor/lift/dev/port.lisp +151 -0
- data/lib/clucumber/vendor/lift/dev/prototypes.lisp +282 -0
- data/lib/clucumber/vendor/lift/dev/random-testing.lisp +124 -0
- data/lib/clucumber/vendor/lift/dev/report-locations.lisp +13 -0
- data/lib/clucumber/vendor/lift/dev/reports.lisp +916 -0
- data/lib/clucumber/vendor/lift/dev/utilities.lisp +242 -0
- data/lib/clucumber/vendor/lift/docs/package.lisp +6 -0
- data/lib/clucumber/vendor/lift/docs/setup.lisp +17 -0
- data/lib/clucumber/vendor/lift/examples/basic-examples.lisp +289 -0
- data/lib/clucumber/vendor/lift/examples/random-testing.lisp +32 -0
- data/lib/clucumber/vendor/lift/lift-documentation.asd +28 -0
- data/lib/clucumber/vendor/lift/lift-test.asd +35 -0
- data/lib/clucumber/vendor/lift/lift.asd +77 -0
- data/lib/clucumber/vendor/lift/test/equality-tests.lisp +40 -0
- data/lib/clucumber/vendor/lift/test/finding-tests.lisp +32 -0
- data/lib/clucumber/vendor/lift/test/lift-test.lisp +783 -0
- data/lib/clucumber/vendor/lift/test/order-of-operations.lisp +54 -0
- data/lib/clucumber/vendor/lift/test/packages.lisp +17 -0
- data/lib/clucumber/vendor/lift/test/test-config-files.lisp +20 -0
- data/lib/clucumber/vendor/lift/test/test-dynamic-variables.lisp +57 -0
- data/lib/clucumber/vendor/lift/test/test-maximum-problems.lisp +74 -0
- data/lib/clucumber/vendor/lift/test/test-prototypes.lisp +278 -0
- data/lib/clucumber/vendor/lift/test/test-timeout.lisp +37 -0
- data/lib/clucumber/vendor/lift/test/tests-in-progress.lisp +62 -0
- data/lib/clucumber/vendor/lift/test/testsuite-expects.lisp +60 -0
- data/lib/clucumber/vendor/lift/timeout/package.lisp +13 -0
- data/lib/clucumber/vendor/lift/timeout/with-timeout.lisp +123 -0
- data/lib/clucumber/vendor/lift/website/stuff/Temp.lisp +34 -0
- data/lib/clucumber/vendor/st-json/st-json.asd +3 -0
- data/lib/clucumber/vendor/st-json/st-json.lisp +310 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/backtrace.lisp +127 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/fallback.lisp +10 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/map-backtrace.lisp +103 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/mucking.lisp +75 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/packages.lisp +13 -0
- data/lib/clucumber/vendor/trivial-backtrace/dev/utilities.lisp +104 -0
- data/lib/clucumber/vendor/trivial-backtrace/test/packages.lisp +5 -0
- data/lib/clucumber/vendor/trivial-backtrace/test/test-setup.lisp +4 -0
- data/lib/clucumber/vendor/trivial-backtrace/test/tests.lisp +16 -0
- data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace-test.asd +22 -0
- data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace.asd +35 -0
- data/lib/clucumber/vendor/usocket/backend/allegro.lisp +199 -0
- data/lib/clucumber/vendor/usocket/backend/armedbear.lisp +491 -0
- data/lib/clucumber/vendor/usocket/backend/clisp.lisp +260 -0
- data/lib/clucumber/vendor/usocket/backend/cmucl.lisp +266 -0
- data/lib/clucumber/vendor/usocket/backend/lispworks.lisp +741 -0
- data/lib/clucumber/vendor/usocket/backend/mcl.lisp +369 -0
- data/lib/clucumber/vendor/usocket/backend/openmcl.lisp +206 -0
- data/lib/clucumber/vendor/usocket/backend/sbcl.lisp +424 -0
- data/lib/clucumber/vendor/usocket/backend/scl.lisp +261 -0
- data/lib/clucumber/vendor/usocket/condition.lisp +227 -0
- data/lib/clucumber/vendor/usocket/package.lisp +82 -0
- data/lib/clucumber/vendor/usocket/server.lisp +45 -0
- data/lib/clucumber/vendor/usocket/test/package.lisp +13 -0
- data/lib/clucumber/vendor/usocket/test/test-usocket.lisp +166 -0
- data/lib/clucumber/vendor/usocket/usocket-test.asd +26 -0
- data/lib/clucumber/vendor/usocket/usocket.asd +37 -0
- data/lib/clucumber/vendor/usocket/usocket.lisp +542 -0
- data/lib/clucumber/vendor/usocket/vendor/kqueue.lisp +1 -0
- data/lib/clucumber/vendor/usocket/vendor/split-sequence.lisp +245 -0
- data/lib/clucumber.rb +29 -7
- metadata +151 -5
@@ -0,0 +1,282 @@
|
|
1
|
+
;;;-*- Mode: Lisp; Package: LIFT -*-
|
2
|
+
|
3
|
+
(in-package #:lift)
|
4
|
+
|
5
|
+
(pushnew :cases *deftest-clauses*)
|
6
|
+
|
7
|
+
(add-code-block
|
8
|
+
:cases 2 :methods
|
9
|
+
(lambda () (def :cases))
|
10
|
+
'((setf (def :cases) (cleanup-parsed-parameter value)))
|
11
|
+
'build-cases-method)
|
12
|
+
|
13
|
+
(defun build-cases-method ()
|
14
|
+
(when (atom (car (def :cases)))
|
15
|
+
(setf (def :cases) (list (def :cases))))
|
16
|
+
;(spy (def :cases))
|
17
|
+
(let ((cases (standardize-cases-form (def :cases))))
|
18
|
+
`(defmethod initialize-prototypes :after ((test ,(def :testsuite-name)))
|
19
|
+
(setf (prototypes test)
|
20
|
+
(rest (process-cases-form
|
21
|
+
,(first cases)
|
22
|
+
,@(mapcar (lambda (a) `',a) (rest cases))))))))
|
23
|
+
|
24
|
+
;; goal is spec := (<tag> <spec>+)
|
25
|
+
;; spec := (<var value>+)
|
26
|
+
(defun standardize-cases-form (cases)
|
27
|
+
(cond ((atom (first cases))
|
28
|
+
(cond ((valid-tag-p (first cases))
|
29
|
+
`(,(first cases) ,@(mapcar #'standardize-cases-form (rest cases))))
|
30
|
+
(t
|
31
|
+
cases)))
|
32
|
+
((and (length-1-list-p cases)
|
33
|
+
(consp (first cases))
|
34
|
+
(valid-tag-p (first (first cases))))
|
35
|
+
(standardize-cases-form (first cases)))
|
36
|
+
(t
|
37
|
+
`(:cross ,@(mapcar #'standardize-cases-form cases)))))
|
38
|
+
|
39
|
+
;;; ---------------------------------------------------------------------------
|
40
|
+
|
41
|
+
(defun check-subcases (cases)
|
42
|
+
(cond ((not (valid-tag-p (first cases)))
|
43
|
+
`(,(default-cases-tag) ,@(mapcar #'standardize-cases-form cases)))
|
44
|
+
(t
|
45
|
+
(mapcar #'standardize-cases-form cases))))
|
46
|
+
|
47
|
+
;;; ---------------------------------------------------------------------------
|
48
|
+
|
49
|
+
(defun default-cases-tag ()
|
50
|
+
:cross)
|
51
|
+
|
52
|
+
;;; ---------------------------------------------------------------------------
|
53
|
+
|
54
|
+
(defun valid-tag-p (tag)
|
55
|
+
(member tag '(:map :cross)))
|
56
|
+
|
57
|
+
;;; ---------------------------------------------------------------------------
|
58
|
+
|
59
|
+
(defmethod process-cases-form :around ((type t) &rest forms)
|
60
|
+
(apply #'call-next-method type (if (atom (car forms))
|
61
|
+
(list forms) forms)))
|
62
|
+
|
63
|
+
;;; ---------------------------------------------------------------------------
|
64
|
+
|
65
|
+
(defmethod process-cases-form ((type t) &rest forms)
|
66
|
+
(cond ((atom (first type))
|
67
|
+
(apply #'process-cases-form (first type) (append (rest type) forms)))
|
68
|
+
(t (apply #'process-cases-form :cross (append type forms)))))
|
69
|
+
|
70
|
+
#+Old
|
71
|
+
(defmethod process-cases-form ((type (eql :map)) &rest forms)
|
72
|
+
(let ((vars (mapcar #'car forms))
|
73
|
+
(values (mapcar #'rest forms)))
|
74
|
+
`(let (,@(mapcar (lambda (var value) `(,var ,@value))
|
75
|
+
vars values))
|
76
|
+
(mapcar (lambda ,vars
|
77
|
+
(list ,@(mapcar (lambda (var) `(cons ',var ,var)) vars)))
|
78
|
+
,@vars))))
|
79
|
+
|
80
|
+
;;; ---------------------------------------------------------------------------
|
81
|
+
|
82
|
+
(defmethod process-cases-form ((type (eql :map)) &rest forms)
|
83
|
+
(let ((vars (ensure-list (flatten (vars-from-assignment forms))))
|
84
|
+
(values (values-from-assignment forms)))
|
85
|
+
`(:b ,@(apply #'mapcar
|
86
|
+
(lambda (&rest args)
|
87
|
+
(mapcar (lambda (var value)
|
88
|
+
(cons var value))
|
89
|
+
vars args))
|
90
|
+
values))))
|
91
|
+
|
92
|
+
;;; ---------------------------------------------------------------------------
|
93
|
+
|
94
|
+
(defmethod process-cases-form ((type (eql :cross)) &rest forms)
|
95
|
+
(let ((vars (ensure-list (flatten (vars-from-assignment forms))))
|
96
|
+
(values (values-from-assignment forms))
|
97
|
+
(result nil))
|
98
|
+
(iterate-over-indexes
|
99
|
+
(mapcar #'length values)
|
100
|
+
(lambda (indexes)
|
101
|
+
(let ((datum nil))
|
102
|
+
(mapcar (lambda (name var index)
|
103
|
+
(push (cons name (elt var index)) datum))
|
104
|
+
vars
|
105
|
+
values
|
106
|
+
indexes)
|
107
|
+
(push (nreverse datum) result)))
|
108
|
+
:right)
|
109
|
+
`(:b ,@(nreverse result))))
|
110
|
+
|
111
|
+
;;; ---------------------------------------------------------------------------
|
112
|
+
|
113
|
+
(defun vars-from-assignment (assignment)
|
114
|
+
(cond ((is-binding-p assignment)
|
115
|
+
(mapcar #'car (second assignment)))
|
116
|
+
((metatilities:dotted-pair-p assignment)
|
117
|
+
(car assignment))
|
118
|
+
((atom (car assignment))
|
119
|
+
(car assignment))
|
120
|
+
((length-1-list-p assignment)
|
121
|
+
(vars-from-assignment (first assignment)))
|
122
|
+
(t (loop for assignment in assignment collect
|
123
|
+
(vars-from-assignment assignment)))))
|
124
|
+
|
125
|
+
;;; ---------------------------------------------------------------------------
|
126
|
+
|
127
|
+
(defun values-from-assignment (assignment)
|
128
|
+
(cond ((is-binding-p assignment)
|
129
|
+
(apply #'mapcar (lambda (&rest bindings)
|
130
|
+
(mapcar (lambda (binding)
|
131
|
+
(cdr binding))
|
132
|
+
bindings))
|
133
|
+
(rest assignment)))
|
134
|
+
((dotted-pair-p assignment)
|
135
|
+
(cdr assignment))
|
136
|
+
((atom (car assignment))
|
137
|
+
(list (eval (first (rest assignment)))))
|
138
|
+
(t
|
139
|
+
(loop for assignment in assignment nconc
|
140
|
+
(ensure-list (values-from-assignment assignment))))))
|
141
|
+
|
142
|
+
;;; ---------------------------------------------------------------------------
|
143
|
+
|
144
|
+
(defun is-binding-p (assignment)
|
145
|
+
(eq (first assignment) :b))
|
146
|
+
|
147
|
+
|
148
|
+
#|
|
149
|
+
|
150
|
+
|
151
|
+
(export '(map-prototypes-of
|
152
|
+
prototypes-of
|
153
|
+
prototype-of
|
154
|
+
prototype-exists-p))
|
155
|
+
|
156
|
+
;;; ---------------------------------------------------------------------------
|
157
|
+
;;; API
|
158
|
+
;;; ---------------------------------------------------------------------------
|
159
|
+
|
160
|
+
(defgeneric map-prototypes-of (fn thing)
|
161
|
+
(:documentation ""))
|
162
|
+
|
163
|
+
;;; ---------------------------------------------------------------------------
|
164
|
+
|
165
|
+
(defgeneric prototypes-of (thing)
|
166
|
+
(:documentation ""))
|
167
|
+
|
168
|
+
;;; ---------------------------------------------------------------------------
|
169
|
+
|
170
|
+
(defgeneric prototype-of (thing)
|
171
|
+
(:documentation ""))
|
172
|
+
|
173
|
+
;;; ---------------------------------------------------------------------------
|
174
|
+
|
175
|
+
(defgeneric prototype-exists-p (thing)
|
176
|
+
(:documentation ""))
|
177
|
+
|
178
|
+
;;; ---------------------------------------------------------------------------
|
179
|
+
;;; implementation
|
180
|
+
;;; ---------------------------------------------------------------------------
|
181
|
+
|
182
|
+
(defmethod map-prototypes-of :around (fn thing)
|
183
|
+
(declare (ignore fn))
|
184
|
+
(when (prototype-exists-p thing)
|
185
|
+
(call-next-method)))
|
186
|
+
|
187
|
+
;;; ---------------------------------------------------------------------------
|
188
|
+
|
189
|
+
(defmethod map-prototypes-of (fn (thing standard-class))
|
190
|
+
(map-subclass-prototypes fn thing))
|
191
|
+
|
192
|
+
;;; ---------------------------------------------------------------------------
|
193
|
+
|
194
|
+
(defmethod map-prototypes-of (fn (thing built-in-class))
|
195
|
+
(map-subclass-prototypes fn thing))
|
196
|
+
|
197
|
+
;;; ---------------------------------------------------------------------------
|
198
|
+
|
199
|
+
(defun map-subclass-prototypes (fn thing)
|
200
|
+
(mopu:map-subclasses thing
|
201
|
+
(lambda (subclass)
|
202
|
+
(when (prototype-exists-p subclass)
|
203
|
+
(funcall fn (prototype-of subclass)))))
|
204
|
+
(values))
|
205
|
+
|
206
|
+
;;; ---------------------------------------------------------------------------
|
207
|
+
|
208
|
+
(defmethod prototypes-of (thing)
|
209
|
+
(containers:collect-using 'map-prototypes-of nil thing))
|
210
|
+
|
211
|
+
;;; ---------------------------------------------------------------------------
|
212
|
+
|
213
|
+
(defmethod prototype-exists-p (thing)
|
214
|
+
;; the expensive way to see if a prototype exists is to try and make one
|
215
|
+
;; and see if it works...
|
216
|
+
(handler-case
|
217
|
+
(let ((creator-method (compute-applicable-methods #'prototype-of (list thing))))
|
218
|
+
(when creator-method
|
219
|
+
(let ((x (prototype-of thing)))
|
220
|
+
(declare (optimize (safety 3) (debug 3) (speed 0) (space 0)))
|
221
|
+
x
|
222
|
+
(values t))))
|
223
|
+
(error (c) (inspect c) nil)))
|
224
|
+
|
225
|
+
;;; ---------------------------------------------------------------------------
|
226
|
+
|
227
|
+
(defmethod prototype-of ((thing standard-class))
|
228
|
+
(allocate-instance thing))
|
229
|
+
|
230
|
+
;;; ---------------------------------------------------------------------------
|
231
|
+
|
232
|
+
(defmethod prototype-of ((thing (eql 'fixnum)))
|
233
|
+
(variates:integer-random variates:*random-generator* -10 10))
|
234
|
+
|
235
|
+
|
236
|
+
|#
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
(defmethod more-prototypes-p :before ((testsuite test-mixin))
|
241
|
+
(setf (current-step testsuite) 'more-prototypes-p))
|
242
|
+
|
243
|
+
;;; ---------------------------------------------------------------------------
|
244
|
+
|
245
|
+
(defmethod initialize-prototypes :before ((testsuite test-mixin))
|
246
|
+
(setf (current-step testsuite) 'initialize-prototypes))
|
247
|
+
|
248
|
+
;;; ---------------------------------------------------------------------------
|
249
|
+
|
250
|
+
(defmethod next-prototype :before ((testsuite test-mixin))
|
251
|
+
(setf (current-step testsuite) 'next-prototype))
|
252
|
+
|
253
|
+
;;; ---------------------------------------------------------------------------
|
254
|
+
|
255
|
+
(defmethod testsuite-teardown :before ((testsuite test-mixin))
|
256
|
+
(setf (current-step testsuite) 'testsuite-teardown))
|
257
|
+
|
258
|
+
;;; ---------------------------------------------------------------------------
|
259
|
+
|
260
|
+
(defmethod start-test :before
|
261
|
+
((result test-result) (testsuite test-mixin) method-name)
|
262
|
+
(declare (ignore method-name))
|
263
|
+
(setf (current-step testsuite) 'start-test))
|
264
|
+
|
265
|
+
;;; ---------------------------------------------------------------------------
|
266
|
+
|
267
|
+
(defmethod end-test :before
|
268
|
+
((result test-result) (testsuite test-mixin) method-name)
|
269
|
+
(declare (ignore method-name))
|
270
|
+
(setf (current-step testsuite) 'end-test))
|
271
|
+
|
272
|
+
;;; ---------------------------------------------------------------------------
|
273
|
+
|
274
|
+
(defmethod setup-test :before ((testsuite test-mixin))
|
275
|
+
(setf (current-step testsuite) 'setup-test))
|
276
|
+
|
277
|
+
;;; ---------------------------------------------------------------------------
|
278
|
+
|
279
|
+
#+Ignore
|
280
|
+
(defmethod teardown-test :before ((testsuite test-mixin))
|
281
|
+
(setf (current-step testsuite) 'teardown-test))
|
282
|
+
|
@@ -0,0 +1,124 @@
|
|
1
|
+
(in-package #:lift)
|
2
|
+
|
3
|
+
;; we redefine the class and possibly method each time, ick.
|
4
|
+
|
5
|
+
(define-condition ensure-random-cases-failure (test-condition)
|
6
|
+
((total :initarg :total :initform 0)
|
7
|
+
(problems :initarg :problems :initform nil))
|
8
|
+
(:report (lambda (condition stream)
|
9
|
+
(format stream "Ensure-random-cases: ~d out of ~d failed. Failing values are: ~{~% ~s~^, ~}"
|
10
|
+
(length (slot-value condition 'problems))
|
11
|
+
(slot-value condition 'total)
|
12
|
+
(slot-value condition 'problems)))))
|
13
|
+
|
14
|
+
(defgeneric random-instance-for-suite (thing suite))
|
15
|
+
|
16
|
+
(defmacro defrandom-instance (instance-type suite &body body)
|
17
|
+
`(progn
|
18
|
+
(defclass ,instance-type () ())
|
19
|
+
(defvar ,(intern (format nil "+~a+" instance-type) :lift)
|
20
|
+
(make-instance ',instance-type))
|
21
|
+
(defmethod random-instance-for-suite
|
22
|
+
((thing ,instance-type) (suite ,(if suite suite t)))
|
23
|
+
,@body)))
|
24
|
+
|
25
|
+
(defmacro ensure-random-cases (count (&rest vars-and-types)
|
26
|
+
&body body)
|
27
|
+
(let ((problems (gensym)))
|
28
|
+
(flet ((intern-type (type)
|
29
|
+
(intern (format nil "+~a+" type) :lift)))
|
30
|
+
`(let ((,problems nil))
|
31
|
+
(loop repeat ,count do
|
32
|
+
(let (,@(mapcar
|
33
|
+
(lambda (var-and-type)
|
34
|
+
`(,(first var-and-type)
|
35
|
+
(random-instance-for-suite
|
36
|
+
,(intern-type (second var-and-type))
|
37
|
+
*current-test*)))
|
38
|
+
vars-and-types))
|
39
|
+
(restart-case
|
40
|
+
(progn ,@body
|
41
|
+
(princ #\. *debug-io*))
|
42
|
+
(ensure-failed (cond)
|
43
|
+
(declare (ignorable cond))
|
44
|
+
(princ #\* *debug-io*)
|
45
|
+
(push (list ,@(mapcar
|
46
|
+
(lambda (var-and-type)
|
47
|
+
`(list ',(first var-and-type)
|
48
|
+
,(first var-and-type)))
|
49
|
+
vars-and-types)) ,problems)))))
|
50
|
+
(when ,problems
|
51
|
+
(let ((condition (make-condition
|
52
|
+
'ensure-random-cases-failure
|
53
|
+
:total ,count
|
54
|
+
:problems ,problems)))
|
55
|
+
(if (find-restart 'ensure-failed)
|
56
|
+
(invoke-restart 'ensure-failed condition)
|
57
|
+
(warn condition))))))))
|
58
|
+
|
59
|
+
(defmacro ensure-random-cases+ (count (&rest vars) (&rest case-form)
|
60
|
+
&body body)
|
61
|
+
(let ((total (gensym))
|
62
|
+
(problems (gensym)))
|
63
|
+
`(let ((,problems nil) (,total 0))
|
64
|
+
(loop repeat ,count do
|
65
|
+
(incf ,total)
|
66
|
+
(destructuring-bind ,vars ,case-form
|
67
|
+
(restart-case
|
68
|
+
(progn ,@body)
|
69
|
+
(ensure-failed (cond)
|
70
|
+
(declare (ignore cond))
|
71
|
+
(push (list ,@vars) ,problems)))))
|
72
|
+
(when ,problems
|
73
|
+
(let ((condition (make-condition
|
74
|
+
'ensure-random-cases-failure
|
75
|
+
:total ,total
|
76
|
+
:problems ,problems)))
|
77
|
+
(if (find-restart 'ensure-failed)
|
78
|
+
(invoke-restart 'ensure-failed condition)
|
79
|
+
(warn condition)))))))
|
80
|
+
|
81
|
+
;;; merge with deftestsuite macro
|
82
|
+
(pushnew :random-instance *deftest-clauses*)
|
83
|
+
|
84
|
+
(add-code-block
|
85
|
+
:random-instance 2 :methods
|
86
|
+
(lambda () (def :random-instances))
|
87
|
+
'((push (cleanup-parsed-parameter value) (def :random-instances)))
|
88
|
+
'build-random-instances-method)
|
89
|
+
|
90
|
+
(defun build-random-instances-method ()
|
91
|
+
`(let (#+allegro
|
92
|
+
(excl:*redefinition-warnings* nil))
|
93
|
+
,@(mapcar (lambda (instance)
|
94
|
+
(let ((atype (first instance))
|
95
|
+
(body (second instance)))
|
96
|
+
`(defrandom-instance ,atype test-mixin ,body)))
|
97
|
+
(def :random-instances))))
|
98
|
+
|
99
|
+
(defgeneric random-number (suite min max))
|
100
|
+
|
101
|
+
(defgeneric random-element (suite sequence))
|
102
|
+
|
103
|
+
(defmethod random-number (suite min max)
|
104
|
+
(declare (ignore suite))
|
105
|
+
(+ min (random (- max min))))
|
106
|
+
|
107
|
+
(defmethod random-element (suite sequence)
|
108
|
+
(elt sequence (random-number suite 0 (1- (length sequence)))))
|
109
|
+
|
110
|
+
(defrandom-instance an-integer test-mixin
|
111
|
+
(random-number suite -100 100))
|
112
|
+
|
113
|
+
(defrandom-instance a-single-float test-mixin
|
114
|
+
(random-number suite -100s0 100.0s0))
|
115
|
+
|
116
|
+
(defrandom-instance a-double-float test-mixin
|
117
|
+
(random-number suite -100d0 100.0d0))
|
118
|
+
|
119
|
+
(defrandom-instance a-symbol test-mixin
|
120
|
+
(random-element suite '(a hello a-c d_f |MiXeD|
|
121
|
+
-2<>#$%#)))
|
122
|
+
|
123
|
+
|
124
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
(in-package #:lift)
|
2
|
+
|
3
|
+
(defmethod generate-report-summary-pathname :around ()
|
4
|
+
(let ((basepath (call-next-method)))
|
5
|
+
(add-implementation-specific-directory-name basepath)))
|
6
|
+
|
7
|
+
(defun add-implementation-specific-directory-name (basepath)
|
8
|
+
(merge-pathnames
|
9
|
+
(make-pathname
|
10
|
+
:directory `(:relative
|
11
|
+
,(asdf::implementation-specific-directory-name)))
|
12
|
+
basepath))
|
13
|
+
|