From ca97177b99d0a7c9c1fbee2a6282ad95fe3d96c1 Mon Sep 17 00:00:00 2001 From: Tom Gurion Date: Sat, 22 Apr 2017 22:32:29 +0100 Subject: [PATCH 1/2] Simplify atoms koans. Fix #185 --- lib/koans/05_atoms.ex | 18 ++---------------- test/koans/atoms_koans_test.exs | 3 --- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/koans/05_atoms.ex b/lib/koans/05_atoms.ex index b565a17..f6b56bb 100644 --- a/lib/koans/05_atoms.ex +++ b/lib/koans/05_atoms.ex @@ -3,29 +3,15 @@ defmodule Atoms do @intro "Atoms" - koan "Atoms are sort of like strings" do + koan "Atoms are constants where their name is their own value" 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 is_boolean(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 diff --git a/test/koans/atoms_koans_test.exs b/test/koans/atoms_koans_test.exs index 743d986..794a81e 100644 --- a/test/koans/atoms_koans_test.exs +++ b/test/koans/atoms_koans_test.exs @@ -5,10 +5,7 @@ defmodule AtomsTests do test "Atoms" do answers = [ :human, - {:multiple, [:atomized, "stringified"]}, {:multiple, [true, true, true, false]}, - true, - "HELLO", ] test_all(Atoms, answers) From e64394fbaa484db285d900b515cc5f5d983b846a Mon Sep 17 00:00:00 2001 From: Tom Gurion Date: Sat, 22 Apr 2017 22:57:52 +0100 Subject: [PATCH 2/2] Add nil example to the atoms koans --- lib/koans/05_atoms.ex | 5 +++++ test/koans/atoms_koans_test.exs | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/koans/05_atoms.ex b/lib/koans/05_atoms.ex index f6b56bb..27d6cfb 100644 --- a/lib/koans/05_atoms.ex +++ b/lib/koans/05_atoms.ex @@ -14,4 +14,9 @@ defmodule Atoms do assert :true == ___ assert :false == ___ end + + koan "Like booleans, the nil value is also an atom" do + assert is_atom(nil) == ___ + assert :nil == ___ + end end diff --git a/test/koans/atoms_koans_test.exs b/test/koans/atoms_koans_test.exs index 794a81e..37bbcdc 100644 --- a/test/koans/atoms_koans_test.exs +++ b/test/koans/atoms_koans_test.exs @@ -6,6 +6,7 @@ defmodule AtomsTests do answers = [ :human, {:multiple, [true, true, true, false]}, + {:multiple, [true, nil]} ] test_all(Atoms, answers)