Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

Commit

Permalink
test: such that constraints [Closes parroty#14]
Browse files Browse the repository at this point in the history
  • Loading branch information
devstopfix committed Aug 7, 2019
1 parent 7947bec commit 7bd65f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/excheck/statement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ defmodule ExCheck.Statement do
end

@doc """
Verify property and return the result as true/faluse value.
It corresonds to triq#check_forall method.
Verify property and return the result as true/false value.
It corresponds to triq#check_forall method.
"""
def verify_property({:"prop:forall", domain, _syntax, fun, _body}) do
iterations = Application.get_env(:excheck, :number_iterations, 100)
Expand Down
24 changes: 24 additions & 0 deletions test/such_that_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
defmodule ExCheck.SuchThatTest do
use ExUnit.Case
use ExCheck

# https://github.com/parroty/excheck/issues/14
property :stj_such_that_constraints do
for_all {s, t, j} in such_that({s_, t_, j_} in {int(), int(), int()} when s_ < j_ and j_ < t_) do
assert j > s, inspect([s, j, t])
assert j < t, inspect([s, j, t])
end
end

defp gen_sjt,
do:
[int(), pos_integer(), pos_integer()]
|> bind(fn [s, dj, dt] -> {s, s + dj, s + dj + dt} end)

property :sjt_bind do
for_all {s, j, t} in gen_sjt() do
assert j > s, inspect([s, j, t])
assert j < t, inspect([s, j, t])
end
end
end

0 comments on commit 7bd65f5

Please sign in to comment.