我跟随旧视频了解流程。我试图发送ping但是我在测试中收回了这个错误。 lib/ping_test.ex:4: undefined function pid/1
我不确定我做错了什么,因为我还不熟悉Elixir。这是我的代码:
defmodule Ping do
def start do
receive do
{:pong, pid} -> send(pid {:ping, self()})
end
end
end
test "it responds to a pong with a ping" do
ping = spawn_link(Ping, :start, [])
send ping, {:pong, self}
assert_receive {:ping, ping}
end
lib/ping_test.ex:4: undefined function pid/1
那么我做错了什么?