Skip to content

Commit

Permalink
Expand lazy seqs as arrays inside clj blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Jul 26, 2010
1 parent c5dbd05 commit 8a02445
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/com/reasonr/scriptjure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
(defmethod emit clojure.lang.IPersistentVector [expr]
(str "[" (str/join ", " (map emit expr)) "]"))

;(defmethod emit clojure.lang.LazySeq [expr]
; (emit (into [] expr)))
(defmethod emit clojure.lang.LazySeq [expr]
(emit (into [] expr)))

(defmethod emit clojure.lang.IPersistentMap [expr]
(letfn [(json-pair [pair] (str (emit (key pair)) ": " (emit (val pair))))]
Expand Down
4 changes: 4 additions & 0 deletions test/test_scriptjure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
(var y 4)))]
(is (= (js (clj one)) (js (clj two))))))

(deftest test-lazy-seq-expands-to-array-inside-clj
(let [vals (range 20)]
(is (= (js (clj vals)) "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]"))))

(deftest test-cljs
(let [foo 42]
(is (= (cljs foo) (js (clj foo))))))
Expand Down

0 comments on commit 8a02445

Please sign in to comment.