Skip to content

Commit

Permalink
Merge pull request #19 from frojasg/chores/add-more-function-usage
Browse files Browse the repository at this point in the history
Add sample usage of domain generator
  • Loading branch information
parroty committed Dec 31, 2015
2 parents 0610e79 + 73ecdc9 commit 4a6ae48
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/excheck_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,23 @@ defmodule ExCheckTest do
assert is_integer(v1) and is_integer(v2)
end

defmodule State, do: defstruct foo: :bar

def state do
domain(:state, fn(self, size) ->
{_, value} = pick(atom, size)
{self, %State{foo: value}}
end, fn
(self, size) ->
{_, value} = pick(atom, max(size-2, 0))
{self, %State{foo: value}}
end)
end

property :my_domain_gen do
for_all x in state do
is_atom(x.foo)
end
end

end

0 comments on commit 4a6ae48

Please sign in to comment.