Skip to content

Commit ef95e1e

Browse files
committed
fix Subvec IFind, add tests
remove PV find floating point test
1 parent 4814435 commit ef95e1e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/cljs/cljs/core.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5524,7 +5524,8 @@ reduces them without incurring seq initialization"
55245524

55255525
IFind
55265526
(-find [coll n]
5527-
(when (<= end (+ start n))
5527+
(when (and (not (neg? n))
5528+
(< (+ start n) end))
55285529
(-find v (+ start n))))
55295530

55305531
IVector

src/test/cljs/cljs/collections_test.cljs

+8-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
(is (= (find [1 2 3] 0) [0 1]))
4040
(is (= (find [1 2 3] -1) nil))
4141
(is (= (find [1 2 3] js/NaN) nil))
42-
(is (= (find [1 2 3] 1.2) nil))
4342
(is (= (find [1 2 3] :a) nil))
4443
(is (= (find [1 2 3] 10) nil)))
4544
)
@@ -99,7 +98,14 @@
9998
sv2 (subvec [0 1 2 3] 1 1)]
10099
(testing "rseq equality"
101100
(is (= (rseq sv1) '(1)))
102-
(is (nil? (rseq sv2))))))
101+
(is (nil? (rseq sv2)))))
102+
(let [s (subvec [0 1 2 3] 0 2)]
103+
(testing "IFind"
104+
(is (= (find s 0) [0 0]))
105+
(is (= (find s 1) [1 1]))
106+
(is (= (find s 2) nil))
107+
(is (= (find s -1) nil))))
108+
)
103109
))
104110

105111
(deftest test-sets

0 commit comments

Comments
 (0)