 
       test "supports match patterns", %{registry: registry} do
         value1 = {1, :atom, 1}
+        value2 = {2, :atom, 2}
+
         {:ok, _} = Registry.register(registry, "hello", value1)
-        value2 = {2, :atom, 2}
         {:ok, _} = Registry.register(registry, "hello", value2)
 
-        assert Registry.match(registry, "hello", {1, :_, :_}) ==
-               [{self(), value1}]
-        assert Registry.match(registry, "hello", {1.0, :_, :_}) ==
-               []
+        assert Registry.match(registry, "hello", {1, :_, :_}) == [{self(), value1}]
+        assert Registry.match(registry, "hello", {1.0, :_, :_}) == []
+
         assert Registry.match(registry, "hello", {:_, :atom, :_}) |> Enum.sort() ==
-               [{self(), value1}, {self(), value2}]
+                 [{self(), value1}, {self(), value2}]
+
         assert Registry.match(registry, "hello", {:"$1", :_, :"$1"}) |> Enum.sort() ==
-               [{self(), value1}, {self(), value2}]
-        assert Registry.match(registry, "hello", {2, :_, :_}) ==
-               [{self(), value2}]
-        assert Registry.match(registry, "hello", {2.0, :_, :_}) ==
-               []
+                 [{self(), value1}, {self(), value2}]
+
+        assert Registry.match(registry, "hello", {2, :_, :_}) == [{self(), value2}]
+        assert Registry.match(registry, "hello", {2.0, :_, :_}) == []
       end
 
       test "supports guards", %{registry: registry} do
         value1 = {1, :atom, 1}
+        value2 = {2, :atom, 2}
+
         {:ok, _} = Registry.register(registry, "hello", value1)
-        value2 = {2, :atom, 2}
         {:ok, _} = Registry.register(registry, "hello", value2)
 
         assert Registry.match(registry, "hello", {:"$1", :_, :_}, [{:<, :"$1", 2}]) ==
-               [{self(), value1}]
-        assert Registry.match(registry, "hello", {:"$1", :_, :_}, [{:>, :"$1", 3}]) ==
-               []
+                 [{self(), value1}]
+
+        assert Registry.match(registry, "hello", {:"$1", :_, :_}, [{:>, :"$1", 3}]) == []
+
         assert Registry.match(registry, "hello", {:"$1", :_, :_}, [{:<, :"$1", 3}]) |> Enum.sort() ==
-               [{self(), value1}, {self(), value2}]
-        assert Registry.match(registry, "hello", {:_, :"$1",  :_}, [{:is_atom, :"$1"}]) |> Enum.sort() ==
-               [{self(), value1}, {self(), value2}]
+                 [{self(), value1}, {self(), value2}]
+
+        assert Registry.match(registry, "hello", {:_, :"$1", :_}, [{:is_atom, :"$1"}])
+               |> Enum.sort() == [{self(), value1}, {self(), value2}]
       end
 
       test "unregister_match supports patterns", %{registry: registry} do
         value1 = {1, :atom, 1}
+        value2 = {2, :atom, 2}
+
         {:ok, _} = Registry.register(registry, "hello", value1)
-        value2 = {2, :atom, 2}
         {:ok, _} = Registry.register(registry, "hello", value2)
 
         Registry.unregister_match(registry, "hello", {2, :_, :_})
-        assert Registry.lookup(registry, "hello") ==
-               [{self(), value1}]
+        assert Registry.lookup(registry, "hello") == [{self(), value1}]
 
         {:ok, _} = Registry.register(registry, "hello", value2)
         Registry.unregister_match(registry, "hello", {2.0, :_, :_})
-        assert Registry.lookup(registry, "hello") ==
-               [{self(), value1}, {self(), value2}]
+        assert Registry.lookup(registry, "hello") == [{self(), value1}, {self(), value2}]
         Registry.unregister_match(registry, "hello", {:_, :atom, :_})
-        assert Registry.lookup(registry, "hello") ==
-               []
+        assert Registry.lookup(registry, "hello") == []
       end
 
       test "unregister_match supports guards", %{registry: registry} do
         value1 = {1, :atom, 1}
+        value2 = {2, :atom, 2}
+
         {:ok, _} = Registry.register(registry, "hello", value1)
-        value2 = {2, :atom, 2}
         {:ok, _} = Registry.register(registry, "hello", value2)
 
         Registry.unregister_match(registry, "hello", {:"$1", :_, :_}, [{:<, :"$1", 2}])
-        assert Registry.lookup(registry, "hello") ==
-               [{self(), value2}]
+        assert Registry.lookup(registry, "hello") == [{self(), value2}]
       end
 
       test "unregister_match supports tricky keys", %{registry: registry} do

        Process.flag(:trap_exit, true)
        parent = self()

        assert Registry.dispatch(registry, "hello", fn _ ->
          raise "will never be invoked"
        end, parallel: false) == :ok

        {:ok, _} = Registry.register(registry, "hello", :value1)
        {:ok, _} = Registry.register(registry, "hello", :value2)
        {:ok, _} = Registry.register(registry, "world", :value3)

        assert Registry.dispatch(registry, "hello", fn entries ->
          assert parent == self()
          for {pid, value} <- entries, do: send(pid, {:dispatch, value})
        end, parallel: false)

        assert_received {:dispatch, :value1}
        assert_received {:dispatch, :value2}
        refute_received {:dispatch, :value3}

        assert Registry.dispatch(registry, "world", fn entries ->
          assert parent == self()
          for {pid, value} <- entries, do: send(pid, {:dispatch, value})
        end, parallel: false)

        refute_received {:dispatch, :value1}
        refute_received {:dispatch, :value2}

Code.require_file("test_helper.exs", __DIR__)

defmodule RegistryTest do
  use ExUnit.Case, async: true
