Improve punctuation in Tasks koans

This commit is contained in:
Felipe Sere
2016-03-21 19:29:05 +00:00
parent b95d4f1202
commit 690627656e

View File

@@ -7,12 +7,12 @@ defmodule Tasks do
assert Task.await(task) + 1 == :__ assert Task.await(task) + 1 == :__
end end
koan "if you don't need a result, use start_link/1" do koan "If you don't need a result, use start_link/1" do
{result, _pid} = Task.start_link(fn -> 1+1 end) {result, _pid} = Task.start_link(fn -> 1+1 end)
assert result == :__ assert result == :__
end end
koan "yield returns nothing if the task isn't done yet" do koan "Yield returns nothing if the task isn't done yet" do
handle = Task.async(fn -> handle = Task.async(fn ->
:timer.sleep(100) :timer.sleep(100)
3 * 3 3 * 3
@@ -20,7 +20,7 @@ defmodule Tasks do
assert Task.yield(handle, 10) == :__ assert Task.yield(handle, 10) == :__
end end
koan "tasks can be aborted with shutdown" do koan "Tasks can be aborted with shutdown" do
handle = Task.async(fn -> handle = Task.async(fn ->
:timer.sleep(100) :timer.sleep(100)
3 * 3 3 * 3
@@ -34,7 +34,7 @@ defmodule Tasks do
assert Task.shutdown(handle) == {:ok, :__} assert Task.shutdown(handle) == {:ok, :__}
end end
koan "you can yield to multiple tasks at once and extract the results" do koan "You can yield to multiple tasks at once and extract the results" do
squares = [1,2,3,4] squares = [1,2,3,4]
|> Enum.map(fn(number) -> Task.async(fn -> number * number end) end) |> Enum.map(fn(number) -> Task.async(fn -> number * number end) end)
|> Task.yield_many(100) |> Task.yield_many(100)