diff --git a/src/malli/generator.cljc b/src/malli/generator.cljc index ce3cfd3e6..aa9901942 100644 --- a/src/malli/generator.cljc +++ b/src/malli/generator.cljc @@ -453,7 +453,9 @@ (gen/double* (merge (let [props (m/properties schema options)] {:infinite? (get props :gen/infinite? false) :NaN? (get props :gen/NaN? false)}) - (-min-max schema options)))) + (-> (-min-max schema options) + (update :min #(some-> % double)) + (update :max #(some-> % double)))))) (defmethod -schema-generator :boolean [_ _] gen/boolean) (defmethod -schema-generator :keyword [_ _] gen/keyword) (defmethod -schema-generator :symbol [_ _] gen/symbol) diff --git a/test/malli/generator_test.cljc b/test/malli/generator_test.cljc index 7e200711d..aeaffb5d5 100644 --- a/test/malli/generator_test.cljc +++ b/test/malli/generator_test.cljc @@ -2,6 +2,7 @@ (:require [clojure.test :refer [are deftest is testing]] [clojure.test.check.clojure-test :refer [defspec]] [clojure.test.check.generators :as gen] + [clojure.test.check :refer [quick-check]] [clojure.test.check.properties :refer [for-all]] [malli.core :as m] [malli.generator :as mg] @@ -11,6 +12,12 @@ :cljs ["@js-joda/timezone/dist/js-joda-timezone-10-year-range"])) #?(:cljs (:require-macros [malli.test-macros :refer [when-env]]))) +(defn shrink [?schema] + (-> (quick-check 1 (for-all [s (mg/generator ?schema)] false) {:seed 0}) + :shrunk + :smallest + first)) + (deftest generator-test (doseq [[?schema _ ?fn] json-schema-test/expectations ;; cljs doesn't have a regex generator :( @@ -1034,3 +1041,7 @@ #?(:clj Exception, :cljs js/Error) #":malli\.generator/and-generator-failure" (mg/generate [:and pos? neg?])))) + +(deftest double-with-long-min-test + (is (m/validate :double (shrink [:double {:min 3}]))) + (is (= 3.0 (shrink [:double {:min 3}]))))