Browse files

Merge pull request #38 from pjstadig/fix-for-1.6

Fix for 1.6
  • Loading branch information...
2 parents c9b0f2e + 8581156 commit 9c703623be4ef69b12ea7e477d34a398aa8007f0 @scgilardi committed Mar 8, 2014
Showing with 12 additions and 4 deletions.
  1. +2 −0 .gitignore
  2. +7 −2 project.clj
  3. +3 −2 test/slingshot/test/slingshot.clj
View
2 .gitignore
@@ -2,5 +2,7 @@ pom.xml
*jar
/lib/
/classes/
+/target/
.lein-failures
.lein-deps-sum
+.lein-repl-history
View
9 project.clj
@@ -1,7 +1,12 @@
(defproject slingshot "0.10.4-SNAPSHOT"
:description "Enhanced throw, try, leveraging Clojure's capabilities"
- :dev-dependencies [[org.clojure/clojure "1.4.0"]]
+ :dev-dependencies [[org.clojure/clojure "1.6.0-beta2"]]
:java-source-path "java/src"
:java-source-paths ["java/src"]
:warn-on-reflection true
- :url "https://github.com/scgilardi/slingshot")
+ :url "https://github.com/scgilardi/slingshot"
+ :profiles {:dev {:dependencies [[org.clojure/clojure "1.6.0-beta2"]]}
+ :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
+ :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
+ :1.6 {:dependencies [[org.clojure/clojure "1.6.0-beta2"]]}}
+ :aliases {"all" ["with-profile" "1.4:1.5:1.6"]})
View
5 test/slingshot/test/slingshot.clj
@@ -2,6 +2,7 @@
(:use [clojure.test]
[slingshot.slingshot :only [try+ throw+ get-throw-context
get-thrown-object]])
+ (:require [clojure.string :as str])
(:import java.util.concurrent.ExecutionException))
(defrecord exception-record [error-code duration-ms message])
@@ -54,7 +55,7 @@
[:keys-yield-values e#])
;; by key present
- (catch (contains? ~'% :a-key) e#
+ (catch (and (set? ~'%) (contains? ~'% :a-key)) e#
[:key-is-present e#])
;; by clojure type, with optional hierarchy
@@ -84,7 +85,7 @@
(try (throw exception-1)
(catch Exception e [:class-exception e])))))
(testing "IllegalArgumentException thrown by clojure/core"
- (is (= :class-iae (first (mega-try (first 1)))))))
+ (is (= :class-iae (first (mega-try (str/replace "foo" 1 1)))))))
(testing "catch by java class generically"
(is (= [:class-string "fail"] (mega-try (throw+ "fail")))))

0 comments on commit 9c70362

Please sign in to comment.