-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeal_test.exs
53 lines (43 loc) · 975 Bytes
/
deal_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
defmodule DealTest do
use ExUnit.Case
doctest Deal
# test "greets the world" do
# assert Deal.hello() == :world
# end
def f(x), do: {:ok, x}
def g(_), do: {:ok, 3}
def h(x), do: {:ok, x+3}
def i(x), do: x+6
test "Simple deal use case" do
result = Deal.with! do
f(1)
g()
h()
end
assert result == {:ok, 6}
end
test "Deal with unexcepted pattern" do
result = Deal.with! do
f(1)
i()
h()
end
assert result == 7
end
test "Deal inlined" do
result = Deal.with! do: (f(1); g(); h())
assert result == {:ok, 6}
end
test "Deal inlined with unexcepted pattern" do
result = Deal.with! do: (f(1); i(); h())
assert result == 7
end
test "Deal with tuple" do
result = Deal.with! do: {f(1), g(), h()}
assert result == {:ok, 6}
end
test "Deal with tuple and unexcepted pattern" do
result = Deal.with! do: {f(1), i(), h()}
assert result == 7
end
end