diff --git a/lib/koans/07_arithmetic.ex b/lib/koans/02_arithmetic.ex similarity index 100% rename from lib/koans/07_arithmetic.ex rename to lib/koans/02_arithmetic.ex diff --git a/lib/koans/04_strings.ex b/lib/koans/03_strings.ex similarity index 100% rename from lib/koans/04_strings.ex rename to lib/koans/03_strings.ex diff --git a/lib/koans/12_tuples.ex b/lib/koans/04_tuples.ex similarity index 100% rename from lib/koans/12_tuples.ex rename to lib/koans/04_tuples.ex diff --git a/lib/koans/02_lists.ex b/lib/koans/05_lists.ex similarity index 100% rename from lib/koans/02_lists.ex rename to lib/koans/05_lists.ex diff --git a/lib/koans/03_maps.ex b/lib/koans/06_maps.ex similarity index 100% rename from lib/koans/03_maps.ex rename to lib/koans/06_maps.ex diff --git a/lib/koans/08_structs.ex b/lib/koans/07_structs.ex similarity index 100% rename from lib/koans/08_structs.ex rename to lib/koans/07_structs.ex diff --git a/lib/koans/09_pattern_matching.ex b/lib/koans/08_pattern_matching.ex similarity index 100% rename from lib/koans/09_pattern_matching.ex rename to lib/koans/08_pattern_matching.ex diff --git a/lib/koans/05_functions.ex b/lib/koans/09_functions.ex similarity index 100% rename from lib/koans/05_functions.ex rename to lib/koans/09_functions.ex diff --git a/lib/koans/06_enum.ex b/lib/koans/10_enums.ex similarity index 100% rename from lib/koans/06_enum.ex rename to lib/koans/10_enums.ex diff --git a/lib/koans/10_processes.ex b/lib/koans/11_processes.ex similarity index 100% rename from lib/koans/10_processes.ex rename to lib/koans/11_processes.ex diff --git a/lib/koans/11_task.ex b/lib/koans/12_task.ex similarity index 100% rename from lib/koans/11_task.ex rename to lib/koans/12_task.ex diff --git a/lib/runner.ex b/lib/runner.ex index d4d4559..fdb700e 100644 --- a/lib/runner.ex +++ b/lib/runner.ex @@ -1,16 +1,17 @@ defmodule Runner do @modules [ Equalities, + Arithmetic, Strings, + Tuples, Lists, Maps, - Functions, - Enums, - Arithmetic, Structs, PatternMatching, + Functions, + Enums, Processes, - Tasks + Tasks, ] def run do diff --git a/test/koans_harness_test.exs b/test/koans_harness_test.exs index 3653f1f..5db07bb 100644 --- a/test/koans_harness_test.exs +++ b/test/koans_harness_test.exs @@ -11,6 +11,55 @@ defmodule KoansHarnessTest do test_all(Equalities, answers) end + test "Arithmetic" do + answers = [ + 4, + 3, + 12, + 3, + 3, + 2.5, + 2, + 1, + 4, + 1, + 2 + ] + + test_all(Arithmetic, answers) + end + + test "Strings" do + answers = [ + "hello", + "hello ", + ["hello", "world"], + "An awful day", + "incredible", + "banana", + "banana", + "String", + "listen" + ] + + test_all(Strings, answers) + end + + test "Tuples" do + answers = [ + 3, + {:a, 1, "hi"}, + "hi", + {:a, "bye"}, + {:a, :new_thing, "hi"}, + {"Huey", "Dewey", "Louie"}, + {:this, :is, :awesome}, + [:this, :can, :be, :a, :list] + ] + + test_all(Tuples, answers) + end + test "Lists" do answers = [1, 3, @@ -55,100 +104,6 @@ defmodule KoansHarnessTest do test_all(Maps, answers) end - test "String" do - answers = [ - "hello", - "hello ", - ["hello", "world"], - "An awful day", - "incredible", - "banana", - "banana", - "String", - "listen" - ] - - test_all(Strings, answers) - end - - test "Functions" do - answers = [ - :light, - 3, - :it_was_truthy, - "It really wasn't", - "Hello Hello Hello ", - "Hello Hello Hello Hello Hello ", - "One and Two", - "only One", - :entire_list, - :single_thing, - "10 is bigger than 5", - "4 is not bigger than 27", - "It was zero", - "The length was 5", - 6, - 6, - "the other one", - 100, - "Full Name" - ] - - test_all(Functions, answers) - end - - test "Enum" do - answers = [ - 4, - 4, - 4, - true, - false, - true, - false, - true, - false, - [10,20,30], - [false, true, false], - [1,2,3], - [1,3], - [2], - [1,2,3], - [1,2,3,4,5], - [1,2,3], - [1,2,3], - [1,2,3], - %{ :odd => [3,1], :even => [4,2] }, - %{ 0 => [6, 3], 1 => [4, 1], 2 => [5, 2]}, - [{1, :a}, {2, :b}, {3, :c}], - [{1, :a}, {2, :b}, {3, :c}], - 2, - nil, - :no_such_element, - 6 - ] - - test_all(Enums, answers) - end - - test "Arithmetic" do - answers = [ - 4, - 3, - 12, - 3, - 3, - 2.5, - 2, - 1, - 4, - 1, - 2 - ] - - test_all(Arithmetic, answers) - end - test "Structs" do answers = [ %Structs.Person{}, @@ -185,6 +140,66 @@ defmodule KoansHarnessTest do test_all(PatternMatching, answers) end + test "Functions" do + answers = [ + :light, + 3, + :it_was_truthy, + "It really wasn't", + "Hello Hello Hello ", + "Hello Hello Hello Hello Hello ", + "One and Two", + "only One", + :entire_list, + :single_thing, + "10 is bigger than 5", + "4 is not bigger than 27", + "It was zero", + "The length was 5", + 6, + 6, + "the other one", + 100, + "Full Name" + ] + + test_all(Functions, answers) + end + + test "Enums" do + answers = [ + 4, + 4, + 4, + true, + false, + true, + false, + true, + false, + [10,20,30], + [false, true, false], + [1,2,3], + [1,3], + [2], + [1,2,3], + [1,2,3,4,5], + [1,2,3], + [1,2,3], + [1,2,3], + %{ :odd => [3,1], :even => [4,2] }, + %{ 0 => [6, 3], 1 => [4, 1], 2 => [5, 2]}, + [{1, :a}, {2, :b}, {3, :c}], + [{1, :a}, {2, :b}, {3, :c}], + 2, + nil, + :no_such_element, + 6 + ] + + test_all(Enums, answers) + end + test "Processes" do answers = [ self, @@ -217,21 +232,6 @@ defmodule KoansHarnessTest do test_all(Tasks, answers) end - test "Tuples" do - answers = [ - 3, - {:a, 1, "hi"}, - "hi", - {:a, "bye"}, - {:a, :new_thing, "hi"}, - {"Huey", "Dewey", "Louie"}, - {:this, :is, :awesome}, - [:this, :can, :be, :a, :list] - ] - - test_all(Tuples, answers) - end - def test_all(module, answers) do module.all_koans |> Enum.zip(answers)