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 248
248
(defmethod emit-constant Integer [x] (emits x))) ; reader puts Integers in metadata
249
249
250
250
#?(: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))))
252
260
: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 " )" ))))
254
269
255
270
#?(:clj
256
271
(defmethod emit-constant BigDecimal [x] (emits (.doubleValue ^BigDecimal x))))
Original file line number Diff line number Diff line change 65
65
(ana/analyze (assoc aenv :context :expr ) 'js/-Infinity)))
66
66
" -Infinity" )))
67
67
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
+
68
78
(deftest test-munge-dotdot
69
79
(is (= 'cljs.core._DOT__DOT_ (comp/munge 'cljs.core/..)))
70
80
(is (= " cljs.core._DOT__DOT_" (comp/munge " cljs.core/.." )))
You can’t perform that action at this time.
0 commit comments