File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -513,8 +513,10 @@ defmodule ExUnit.DocTest do
513
513
defp test_import ( mod , _ ) , do: [ quote ( do: import ( unquote ( mod ) ) ) ]
514
514
515
515
defp string_to_quoted ( location , stack , expr , doctest ) do
516
+ expr = IO . iodata_to_binary ( expr )
517
+
516
518
try do
517
- Code . string_to_quoted! ( IO . iodata_to_binary ( expr ) , location )
519
+ Code . string_to_quoted! ( expr , location )
518
520
rescue
519
521
e ->
520
522
ex_message = "(#{ inspect ( e . __struct__ ) } ) #{ Exception . message ( e ) } "
Original file line number Diff line number Diff line change @@ -239,6 +239,12 @@ defmodule ExUnit.DocTestTest.Invalid do
239
239
1 + * 1
240
240
"""
241
241
def result , do: :ok
242
+
243
+ @ doc """
244
+ iex> 123 +
245
+ :mixed
246
+ """
247
+ def mixed , do: :ok
242
248
end
243
249
|> ExUnit.BeamHelpers . write_beam ( )
244
250
@@ -781,7 +787,21 @@ defmodule ExUnit.DocTestTest do
781
787
test/ex_unit/doc_test_test.exs:#{ starting_line + 54 } : ExUnit.DocTestTest.Invalid (module)
782
788
"""
783
789
784
- assert output =~ "9 doctests, 9 failures"
790
+ assert output =~ """
791
+ 10) doctest ExUnit.DocTestTest.Invalid.mixed/0 (10) (ExUnit.DocTestTest.InvalidCompiled)
792
+ test/ex_unit/doc_test_test.exs:#{ doctest_line }
793
+ Doctest did not compile, got: (TokenMissingError) test/ex_unit/doc_test_test.exs:#{ starting_line + 61 } :6: syntax error: expression is incomplete
794
+ #{ line_placeholder ( starting_line + 61 ) } |
795
+ #{ starting_line + 61 } | 123 +
796
+ #{ line_placeholder ( starting_line + 61 ) } | ^
797
+ doctest:
798
+ iex> 123 +
799
+ :mixed
800
+ stacktrace:
801
+ test/ex_unit/doc_test_test.exs:#{ starting_line + 61 } : ExUnit.DocTestTest.Invalid (module)
802
+ """
803
+
804
+ assert output =~ "10 doctests, 10 failures"
785
805
end
786
806
787
807
test "pattern matching assertions in doctests" do
You can’t perform that action at this time.
0 commit comments