Fork me on GitHub
#clojure-spec
<
2017-05-18
>
misha07:05:46

@gphilipp I'd think macro is doable, if you really need to have several BTs. However I'd start with (s/or ...) with all the variants you want in it, and see if that's enough

wilkerlucio14:05:41

Hello, I'm trying to use the overrides argument on a generator, but I'm not sure how I supposed to use it

wilkerlucio14:05:45

I'm trying like this:

wilkerlucio14:05:22

(s/exercise
    (s/keys :req [:some/data
                  :some/more-data])
    5
    {:some/data #(gen'/for [i (s/gen (s/int-in 1 1000000))]
                                 (-> i bigdec (/ 100.0M) (* -1)))})

wilkerlucio14:05:42

but that doesn't work, does someone have an example on how to use it?

Alex Miller (Clojure team)14:05:28

that looks roughly correct, maybe share more of the example?

wilkerlucio18:05:23

@alexmiller a more complete example here:

wilkerlucio18:05:35

sorry the noise now, I was looking at the wrong number, A is always even here, saying it's correct, I'll check my other example again

wilkerlucio18:05:52

@alexmiller ok, I think I might have found a bug

wilkerlucio18:05:15

it works fine when the spec is not defined in terms of other spec

wilkerlucio18:05:22

here is an example where the override doesn't work

wilkerlucio18:05:34

(s/def ::common-etc int?)
  (s/def ::a ::common-etc)
  (s/def ::b int?)

  (s/exercise (s/keys :req [::a ::b])
              30
              {::a #(gen/fmap (fn [x] (* x 2)) (s/gen int?))})

wilkerlucio18:05:05

if ::a was defined as int? it works, but when making it reference other spec, the override version is not used

Alex Miller (Clojure team)21:05:56

Oh, yes there is a ticket for this