Permalink
Browse files

Subvec should not delegate -find, additional tests

1 parent ef95e1e commit d598fd9ca9b7a104741d6a68a6222093059d7389 @swannodette swannodette committed Jun 28, 2017
Showing with 14 additions and 8 deletions.
  1. +4 −3 src/main/cljs/cljs/core.cljs
  2. +10 −5 src/test/cljs/cljs/collections_test.cljs
@@ -5524,9 +5524,10 @@ reduces them without incurring seq initialization"
IFind
(-find [coll n]
- (when (and (not (neg? n))
- (< (+ start n) end))
- (-find v (+ start n))))
+ (when-not (neg? n)
+ (let [idx (+ start n)]
+ (when (< idx end)
+ [n (-lookup v idx)]))))
IVector
(-assoc-n [coll n val]
@@ -99,12 +99,17 @@
(testing "rseq equality"
(is (= (rseq sv1) '(1)))
(is (nil? (rseq sv2)))))
- (let [s (subvec [0 1 2 3] 0 2)]
+ (let [sv1 (subvec [0 1 2 3] 0 2)
+ sv2 (subvec [0 1 2 3] 1 3)]
(testing "IFind"
- (is (= (find s 0) [0 0]))
- (is (= (find s 1) [1 1]))
- (is (= (find s 2) nil))
- (is (= (find s -1) nil))))
+ (is (= (find sv1 0) [0 0]))
+ (is (= (find sv1 1) [1 1]))
+ (is (= (find sv1 2) nil))
+ (is (= (find sv1 -1) nil))
+ (is (= (find sv2 0) [0 1]))
+ (is (= (find sv2 1) [1 2]))
+ (is (= (find sv2 2) nil))
+ (is (= (find sv2 -1) nil))))
)
))

0 comments on commit d598fd9

Please sign in to comment.