3 (in-package :it.bese.FiveAM)
5 (in-suite :it.bese.FiveAM)
8 :description "Suite for tests which should fail."
9 :default-test-args '(:fixture null-fixture :compile-at :run-time))
11 (defmacro with-test-results ((results test-name) &body body)
12 `(let ((,results (with-*test-dribble* nil (run ',test-name))))
15 (def-fixture null-fixture ()
20 (test (is1 :suite test-suite)
28 (test (is2 :suite test-suite :fixture foo)
37 (with-test-results (results is1)
38 (is (= 6 (length results)))
39 (is (every #'test-passed-p results)))
40 (with-test-results (results is2)
41 (is (= 6 (length results)))
42 (is (every #'test-failure-p results))))
44 (test signals/finishes
54 (test (fail1 :suite test-suite)
55 (fail "This is supposed to fail"))
58 (with-test-results (results fail1)
59 (is (= 1 (length results)))
60 (is (test-failure-p (first results)))))
62 ;;;; non top level checks
67 (is (= 1 (incf state)))))
69 ;;;; Test dependencies
71 (test (ok :suite test-suite)
74 (test (not-ok :suite test-suite)
75 (fail "This is supposed to fail."))
77 (test (and1 :depends-on (and ok not-ok) :suite test-suite)
80 (test (and2 :depends-on (and ok) :suite test-suite)
84 (with-test-results (results and1)
85 (is (= 3 (length results)))
86 ;; we should have one skippedw one failed and one passed
87 (is (some #'test-passed-p results))
88 (is (some #'test-skipped-p results))
89 (is (some #'test-failure-p results)))
90 (with-test-results (results and2)
91 (is (= 2 (length results)))
92 (is (every #'test-passed-p results))))
94 (test (or1 :depends-on (or ok not-ok) :suite test-suite)
97 (test (or2 :depends-on (or not-ok ok) :suite test-suite)
101 (with-test-results (results or1)
102 (is (= 2 (length results)))
103 (is (every #'test-passed-p results)))
104 (with-test-results (results or2)
105 (is (= 3 (length results)))
106 (is (= 2 (length (remove-if-not #'test-passed-p results))))))
108 (test (not1 :depends-on (not not-ok) :suite test-suite)
111 (test (not2 :depends-on (not ok) :suite test-suite)
115 (with-test-results (results not1)
116 (is (= 2 (length results)))
117 (is (some #'test-passed-p results))
118 (is (some #'test-failure-p results)))
119 (with-test-results (results not2)
120 (is (= 2 (length results)))
121 (is (some #'test-passed-p results))
122 (is (some #'test-skipped-p results))))
124 (test (nested-logic :depends-on (and ok (not not-ok) (not not-ok))
129 (with-test-results (results nested-logic)
130 (is (= 3 (length results)))
131 (is (= 2 (length (remove-if-not #'test-passed-p results))))
132 (is (= 1 (length (remove-if-not #'test-failure-p results))))))
134 (test (circular-0 :depends-on (and circular-1 circular-2 or1)
136 (fail "we depend on a circular dependency, we should not be tested."))
138 (test (circular-1 :depends-on (and circular-2)
140 (fail "we have a circular depednency, we should not be tested."))
142 (test (circular-2 :depends-on (and circular-1)
144 (fail "we have a circular depednency, we should not be tested."))
147 (signals circular-dependency
149 (signals circular-dependency
151 (signals circular-dependency
155 (for-all ((a (gen-integer)))
158 (test for-all-guarded
159 (for-all ((less (gen-integer))
160 (more (gen-integer) (< less more)))
164 (macrolet ((test-gen-float (type)
165 `(for-all ((unbounded (gen-float :type ',type))
166 (bounded (gen-float :type ',type :bound 42)))
167 (is (typep unbounded ',type))
168 (is (typep bounded ',type))
169 (is (<= (abs bounded) 42)))))
170 (test-gen-float single-float)
171 (test-gen-float short-float)
172 (test-gen-float double-float)
173 (test-gen-float long-float)))
176 (for-all ((c (gen-character)))
178 (for-all ((c (gen-character :code (gen-integer :min 32 :max 40))))
180 (member c (list #\Space #\! #\" #\# #\$ #\% #\& #\' #\())))
183 (for-all ((s (gen-string)))
185 (for-all ((s (gen-string :length (gen-integer :min 0 :max 2))))
186 (is (<= (length s) 2)))
187 (for-all ((s (gen-string :elements (gen-character :code (gen-integer :min 0 :max 0))
188 :length (constantly 2))))
189 (is (= 2 (length s)))
190 (is (every (curry #'char= #\Null) s))))
192 (defun dummy-mv-generator ()
196 (test for-all-destructuring-bind
197 (for-all (((a b) (dummy-mv-generator)))