Skip to content

Commit 164e37a

Browse files
committed
Resolve config at runtime rather than compile time
Use of module attributes means that these values are resolved at compile time, and thus do not change when projects using this lib change their mix config. Unless they wipe the library and manually compile them that is. I've moved them to be resolved at compile time, which fixes this problem. Mix conf is stored in an ETS table, so it's still v fast :)
1 parent 034a958 commit 164e37a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/excheck.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ defmodule ExCheck do
66
add 'use ExCheck' in the ExUnit test files.
77
"""
88

9-
@iterations Application.get_env(:excheck, :number_iterations, 100)
10-
119
defmacro __using__(_opts \\ []) do
1210
quote do
1311
import ExCheck.Predicate
@@ -43,7 +41,8 @@ defmodule ExCheck do
4341
If the module name is specified, check all the methods prefixed with 'prop_'.
4442
"""
4543
def check(target, iterations \\ :nil) do
46-
case :triq.check(target, iterations || @iterations) do
44+
default_iterations = Application.get_env(:excheck, :number_iterations, 100)
45+
case :triq.check(target, iterations || default_iterations) do
4746
true ->
4847
true
4948
false ->

lib/excheck/statement.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ defmodule ExCheck.Statement do
22
@moduledoc """
33
Provides macros for test statements.
44
"""
5-
@iteration_count Application.get_env(:excheck, :number_iterations, 100)
65

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

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

0 commit comments

Comments
 (0)