Skip to content

Commit

Permalink
Merge pull request #22 from lpil/fix/runtime-config
Browse files Browse the repository at this point in the history
Resolve config at runtime rather than compile time
  • Loading branch information
parroty committed Feb 29, 2016
2 parents 034a958 + 164e37a commit 6572064
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
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

0 comments on commit 6572064

Please sign in to comment.