Skip to content

Commit b1d6e6a

Browse files
authored
Merge pull request #43 from dgr/dgr-convert-exceptions
Convert `thrown?` clauses to handle CLJS and Clojure JVM
2 parents 1100479 + c35fd05 commit b1d6e6a

18 files changed

+60
-60
lines changed

test/clojure/core_test/char.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
)
1515

1616
(is (thrown? IllegalArgumentException (char -1)))
17-
(is (thrown? Exception (char nil)))))
17+
(is (thrown? #?(:cljs :default :default Exception) (char nil)))))

test/clojure/core_test/denominator.cljc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
(is (= 3 (denominator 2/3)))
1111
(is (= 4 (denominator 3/4)))
1212

13-
(is (thrown? Exception (denominator 1)))
14-
(is (thrown? Exception (denominator 1.0)))
15-
(is (thrown? Exception (denominator 1N)))
16-
(is (thrown? Exception (denominator 1.0M)))
17-
(is (thrown? Exception (denominator ##Inf)))
18-
(is (thrown? Exception (denominator ##NaN)))
19-
(is (thrown? Exception (denominator nil))))))
13+
(is (thrown? #?(:cljs :default :default Exception) (denominator 1)))
14+
(is (thrown? #?(:cljs :default :default Exception) (denominator 1.0)))
15+
(is (thrown? #?(:cljs :default :default Exception) (denominator 1N)))
16+
(is (thrown? #?(:cljs :default :default Exception) (denominator 1.0M)))
17+
(is (thrown? #?(:cljs :default :default Exception) (denominator ##Inf)))
18+
(is (thrown? #?(:cljs :default :default Exception) (denominator ##NaN)))
19+
(is (thrown? #?(:cljs :default :default Exception) (denominator nil))))))

test/clojure/core_test/intern.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
(is (= 42 (var-get x-var))))
2222

2323
;; Trying to intern to an unknown namespace should throw
24-
(is (thrown? Exception (intern 'unknown-namespace 'x)))
25-
(is (thrown? Exception (intern 'unknonw-namespace 'x 42)))))
24+
(is (thrown? #?(:cljs :default :default Exception) (intern 'unknown-namespace 'x)))
25+
(is (thrown? #?(:cljs :default :default Exception) (intern 'unknonw-namespace 'x 42)))))

test/clojure/core_test/keyword.cljc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878

7979
(is (nil? (keyword nil))) ; (keyword nil) => nil, surprisingly
8080
(is (= :abc (keyword nil "abc"))) ; But if ns is nil, it just ignores it.
81-
(is (thrown? Exception (keyword "abc" nil))) ; But if name is nil, then we throw.
81+
(is (thrown? #?(:cljs :default :default Exception) (keyword "abc" nil))) ; But if name is nil, then we throw.
8282

8383
;; Two arg version requires namespace and symbol to be a string, not
8484
;; a symbol or keyword like the one arg version.
85-
(is (thrown? Exception (keyword 'abc "abc")))
86-
(is (thrown? Exception (keyword "abc" 'abc)))
87-
(is (thrown? Exception (keyword :abc "abc")))
88-
(is (thrown? Exception (keyword "abc" :abc)))))
85+
(is (thrown? #?(:cljs :default :default Exception) (keyword 'abc "abc")))
86+
(is (thrown? #?(:cljs :default :default Exception) (keyword "abc" 'abc)))
87+
(is (thrown? #?(:cljs :default :default Exception) (keyword :abc "abc")))
88+
(is (thrown? #?(:cljs :default :default Exception) (keyword "abc" :abc)))))

test/clojure/core_test/minus.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
;; Zero arg
7171
#?(:cljs nil
72-
:default (is (thrown? Exception (-))))
72+
:default (is (thrown? #?(:cljs :default :default Exception) (-))))
7373

7474
;; Single arg
7575
(is (= -3 (- 3)))

test/clojure/core_test/mod.cljc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
ratio? -1/3 -3 -4/3
7979
ratio? -7/2 -37/2 -15]))
8080

81-
(is (thrown? Exception (mod 10 0)))
82-
(is (thrown? Exception (mod ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
81+
(is (thrown? #?(:cljs :default :default Exception) (mod 10 0)))
82+
(is (thrown? #?(:cljs :default :default Exception) (mod ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
8383
(is (NaN? (mod 1 ##Inf)))
84-
(is (thrown? Exception (mod ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
84+
(is (thrown? #?(:cljs :default :default Exception) (mod ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
8585
(is (NaN? (mod 1 ##-Inf)))
86-
(is (thrown? Exception (mod ##NaN 1)))
87-
(is (thrown? Exception (mod 1 ##NaN)))
88-
(is (thrown? Exception (mod ##NaN 1)))))
86+
(is (thrown? #?(:cljs :default :default Exception) (mod ##NaN 1)))
87+
(is (thrown? #?(:cljs :default :default Exception) (mod 1 ##NaN)))
88+
(is (thrown? #?(:cljs :default :default Exception) (mod ##NaN 1)))))

test/clojure/core_test/name.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"abc*+!-_'?<>=" :abc/abc*+!-_'?<>=
1414
"abc*+!-_'?<>=" 'abc/abc*+!-_'?<>=)
1515

16-
(is (thrown? Exception (name nil)))))
16+
(is (thrown? #?(:cljs :default :default Exception) (name nil)))))

test/clojure/core_test/namespace.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
nil :abc
1212
nil 'abc)
1313

14-
(is (thrown? Exception (namespace nil)))))
14+
(is (thrown? #?(:cljs :default :default Exception) (namespace nil)))))

test/clojure/core_test/nan_questionmark.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
(when-var-exists clojure.core/NaN?
66
(deftest test-NaN?
7-
(is (thrown? Exception (NaN? nil)))
8-
(is (thrown? Exception (NaN? "##NaN")))
7+
(is (thrown? #?(:cljs :default :default Exception) (NaN? nil)))
8+
(is (thrown? #?(:cljs :default :default Exception) (NaN? "##NaN")))
99
(is (double? ##NaN))
1010
;; NaN is not equal to anything, even itself.
1111
;; See: https://clojure.org/guides/equality

test/clojure/core_test/numerator.cljc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
(is (= 2 (numerator 2/3)))
1111
(is (= 3 (numerator 3/4)))])
1212

13-
(is (thrown? Exception (numerator 1)))
14-
(is (thrown? Exception (numerator 1.0)))
15-
(is (thrown? Exception (numerator 1N)))
16-
(is (thrown? Exception (numerator 1.0M)))
17-
(is (thrown? Exception (numerator ##Inf)))
18-
(is (thrown? Exception (numerator ##NaN)))
19-
(is (thrown? Exception (numerator nil)))))
13+
(is (thrown? #?(:cljs :default :default Exception) (numerator 1)))
14+
(is (thrown? #?(:cljs :default :default Exception) (numerator 1.0)))
15+
(is (thrown? #?(:cljs :default :default Exception) (numerator 1N)))
16+
(is (thrown? #?(:cljs :default :default Exception) (numerator 1.0M)))
17+
(is (thrown? #?(:cljs :default :default Exception) (numerator ##Inf)))
18+
(is (thrown? #?(:cljs :default :default Exception) (numerator ##NaN)))
19+
(is (thrown? #?(:cljs :default :default Exception) (numerator nil)))))

0 commit comments

Comments
 (0)