@@ -52,12 +52,12 @@ defmodule ExUnit.DocTest do
52
52
2
53
53
54
54
If you want to keep any two tests separate from each other,
55
- add an empty line between them:
55
+ add an empty line between them (assume > to stand for iex> here) :
56
56
57
- iex > a = 1
57
+ > a = 1
58
58
1
59
59
60
- iex > a + 1 # will fail with a "function a/0 undefined" error
60
+ > a + 1 # will fail with a "function a/0 undefined" error
61
61
2
62
62
63
63
Similarly to iex you can use numbers in your "prompts":
@@ -189,6 +189,8 @@ defmodule ExUnit.DocTest do
189
189
{ tests , whole_expr } = Enum . map_reduce exprs , "" , fn { expr , expected } , acc ->
190
190
{ test_case_content ( expr , expected , module , line , file , stack ) , acc <> expr <> "\n " }
191
191
end
192
+ whole_expr = String . strip ( whole_expr )
193
+
192
194
{ exception , message } = case Enum . find ( exprs , exc_filter_fn ) do
193
195
{ _ , { :error , exception , message } } ->
194
196
{ exception , message }
@@ -288,7 +290,7 @@ defmodule ExUnit.DocTest do
288
290
quote do
289
291
raise ExUnit.ExpectationError ,
290
292
[ prelude: "Expected doctest" ,
291
- description: unquote ( expr ) ,
293
+ description: unquote ( String . strip ( expr ) ) ,
292
294
expected: "successfully" ,
293
295
reason: "compile" ,
294
296
actual: unquote ( "** #{ inspect e . __record__ ( :name ) } #{ e . message } " ) ] ,
0 commit comments