Simplify cases
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user