Hey Tim,
When you write a property, like your `has-agroup`, there's no need to call
`gen/sample`. You can simply write: (prop/for-all [v my-generator] ...)
-Reid
On Sunday, August 10, 2014 6:04:21 PM UTC-5, frye wrote:
>
> Oook, this is starting to sink in.
>
> I've gotten a little farther, in that I can run quick-check with my custom
> generator. However, after a bunch of values had been generated, it fails on
> a NullPointerException. How can I know where the breakdown is happening?
>
> => (tc/quick-check 100 u/has-agroup)
> {:email , :last-name , :first-name , :username }
> {:email , :last-name , :first-name , :username 0}
> {:email , :last-name , :first-name Rq, :username 0}
> {:email 5D2, :last-name R4F, :first-name x, :username G0H}
> ...
> {:email 8KQgSr497EPw14X80oEbWC0, :last-name cdkLb8D5ol, :first-name
> 8DCOXz1U4S3JM641u5I7yPwQ, :username DADOk}
> {:email x, :last-name Qq3h07d6Cbs4, :first-name 6H6Enrwu, :username
> yf40SClLjJHp1ptbnx4I9xFbwI3}
> *NullPointerException clojure.test.check.generators/gen-bind/fn--18990
> (generators.clj:77)*
> bkell.bkell> (pst *e)
> NullPointerException
> clojure.test.check.generators/gen-bind/fn--18990
> (generators.clj:77)
> clojure.test.check.generators/gen-bind/fn--18990
> (generators.clj:79)
> clojure.test.check.generators/gen-bind/fn--18990
> (generators.clj:77)
> clojure.test.check.generators/gen-fmap/fn--18985
> (generators.clj:70)
> clojure.test.check.generators/call-gen (generators.clj:56)
> clojure.test.check/quick-check (check.clj:57)
> bkell.bkell/eval19267 (form-init7280611083923741467.clj:1)
> clojure.lang.Compiler.eval (Compiler.java:6703)
> clojure.lang.Compiler.eval (Compiler.java:6666)
> clojure.core/eval (core.clj:2927)
> clojure.main/repl/read-eval-print--6625/fn--6628 (main.clj:239)
> clojure.main/repl/read-eval-print--6625 (main.clj:239)
>
>
> This is my domain function:
>
> (defn *create-user*
> ([] (create {}))
> ([opts]
> (println opts)
> (let [sans-nils (apply merge (for [[k v]
> opts
> :when (not (nil? v))]
> {k v}))]
>
> (merge {:id (mu/generate-uuid)
> :username ""
> :password (crypto/base64 12)
> :first-name ""
> :last-name ""
> :email ""
> :country {}}
> sans-nils))))
>
>
> And these are my test functions.
>
> (def gend-user
> (gen/fmap *du/create-user*
> (gen/hash-map :username gen/string-alpha-numeric
> :first-name gen/string-alpha-numeric
> :last-name gen/string-alpha-numeric
> :email gen/string-alpha-numeric)))
>
> (def has-agroup
> (prop/for-all [v (gen/sample gend-user)]
> (-> v nil? not)))
>
>
>
> Tim Washington
> Interruptsoftware.com <http://interruptsoftware.com>
>
>
> On Sun, Aug 10, 2014 at 3:02 PM, Sam Ritchie <[email protected]
> <javascript:>> wrote:
>
>> You can to use gen/fmap to build up generators. Here's an example:
>>
>>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.