Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve config at runtime rather than compile time #22

Merged
merged 1 commit into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/excheck.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ defmodule ExCheck do
add 'use ExCheck' in the ExUnit test files.
"""

@iterations Application.get_env(:excheck, :number_iterations, 100)

defmacro __using__(_opts \\ []) do
quote do
import ExCheck.Predicate
Expand Down Expand Up @@ -43,7 +41,8 @@ defmodule ExCheck do
If the module name is specified, check all the methods prefixed with 'prop_'.
"""
def check(target, iterations \\ :nil) do
case :triq.check(target, iterations || @iterations) do
default_iterations = Application.get_env(:excheck, :number_iterations, 100)
case :triq.check(target, iterations || default_iterations) do
true ->
true
false ->
Expand Down
4 changes: 2 additions & 2 deletions lib/excheck/statement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule ExCheck.Statement do
@moduledoc """
Provides macros for test statements.
"""
@iteration_count Application.get_env(:excheck, :number_iterations, 100)

@doc """
Generate property method and ExUnit tests.
Expand Down Expand Up @@ -36,7 +35,8 @@ defmodule ExCheck.Statement do
It corresonds to triq#check_forall method.
"""
def verify_property({:"prop:forall", domain, _syntax, fun, _body}) do
verify_property(0, @iteration_count, domain, fun, 0)
iterations = Application.get_env(:excheck, :number_iterations, 100)
verify_property(0, iterations, domain, fun, 0)
end

defp verify_property(n, n, _domain, _fun, _count), do: true
Expand Down