Permalink
Browse files

CLJS-787: cljs.reader does not read blank string as nil

set `cljs.reader/read-string` `eof-is-error` param to `cljs.reader/read`
to false just like Clojure's EDN reader
  • Loading branch information...
1 parent c1a29f1 commit 279157ac526f7aa0b01b95091821491f574024eb David Nolen committed May 8, 2014
Showing with 7 additions and 5 deletions.
  1. +1 −1 src/cljs/cljs/reader.cljs
  2. +6 −4 test/cljs/cljs/reader_test.cljs
@@ -432,7 +432,7 @@ nil if the end of stream has been reached")
"Reads one object from the string s"
[s]
(let [r (push-back-reader s)]
- (read r true nil false)))
+ (read r false nil false)))
;; read instances
@@ -43,10 +43,8 @@
(reader/read-string "#queue [1 2]")))
;; comments
- (assert (= :threw (try
- (reader/read-string ";foo")
- :failed-to-throw
- (catch js/Error e :threw))))
+ (assert (nil? (reader/read-string ";foo")))
+
(assert (= 3 (try
(reader/read-string ";foo\n3")
(catch js/Error e :threw))))
@@ -166,4 +164,8 @@
(assert (array? (aget (reader/read-string "#js {\"foo\" #js [1 2 3]}") "foo")))
(assert (= (seq (aget (reader/read-string "#js {\"foo\" #js [1 2 3]}") "foo")) '(1 2 3)))
+ ;; CLJS-787
+
+ (assert (nil? (reader/read-string "")))
+
:ok)

0 comments on commit 279157a

Please sign in to comment.