Improve some descriptions a little bit

This commit is contained in:
Uku Taht
2016-03-20 20:31:48 +00:00
parent bd5972a867
commit 7ee7514192
4 changed files with 13 additions and 18 deletions

View File

@@ -1,35 +1,35 @@
defmodule Tuples do defmodule Tuples do
use Koans use Koans
koan "tuples have a size" do koan "Tuples have a size" do
assert tuple_size({:a, :b, :c}) == :__ assert tuple_size({:a, :b, :c}) == :__
end end
koan "tuples can contain different things" do koan "Tuples can contain different things" do
assert {:a, 1, "hi"} == :__ assert {:a, 1, "hi"} == :__
end end
koan "you can pull out individual elements" do koan "You can pull out individual elements" do
assert elem({:a, "hi"}, 1) == :__ assert elem({:a, "hi"}, 1) == :__
end end
koan "you can change individual elements of a tuple" do koan "You can change individual elements of a tuple" do
assert put_elem({:a, "hi"}, 1, "bye") == :__ assert put_elem({:a, "hi"}, 1, "bye") == :__
end end
koan "you can also simply extend a tuple with new stuff" do koan "You can also simply extend a tuple with new stuff" do
assert Tuple.insert_at({:a, "hi"}, 1, :new_thing) == :__ assert Tuple.insert_at({:a, "hi"}, 1, :new_thing) == :__
end end
koan "add things at the end" do koan "Add things at the end" do
assert Tuple.append({"Huey", "Dewey"}, "Louie") == :__ assert Tuple.append({"Huey", "Dewey"}, "Louie") == :__
end end
koan "or also remove them" do koan "Or remove them" do
assert Tuple.delete_at({:this, :is, :not, :awesome}, 2) == :__ assert Tuple.delete_at({:this, :is, :not, :awesome}, 2) == :__
end end
koan "turn it into a list in case you need it" do koan "Turn it into a list in case you need it" do
assert Tuple.to_list({:this, :can, :be, :a, :list}) == :__ assert Tuple.to_list({:this, :can, :be, :a, :list}) == :__
end end
end end

View File

@@ -9,10 +9,6 @@ defmodule Lists do
assert List.last([1, 2, 3]) == :__ assert List.last([1, 2, 3]) == :__
end end
koan "Diversity is embraced" do
assert [1, 2] ++ [:a, "b"] == :__
end
koan "Things can evolve" do koan "Things can evolve" do
assert [1, 2, 3] -- [3] == :__ assert [1, 2, 3] -- [3] == :__
end end

View File

@@ -17,15 +17,15 @@ defmodule Maps do
assert Map.values(%{ :name => "Jon", :last_name => "Snow", :age => 27 }) == :__ assert Map.values(%{ :name => "Jon", :last_name => "Snow", :age => 27 }) == :__
end end
koan "Fetching a value returns a touple with ok when it exists..." do koan "Fetching a value returns a tuple with ok when it exists" do
assert Map.fetch(%{ :name => "Jon", :last_name => "Snow", :age => 27 }, :age) == :__ assert Map.fetch(%{ :name => "Jon", :last_name => "Snow", :age => 27 }, :age) == :__
end end
koan "...or the atom :error when it doesnt." do koan "Or the atom :error when it doesnt" do
assert Map.fetch(%{ :name => "Jon", :last_name => "Snow", :age => 27 }, :family) == :__ assert Map.fetch(%{ :name => "Jon", :last_name => "Snow", :age => 27 }, :family) == :__
end end
koan "Extending a map is a simple as put'ing in a new pair" do koan "Extending a map is a simple as putting in a new pair" do
assert Map.put(%{ :name => "Jon", :last_name => "Snow"}, :age, 27) == :__ assert Map.put(%{ :name => "Jon", :last_name => "Snow"}, :age, 27) == :__
end end
@@ -33,7 +33,7 @@ defmodule Maps do
assert Map.put(%{ :name => "Jon", :last_name => "Snow", :age => 15}, :age, 27) == :__ assert Map.put(%{ :name => "Jon", :last_name => "Snow", :age => 15}, :age, 27) == :__
end end
koan "Or you can use some syntactic sugar for exiting elements." do koan "Or you can use some syntactic sugar for exiting elements" do
initial = %{ :name => "Jon", :last_name => "Snow", :age => 16} initial = %{ :name => "Jon", :last_name => "Snow", :age => 16}
assert %{ initial | :age => 27 } == :__ assert %{ initial | :age => 27 } == :__
end end
@@ -46,7 +46,7 @@ defmodule Maps do
assert Map.new( [{:name, "Jon"}, {:last_name, "Snow"}, {:age, 27}] ) == :__ assert Map.new( [{:name, "Jon"}, {:last_name, "Snow"}, {:age, 27}] ) == :__
end end
koan "Going back to a list of pairs is just as easy." do koan "Going back to a list of pairs is just as easy" do
assert Map.to_list(%{ :name => "Jon", :last_name => "Snow", :age => 27 }) == :__ assert Map.to_list(%{ :name => "Jon", :last_name => "Snow", :age => 27 }) == :__
end end

View File

@@ -63,7 +63,6 @@ defmodule KoansHarnessTest do
test "Lists" do test "Lists" do
answers = [1, answers = [1,
3, 3,
[1,2,:a,"b"],
[1,2], [1,2],
[1,2,3], [1,2,3],
[1,3], [1,3],