Created
August 2, 2017 23:20
-
-
Save knewter/ebdd22838a7bd77b35eeea03baab2c6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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