File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4216,6 +4216,7 @@ reduces them without incurring seq initialization"
4216
4216
there are fewer than n. Returns a stateful transducer when
4217
4217
no collection is provided."
4218
4218
([n]
4219
+ {:pre [(number? n)]}
4219
4220
(fn [rf]
4220
4221
(let [na (volatile! n)]
4221
4222
(fn
@@ -4231,6 +4232,7 @@ reduces them without incurring seq initialization"
4231
4232
(ensure-reduced result)
4232
4233
result)))))))
4233
4234
([n coll]
4235
+ {:pre [(number? n)]}
4234
4236
(lazy-seq
4235
4237
(when (pos? n)
4236
4238
(when-let [s (seq coll)]
@@ -4240,6 +4242,7 @@ reduces them without incurring seq initialization"
4240
4242
" Returns a lazy sequence of all but the first n items in coll.
4241
4243
Returns a stateful transducer when no collection is provided."
4242
4244
([n]
4245
+ {:pre [(number? n)]}
4243
4246
(fn [rf]
4244
4247
(let [na (volatile! n)]
4245
4248
(fn
@@ -4252,6 +4255,7 @@ reduces them without incurring seq initialization"
4252
4255
result
4253
4256
(rf result input))))))))
4254
4257
([n coll]
4258
+ {:pre [(number? n)]}
4255
4259
(let [step (fn [n coll]
4256
4260
(let [s (seq coll)]
4257
4261
(if (and (pos? n) s)
@@ -8370,6 +8374,7 @@ reduces them without incurring seq initialization"
8370
8374
" Returns a lazy seq of every nth item in coll. Returns a stateful
8371
8375
transducer when no collection is provided."
8372
8376
([n]
8377
+ {:pre [(number? n)]}
8373
8378
(fn [rf]
8374
8379
(let [ia (volatile! -1 )]
8375
8380
(fn
@@ -8381,6 +8386,7 @@ reduces them without incurring seq initialization"
8381
8386
(rf result input)
8382
8387
result)))))))
8383
8388
([n coll]
8389
+ {:pre [(number? n)]}
8384
8390
(lazy-seq
8385
8391
(when-let [s (seq coll)]
8386
8392
(cons (first s) (take-nth n (drop n s)))))))
Original file line number Diff line number Diff line change 698
698
(is (= (hash 'foo) (hash (symbol " foo" ))))
699
699
(is (= (hash 'foo/bar) (hash (symbol " foo" " bar" ))))
700
700
(is (= (lazy-cat [1 ] [2 ] [3 ]) '(1 2 3 )))
701
- ))
701
+ ; ; Make sure take/drop raise an error when given nil as an argument
702
+ (is (try (do (take nil [1 2 3 ]) false )
703
+ (catch js/Error e true )))
704
+ (is (try (do (drop nil [1 2 3 ]) false )
705
+ (catch js/Error e true )))
706
+ (is (try (do (take-nth nil [1 2 3 ]) false )
707
+ (catch js/Error e true )))))
702
708
703
709
(deftest test-booleans
704
710
(testing " Testing boolean predicates"
You can’t perform that action at this time.
0 commit comments