Skip to content

Commit

Permalink
Merge pull request #105 from iamvery/atoms-koan
Browse files Browse the repository at this point in the history
Atoms koan
  • Loading branch information
ukutaht committed May 5, 2016
2 parents 0a57e38 + ad011d8 commit 3e163a2
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/koans/03_atoms.ex
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions test/koans/atoms_koans_test.exs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3e163a2

Please sign in to comment.