Merge pull request #105 from iamvery/atoms-koan

Atoms koan
This commit is contained in:
Uku Taht
2016-05-05 23:38:34 +01:00
12 changed files with 45 additions and 0 deletions

29
lib/koans/03_atoms.ex Normal file
View File

@@ -0,0 +1,29 @@
defmodule Atoms do
use Koans
koan "Atoms are sort of like strings" do
adam = :human
assert adam == ___
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
assert is_atom(true) == ___
assert is_atom(false) == ___
assert :true == ___
assert :false == ___
end
koan "Modules are also atoms" do
assert is_atom(String) == ___
end
koan "Functions can be called on the atom too" do
assert :"Elixir.String" == String
assert :"Elixir.String".upcase("hello") == ___
end
end

View File

@@ -0,0 +1,16 @@
defmodule AtomsTests do
use ExUnit.Case
import TestHarness
test "Atoms" do
answers = [
:human,
{:multiple, [:atomized, "stringified"]},
{:multiple, [true, true, true, false]},
true,
"HELLO",
]
test_all(Atoms, answers)
end
end