Skip to content

Commit 6443339

Browse files
committed
* simple test cases and comments about state of things
1 parent 91e8ee4 commit 6443339

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/cljs/cljs/bigint_test.cljs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;; Copyright (c) Rich Hickey. All rights reserved.
2+
;; The use and distribution terms for this software are covered by the
3+
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
;; which can be found in the file epl-v10.html at the root of this distribution.
5+
;; By using this software in any fashion, you are agreeing to be bound by
6+
;; the terms of this license.
7+
;; You must not remove this notice, or any other, from this software.
8+
9+
(ns cljs.bigint-test
10+
(:require [cljs.test :refer-macros [deftest is testing]]))
11+
12+
(deftest test-bigint
13+
(testing "BigInt Basics"
14+
(is (bigint? 1N))
15+
(is (bigint? 9007199254740992))
16+
(is (bigint? -9007199254740992)))
17+
(testing "BigInt & Number equality"
18+
;; the below is a bit backwards from Clojure
19+
;; i.e. (= 0.5 1/2) ; false
20+
;; but (== 0.5 1/2) ; true
21+
(is (= 1 1N))
22+
(is (= 1N 1))
23+
(is (= 1 1N 1))
24+
(is (not (== 1 1N)))
25+
(is (not (== 1N 1)))
26+
(is (not (== 1 1N 1))))
27+
(testing "BigInt Hashing"
28+
(is (= (hash 1N) (hash 1)))
29+
(is (= (hash 9007199254740992) (hash 9007199254740992)))
30+
(is (= (hash -9007199254740992) (hash -9007199254740992))))
31+
(testing "BigInt as HashMap keys"
32+
(let [m {1N 2}]
33+
(is (= 2 (get m 1N)))
34+
(is (= 2 (get m 1))))))
35+
36+
(comment
37+
38+
(cljs.test/run-tests)
39+
40+
)

0 commit comments

Comments
 (0)