File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -2185,6 +2185,22 @@ reduces them without incurring seq initialization"
2185
2185
2186
2186
:else false ))
2187
2187
2188
+ (defn ^boolean float?
2189
+ " Returns true for JavaScript numbers, false otherwise."
2190
+ [x]
2191
+ (number? x))
2192
+
2193
+ (defn ^boolean double?
2194
+ " Returns true for JavaScript numbers, false otherwise."
2195
+ [x]
2196
+ (number? x))
2197
+
2198
+ (defn ^boolean infinite?
2199
+ " Returns true for Infinity and -Infinity values."
2200
+ [x]
2201
+ (or (identical? x js/Number.POSITIVE_INFINITY)
2202
+ (identical? x js/Number.NEGATIVE_INFINITY)))
2203
+
2188
2204
(defn ^boolean contains?
2189
2205
" Returns true if key is present in the given collection, otherwise
2190
2206
returns false. Note that for numerically indexed collections like
Original file line number Diff line number Diff line change 7
7
; You must not remove this notice, or any other, from this software.
8
8
9
9
(ns cljs.pprint
10
- (:refer-clojure :exclude [deftype print println pr prn])
10
+ (:refer-clojure :exclude [deftype print println pr prn float? ])
11
11
(:require-macros
12
12
[cljs.pprint :as m :refer [with-pretty-writer getf setf deftype
13
13
pprint-logical-block print-length-loop
Original file line number Diff line number Diff line change 443
443
`(spec (and c/int? #(int-in-range? ~start ~end %))
444
444
:gen #(gen/large-integer* {:min ~start :max (dec ~end)})))
445
445
446
+ (defmacro double-in
447
+ " Specs a 64-bit floating point number. Options:
448
+
449
+ :infinite? - whether +/- infinity allowed (default true)
450
+ :NaN? - whether NaN allowed (default true)
451
+ :min - minimum value (inclusive, default none)
452
+ :max - maximum value (inclusive, default none)"
453
+ [& {:keys [infinite? NaN? min max]
454
+ :or {infinite? true NaN? true }
455
+ :as m}]
456
+ `(spec (and c/double?
457
+ ~@(when-not infinite? '[#(not (infinite? %))])
458
+ ~@(when-not NaN? '[#(not (js/isNaN %))])
459
+ ~@(when max `[#(<= % ~max)])
460
+ ~@(when min `[#(<= ~min %)]))
461
+ :gen #(gen/double* ~m)))
462
+
446
463
(defmacro merge
447
464
" Takes map-validating specs (e.g. 'keys' specs) and
448
465
returns a spec that returns a conformed map satisfying all of the
Original file line number Diff line number Diff line change @@ -94,7 +94,8 @@ gen-builtins
94
94
pos-int? (large-integer* {:min 1 })
95
95
neg-int? (large-integer* {:max -1 })
96
96
nat-int? (large-integer* {:min 0 })
97
- ; float? (double)
97
+ float? (double )
98
+ double? (double )
98
99
string? (string-alphanumeric )
99
100
ident? (one-of [(keyword-ns ) (symbol-ns )])
100
101
simple-ident? (one-of [(keyword ) (symbol )])
You can’t perform that action at this time.
0 commit comments