Simplify cases

This commit is contained in:
Jay Hayes
2016-05-02 18:56:27 -05:00
parent 71dfd882c6
commit cc47f7c9c6
2 changed files with 7 additions and 19 deletions

View File

@@ -94,27 +94,15 @@ defmodule Processes do
end end
koan "Parent processes can be informed about exiting children, if they trap and link" do koan "Parent processes can be informed about exiting children, if they trap and link" do
parent = self() Process.flag(:trap_exit, true)
spawn(fn -> spawn_link(fn -> Process.exit(self, :normal) end)
Process.flag(:trap_exit, true)
spawn_link(fn -> Process.exit(self(), :normal) end)
receive do
{:EXIT, _pid ,reason} -> send parent, {:exited, reason}
end
end)
assert_receive ___ assert_receive {:EXIT, _pid, ___}
end end
koan "If you monitor your children, you'll be automatically informed for their depature" do koan "If you monitor your children, you'll be automatically informed for their depature" do
parent = self() spawn_monitor(fn -> Process.exit(self(), :normal) end)
spawn(fn ->
spawn_monitor(fn -> Process.exit(self(), :normal) end)
receive do
{:DOWN, _ref, :process, _pid, reason} -> send parent, {:exited, reason}
end
end)
assert_receive ___ assert_receive {:DOWN, _ref, :process, _pid, ___}
end end
end end

View File

@@ -15,8 +15,8 @@ defmodule ProcessesTests do
{:exited, :random_reason}, {:exited, :random_reason},
true, true,
false, false,
{:exited, :normal}, :normal,
{:exited, :normal}, :normal,
] ]
test_all(Processes, answers) test_all(Processes, answers)