>
> Generated samples aren't unique.

Is there any reason why samples are not unique? Is this on purpose, or just 
an accidental consequence of the implementation?

Conform like this:
>
> (s/conform (:args (s/get-spec `wtv)) [0])
>
>
If I conform like that, it is not really conforming my function spec, just 
the argument spec. Like, I have the same issue if doing `(s/valid? `wtv 
(wtv 0))`. Basically, I want to understand the semantics of exercise-fn. 
Does it just call my function with input generated from the args spec, and 
does not care about return? I thought it was supposed to show you example 
of input which do make the spec valid.

Nevermind, the doc string answers this:

exercises the fn named by sym (a symbol) by applying it to
> n (default 10) generated samples of its args spec. When fspec is
> supplied its arg spec is used, and sym-or-f can be a fn.  Returns a
> sequence of tuples of [args ret].
>
>
On Sunday, 2 April 2017 03:55:19 UTC-7, Leon Grapenthin wrote:
>
> Generated samples aren't unique.
>
> Conform like this:
>
> (s/conform (:args (s/get-spec `wtv)) [0])
>
>
> On Thursday, March 30, 2017 at 2:55:35 AM UTC+2, Didier wrote:
>>
>> If you look at this example:
>>
>> (defn wtv [in] (if (= 0 in) 0 10))
>> (s/fdef wtv
>>         :args (s/cat :in int?)
>>         :ret (s/and int? #(not= 0 %)))
>>
>> (s/exercise-fn `wtv)
>> (s/conform `wtv (wtv 0))
>>
>> You'll see that exercise gives you most of the time the following sample:
>>
>> [(0) 0]
>>
>> But this fails to conform:
>>
>> => (s/conform `wtv (wtv 0))
>>
>> => :clojure.spec/invalid
>>
>>
>>  Also, why does exercise give repeated samples? Shouldn't they be unique?
>>
>> ([(0) 0] 
>>  [(-1) 10] 
>>  [(0) 0] 
>>  [(-1) 10] 
>>  [(-2) 10] 
>>  [(2) 10] 
>>  [(0) 0] 
>>  [(-1) 10] 
>>  [(-2) 10] 
>>  [(0) 0]) 
>>
>> Thanks
>>
>

-- 
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