Move koan about keyword lists as arguments to the function koan
This commit is contained in:
@@ -31,17 +31,4 @@ defmodule KeywordLists do
|
|||||||
|
|
||||||
assert_raise ArgumentError, fn -> not_kw_list[___] end
|
assert_raise ArgumentError, fn -> not_kw_list[___] end
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Conveniently keyword lists can be used for function options" do
|
|
||||||
transform = fn str, opts ->
|
|
||||||
if opts[:upcase] do
|
|
||||||
String.upcase(str)
|
|
||||||
else
|
|
||||||
str
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert transform.("good", upcase: true) == ___
|
|
||||||
assert transform.("good", upcase: false) == ___
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@@ -97,4 +97,17 @@ defmodule Functions do
|
|||||||
|
|
||||||
assert result == ___
|
assert result == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
|
koan "Conveniently keyword lists can be used for function options" do
|
||||||
|
transform = fn str, opts ->
|
||||||
|
if opts[:upcase] do
|
||||||
|
String.upcase(str)
|
||||||
|
else
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert transform.("good", upcase: true) == ___
|
||||||
|
assert transform.("good", upcase: false) == ___
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@@ -18,6 +18,7 @@ defmodule FunctionsTests do
|
|||||||
100,
|
100,
|
||||||
1000,
|
1000,
|
||||||
"Full Name",
|
"Full Name",
|
||||||
|
{:multiple, ["GOOD", "good"]},
|
||||||
]
|
]
|
||||||
|
|
||||||
test_all(Functions, answers)
|
test_all(Functions, answers)
|
||||||
|
@@ -9,7 +9,6 @@ defmodule KeywordListsTests do
|
|||||||
"baz",
|
"baz",
|
||||||
{:multiple, [:foo, "bar"]},
|
{:multiple, [:foo, "bar"]},
|
||||||
"foo",
|
"foo",
|
||||||
{:multiple, ["GOOD", "good"]},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
test_all(KeywordLists, answers)
|
test_all(KeywordLists, answers)
|
||||||
|
Reference in New Issue
Block a user