-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from iamvery/atoms-koan
Atoms koan
- Loading branch information
Showing
12 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |