Skip to content

Commit 5b0be91

Browse files
jank's math epic (#875)
* Update `dec` tests for jank * Update `inc` tests for jank * Update `+'` & `*'` tests for jank
1 parent eb8daa1 commit 5b0be91

5 files changed

Lines changed: 31 additions & 26 deletions

File tree

test/clojure/core_test/dec.cljc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns clojure.core-test.dec
22
(:require [clojure.test :as t :refer [are deftest is testing]]
3+
[clojure.core-test.number-range :refer [min-int]]
34
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists] :as p]))
45

56
(when-var-exists dec
@@ -27,6 +28,7 @@
2728
:cljr (is (p/thrown? (dec Int64/MinValue)))
2829
:cljs (is (= (dec js/Number.MIN_SAFE_INTEGER) (- js/Number.MIN_SAFE_INTEGER 2)))
2930
:lpy [] ; Python integers cannot underflow
31+
:jank (is (p/thrown? (dec min-int)))
3032
:default (is false "TODO underflow")))
3133

3234
(testing "dec-nil"

test/clojure/core_test/inc.cljc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns clojure.core-test.inc
22
(:require [clojure.test :as t :refer [are deftest is testing]]
3+
[clojure.core-test.number-range :refer [max-int]]
34
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists] :as p]))
45

56
(when-var-exists inc
@@ -28,6 +29,7 @@
2829
:cljr (is (p/thrown? (inc Int64/MaxValue)))
2930
:cljs (is (= (inc js/Number.MAX_SAFE_INTEGER) (+ 2 js/Number.MAX_SAFE_INTEGER)))
3031
:lpy nil ; Python integers cannot overflow
32+
:jank (is (p/thrown? (inc max-int)))
3133
:default (is false "overflow untested")))
3234

3335
(testing "inc-nil"

test/clojure/core_test/plus_squote.cljc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns clojure.core-test.plus-squote
22
(:require [clojure.test :as t :refer [are deftest is]]
33
[clojure.core-test.number-range :as r]
4-
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists] :as p]))
4+
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists big-int?] :as p]))
55

66
(when-var-exists +'
77
(deftest test-+'
@@ -73,15 +73,15 @@
7373
(is (p/thrown? (+' 1 nil)))
7474
(is (p/thrown? (+' nil 1)))
7575

76-
(is (instance? clojure.lang.BigInt (+' 0 1N)))
77-
(is (instance? clojure.lang.BigInt (+' 0N 1)))
78-
(is (instance? clojure.lang.BigInt (+' 0N 1N)))
79-
(is (instance? clojure.lang.BigInt (+' 1N 1)))
80-
(is (instance? clojure.lang.BigInt (+' 1 1N)))
81-
(is (instance? clojure.lang.BigInt (+' 1N 1N)))
82-
(is (instance? clojure.lang.BigInt (+' 1 5N)))
83-
(is (instance? clojure.lang.BigInt (+' 1N 5)))
84-
(is (instance? clojure.lang.BigInt (+' 1N 5N)))
76+
(is (big-int? (+' 0 1N)))
77+
(is (big-int? (+' 0N 1)))
78+
(is (big-int? (+' 0N 1N)))
79+
(is (big-int? (+' 1N 1)))
80+
(is (big-int? (+' 1 1N)))
81+
(is (big-int? (+' 1N 1N)))
82+
(is (big-int? (+' 1 5N)))
83+
(is (big-int? (+' 1N 5)))
84+
(is (big-int? (+' 1N 5N)))
8585

86-
(is (instance? clojure.lang.BigInt (+' -1 r/min-int)))
87-
(is (instance? clojure.lang.BigInt (+' r/min-int -1)))))
86+
(is (big-int? (+' -1 r/min-int)))
87+
(is (big-int? (+' r/min-int -1)))))

test/clojure/core_test/portability.cljc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
;; return true if the fractional part of the double is zero
1919
#?(:cljs (integer? n)
2020
:lpy (integer? n)
21+
:jank (cpp/jank.runtime.is_big_integer n)
2122
:default
2223
(and (integer? n)
2324
(not (int? n)))))

test/clojure/core_test/star_squote.cljc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns clojure.core-test.star-squote
22
(:require [clojure.test :as t :refer [are deftest is]]
33
[clojure.core-test.number-range :as r]
4-
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists] :as p]))
4+
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists big-int?] :as p]))
55

66
(when-var-exists *'
77
(deftest test-*'
@@ -73,17 +73,17 @@
7373
(is (p/thrown? (*' 1 nil)))
7474
(is (p/thrown? (*' nil 1)))
7575

76-
(is (instance? clojure.lang.BigInt (*' 0 1N)))
77-
(is (instance? clojure.lang.BigInt (*' 0N 1)))
78-
(is (instance? clojure.lang.BigInt (*' 0N 1N)))
79-
(is (instance? clojure.lang.BigInt (*' 1N 1)))
80-
(is (instance? clojure.lang.BigInt (*' 1 1N)))
81-
(is (instance? clojure.lang.BigInt (*' 1N 1N)))
82-
(is (instance? clojure.lang.BigInt (*' 1 5N)))
83-
(is (instance? clojure.lang.BigInt (*' 1N 5)))
84-
(is (instance? clojure.lang.BigInt (*' 1N 5N)))
76+
(is (big-int? (*' 0 1N)))
77+
(is (big-int? (*' 0N 1)))
78+
(is (big-int? (*' 0N 1N)))
79+
(is (big-int? (*' 1N 1)))
80+
(is (big-int? (*' 1 1N)))
81+
(is (big-int? (*' 1N 1N)))
82+
(is (big-int? (*' 1 5N)))
83+
(is (big-int? (*' 1N 5)))
84+
(is (big-int? (*' 1N 5N)))
8585

86-
(is (instance? clojure.lang.BigInt (*' -1 r/min-int)))
87-
(is (instance? clojure.lang.BigInt (*' r/min-int -1)))
88-
(is (instance? clojure.lang.BigInt (*' (long (/ r/min-int 2)) 3)))
89-
(is (instance? clojure.lang.BigInt (*' 3 (long (/ r/min-int 2)))))))
86+
(is (big-int? (*' -1 r/min-int)))
87+
(is (big-int? (*' r/min-int -1)))
88+
(is (big-int? (*' (long (/ r/min-int 2)) 3)))
89+
(is (big-int? (*' 3 (long (/ r/min-int 2)))))))

0 commit comments

Comments
 (0)