@@ -112,12 +112,27 @@ defmodule ExUnit.AssertionsTest do
112112 :hello = assert_received :hello
113113 end
114114
115+ test "assert received with pinned variable" do
116+ status = :valid
117+ send self ( ) , { :status , :invalid }
118+ try do
119+ "This should never be tested" = assert_received { :status , ^ status }
120+ rescue
121+ error in [ ExUnit.AssertionError ] ->
122+ "No message matching {:status, ^status} after 0ms.\n " <>
123+ "The following variables were pinned:\n " <>
124+ " status = :valid\n " <>
125+ "Process mailbox:\n " <>
126+ " {:status, :invalid}" = error . message
127+ end
128+ end
129+
115130 test "assert received when empty mailbox" do
116131 try do
117132 "This should never be tested" = assert_received :hello
118133 rescue
119134 error in [ ExUnit.AssertionError ] ->
120- "No message matching :hello after 0ms. The process mailbox is empty." = error . message
135+ "No message matching :hello after 0ms.\n The process mailbox is empty." = error . message
121136 end
122137 end
123138
@@ -127,7 +142,9 @@ defmodule ExUnit.AssertionsTest do
127142 "This should never be tested" = assert_received :hello
128143 rescue
129144 error in [ ExUnit.AssertionError ] ->
130- "No message matching :hello after 0ms. Process mailbox:\n {:message, :not_expected, :at_all}" = error . message
145+ "No message matching :hello after 0ms.\n " <>
146+ "Process mailbox:\n " <>
147+ " {:message, :not_expected, :at_all}" = error . message
131148 end
132149 end
133150
@@ -137,10 +154,11 @@ defmodule ExUnit.AssertionsTest do
137154 "This should never be tested" = assert_received x when x == :hello
138155 rescue
139156 error in [ ExUnit.AssertionError ] ->
140- "No message matching x when x == :hello after 0ms. Process mailbox:\n " <>
141- "{:message, 1}\n {:message, 2}\n {:message, 3}\n {:message, 4}\n " <>
142- "{:message, 5}\n {:message, 6}\n {:message, 7}\n {:message, 8}\n " <>
143- "{:message, 9}\n {:message, 10}\n Showing only 10 of 11 messages." = error . message
157+ "No message matching x when x == :hello after 0ms.\n Process mailbox:" <>
158+ "\n {:message, 1}\n {:message, 2}\n {:message, 3}" <>
159+ "\n {:message, 4}\n {:message, 5}\n {:message, 6}" <>
160+ "\n {:message, 7}\n {:message, 8}\n {:message, 9}" <>
161+ "\n {:message, 10}\n Showing only 10 of 11 messages." = error . message
144162 end
145163 end
146164
0 commit comments