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