Merge pull request #189 from Nagasaki45/atoms

Simplify atoms koans. Fix #185
This commit is contained in:
Uku Taht
2017-04-24 09:51:16 +01:00
committed by GitHub
2 changed files with 6 additions and 17 deletions

View File

@@ -3,29 +3,20 @@ defmodule Atoms do
@intro "Atoms" @intro "Atoms"
koan "Atoms are sort of like strings" do koan "Atoms are constants where their name is their own value" do
adam = :human adam = :human
assert adam == ___ assert adam == ___
end end
koan "Strings can be converted to atoms, and vice versa" do
assert String.to_atom("atomized") == ___
assert Atom.to_string(:stringified) == ___
end
koan "It is surprising to find out that booleans are atoms" do koan "It is surprising to find out that booleans are atoms" do
assert is_atom(true) == ___ assert is_atom(true) == ___
assert is_atom(false) == ___ assert is_boolean(false) == ___
assert :true == ___ assert :true == ___
assert :false == ___ assert :false == ___
end end
koan "Modules are also atoms" do koan "Like booleans, the nil value is also an atom" do
assert is_atom(String) == ___ assert is_atom(nil) == ___
end assert :nil == ___
koan "Functions can be called on the atom too" do
assert :"Elixir.String" == String
assert :"Elixir.String".upcase("hello") == ___
end end
end end

View File

@@ -5,10 +5,8 @@ defmodule AtomsTests do
test "Atoms" do test "Atoms" do
answers = [ answers = [
:human, :human,
{:multiple, [:atomized, "stringified"]},
{:multiple, [true, true, true, false]}, {:multiple, [true, true, true, false]},
true, {:multiple, [true, nil]}
"HELLO",
] ]
test_all(Atoms, answers) test_all(Atoms, answers)