X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=t%2Ftests.lisp;h=27b42294e9658e6dbfd99d327e051bdcc31887b7;hb=e7f192be4e9a88bd0caf8314ffb2850dfa66b488;hp=0b95b8c4aaa9310ca45f21138cec78f1d6183be6;hpb=f41aacc9b41270d2b0aef60a85aaf57f40131963;p=fiveam.git diff --git a/t/tests.lisp b/t/tests.lisp index 0b95b8c..27b4229 100644 --- a/t/tests.lisp +++ b/t/tests.lisp @@ -4,7 +4,9 @@ (in-suite :it.bese.fiveam) -(def-suite test-suite :description "Suite for tests which should fail.") +(def-suite test-suite + :description "Suite for tests which should fail." + :in nil) (defmacro with-test-results ((results test-name) &body body) `(let ((,results (with-*test-dribble* nil (run ',test-name)))) @@ -130,15 +132,15 @@ (is (= 1 (length (remove-if-not #'test-failure-p results)))))) (def-test circular-0 (:depends-on (and circular-1 circular-2 or1) - :suite test-suite) + :suite test-suite) (fail "we depend on a circular dependency, we should not be tested.")) (def-test circular-1 (:depends-on (and circular-2) - :suite test-suite) + :suite test-suite) (fail "we have a circular depednency, we should not be tested.")) (def-test circular-2 (:depends-on (and circular-1) - :suite test-suite) + :suite test-suite) (fail "we have a circular depednency, we should not be tested.")) (def-test circular () @@ -150,19 +152,19 @@ (run 'circular-2))) -(def-suite before-test-suite :description "Suite for before test") +(def-suite before-test-suite :description "Suite for before test" :in nil) (def-test before-0 (:suite before-test-suite) (pass)) (def-test before-1 (:depends-on (:before before-0) - :suite before-test-suite) + :suite before-test-suite) (fail)) -(def-suite before-test-suite-2 :description "Suite for before test") +(def-suite before-test-suite-2 :description "Suite for before test" :in nil) (def-test before-2 (:depends-on (:before before-3) - :suite before-test-suite-2) + :suite before-test-suite-2) (pass)) (def-test before-3 (:suite before-test-suite-2) @@ -227,7 +229,11 @@ (test-gen-float single-float) (test-gen-float short-float) (test-gen-float double-float) - (test-gen-float long-float))) + (test-gen-float long-float) + + (for-all ((value (gen-float :type 'single-float :min 1 :max 2))) + (is (typep value 'single-float)) + (is (<= (coerce 1 'single-float) value (coerce 2 'single-float)))))) (def-test gen-character () (for-all ((c (gen-character))) @@ -257,4 +263,32 @@ (def-test introspection () (is (= (length (list-all-suites)) - (hash-table-count *suites*)))) \ No newline at end of file + (hash-table-count *suites*)))) + +(defvar *special-variable* nil) + +(def-fixture fixture-for-suite (value) + (progn + (setf *special-variable* value) + (&body))) + +(def-suite suite-with-fixture :fixture (fixture-for-suite 42) :in :it.bese.fiveam) + +(def-test test-with-suite-fixture (:suite suite-with-fixture) + (is (= 42 *special-variable*))) + +(def-test add-remove-test-from-suite () + (let ((*test* (make-hash-table :test 'eql)) + (*suites* (make-hash-table :test 'eql))) + (in-suite* empty :in nil) + (is (null (get-test 'foo))) + + (def-test foo (:suite nil) t) + (is-true (get-test 'foo)) + (is-false (gethash 'foo (tests *suite*))) + + (def-test foo () t) + (is-true (gethash 'foo (tests *suite*))) + + (def-test foo (:suite nil) t) + (is-false (gethash 'foo (tests *suite*)))))