|
428 | 428 | (gen/return (first es))
|
429 | 429 | (gen/elements es)))
|
430 | 430 |
|
| 431 | +(defn- double-gen [schema options] |
| 432 | + (gen/double* (merge (let [props (m/properties schema options)] |
| 433 | + {:infinite? (get props :gen/infinite? false) |
| 434 | + :NaN? (get props :gen/NaN? false)}) |
| 435 | + (-> (-min-max schema options) |
| 436 | + (update :min #(some-> % double)) |
| 437 | + (update :max #(some-> % double)))))) |
| 438 | + |
431 | 439 | (defmulti -schema-generator (fn [schema options] (m/type schema options)) :default ::default)
|
432 | 440 |
|
433 | 441 | (defmethod -schema-generator ::default [schema options] (ga/gen-for-pred (m/validator schema options)))
|
|
476 | 484 | (defmethod -schema-generator :nil [_ _] nil-gen)
|
477 | 485 | (defmethod -schema-generator :string [schema options] (-string-gen schema options))
|
478 | 486 | (defmethod -schema-generator :int [schema options] (gen/large-integer* (-min-max schema options)))
|
479 |
| -(defmethod -schema-generator :double [schema options] |
480 |
| - (gen/double* (merge (let [props (m/properties schema options)] |
481 |
| - {:infinite? (get props :gen/infinite? false) |
482 |
| - :NaN? (get props :gen/NaN? false)}) |
483 |
| - (-> (-min-max schema options) |
484 |
| - (update :min #(some-> % double)) |
485 |
| - (update :max #(some-> % double)))))) |
486 |
| -(defmethod -schema-generator :float [schema options] |
487 |
| - (let [max-float #?(:clj Float/MAX_VALUE :cljs (.-MAX_VALUE js/Number)) |
488 |
| - min-float (- max-float) |
489 |
| - props (m/properties schema options) |
490 |
| - min-max-props (-min-max schema options) |
491 |
| - infinite? #?(:clj false :cljs (get props :gen/infinite? false))] |
492 |
| - (->> (merge {:infinite? infinite? |
493 |
| - :NaN? (get props :gen/NaN? false)} |
494 |
| - (-> min-max-props |
495 |
| - (update :min #(or (some-> % float) |
496 |
| - #?(:clj min-float :cljs nil))) |
497 |
| - (update :max #(or (some-> % float) |
498 |
| - #?(:clj max-float :cljs nil))))) |
499 |
| - (gen/double*) |
500 |
| - (gen/fmap float)))) |
| 487 | +(defmethod -schema-generator :double [schema options] (double-gen schema options)) |
| 488 | +(defmethod -schema-generator :float [schema options] (double-gen schema options)) |
501 | 489 | (defmethod -schema-generator :boolean [_ _] gen/boolean)
|
502 | 490 | (defmethod -schema-generator :keyword [_ _] gen/keyword)
|
503 | 491 | (defmethod -schema-generator :symbol [_ _] gen/symbol)
|
|
0 commit comments