@@ -1,16 +1,17 @@
|
|||||||
defmodule Runner do
|
defmodule Runner do
|
||||||
@modules [
|
@modules [
|
||||||
Equalities,
|
Equalities,
|
||||||
|
Arithmetic,
|
||||||
Strings,
|
Strings,
|
||||||
|
Tuples,
|
||||||
Lists,
|
Lists,
|
||||||
Maps,
|
Maps,
|
||||||
Functions,
|
|
||||||
Enums,
|
|
||||||
Arithmetic,
|
|
||||||
Structs,
|
Structs,
|
||||||
PatternMatching,
|
PatternMatching,
|
||||||
|
Functions,
|
||||||
|
Enums,
|
||||||
Processes,
|
Processes,
|
||||||
Tasks
|
Tasks,
|
||||||
]
|
]
|
||||||
|
|
||||||
def run do
|
def run do
|
||||||
|
|||||||
@@ -11,6 +11,55 @@ defmodule KoansHarnessTest do
|
|||||||
test_all(Equalities, answers)
|
test_all(Equalities, answers)
|
||||||
end
|
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
|
test "Lists" do
|
||||||
answers = [1,
|
answers = [1,
|
||||||
3,
|
3,
|
||||||
@@ -55,100 +104,6 @@ defmodule KoansHarnessTest do
|
|||||||
test_all(Maps, answers)
|
test_all(Maps, answers)
|
||||||
end
|
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
|
test "Structs" do
|
||||||
answers = [
|
answers = [
|
||||||
%Structs.Person{},
|
%Structs.Person{},
|
||||||
@@ -185,6 +140,66 @@ defmodule KoansHarnessTest do
|
|||||||
test_all(PatternMatching, answers)
|
test_all(PatternMatching, answers)
|
||||||
end
|
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
|
test "Processes" do
|
||||||
answers = [
|
answers = [
|
||||||
self,
|
self,
|
||||||
@@ -217,21 +232,6 @@ defmodule KoansHarnessTest do
|
|||||||
test_all(Tasks, answers)
|
test_all(Tasks, answers)
|
||||||
end
|
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
|
def test_all(module, answers) do
|
||||||
module.all_koans
|
module.all_koans
|
||||||
|> Enum.zip(answers)
|
|> Enum.zip(answers)
|
||||||
|
|||||||
Reference in New Issue
Block a user