Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## todo
- ## error messageの変数名がtest caseのほうではない
- ## leftはrightのsubsetだがrightにマージしているので値が変わっているのでわかりにくい?ここは仕様の問題でもあると思うが、、
- defmodule AssertionMatch do
- import ExUnit.Assertions
- def assert_match?(left, right) do
- right_map = case right do
- %_{} -> Map.from_struct(right)
- %{} -> right
- _ -> :error
- end
- left = Map.merge(right_map , left);
- assert left == right_map
- end
- end
- defmodule Struct do
- defstruct a: 1, b: 1, z: 10
- end
- defmodule Main do
- left_main = %{a: 1, b: 2 };
- right_main = %Struct{}
- import AssertionMatch
- assert_match?(left_main,right_main)
- # Assertion with == failed
- # code: left == right_map
- # left: %{a: 1, b: 2, z: 10}
- # right: %{a: 1, b: 1, z: 10}
- end
Add Comment
Please, Sign In to add comment