We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce17aa9 commit eaad87aCopy full SHA for eaad87a
lib/elixir/test/elixir/kernel/with_test.exs
@@ -5,7 +5,6 @@ defmodule Kernel.WithTest do
5
6
test "basic with" do
7
assert with({:ok, res} <- ok(41), do: res) == 41
8
- assert with(res <- four(), do: res + 10) == 14
9
end
10
11
test "matching with" do
@@ -14,6 +13,12 @@ defmodule Kernel.WithTest do
14
13
assert with({:ok, _} = res <- ok(42), do: elem(res, 1)) == 42
15
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
+
22
test "with guards" do
23
assert with(x when x < 2 <- four(), do: :ok) == 4
24
assert with(x when x > 2 <- four(), do: :ok) == :ok
0 commit comments