forked from dojo-toulouse/elixir-koans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout_testing.exs
executable file
·40 lines (29 loc) · 1.13 KB
/
about_testing.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
#!/usr/bin/env elixir
# This should be replaced with the correct code to start the ExUnit server
Koans.About_testing.start_exUnit!
defmodule About_testing do
use FakeUnit.Case
use Koans.About_testing
think "We shall contemplate truth by testing reality, via asserts." do
assert __?
end
think "When reality lies, we shall refute truth" do
refute __?
end
think "Enlightenment may be more easily achieved with appropriate messages." do
assert __?, "This should be true -- Please fix this"
end
think "To understand reality, we must compare our expectations against reality." do
expected_value = __?
actual_value = 1 + 1
assert expected_value == actual_value
end
think "Assertions are smart" do
is_1_equal_2? = fn -> assert 1 == 2 end
is_1_greater_than_2? = fn -> assert 1 > 2 end
message = "Assertion with " <> __? <> " failed"
assert_raise ExUnit.AssertionError, message, is_1_equal_2?
message = "Assertion with " <> __? <> " failed"
assert_raise ExUnit.AssertionError, message, is_1_greater_than_2?
end
end