diff --git a/src/malli/generator.cljc b/src/malli/generator.cljc index 8d0365119..543b723b0 100644 --- a/src/malli/generator.cljc +++ b/src/malli/generator.cljc @@ -223,31 +223,27 @@ (-never-gen options)))) (comment + ;; unsatisfiable (do (sample [:and :int [:>= 1.5] [:<= 1.5]] {:size 1000}) nil) - (do (sample [:and :int [:>= 1] [:<= 1]] {:size 1000}) - nil) - (do (sample [:and :int [:>= 1] [:<= 1]] {:size 1000}) - nil) + (assert (= #{1} (set (sample [:and :int [:>= 1] [:<= 1]] {:size 1000})))) ;;FIXME never generates 2 (do (sample [:and :int [:or [:and [:>= 1] [:<= 1]] [:and [:>= 2] [:<= 2]]]] {:size 10}) nil) - (do (distinct (sample [:and :int [:or - [:and [:>= 2] [:<= 2]] - [:and [:>= 1] [:<= 1]]]] {:size 100000})) - nil) - (do (= #{2 3} (set (distinct (sample [:and :int [:>= 2] [:and [:or [:<= 3] [:<= 2]]]] {:size 100000})))) - nil) - (do (distinct (sample [:or - [:and [:>= 2] [:<= 2]] - [:and [:>= 1] [:<= 1]]] {:size 100000})) - nil) - (do (distinct (sample [:and [:>= 2] [:<= 2]] {:size 100000})) - nil) - (do (distinct (sample [:and [:> 2] [:< 3]] {:size 100000})) + ;;FIXME never generates 1 + (do (set (sample [:and :int [:or + [:and [:>= 2] [:<= 2]] + [:and [:>= 1] [:<= 1]]]] {:size 100000})) nil) + (assert (= #{2 3} (set (distinct (sample [:and :int [:>= 2] [:and [:or [:<= 3] [:<= 2]]]] {:size 100000}))))) + (assert (= #{2 2.0 1 1.0}) + (set (sample [:or + [:and [:>= 2] [:<= 2]] + [:and [:>= 1] [:<= 1]]] {:size 100000}))) + (assert (= #{2 2.0} (set (sample [:and [:>= 2] [:<= 2]] {:size 100000})))) + (assert (every? #(< 2 % 3) (sample [:and [:> 2] [:< 3]] {:size 100000}))) ) (defn- gen-one-of [gs]