Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix printing of RegExp objects

  • Loading branch information...
commit 63cd8ce9c7c9a8864deb676f2b855b8018698d57 1 parent ed53a10
@brandonbloom brandonbloom authored David Nolen committed
Showing with 8 additions and 3 deletions.
  1. +6 −1 src/cljs/cljs/core.cljs
  2. +2 −2 test/cljs/cljs/core_test.cljs
View
7 src/cljs/cljs/core.cljs
@@ -6028,6 +6028,9 @@ reduces them without incurring seq initialization"
;;;;;;;;;;;;;;;;;;;;;;;;; Regular Expressions ;;;;;;;;;;
+(defn regexp? [o]
+ (js* "~{o} instanceof RegExp"))
+
(defn re-matches
"Returns the result of (re-find re s) if re fully matches s."
[re s]
@@ -6092,10 +6095,12 @@ reduces them without incurring seq initialization"
;; handle CLJS ctors
(and (not (nil? obj))
^boolean (.-cljs$lang$type obj))
- (.cljs$lang$ctorPrSeq obj obj)
+ (.cljs$lang$ctorPrSeq obj obj)
(satisfies? IPrintable obj) (-pr-seq obj opts)
+ (regexp? obj) (list "#\"" (.-source obj) "\"")
+
:else (list "#<" (str obj) ">")))))
(defn- pr-sb [objs opts]
View
4 test/cljs/cljs/core_test.cljs
@@ -213,8 +213,8 @@
(assoc (cljs.core.ObjMap. nil (array) (js-obj)) :foo 5)))
(assert (= "\"asdf\"" (pr-str "asdf")))
- (assert (= "[1 true {:a 2, :b 42} #<Array [3, 4]>]"
- (pr-str [1 true {:a 2 :b 42} (array 3 4)])))
+ (assert (= "[1 true {:a 2, :b #\"x\\\"y\"} #<Array [3, 4]>]"
+ (pr-str [1 true {:a 2 :b #"x\"y"} (array 3 4)])))
(assert (= "\"asdf\"\n" (prn-str "asdf")))
(assert (= "[1 true {:a 2, :b 42} #<Array [3, 4]>]\n"
Please sign in to comment.
Something went wrong with that request. Please try again.