Hi there,
I'm trying to get my head wrapped around test.check
<https://github.com/clojure/test.check/>. My current stumbling block is
custom generators. Of course I've combed through the docs
<https://github.com/clojure/test.check/blob/master/doc/intro.md#record-generators>
and source
<https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.clj>.
And I'm pretty sure I need to use *gen-bind* to get this all working. But
it's just not clicking yet.
Let's say I want to create a *user* and a *group*, where a user can belong
to many groups. So let's say I have a generic *create-user* function.
(defn *create-user* [opts]
(merge {:id (mu/generate-uuid)
:username ""
:password (crypto/base64 12)
:first-name ""
:last-name ""
:email ""
:country {}}
opts))
And a generic *create-group* function.
(defn create [opts]
(merge {:id (mu/generate-uuid)
:name ""
:users []}
opts))
1. Now, if I try `*(gen/sample create-user)*`, or `*(gen/sample
(gen/vector du/create))*`it will fail.
2. I also want to do the same thing with groups (ie *(gen/sample
create-user)*).
3. Additionally however, I want to assert that a created group will
always have at least 1 user in the `*:users []*` k/v field.
How can I make test.check generators for these data structures?
Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>
--
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.