File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 248248 (defmethod emit-constant Integer [x] (emits x))) ; reader puts Integers in metadata
249249
250250#?(:clj
251- (defmethod emit-constant Double [x] (emits x))
251+ (defmethod emit-constant Double [x]
252+ (let [x (double x)]
253+ (cond (Double/isNaN x)
254+ (emits " NaN" )
255+
256+ (Double/isInfinite x)
257+ (emits (if (pos? x) " Infinity" " -Infinity" ))
258+
259+ :else (emits x))))
252260 :cljs
253- (defmethod emit-constant js /Number [x] (emits " (" x " )" )))
261+ (defmethod emit-constant js /Number [x]
262+ (cond (js/isNaN x)
263+ (emits " NaN" )
264+
265+ (not (js/isFinite x))
266+ (emits (if (pos? x) " Infinity" " -Infinity" ))
267+
268+ :else (emits " (" x " )" ))))
254269
255270#?(:clj
256271 (defmethod emit-constant BigDecimal [x] (emits (.doubleValue ^BigDecimal x))))
Original file line number Diff line number Diff line change 6565 (ana/analyze (assoc aenv :context :expr ) 'js/-Infinity)))
6666 " -Infinity" )))
6767
68+ (deftest test-cljs-2352
69+ (are [form result]
70+ (= (with-out-str
71+ (comp/emit
72+ (ana/analyze (assoc aenv :context :expr ) form)))
73+ result)
74+ Double/NaN " ##NaN"
75+ Double/POSITIVE_INFINITY " ##Inf"
76+ Double/NEGATIVE_INFINITY " ##-Inf" ))
77+
6878(deftest test-munge-dotdot
6979 (is (= 'cljs.core._DOT__DOT_ (comp/munge 'cljs.core/..)))
7080 (is (= " cljs.core._DOT__DOT_" (comp/munge " cljs.core/.." )))
You can’t perform that action at this time.
0 commit comments