Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Nov 23, 2024
1 parent 1320d02 commit d9646da
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/malli/generator.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit d9646da

Please sign in to comment.