diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-01-21 15:44:31 +0000 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2009-01-21 15:44:31 +0000 |
commit | 46681192663f8962f8b3d5cb10fe8f89451625d9 (patch) | |
tree | edbeb53c52bf676a6c11a989a16d552ebbb4d00e /src/clojure/contrib/test_is/tests.clj | |
parent | 1e1439ab3e476f1e12bdd12a14e8f45d70d4e68f (diff) |
test_is.clj: new assertion "(is (thrown-with-msg? class re ...))"
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")) |