Fix Elixir 1.4 function paren warnings
This commit is contained in:
@@ -2,7 +2,7 @@ defmodule Display.Paint do
|
|||||||
def red(str), do: painter().red(str)
|
def red(str), do: painter().red(str)
|
||||||
def cyan(str), do: painter().cyan(str)
|
def cyan(str), do: painter().cyan(str)
|
||||||
def green(str), do: painter().green(str)
|
def green(str), do: painter().green(str)
|
||||||
def yellow(str), do: painter.yellow(str)
|
def yellow(str), do: painter().yellow(str)
|
||||||
|
|
||||||
defp painter do
|
defp painter do
|
||||||
case Mix.env do
|
case Mix.env do
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ defmodule Processes do
|
|||||||
@intro "Processes"
|
@intro "Processes"
|
||||||
|
|
||||||
koan "You are a process" do
|
koan "You are a process" do
|
||||||
assert Process.alive?(self) == ___
|
assert Process.alive?(self()) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "You can ask a process to introduce itself" do
|
koan "You can ask a process to introduce itself" do
|
||||||
information = Process.info(self)
|
information = Process.info(self())
|
||||||
|
|
||||||
assert information[:status] == ___
|
assert information[:status] == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Processes are referenced by their process ID (pid)" do
|
koan "Processes are referenced by their process ID (pid)" do
|
||||||
assert is_pid(self) == ___
|
assert is_pid(self()) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "New processes are spawned functions" do
|
koan "New processes are spawned functions" do
|
||||||
@@ -24,7 +24,7 @@ defmodule Processes do
|
|||||||
end
|
end
|
||||||
|
|
||||||
koan "Processes can send and receive messages" do
|
koan "Processes can send and receive messages" do
|
||||||
send self, "hola!"
|
send self(), "hola!"
|
||||||
|
|
||||||
receive do
|
receive do
|
||||||
msg -> assert msg == ___
|
msg -> assert msg == ___
|
||||||
@@ -32,8 +32,8 @@ defmodule Processes do
|
|||||||
end
|
end
|
||||||
|
|
||||||
koan "Received messages are queued, first in first out" do
|
koan "Received messages are queued, first in first out" do
|
||||||
send self, "hola!"
|
send self(), "hola!"
|
||||||
send self, "como se llama?"
|
send self(), "como se llama?"
|
||||||
|
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
@@ -48,7 +48,7 @@ defmodule Processes do
|
|||||||
|
|
||||||
pid = spawn(greeter)
|
pid = spawn(greeter)
|
||||||
|
|
||||||
send pid, {:hello, self}
|
send pid, {:hello, self()}
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -56,17 +56,17 @@ defmodule Processes do
|
|||||||
receive do
|
receive do
|
||||||
{caller, value} ->
|
{caller, value} ->
|
||||||
send caller, String.upcase(value)
|
send caller, String.upcase(value)
|
||||||
yelling_echo_loop
|
yelling_echo_loop()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Use tail recursion to receive multiple messages" do
|
koan "Use tail recursion to receive multiple messages" do
|
||||||
pid = spawn_link(&yelling_echo_loop/0)
|
pid = spawn_link(&yelling_echo_loop/0)
|
||||||
|
|
||||||
send pid, {self, "o"}
|
send pid, {self(), "o"}
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
|
|
||||||
send pid, {self, "hai"}
|
send pid, {self(), "hai"}
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,16 +86,16 @@ defmodule Processes do
|
|||||||
state(initial_state)
|
state(initial_state)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
send pid, {self, :get}
|
send pid, {self(), :get}
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
|
|
||||||
send pid, {self, :set, "bar"}
|
send pid, {self(), :set, "bar"}
|
||||||
send pid, {self, :get}
|
send pid, {self(), :get}
|
||||||
assert_receive ___
|
assert_receive ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Waiting for a message can get boring" do
|
koan "Waiting for a message can get boring" do
|
||||||
parent = self
|
parent = self()
|
||||||
spawn(fn -> receive do
|
spawn(fn -> receive do
|
||||||
after
|
after
|
||||||
5 -> send parent, {:waited_too_long, "I am impatient"}
|
5 -> send parent, {:waited_too_long, "I am impatient"}
|
||||||
@@ -106,7 +106,7 @@ defmodule Processes do
|
|||||||
end
|
end
|
||||||
|
|
||||||
koan "Trapping will allow you to react to someone terminating the process" do
|
koan "Trapping will allow you to react to someone terminating the process" do
|
||||||
parent = self
|
parent = self()
|
||||||
pid = spawn(fn ->
|
pid = spawn(fn ->
|
||||||
Process.flag(:trap_exit, true)
|
Process.flag(:trap_exit, true)
|
||||||
send parent, :ready
|
send parent, :ready
|
||||||
@@ -126,13 +126,13 @@ defmodule Processes do
|
|||||||
|
|
||||||
koan "Parent processes can trap exits for children they are linked to" do
|
koan "Parent processes can trap exits for children they are linked to" do
|
||||||
Process.flag(:trap_exit, true)
|
Process.flag(:trap_exit, true)
|
||||||
spawn_link(fn -> Process.exit(self, :normal) end)
|
spawn_link(fn -> Process.exit(self(), :normal) end)
|
||||||
|
|
||||||
assert_receive {:EXIT, _pid, ___}
|
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
|
||||||
spawn_monitor(fn -> Process.exit(self, :normal) end)
|
spawn_monitor(fn -> Process.exit(self(), :normal) end)
|
||||||
|
|
||||||
assert_receive {:DOWN, _ref, :process, _pid, ___}
|
assert_receive {:DOWN, _ref, :process, _pid, ___}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ defmodule Tracker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def visited do
|
def visited do
|
||||||
summarize[:visited_modules]
|
summarize()[:visited_modules]
|
||||||
end
|
end
|
||||||
|
|
||||||
def complete? do
|
def complete? do
|
||||||
%{total: total, current: completed} = summarize
|
%{total: total, current: completed} = summarize()
|
||||||
total == completed
|
total == completed
|
||||||
end
|
end
|
||||||
|
|
||||||
def summarize, do: get |> summarize
|
def summarize, do: get() |> summarize()
|
||||||
defp summarize(%{total: total,
|
defp summarize(%{total: total,
|
||||||
koans: completed,
|
koans: completed,
|
||||||
visited_modules: modules}) do
|
visited_modules: modules}) do
|
||||||
|
|||||||
2
mix.exs
2
mix.exs
@@ -6,7 +6,7 @@ defmodule Koans.Mixfile do
|
|||||||
version: "0.0.1",
|
version: "0.0.1",
|
||||||
elixir: ">= 1.2.1 and <= 1.4.0",
|
elixir: ">= 1.2.1 and <= 1.4.0",
|
||||||
elixirc_paths: elixirc_path(Mix.env),
|
elixirc_paths: elixirc_path(Mix.env),
|
||||||
deps: deps]
|
deps: deps()]
|
||||||
end
|
end
|
||||||
|
|
||||||
def application do
|
def application do
|
||||||
|
|||||||
Reference in New Issue
Block a user