Elixir: Genservers
🚧 In development
Instructions
🚧 In development
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Elixir: Genservers
🚧 In development
Instructions
🚧 In development
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Your exercise will be checked with these tests:
defmodule Test do
use ExUnit.Case
describe "solution genserver work" do
test "initialization work" do
{:ok, pid} = Solution.start_link()
assert Process.alive?(pid)
Process.exit(pid, :normal)
end
test "current_state work" do
{:ok, pid} = Solution.start_link(%{test: "value"})
assert Solution.current_state() == %{test: "value"}
Process.exit(pid, :normal)
end
test "reset work" do
{:ok, pid} = Solution.start_link(%{test: "value"})
assert Solution.reset() == :ok
assert Solution.current_state() == %{}
Process.exit(pid, :normal)
end
test "has? work" do
{:ok, pid} = Solution.start_link(%{test: "value"})
assert Solution.has?(:test)
refute Solution.has?(:some)
Process.exit(pid, :normal)
end
test "add work" do
{:ok, pid} = Solution.start_link(%{test: "value"})
assert Solution.add(:some, 2) == :ok
assert Solution.current_state() == %{test: "value", some: 2}
Process.exit(pid, :normal)
end
test "drop work" do
{:ok, pid} = Solution.start_link(%{test: "value"})
assert Solution.drop(:some) == :ok
assert Solution.current_state() == %{test: "value"}
assert Solution.drop(:test) == :ok
assert Solution.current_state() == %{}
Process.exit(pid, :normal)
end
end
endTeacher's solution will be available in:
20:00
