parroty / excheck

Property-based testing library for Elixir (QuickCheck style).
MIT License
316 stars 26 forks source link

Compiler warning #46

Open edescourtis opened 6 years ago

edescourtis commented 6 years ago

I keep getting this warning how to get this resolved?

All I have is a simple module with this:

  use ExUnit.Case, async: false
  use ExCheck

warning: this clause cannot match because a previous clause at line 1 always matches

Env:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
chazsconi commented 6 years ago

@edescourtis It seems the problem is caused by use ExCheck doing a use ExUnit.Callbacks which maybe fails because it has already been imported by use ExUnit.Case.

I worked around this by replacing use ExCheck by the following. This does the same but with the two lines commented - maybe in some cases use ExCheck.Generator is also needed by in my case it wasn't so I removed it also.

  import ExCheck.Predicate
  import ExCheck.Statement
  # use ExCheck.Generator
  # use ExUnit.Callbacks
  import :triq_dom, except: [atom: 0], only: :functions

  setup(context) do
    # Redirect all output first to IOServer process before test starts
    ExCheck.IOServer.redirect(self())
    {:ok, context}
  end
devstopfix commented 5 years ago

We can remove use ExUnit.Callbacks from lib/excheck.ex line 14. The test cases must either:

use ExUnit.Case
use ExCheck

or

use ExUnit.Callbacks
use ExCheck