Skip to content

Commit eaad87a

Browse files
committed
Avoid warning in test
warning: this clause cannot match because a previous clause at line 8 always matches
1 parent ce17aa9 commit eaad87a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/elixir/test/elixir/kernel/with_test.exs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ defmodule Kernel.WithTest do
55

66
test "basic with" do
77
assert with({:ok, res} <- ok(41), do: res) == 41
8-
assert with(res <- four(), do: res + 10) == 14
98
end
109

1110
test "matching with" do
@@ -14,6 +13,12 @@ defmodule Kernel.WithTest do
1413
assert with({:ok, _} = res <- ok(42), do: elem(res, 1)) == 42
1514
end
1615

16+
test "always matching clause in with" do
17+
# using eval to avoid "clause cannot match" warning
18+
assert {14, []} =
19+
Code.eval_quoted(quote do: with(res <- 2 * 2, do: res + 10))
20+
end
21+
1722
test "with guards" do
1823
assert with(x when x < 2 <- four(), do: :ok) == 4
1924
assert with(x when x > 2 <- four(), do: :ok) == :ok

0 commit comments

Comments
 (0)