Skip to content

Instantly share code, notes, and snippets.

@knewter
Created August 2, 2017 23:20
defmodule SomeModule do
def func(map, key) do
for {k, v} <- map, into: %{} do
{k, v/map[key]}
end
end
end
defmodule MapDivisionTest do
use ExUnit.Case
doctest MapDivision
test "the thing" do
map =
%{
"cash" => 100,
"a" => 1,
"b" => 2
}
expected =
%{
"cash" => 1,
"a" => 1/100,
"b" => 2/100
}
assert SomeModule.func(map, "cash") == expected
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment