From 2881c95c0009d5dfc60972334e8815e5d4e298d3 Mon Sep 17 00:00:00 2001 From: Sven Gehring Date: Wed, 22 Mar 2017 10:38:42 +0100 Subject: [PATCH] Split koan with race condition into two more logical ones --- lib/koans/15_processes.ex | 13 ++++++++++++- test/koans/processes_koans_test.exs | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/koans/15_processes.ex b/lib/koans/15_processes.ex index 8f03cf1..65c3419 100644 --- a/lib/koans/15_processes.ex +++ b/lib/koans/15_processes.ex @@ -17,9 +17,20 @@ defmodule Processes do assert is_pid(self()) == ___ end - koan "New processes are spawned functions" do + koan "Like our current process, new processes are spawned functions" do pid = spawn(fn -> nil end) + assert is_pid(pid) == ___ + end + + koan "Processes exit after executing their function, unless they wait for something" do + wait_forever = fn -> + receive do + end + end + + pid = spawn(wait_forever) + assert Process.alive?(pid) == ___ end diff --git a/test/koans/processes_koans_test.exs b/test/koans/processes_koans_test.exs index d258c53..d3dd9a5 100644 --- a/test/koans/processes_koans_test.exs +++ b/test/koans/processes_koans_test.exs @@ -8,6 +8,7 @@ defmodule ProcessesTests do :running, true, true, + true, "hola!", {:multiple, ["hola!", "como se llama?"]}, :how_are_you?,