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
47 changes: 25 additions & 22 deletions test/clojure/core_test/abs.cljc
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
(ns clojure.core-test.abs
(:require [clojure.test :as t]))
(:require [clojure.test :as t :refer [deftest testing is are]]
[clojure.core-test.portability :as p]))

(t/deftest common
(t/is (thrown? NullPointerException (abs nil)))
(t/are [in ex] (= ex (abs in))
-1 1
1 1
Long/MIN_VALUE Long/MIN_VALUE ; Special case!
-1.0 1.0
-0.0 0.0
##-Inf ##Inf
##Inf ##Inf
-123.456M 123.456M
-123N 123N
-1/5 1/5)
(t/is (NaN? (abs ##NaN))))
(p/when-var-exists clojure.core/abs
(deftest test-abs
(testing "common"
(are [in ex] (= ex (abs in))
-1 1
1 1
Long/MIN_VALUE Long/MIN_VALUE ; Special case!
-1.0 1.0
-0.0 0.0
##-Inf ##Inf
##Inf ##Inf
-123.456M 123.456M
-123N 123N
-1/5 1/5)
(is (NaN? (abs ##NaN)))
(is (thrown? NullPointerException (abs nil))))

(t/deftest unboxed
(let [a 42
b -42
a' (abs a)
b' (abs b)]
(t/is (= 42 a'))
(t/is (= 42 b'))))
(testing "unboxed"
(let [a 42
b -42
a' (abs a)
b' (abs b)]
(is (= 42 a'))
(is (= 42 b'))))))
49 changes: 26 additions & 23 deletions test/clojure/core_test/aclone.cljc
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
(ns clojure.core-test.aclone
(:require [clojure.test :as t :refer [deftest is]]))
(:require [clojure.test :as t :refer [deftest testing is are]]
[clojure.core-test.portability :as p]))

(defn clone-test
[a b]
(aset a 0 1)
(aset a 1 2)
(aset a 2 3)
(let [a' (aclone a)
b' (aclone b)]
(is (= 3 (alength a')))
(is (every? identity (map #(= (aget a %) (aget a' %)) (range 3))))
(is (zero? (alength b')))
(is (not (identical? a a')))
(is (not (identical? b b')))
(aset a 1 11)
(is (= 11 (aget a 1)))
(is (= 2 (aget a' 1)))
(aset a' 2 12)
(is (= 3 (aget a 2)))
(is (= 12 (aget a' 2)))))
(p/when-var-exists clojure.core/aclone
(defn clone-test
[a b]
(aset a 0 1)
(aset a 1 2)
(aset a 2 3)
(let [a' (aclone a)
b' (aclone b)]
(is (= 3 (alength a')))
(is (every? identity (map #(= (aget a %) (aget a' %)) (range 3))))
(is (zero? (alength b')))
(is (not (identical? a a')))
(is (not (identical? b b')))
(aset a 1 11)
(is (= 11 (aget a 1)))
(is (= 2 (aget a' 1)))
(aset a' 2 12)
(is (= 3 (aget a 2)))
(is (= 12 (aget a' 2)))))

(deftest integer-arrays
(clone-test (int-array 3) (int-array 0)))
(deftest test-aclone
(testing "integer-arrays"
(clone-test (int-array 3) (int-array 0)))

(deftest object-arrays
(clone-test (object-array 3) (object-array 0)))
(testing "object-arrays"
(clone-test (object-array 3) (object-array 0)))))
Loading
Loading