Use triple underscore instead of double

This commit is contained in:
Uku Taht
2016-04-20 11:23:44 +01:00
parent ea2bb8f9bf
commit ded0f11ec6
16 changed files with 148 additions and 161 deletions

View File

@@ -2,53 +2,53 @@ defmodule PatternMatching do
use Koans
koan "One matches one" do
assert match?(1, __)
assert match?(1, ___)
end
koan "A pattern can change" do
a = 1
assert a = __
assert a = ___
end
koan "A pattern can also be strict" do
a = 1
assert ^a = __
assert ^a = ___
end
koan "Patterns can be used to pull things apart" do
[head | tail] = [1,2,3,4]
assert head == __
assert tail == __
assert head == ___
assert tail == ___
end
koan "And then put them back together" do
head = 1
tail = [2,3,4]
assert __ == [head | tail]
assert ___ == [head | tail]
end
koan "Some values can be ignored" do
[_first, _second, third, _fourth] = [1,2,3,4]
assert third == __
assert third == ___
end
koan "Strings come apart just a easily" do
"Shopping list: " <> items = "Shopping list: eggs, milk"
assert items == __
assert items == ___
end
koan "Patterns show what you really care about" do
%{make: make} = %{type: "car", year: 2016, make: "Honda", color: "black"}
assert make == __
assert make == ___
end
koan "The pattern can make assertions about what it expects" do
assert match?([1, _second, _third], __)
assert match?([1, _second, _third], ___)
end
def make_noise(%{type: "cat"}), do: "Meow"
@@ -60,9 +60,9 @@ defmodule PatternMatching do
cat = %{type: "cat", legs: 4, age: 3, color: "grey"}
snake = %{type: "snake", legs: 0, age: 20, color: "black"}
assert make_noise(dog) == __
assert make_noise(cat) == __
assert make_noise(snake) == __
assert make_noise(dog) == ___
assert make_noise(cat) == ___
assert make_noise(snake) == ___
end
koan "Errors are shaped differently than sucessful results" do
@@ -71,6 +71,6 @@ defmodule PatternMatching do
_ -> flunk("I should not happen")
end
assert result == __
assert result == ___
end
end