Skip to content

Commit

Permalink
Added regression test for catching checked exceptions.
Browse files Browse the repository at this point in the history
Signed-off-by: Rich Hickey <richhickey@gmail.com>
  • Loading branch information
Paul M Bauer authored and richhickey committed Feb 29, 2012
1 parent b62df08 commit 7654bba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/script/run_tests.clj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ clojure.test-clojure.string
clojure.test-clojure.test
clojure.test-clojure.test-fixtures
clojure.test-clojure.transients
clojure.test-clojure.try-catch
clojure.test-clojure.vars
clojure.test-clojure.vectors
])
Expand Down
24 changes: 24 additions & 0 deletions test/clojure/test_clojure/try_catch.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.

; Author: Paul M Bauer

(ns clojure.test-clojure.try-catch
(:use clojure.test))

(defn- get-exception [expression]
(try (eval expression)
nil
(catch java.lang.Throwable t
t)))

(deftest catch-receives-checked-exception
(are [expression expected-exception] (= expected-exception
(type (get-exception expression)))
"Eh, I'm pretty safe" nil
'(java.io.FileReader. "CAFEBABEx0/idonotexist") java.io.FileNotFoundException))

0 comments on commit 7654bba

Please sign in to comment.