diff options
Diffstat (limited to 'src/clojure/contrib/test_is/tests.clj')
-rw-r--r-- | src/clojure/contrib/test_is/tests.clj | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_is/tests.clj b/src/clojure/contrib/test_is/tests.clj index 2589cc77..6687ad12 100644 --- a/src/clojure/contrib/test_is/tests.clj +++ b/src/clojure/contrib/test_is/tests.clj @@ -41,9 +41,20 @@ (deftest can-test-thrown (is (thrown? ArithmeticException (/ 1 0)) "Should pass") + ;; No exception is thrown: (is (thrown? Exception (+ 1 1)) "Should fail") + ;; Wrong class of exception is thrown: (is (thrown? ArithmeticException (throw (RuntimeException.))) "Should error")) +(deftest can-test-thrown-with-msg + (is (thrown-with-msg? ArithmeticException #"Divide by zero" (/ 1 0)) "Should pass") + ;; Wrong message string: + (is (thrown-with-msg? ArithmeticException #"Something else" (/ 1 0)) "Should fail") + ;; No exception is thrown: + (is (thrown? Exception (+ 1 1)) "Should fail") + ;; Wrong class of exception is thrown: + (is (thrown-with-msg? IllegalArgumentException #"Divide by zero" (/ 1 0)) "Should error")) + (deftest can-catch-unexpected-exceptions (is (= 1 (throw (Exception.))) "Should error")) |