Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/clojure/core_test/char.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
)

(is (thrown? IllegalArgumentException (char -1)))
(is (thrown? Exception (char nil)))))
(is (thrown? #?(:cljs :default :default Exception) (char nil)))))
14 changes: 7 additions & 7 deletions test/clojure/core_test/denominator.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
(is (= 3 (denominator 2/3)))
(is (= 4 (denominator 3/4)))

(is (thrown? Exception (denominator 1)))
(is (thrown? Exception (denominator 1.0)))
(is (thrown? Exception (denominator 1N)))
(is (thrown? Exception (denominator 1.0M)))
(is (thrown? Exception (denominator ##Inf)))
(is (thrown? Exception (denominator ##NaN)))
(is (thrown? Exception (denominator nil))))))
(is (thrown? #?(:cljs :default :default Exception) (denominator 1)))
(is (thrown? #?(:cljs :default :default Exception) (denominator 1.0)))
(is (thrown? #?(:cljs :default :default Exception) (denominator 1N)))
(is (thrown? #?(:cljs :default :default Exception) (denominator 1.0M)))
(is (thrown? #?(:cljs :default :default Exception) (denominator ##Inf)))
(is (thrown? #?(:cljs :default :default Exception) (denominator ##NaN)))
(is (thrown? #?(:cljs :default :default Exception) (denominator nil))))))
4 changes: 2 additions & 2 deletions test/clojure/core_test/intern.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
(is (= 42 (var-get x-var))))

;; Trying to intern to an unknown namespace should throw
(is (thrown? Exception (intern 'unknown-namespace 'x)))
(is (thrown? Exception (intern 'unknonw-namespace 'x 42)))))
(is (thrown? #?(:cljs :default :default Exception) (intern 'unknown-namespace 'x)))
(is (thrown? #?(:cljs :default :default Exception) (intern 'unknonw-namespace 'x 42)))))
10 changes: 5 additions & 5 deletions test/clojure/core_test/keyword.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@

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

;; Two arg version requires namespace and symbol to be a string, not
;; a symbol or keyword like the one arg version.
(is (thrown? Exception (keyword 'abc "abc")))
(is (thrown? Exception (keyword "abc" 'abc)))
(is (thrown? Exception (keyword :abc "abc")))
(is (thrown? Exception (keyword "abc" :abc)))))
(is (thrown? #?(:cljs :default :default Exception) (keyword 'abc "abc")))
(is (thrown? #?(:cljs :default :default Exception) (keyword "abc" 'abc)))
(is (thrown? #?(:cljs :default :default Exception) (keyword :abc "abc")))
(is (thrown? #?(:cljs :default :default Exception) (keyword "abc" :abc)))))
2 changes: 1 addition & 1 deletion test/clojure/core_test/minus.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

;; Zero arg
#?(:cljs nil
:default (is (thrown? Exception (-))))
:default (is (thrown? #?(:cljs :default :default Exception) (-))))

;; Single arg
(is (= -3 (- 3)))
Expand Down
12 changes: 6 additions & 6 deletions test/clojure/core_test/mod.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
ratio? -1/3 -3 -4/3
ratio? -7/2 -37/2 -15]))

(is (thrown? Exception (mod 10 0)))
(is (thrown? Exception (mod ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
(is (thrown? #?(:cljs :default :default Exception) (mod 10 0)))
(is (thrown? #?(:cljs :default :default Exception) (mod ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
(is (NaN? (mod 1 ##Inf)))
(is (thrown? Exception (mod ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
(is (thrown? #?(:cljs :default :default Exception) (mod ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
(is (NaN? (mod 1 ##-Inf)))
(is (thrown? Exception (mod ##NaN 1)))
(is (thrown? Exception (mod 1 ##NaN)))
(is (thrown? Exception (mod ##NaN 1)))))
(is (thrown? #?(:cljs :default :default Exception) (mod ##NaN 1)))
(is (thrown? #?(:cljs :default :default Exception) (mod 1 ##NaN)))
(is (thrown? #?(:cljs :default :default Exception) (mod ##NaN 1)))))
2 changes: 1 addition & 1 deletion test/clojure/core_test/name.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"abc*+!-_'?<>=" :abc/abc*+!-_'?<>=
"abc*+!-_'?<>=" 'abc/abc*+!-_'?<>=)

(is (thrown? Exception (name nil)))))
(is (thrown? #?(:cljs :default :default Exception) (name nil)))))
2 changes: 1 addition & 1 deletion test/clojure/core_test/namespace.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
nil :abc
nil 'abc)

(is (thrown? Exception (namespace nil)))))
(is (thrown? #?(:cljs :default :default Exception) (namespace nil)))))
4 changes: 2 additions & 2 deletions test/clojure/core_test/nan_questionmark.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

(when-var-exists clojure.core/NaN?
(deftest test-NaN?
(is (thrown? Exception (NaN? nil)))
(is (thrown? Exception (NaN? "##NaN")))
(is (thrown? #?(:cljs :default :default Exception) (NaN? nil)))
(is (thrown? #?(:cljs :default :default Exception) (NaN? "##NaN")))
(is (double? ##NaN))
;; NaN is not equal to anything, even itself.
;; See: https://clojure.org/guides/equality
Expand Down
14 changes: 7 additions & 7 deletions test/clojure/core_test/numerator.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
(is (= 2 (numerator 2/3)))
(is (= 3 (numerator 3/4)))])

(is (thrown? Exception (numerator 1)))
(is (thrown? Exception (numerator 1.0)))
(is (thrown? Exception (numerator 1N)))
(is (thrown? Exception (numerator 1.0M)))
(is (thrown? Exception (numerator ##Inf)))
(is (thrown? Exception (numerator ##NaN)))
(is (thrown? Exception (numerator nil)))))
(is (thrown? #?(:cljs :default :default Exception) (numerator 1)))
(is (thrown? #?(:cljs :default :default Exception) (numerator 1.0)))
(is (thrown? #?(:cljs :default :default Exception) (numerator 1N)))
(is (thrown? #?(:cljs :default :default Exception) (numerator 1.0M)))
(is (thrown? #?(:cljs :default :default Exception) (numerator ##Inf)))
(is (thrown? #?(:cljs :default :default Exception) (numerator ##NaN)))
(is (thrown? #?(:cljs :default :default Exception) (numerator nil)))))
2 changes: 1 addition & 1 deletion test/clojure/core_test/partial.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(let [simple-use (partial inc 2)]
(is (= 3 (simple-use))))
(let [lazily-evaluated (partial inc 2 3)]
#?(:clj (is (thrown? Exception (lazily-evaluated)))
#?(:clj (is (thrown? #?(:cljs :default :default Exception) (lazily-evaluated)))
:cljs (is (thrown? js/Error (lazily-evaluated)))))
(let [variadic (partial test-fn 1 2 3)]
(is (= [1 2 3 4] (variadic 4)))
Expand Down
8 changes: 4 additions & 4 deletions test/clojure/core_test/plus.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@

#?@(:cljs []
:default
[(is (thrown? Exception (+ r/max-int 1)))
(is (thrown? Exception (+ r/min-int -1)))
[(is (thrown? #?(:cljs :default :default Exception) (+ r/max-int 1)))
(is (thrown? #?(:cljs :default :default Exception) (+ r/min-int -1)))
(is (instance? clojure.lang.BigInt (+ 0 1N)))
(is (instance? clojure.lang.BigInt (+ 0N 1)))
(is (instance? clojure.lang.BigInt (+ 0N 1N)))
Expand Down Expand Up @@ -132,8 +132,8 @@
;; This case is pretty safe.
1.5 1.0 1/2)

(is (thrown? Exception (+ 1/2 nil)))
(is (thrown? Exception (+ nil 1/2)))
(is (thrown? #?(:cljs :default :default Exception) (+ 1/2 nil)))
(is (thrown? #?(:cljs :default :default Exception) (+ nil 1/2)))

#?@(:cljs nil
:default
Expand Down
4 changes: 2 additions & 2 deletions test/clojure/core_test/plus_singlequote.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
6N 1N 5
6N 1N 5N)

(is (thrown? Exception (+' 1 nil)))
(is (thrown? Exception (+' nil 1)))
(is (thrown? #?(:cljs :default :default Exception) (+' 1 nil)))
(is (thrown? #?(:cljs :default :default Exception) (+' nil 1)))

(is (instance? clojure.lang.BigInt (+' 0 1N)))
(is (instance? clojure.lang.BigInt (+' 0N 1)))
Expand Down
12 changes: 6 additions & 6 deletions test/clojure/core_test/quot.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
double? 0.0 1 ##Inf
double? 0.0 1 ##-Inf)

(is (thrown? Exception (quot 10 0)))
(is (thrown? Exception (quot ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
(is (thrown? Exception (quot ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
(is (thrown? Exception (quot ##NaN 1)))
(is (thrown? Exception (quot 1 ##NaN)))
(is (thrown? Exception (quot ##NaN 1)))))
(is (thrown? #?(:cljs :default :default Exception) (quot 10 0)))
(is (thrown? #?(:cljs :default :default Exception) (quot ##Inf 1))) ; surprising since (/ ##Inf 1) = ##Inf
(is (thrown? #?(:cljs :default :default Exception) (quot ##-Inf 1))) ; surprising since (/ ##-Inf 1) = ##-Inf
(is (thrown? #?(:cljs :default :default Exception) (quot ##NaN 1)))
(is (thrown? #?(:cljs :default :default Exception) (quot 1 ##NaN)))
(is (thrown? #?(:cljs :default :default Exception) (quot ##NaN 1)))))
6 changes: 3 additions & 3 deletions test/clojure/core_test/slash.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

;; Zero arg
#?(:cljs nil
:default (is (thrown? Exception (/))))
:default (is (thrown? #?(:cljs :default :default Exception) (/))))

;; Single arg
#?(:cljs (is (= 0.5 (/ 2)))
Expand Down Expand Up @@ -151,8 +151,8 @@
;; Multi arg
(is (= 362880N (/ 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9)))

(is (thrown? Exception (/ 1/2 nil)))
(is (thrown? Exception (/ nil 1/2)))))
(is (thrown? #?(:cljs :default :default Exception) (/ 1/2 nil)))
(is (thrown? #?(:cljs :default :default Exception) (/ nil 1/2)))))

(testing "inf-nan"
(are [expected x y] (= expected (/ x y))
Expand Down
12 changes: 6 additions & 6 deletions test/clojure/core_test/star.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
(is (instance? clojure.lang.BigInt (* 1N 5)))
(is (instance? clojure.lang.BigInt (* 1N 5N)))

(is (thrown? Exception (* -1 r/min-int)))
(is (thrown? Exception (* r/min-int -1)))
(is (thrown? Exception (* (long (/ r/min-int 2)) 3)))
(is (thrown? Exception (* 3 (long (/ r/min-int 2)))))]))
(is (thrown? #?(:cljs :default :default Exception) (* -1 r/min-int)))
(is (thrown? #?(:cljs :default :default Exception) (* r/min-int -1)))
(is (thrown? #?(:cljs :default :default Exception) (* (long (/ r/min-int 2)) 3)))
(is (thrown? #?(:cljs :default :default Exception) (* 3 (long (/ r/min-int 2)))))]))

#?(:cljs nil
:default
Expand Down Expand Up @@ -118,8 +118,8 @@
-1/10 -1/2 1/5
1/10 -1/2 -1/5)

(is (thrown? Exception (* 1/2 nil)))
(is (thrown? Exception (* nil 1/2)))))
(is (thrown? #?(:cljs :default :default Exception) (* 1/2 nil)))
(is (thrown? #?(:cljs :default :default Exception) (* nil 1/2)))))

(testing "inf-nan"
(testing "Multiplication with infinities"
Expand Down
4 changes: 2 additions & 2 deletions test/clojure/core_test/star_singlequote.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
5 1N 5
5 1N 5N)

(is (thrown? Exception (*' 1 nil)))
(is (thrown? Exception (*' nil 1)))
(is (thrown? #?(:cljs :default :default Exception) (*' 1 nil)))
(is (thrown? #?(:cljs :default :default Exception) (*' nil 1)))

(is (instance? clojure.lang.BigInt (*' 0 1N)))
(is (instance? clojure.lang.BigInt (*' 0N 1)))
Expand Down
6 changes: 3 additions & 3 deletions test/clojure/core_test/zero_questionmark.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
false -1.0M)

(is #?@(:cljs [(= false (zero? nil))]
:default [(thrown? Exception (zero? nil))]))
:default [(thrown? #?(:cljs :default :default Exception) (zero? nil))]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but this conversion was automated. I saw it during the review, as well, but didn't think it was worth more iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I'm going through and catching some of those by hand. I'll try to do a deeper, file-by-file pass.

(is #?@(:cljs [(= false (zero? false))]
:default [(thrown? Exception (zero? false))]))
:default [(thrown? #?(:cljs :default :default Exception) (zero? false))]))
(is #?@(:cljs [(= false (zero? true))]
:default [(thrown? Exception (zero? true))]))))
:default [(thrown? #?(:cljs :default :default Exception) (zero? true))]))))
Loading