File tree 2 files changed +16
-6
lines changed
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -5476,12 +5476,15 @@ reduces them without incurring seq initialization"
5476
5476
(defn- build-subvec [meta v start end __hash]
5477
5477
(if (instance? Subvec v)
5478
5478
(recur meta (.-v v) (+ (.-start v) start) (+ (.-start v) end) __hash)
5479
- (let [c (count v)]
5480
- (when (or (neg? start)
5481
- (neg? end)
5482
- (> start c)
5483
- (> end c))
5484
- (throw (js/Error. " Index out of bounds" )))
5479
+ (do
5480
+ (when-not (vector? v)
5481
+ (throw (js/Error. " v must satisfy IVector" )))
5482
+ (let [c (count v)]
5483
+ (when (or (neg? start)
5484
+ (neg? end)
5485
+ (> start c)
5486
+ (> end c))
5487
+ (throw (js/Error. " Index out of bounds" ))))
5485
5488
(Subvec. meta v start end __hash))))
5486
5489
5487
5490
(defn subvec
Original file line number Diff line number Diff line change 1262
1262
(case (swap! x m) :a 0 :default )
1263
1263
(is (= :b @x)))))
1264
1264
1265
+ (deftest test-cljs-2021
1266
+ (let [check-if-throws #(try (% ) (catch js/Error e :fail ))]
1267
+ (is (= :fail (check-if-throws #(subvec nil 0 0 ))))
1268
+ (is (= :fail (check-if-throws #(subvec {:foo :bar } 0 1 ))))
1269
+ (is (= :fail (check-if-throws #(subvec '(:foo ) 0 1 ))))
1270
+ (is (= :fail (check-if-throws #(subvec #{:foo } 0 1 ))))))
1271
+
1265
1272
(comment
1266
1273
; ; ObjMap
1267
1274
; ; (let [ks (map (partial str "foo") (range 500))
You can’t perform that action at this time.
0 commit comments