Skip to content

Commit d598fd9

Browse files
committed
Subvec should not delegate -find, additional tests
1 parent ef95e1e commit d598fd9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/cljs/cljs/core.cljs

+4-3
Original file line numberDiff line numberDiff line change
@@ -5524,9 +5524,10 @@ reduces them without incurring seq initialization"
55245524

55255525
IFind
55265526
(-find [coll n]
5527-
(when (and (not (neg? n))
5528-
(< (+ start n) end))
5529-
(-find v (+ start n))))
5527+
(when-not (neg? n)
5528+
(let [idx (+ start n)]
5529+
(when (< idx end)
5530+
[n (-lookup v idx)]))))
55305531

55315532
IVector
55325533
(-assoc-n [coll n val]

src/test/cljs/cljs/collections_test.cljs

+10-5
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,17 @@
9999
(testing "rseq equality"
100100
(is (= (rseq sv1) '(1)))
101101
(is (nil? (rseq sv2)))))
102-
(let [s (subvec [0 1 2 3] 0 2)]
102+
(let [sv1 (subvec [0 1 2 3] 0 2)
103+
sv2 (subvec [0 1 2 3] 1 3)]
103104
(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))))
105+
(is (= (find sv1 0) [0 0]))
106+
(is (= (find sv1 1) [1 1]))
107+
(is (= (find sv1 2) nil))
108+
(is (= (find sv1 -1) nil))
109+
(is (= (find sv2 0) [0 1]))
110+
(is (= (find sv2 1) [1 2]))
111+
(is (= (find sv2 2) nil))
112+
(is (= (find sv2 -1) nil))))
108113
)
109114
))
110115

0 commit comments

Comments
 (0)