3 (in-package :it.bese.FiveAM)
5 (in-suite :it.bese.FiveAM)
7 (def-suite test-suite :description "Suite for tests which should fail.")
9 (defmacro with-test-results ((results test-name) &body body)
10 `(let ((,results (with-*test-dribble* nil (run ',test-name))))
15 (test (is1 :suite test-suite)
23 (test (is2 :suite test-suite)
32 (with-test-results (results is1)
33 (is (= 6 (length results)))
34 (is (every #'test-passed-p results)))
35 (with-test-results (results is2)
36 (is (= 6 (length results)))
37 (is (every #'test-failure-p results))))
39 (test signals/finishes
49 (test (fail1 :suite test-suite)
50 (fail "This is supposed to fail"))
53 (with-test-results (results fail1)
54 (is (= 1 (length results)))
55 (is (test-failure-p (first results)))))
57 ;;;; non top level checks
62 (is (= 1 (incf state)))))
64 ;;;; Test dependencies
66 (test (ok :suite test-suite)
69 (test (not-ok :suite test-suite)
70 (fail "This is supposed to fail."))
72 (test (and1 :depends-on (and ok not-ok) :suite test-suite)
75 (test (and2 :depends-on (and ok) :suite test-suite)
79 (with-test-results (results and1)
80 (is (= 3 (length results)))
81 ;; we should have one skippedw one failed and one passed
82 (is (some #'test-passed-p results))
83 (is (some #'test-skipped-p results))
84 (is (some #'test-failure-p results)))
85 (with-test-results (results and2)
86 (is (= 2 (length results)))
87 (is (every #'test-passed-p results))))
89 (test (or1 :depends-on (or ok not-ok) :suite test-suite)
92 (test (or2 :depends-on (or not-ok ok) :suite test-suite)
96 (with-test-results (results or1)
97 (is (= 2 (length results)))
98 (is (every #'test-passed-p results)))
99 (with-test-results (results or2)
100 (is (= 3 (length results)))
101 (is (= 2 (length (remove-if-not #'test-passed-p results))))))
103 (test (not1 :depends-on (not not-ok) :suite test-suite)
106 (test (not2 :depends-on (not ok) :suite test-suite)
110 (with-test-results (results not1)
111 (is (= 2 (length results)))
112 (is (some #'test-passed-p results))
113 (is (some #'test-failure-p results)))
114 (with-test-results (results not2)
115 (is (= 2 (length results)))
116 (is (some #'test-passed-p results))
117 (is (some #'test-skipped-p results))))
119 (test (nested-logic :depends-on (and ok (not not-ok) (not not-ok))
124 (with-test-results (results nested-logic)
125 (is (= 3 (length results)))
126 (is (= 2 (length (remove-if-not #'test-passed-p results))))
127 (is (= 1 (length (remove-if-not #'test-failure-p results))))))
129 (test (circular-0 :depends-on (and circular-1 circular-2 or1)
131 (fail "we depend on a circular dependency, we should not be tested."))
133 (test (circular-1 :depends-on (and circular-2)
135 (fail "we have a circular depednency, we should not be tested."))
137 (test (circular-2 :depends-on (and circular-1)
139 (fail "we have a circular depednency, we should not be tested."))
142 (signals circular-dependency
144 (signals circular-dependency
146 (signals circular-dependency
150 (for-all ((a (gen-integer)))
153 (test for-all-guarded
154 (for-all ((less (gen-integer))
155 (more (gen-integer) (< less more)))
159 (macrolet ((test-gen-float (type)
160 `(for-all ((unbounded (gen-float :type ',type))
161 (bounded (gen-float :type ',type :bound 42)))
162 (is (typep unbounded ',type))
163 (is (typep bounded ',type))
164 (is (<= (abs bounded) 42)))))
165 (test-gen-float single-float)
166 (test-gen-float short-float)
167 (test-gen-float double-float)
168 (test-gen-float long-float)))
171 (for-all ((c (gen-character)))
173 (for-all ((c (gen-character :code (gen-integer :min 32 :max 40))))
175 (member c (list #\Space #\! #\" #\# #\$ #\% #\& #\' #\())))
178 (for-all ((s (gen-string)))
180 (for-all ((s (gen-string :length (gen-integer :min 0 :max 2))))
181 (is (<= (length s) 2)))
182 (for-all ((s (gen-string :elements (gen-character :code (gen-integer :min 0 :max 0))
183 :length (constantly 2))))
184 (is (= 2 (length s)))
185 (is (every (curry #'char= #\Null) s))))
187 (defun dummy-mv-generator ()
191 (test for-all-destructuring-bind
192 (for-all (((a b) (dummy-mv-generator)))