At a glance, this is probably the normal increasing-size behavior of 
test.check, and the bias should only be present for the first few samples. 
E.g., if you do a (take 1000 (gen/sample ...)), it should be more uniform.

Whether it's a real problem depends on how you're running your tests. I 
haven't yet looked into whether clojure.spec provides some default way of 
running test.check properties, so I'm not sure about that. But as long as 
you're running "enough" tests, e.g. >100, it should be fine.

On Monday, May 30, 2016 at 4:05:52 PM UTC-5, Jeroen van Dijk wrote:
>
> I'm trying to generate logical predicates in order to test a function that 
> should return the predicate in DNF. The generation seems to be biased 
> towards one of the predicates. What am I doing wrong?
>
> (require '[clojure.spec :as s])
> (require '[clojure.spec.gen :as gen])
>
> (s/def ::atom string?)
>
> (s/def ::predicate (s/or
>                     ::not-predicate
>                     ::and-predicate
>                     ::or-predicate
>                     ::atom))
>
> (s/def ::and-predicate (s/cat :pred #{:and} :args (s/+ ::predicate)))
> (s/def ::or-predicate  (s/cat :pred #{:or} :args (s/+ ::predicate)))
> (s/def ::not-predicate (s/tuple :pred #{:not} ::predicate))
>
> (prn (take 5 (gen/sample (s/gen ::predicate))))
> ;;=> 
> ((:and (:and "")) "" "X" "G" (:and "yd" (:and "c" "" (:and "F" (:and "" 
> "8" "Hb" "U0d")) "C") (:and (:and "1" "e" (:and "ME01" "w" "Y4" "" "P4") 
> "J4m4" "8") "Q7c" "") (:and (:and (:and "" "dG"))) "gw5"))
>
>
> No :or's or :not's here. If I change the order of s/or above the bias 
> changes. What's a better approach?
>
> Thanks,
> Jeroen
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to