Browse files

CLJS-778: RSeq does not implement INext, incorrect -rest implementation

  • Loading branch information...
1 parent 525154f commit 87deb8b080d0c930fe92a7a58c51f22a559033e5 @swannodette swannodette committed Mar 4, 2014
Showing with 10 additions and 0 deletions.
  1. +6 −0 src/cljs/cljs/core.cljs
  2. +4 −0 test/cljs/cljs/core_test.cljs
View
6 src/cljs/cljs/core.cljs
@@ -772,6 +772,12 @@ reduces them without incurring seq initialization"
(-nth ci i))
(-rest [coll]
(if (pos? i)
+ (RSeq. ci (dec i) nil)
+ ()))
+
+ INext
+ (-next [coll]
+ (when (pos? i)
(RSeq. ci (dec i) nil)))
ICounted
View
4 test/cljs/cljs/core_test.cljs
@@ -2150,6 +2150,10 @@
(assert (= 4 (get (range 1 3) n 4)))
(assert (= :fail (try (nth (range 1 3) n 4) (catch js/Error e :fail)))))
+ ;; CLJS-778
+ (assert (= (-rest (rseq [0])) ()))
+ (assert (nil? (-next (rseq [0]))))
+ (assert (= (set (rseq [0])) #{0}))
:ok
)

0 comments on commit 87deb8b

Please sign in to comment.