Skip to content

Commit

Permalink
Pull tests_counter type check to private function
Browse files Browse the repository at this point in the history
  • Loading branch information
smpoulsen committed Jul 4, 2016
1 parent 3ccec28 commit 03eabc4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/excheck/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ defmodule ExCheck.Formatter do

@doc false
def handle_event(event = {:suite_finished, _run_us, _load_us}, config) do
updated_test_count =
if is_map(config.tests_counter) do
%{test: config.tests_counter.test + ExCheck.IOServer.total_tests}
else
config.tests_counter + ExCheck.IOServer.total_tests
end
new_cfg = %{config | tests_counter: updated_test_count}
updated_tests_count = update_tests_counter(config.tests_counter)
new_cfg = %{config | tests_counter: updated_tests_count}
print_property_test_errors
CF.handle_event(event, new_cfg)
end
Expand All @@ -34,4 +29,11 @@ defmodule ExCheck.Formatter do
:io.format(msg, value_list)
end)
end

defp update_tests_counter(tests_counter) when is_integer(tests_counter) do
tests_counter + ExCheck.IOServer.total_tests
end
defp update_tests_counter(tests_counter) when is_map(tests_counter) do
%{tests_counter | test: tests_counter.test + ExCheck.IOServer.total_tests}
end
end

0 comments on commit 03eabc4

Please sign in to comment.