Merge pull request #174 from elixirkoans/iamvery/tweaks-to-pr-170

Tweaks to #170 MapSet example
This commit is contained in:
Felipe Seré
2017-02-19 13:52:51 +00:00
committed by GitHub
2 changed files with 17 additions and 3 deletions

View File

@@ -15,8 +15,22 @@ defmodule MapSets do
assert MapSet.size(new_set) == ___
end
koan "Even though I am like a list I am unordered after 32 elements" do
assert 1..33 |> MapSet.new() |> Enum.fetch(0) == {___, 11}
def sorted?(set) do
list = MapSet.to_list(set)
sorted = Enum.sort(list)
list == sorted
end
koan "You cannot depend on my order" do
new_set = MapSet.new(1..33)
assert sorted?(new_set) == ___
# Note: The number "33" is actually special here. Erlang uses a different
# implementation for maps after 32 elements which does not maintain order.
# http://stackoverflow.com/a/40408469
# What do you think this answer to this assertion is?
assert sorted?(@set) == ___
end
koan "Does this value exist in the map set?" do

View File

@@ -6,7 +6,7 @@ defmodule MapSetsTest do
answers = [
1,
3,
:ok,
{:multiple, [false, true]},
true,
{:multiple, [true, false]},
true,