Skip to content

Commit 7580dea

Browse files
authored
Prep jank support (#71)
* prep jank support * prep * note block * wip * keyword * -Exception * -Exception * -Exception * update copied comment to match actual namespace * rm jank workaround
1 parent 1aac112 commit 7580dea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+182
-179
lines changed

deps.edn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:paths ["test"]}

test/clojure/core_test/abs.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
[-1/5 1/5]))
2323
(is (NaN? (abs ##NaN)))
2424
#?(:cljs (is (zero? (abs nil)))
25-
:default(is (thrown? Exception (abs nil)))))
25+
:default (is (thrown? #?(:clj Exception) (abs nil)))))
2626

2727
(testing "unboxed"
2828
(let [a 42

test/clojure/core_test/bit_and.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
(when-var-exists clojure.core/bit-and
77
(deftest test-bit-and
8-
#?(:clj (is (thrown? Exception (bit-and nil 1)))
9-
:cljs (is (= 0 (bit-and nil 1))))
10-
#?(:clj (is (thrown? Exception (bit-and 1 nil)))
11-
:cljs (is (= 0 (bit-and 1 nil))))
8+
#?(:cljs (is (= 0 (bit-and nil 1)))
9+
:default (is (thrown? #?(:clj Exception) (bit-and nil 1))))
10+
#?(:cljs (is (= 0 (bit-and 1 nil)))
11+
:default (is (thrown? #?(:clj Exception) (bit-and 1 nil))))
1212

1313
(are [ex a b] (= ex (bit-and a b))
1414
8 12 9

test/clojure/core_test/bit_and_not.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
(when-var-exists clojure.core/bit-and-not
77
(deftest test-bit-and-not
8-
#?(:clj (is (thrown? Exception (bit-and-not nil 1)))
9-
:cljs (is (= 0 (bit-and-not nil 1))))
10-
#?(:clj (is (thrown? Exception (bit-and-not 1 nil)))
11-
:cljs (is (= 1 (bit-and-not 1 nil))))
8+
#?(:cljs (is (= 0 (bit-and-not nil 1)))
9+
:default (is (thrown? #?(:clj Exception) (bit-and-not nil 1))))
10+
#?(:cljs (is (= 1 (bit-and-not 1 nil)))
11+
:default (is (thrown? #?(:clj Exception) (bit-and-not 1 nil))))
1212

1313
(are [ex a b] (= ex (bit-and-not a b))
1414
0 0 0

test/clojure/core_test/bit_clear.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-clear
66
(deftest test-bit-clear
7-
#?(:clj (is (thrown? Exception (bit-clear nil 1)))
8-
:cljs (is (= 0 (bit-clear nil 1))))
9-
#?(:clj (is (thrown? Exception (bit-clear 1 nil)))
10-
:cljs (is (= 0 (bit-clear 1 nil))))
7+
#?(:cljs (is (= 0 (bit-clear nil 1)))
8+
:default (is (thrown? #?(:clj Exception) (bit-clear nil 1))))
9+
#?(:cljs (is (= 0 (bit-clear 1 nil)))
10+
:default (is (thrown? #?(:clj Exception) (bit-clear 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-clear a b))
1313
3 11 3)))

test/clojure/core_test/bit_flip.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-flip
66
(deftest test-bit-flip
7-
#?(:clj (is (thrown? Exception (bit-flip nil 1)))
8-
:cljs (is (= 2 (bit-flip nil 1))))
9-
#?(:clj (is (thrown? Exception (bit-flip 1 nil)))
10-
:cljs (is (= 0 (bit-flip 1 nil))))
7+
#?(:cljs (is (= 2 (bit-flip nil 1)))
8+
:default (is (thrown? #?(:clj Exception) (bit-flip nil 1))))
9+
#?(:cljs (is (= 0 (bit-flip 1 nil)))
10+
:default (is (thrown? #?(:clj Exception) (bit-flip 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-flip a b))
1313
2r1111 2r1011 2

test/clojure/core_test/bit_not.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
(when-var-exists clojure.core/bit-not
66
(deftest test-bit-not
7-
#?(:clj (is (thrown? Exception (bit-not nil)))
8-
:cljs (is (= -1 (bit-not nil))))
7+
#?(:cljs (is (= -1 (bit-not nil)))
8+
:default (is (thrown? #?(:clj Exception) (bit-not nil))))
99

1010
(are [ex a] (= ex (bit-not a))
1111
-2r1000 2r0111

test/clojure/core_test/bit_or.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
(when-var-exists clojure.core/bit-or
77
(deftest test-bit-or
8-
#?(:clj (is (thrown? Exception (bit-or nil 1)))
9-
:cljs (is (bit-or nil 1)))
10-
#?(:clj (is (thrown? Exception (bit-or 1 nil)))
11-
:cljs (is (bit-or 1 nil)))
8+
#?(:cljs (is (bit-or nil 1))
9+
:default (is (thrown? #?(:clj Exception) (bit-or nil 1))))
10+
#?(:cljs (is (bit-or 1 nil))
11+
:default (is (thrown? #?(:clj Exception) (bit-or 1 nil))))
1212

1313
(are [ex a b] (= ex (bit-or a b))
1414
2r1101 2r1100 2r1001

test/clojure/core_test/bit_set.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-set
66
(deftest test-bit-set
7-
#?(:clj (is (thrown? Exception (bit-set nil 1)))
8-
:cljs (is (bit-set nil 1)))
9-
#?(:clj (is (thrown? Exception (bit-set 1 nil)))
10-
:cljs (is (bit-set 1 nil)))
7+
#?(:cljs (is (bit-set nil 1))
8+
:default (is (thrown? #?(:clj Exception) (bit-set nil 1))))
9+
#?(:cljs (is (bit-set 1 nil))
10+
:default (is (thrown? #?(:clj Exception) (bit-set 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-set a b))
1313
2r1111 2r1011 2

test/clojure/core_test/bit_shift_left.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-shift-left
66
(deftest test-bit-shift-left
7-
#?(:clj (is (thrown? Exception (bit-shift-left nil 1)))
8-
:cljs (is (= 0 (bit-shift-left nil 1))))
9-
#?(:clj (is (thrown? Exception (bit-shift-left 1 nil)))
10-
:cljs (is (= 1 (bit-shift-left 1 nil))))
7+
#?(:cljs (is (= 0 (bit-shift-left nil 1)))
8+
:default (is (thrown? #?(:clj Exception) (bit-shift-left nil 1))))
9+
#?(:cljs (is (= 1 (bit-shift-left 1 nil)))
10+
:default (is (thrown? #?(:clj Exception) (bit-shift-left 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-shift-left a b))
1313
1024 1 10

test/clojure/core_test/bit_shift_right.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-shift-right
66
(deftest test-bit-shift-right
7-
#?(:clj (is (thrown? Exception (bit-shift-right nil 1)))
8-
:cljs (is (bit-shift-right nil 1)))
9-
#?(:clj (is (thrown? Exception (bit-shift-right 1 nil)))
10-
:cljs (is (bit-shift-right 1 nil)))
7+
#?(:cljs (is (bit-shift-right nil 1))
8+
:default (is (thrown? #?(:clj Exception) (bit-shift-right nil 1))))
9+
#?(:cljs (is (bit-shift-right 1 nil))
10+
:default (is (thrown? #?(:clj Exception) (bit-shift-right 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-shift-right a b))
1313
2r1101 2r1101 0

test/clojure/core_test/bit_test.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
(when-var-exists clojure.core/bit-test
66
(deftest test-bit-test
7-
#?(:clj (is (thrown? Exception (bit-test nil 1)))
8-
:cljs (is (= false (bit-test nil 1))))
9-
#?(:clj (is (thrown? Exception (bit-test 1 nil)))
10-
:cljs (is (= true (bit-test 1 nil))))
7+
#?(:cljs (is (= false (bit-test nil 1)))
8+
:default (is (thrown? #?(:clj Exception) (bit-test nil 1))))
9+
#?(:cljs (is (= true (bit-test 1 nil)))
10+
:default (is (thrown? #?(:clj Exception) (bit-test 1 nil))))
1111

1212
(are [ex a b] (= ex (bit-test a b))
1313
true 2r1001 0

test/clojure/core_test/bit_xor.cljc

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
(when-var-exists clojure.core/bit-xor
77
(deftest test-bit-xor
8-
#?(:clj (is (thrown? Exception (bit-xor nil 1)))
9-
:cljs (is (bit-xor nil 1)))
10-
#?(:clj (is (thrown? Exception (bit-xor 1 nil)))
11-
:cljs (is (bit-xor 1 nil)))
8+
#?(:cljs (is (bit-xor nil 1))
9+
:default (is (thrown? #?(:clj Exception) (bit-xor nil 1))))
10+
#?(:cljs (is (bit-xor 1 nil))
11+
:default (is (thrown? #?(:clj Exception) (bit-xor 1 nil))))
1212

1313
(are [ex a b] (= ex (bit-xor a b))
1414
2r0101 2r1100 2r1001

test/clojure/core_test/byte.cljc

+9-11
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
;; `java.lang.Byte`, but there is no predicate for it. Here, we just
1010
;; test whether it's a fixed-length integer of some sort.
1111
(is (int? (byte 0)))
12-
#?@(:cljs []
13-
:default
14-
[(is (instance? java.lang.Byte (byte 0)))])
12+
#?(:clj (is (instance? java.lang.Byte (byte 0))))
1513

1614
;; Check conversions and rounding from other numeric types
1715
(are [expected x] (= expected (byte x))
@@ -56,12 +54,12 @@
5654
(is (= nil (byte nil)))]
5755
:default
5856
[ ;; `byte` throws outside the range of 127 ... -128.
59-
(is (thrown? Exception (byte -128.000001)))
60-
(is (thrown? Exception (byte -129)))
61-
(is (thrown? Exception (byte 128)))
62-
(is (thrown? Exception (byte 127.000001)))
57+
(is (thrown? #?(:clj Exception) (byte -128.000001)))
58+
(is (thrown? #?(:clj Exception) (byte -129)))
59+
(is (thrown? #?(:clj Exception) (byte 128)))
60+
(is (thrown? #?(:clj Exception) (byte 127.000001)))
6361
;; Check handling of other types
64-
(is (thrown? Exception (byte "0")))
65-
(is (thrown? Exception (byte :0)))
66-
(is (thrown? Exception (byte [0])))
67-
(is (thrown? Exception (byte nil)))])))
62+
(is (thrown? #?(:clj Exception) (byte "0")))
63+
(is (thrown? #?(:clj Exception) (byte :0)))
64+
(is (thrown? #?(:clj Exception) (byte [0])))
65+
(is (thrown? #?(:clj Exception) (byte nil)))])))

test/clojure/core_test/char.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
;; TODO: Add Unicode tests
1414
)
1515

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

test/clojure/core_test/count.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
2 "ab")
2424

2525
;; Negative tests
26-
(are [x] (thrown? #?(:cljs :default, :default Exception) (count x))
26+
(are [x] (thrown? #?(:cljs :default :clj Exception) (count x))
2727
1
2828
:a
2929
'a
30-
#?(:clj \a))))
30+
#?@(:cljs [] :default [\a]))))

test/clojure/core_test/dec.cljc

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
(testing "underflow"
2626
#?(:clj (is (thrown? Exception (dec Long/MIN_VALUE)))
27-
:cljs (is (= (dec js/Number.MIN_SAFE_INTEGER) (- js/Number.MIN_SAFE_INTEGER 2)))))
27+
:cljs (is (= (dec js/Number.MIN_SAFE_INTEGER) (- js/Number.MIN_SAFE_INTEGER 2)))
28+
:default (is false "TODO underflow")))
2829

2930
(testing "dec-nil"
3031
;; ClojureScript says (= -1 (dec nil)) because JavaScript casts null to 0

test/clojure/core_test/denominator.cljc

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
(is (= 3 (denominator 2/3)))
99
(is (= 4 (denominator 3/4)))
1010

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

test/clojure/core_test/double.cljc

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
[(is (= "0" (double "0")))
2525
(is (= :0 (double :0)))]
2626
:default
27+
[(is (thrown? #?(:clj Exception) (double "0")))
28+
(is (thrown? #?(:clj Exception) (double :0)))])
29+
30+
#?@(:clj
2731
[(is (instance? java.lang.Double (double 0)))
2832
(is (instance? java.lang.Double (double 0.0)))
2933
(is (instance? java.lang.Double (double 0N)))
30-
(is (instance? java.lang.Double (double 0.0M)))
31-
(is (thrown? Exception (double "0")))
32-
(is (thrown? Exception (double :0)))])))
34+
(is (instance? java.lang.Double (double 0.0M)))])))

test/clojure/core_test/drop.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(is (doall (drop 1 #{:a :b :c})))
2323

2424
;; Negative tests
25-
(is (thrown? #?(:cljs :default, :default Exception)
25+
(is (thrown? #?(:cljs :default :clj Exception)
2626
(doall (drop nil (range 0 10)))))
27-
(is (thrown? #?(:cljs :default, :default Exception)
27+
(is (thrown? #?(:cljs :default :clj Exception)
2828
(into [] (drop nil) (range 0 10))))))

test/clojure/core_test/drop_last.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
;; Negative tests
1616
;; Note: `doall` is required to realize the lazy sequence and
1717
;; force it to throw
18-
(is (thrown? #?(:cljs :default, :default Exception)
18+
(is (thrown? #?(:cljs :default :clj Exception)
1919
(doall (drop-last nil (range 5)))))))

test/clojure/core_test/drop_while.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(is (= [] (into [] (drop-while #(< % 5)) nil)))
1616

1717
;; Negative tests
18-
(is (thrown? #?(:cljs :default, :default Exception)
18+
(is (thrown? #?(:cljs :default :clj Exception)
1919
(doall (drop-while nil (range 0 10)))))
20-
(is (thrown? #?(:cljs :default, :default Exception)
20+
(is (thrown? #?(:cljs :default :clj Exception)
2121
(into [] (drop-while nil) (range 0 10))))))

test/clojure/core_test/float.cljc

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
(is (= ##-Inf (float ##-Inf)))
3434
(is (= "0" (float "0")))
3535
(is (= :0 (float :0)))]
36-
:default
36+
:default [(is (thrown? #?(:clj Exception) (float r/max-double)))
37+
(is (thrown? #?(:clj Exception) (float ##Inf)))
38+
(is (thrown? #?(:clj Exception) (float ##-Inf)))
39+
(is (thrown? #?(:clj Exception) (float "0")))
40+
(is (thrown? #?(:clj Exception) (float :0)))])
41+
42+
#?@(:clj
3743
[(is (instance? java.lang.Float (float 0)))
3844
(is (instance? java.lang.Float (float 0.0)))
3945
(is (instance? java.lang.Float (float 0N)))
40-
(is (instance? java.lang.Float (float 0.0M)))
41-
(is (thrown? Exception (float r/max-double)))
42-
(is (thrown? Exception (float ##Inf)))
43-
(is (thrown? Exception (float ##-Inf)))
44-
(is (thrown? Exception (float "0")))
45-
(is (thrown? Exception (float :0)))])))
46+
(is (instance? java.lang.Float (float 0.0M)))])))

test/clojure/core_test/inc.cljc

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
(testing "overflow"
2727
#?(:clj (is (thrown? Exception (inc Long/MAX_VALUE)))
28-
:cljs (is (= (inc js/Number.MAX_SAFE_INTEGER) (+ 2 js/Number.MAX_SAFE_INTEGER)))))
28+
:cljs (is (= (inc js/Number.MAX_SAFE_INTEGER) (+ 2 js/Number.MAX_SAFE_INTEGER)))
29+
:default (is false "overflow untested")))
2930

3031
(testing "inc-nil"
3132
;; ClojureScript says (= 1 (inc nil)) because JavaScript casts null to 0
3233
;; https://clojuredocs.org/clojure.core/inc#example-6156a59ee4b0b1e3652d754f
33-
#?(:clj (is (thrown? Exception (inc #_:clj-kondo/ignore nil)))
34-
:cljs (is (= 1 (inc #_:clj-kondo/ignore nil)))))))
34+
#?(:cljs (is (= 1 (inc #_:clj-kondo/ignore nil)))
35+
:default (is (thrown? #?(:clj Exception) (inc #_:clj-kondo/ignore nil)))))))

test/clojure/core_test/int.cljc

+9-11
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
;; predicate for it. Here, we just test whether it's a fixed-length
1212
;; integer of some sort.
1313
(is (int? (int 0)))
14-
#?(:cljs nil
15-
:default
16-
(is (instance? java.lang.Integer (int 0))))
14+
#?(:clj (is (instance? java.lang.Integer (int 0))))
1715

1816
;; Check conversions and rounding from other numeric types
1917
(are [expected x] (= expected (int x))
@@ -44,13 +42,13 @@
4442
#?@(:cljs []
4543
:default
4644
[ ;; `int` throws outside the range of 32767 ... -32768.
47-
(is (thrown? Exception (int -2147483648.000001)))
48-
(is (thrown? Exception (int -2147483649)))
49-
(is (thrown? Exception (int 2147483648)))
50-
(is (thrown? Exception (int 2147483647.000001)))
45+
(is (thrown? #?(:clj Exception) (int -2147483648.000001)))
46+
(is (thrown? #?(:clj Exception) (int -2147483649)))
47+
(is (thrown? #?(:clj Exception) (int 2147483648)))
48+
(is (thrown? #?(:clj Exception) (int 2147483647.000001)))
5149

5250
;; Check handling of other types
53-
(is (thrown? Exception (int "0")))
54-
(is (thrown? Exception (int :0)))
55-
(is (thrown? Exception (int [0])))
56-
(is (thrown? Exception (int nil)))])))
51+
(is (thrown? #?(:clj Exception) (int "0")))
52+
(is (thrown? #?(:clj Exception) (int :0)))
53+
(is (thrown? #?(:clj Exception) (int [0])))
54+
(is (thrown? #?(:clj Exception) (int nil)))])))

test/clojure/core_test/intern.cljc

+2-2
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? #?(:cljs :default :default Exception) (intern 'unknown-namespace 'x)))
25-
(is (thrown? #?(:cljs :default :default Exception) (intern 'unknonw-namespace 'x 42)))))
24+
(is (thrown? #?(:cljs :default :clj Exception) (intern 'unknown-namespace 'x)))
25+
(is (thrown? #?(:cljs :default :clj Exception) (intern 'unknonw-namespace 'x 42)))))

0 commit comments

Comments
 (0)