X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=t%2Ftests.lisp;h=caba093491069a8b9b6b4a6b2d7fbf3a3f3ea6ac;hb=8a32d7c6d3c1b7a43127731585f8a4bf9518b171;hp=3592ee582f7e6410bb9b44daf679fc6346bd5481;hpb=a7d389cd1eebbc3cbfae58a8885d07680eb7ae8f;p=fiveam.git diff --git a/t/tests.lisp b/t/tests.lisp index 3592ee5..caba093 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) @@ -259,6 +261,10 @@ (is (= 1 a)) (is (= 1 b)))) +(def-test introspection () + (is (= (length (list-all-suites)) + (hash-table-count *suites*)))) + (defvar *special-variable* nil) (def-fixture fixture-for-suite (value) @@ -270,3 +276,20 @@ (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))) + (def-suite empty :in nil) + (in-suite empty) + (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*)))))