@@ -635,18 +635,17 @@ defmodule ExUnit.DocTestTest do
635635 """
636636
637637 assert output =~ """
638- 9) doctest ExUnit.DocTestTest.Invalid.dedented_past_fence /0 (9) (ExUnit.DocTestTest.ActuallyCompiled)
638+ 9) doctest ExUnit.DocTestTest.Invalid.b /0 (9) (ExUnit.DocTestTest.ActuallyCompiled)
639639 test/ex_unit/doc_test_test.exs:#{ doctest_line }
640- Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 57 } :5: unexpected token: "`" (column 5, code point U+0060)
641- #{ line_placeholder ( starting_line + 57 ) } |
642- #{ starting_line + 57 } | ```
643- #{ line_placeholder ( starting_line + 57 ) } | ^
640+ Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 33 } :6: syntax error before: '*'
641+ #{ line_placeholder ( starting_line + 33 ) } |
642+ #{ starting_line + 33 } | 1 + * 1
643+ #{ line_placeholder ( starting_line + 33 ) } | ^
644644 doctest:
645- iex> 1 + 2
646- 3
647- ```
645+ iex> 1 + * 1
646+ 1
648647 stacktrace:
649- test/ex_unit/doc_test_test.exs:#{ starting_line + 56 } : ExUnit.DocTestTest.Invalid (module)
648+ test/ex_unit/doc_test_test.exs:#{ starting_line + 33 } : ExUnit.DocTestTest.Invalid (module)
650649 """
651650
652651 assert output =~ """
@@ -680,15 +679,30 @@ defmodule ExUnit.DocTestTest do
680679 """
681680
682681 assert output =~ """
683- 12) doctest ExUnit.DocTestTest.Invalid.invalid_utf8/0 (12) (ExUnit.DocTestTest.ActuallyCompiled)
682+ 12) doctest ExUnit.DocTestTest.Invalid.dedented_past_fence/0 (12) (ExUnit.DocTestTest.ActuallyCompiled)
683+ test/ex_unit/doc_test_test.exs:#{ doctest_line }
684+ Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 57 } :5: unexpected token: "`" (column 5, code point U+0060)
685+ #{ line_placeholder ( starting_line + 57 ) } |
686+ #{ starting_line + 57 } | ```
687+ #{ line_placeholder ( starting_line + 57 ) } | ^
688+ doctest:
689+ iex> 1 + 2
690+ 3
691+ ```
692+ stacktrace:
693+ test/ex_unit/doc_test_test.exs:#{ starting_line + 56 } : ExUnit.DocTestTest.Invalid (module)
694+ """
695+
696+ assert output =~ """
697+ 13) doctest ExUnit.DocTestTest.Invalid.invalid_utf8/0 (13) (ExUnit.DocTestTest.ActuallyCompiled)
684698 test/ex_unit/doc_test_test.exs:#{ doctest_line }
685699 Doctest did not compile, got: (UnicodeConversionError) invalid encoding starting at <<255, 34, 41>>
686700 stacktrace:
687701 test/ex_unit/doc_test_test.exs:#{ starting_line + 63 } : ExUnit.DocTestTest.Invalid (module)
688702 """
689703
690704 assert output =~ """
691- 13 ) doctest ExUnit.DocTestTest.Invalid.misplaced_opaque_type/0 (13 ) (ExUnit.DocTestTest.ActuallyCompiled)
705+ 14 ) doctest ExUnit.DocTestTest.Invalid.misplaced_opaque_type/0 (14 ) (ExUnit.DocTestTest.ActuallyCompiled)
692706 test/ex_unit/doc_test_test.exs:#{ doctest_line }
693707 Doctest did not compile, got: (TokenMissingError) test/ex_unit/doc_test_test.exs:#{ starting_line + 69 } :7: missing terminator: } (for "{" starting at line #{ starting_line + 69 } )
694708 #{ line_placeholder ( starting_line + 69 ) } |
@@ -702,28 +716,8 @@ defmodule ExUnit.DocTestTest do
702716 test/ex_unit/doc_test_test.exs:#{ starting_line + 69 } : ExUnit.DocTestTest.Invalid (module)
703717 """
704718
705- assert output =~ "14) doctest ExUnit.DocTestTest.Invalid.raising_inspect/0"
706- assert output =~ "iex> ExUnit.DocTestTest.Haiku.new(:this, :is, {:not, :a, :haiku})"
707-
708- assert output =~
709- "test/ex_unit/doc_test_test.exs:#{ starting_line + 82 } : ExUnit.DocTestTest.Invalid (module)"
710-
711719 assert output =~ """
712- 15) doctest ExUnit.DocTestTest.Invalid.b/0 (15) (ExUnit.DocTestTest.ActuallyCompiled)
713- test/ex_unit/doc_test_test.exs:#{ doctest_line }
714- Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 33 } :6: syntax error before: '*'
715- #{ line_placeholder ( starting_line + 33 ) } |
716- #{ starting_line + 33 } | 1 + * 1
717- #{ line_placeholder ( starting_line + 33 ) } | ^
718- doctest:
719- iex> 1 + * 1
720- 1
721- stacktrace:
722- test/ex_unit/doc_test_test.exs:#{ starting_line + 33 } : ExUnit.DocTestTest.Invalid (module)
723- """
724-
725- assert output =~ """
726- 16) doctest ExUnit.DocTestTest.Invalid.t/0 (16) (ExUnit.DocTestTest.ActuallyCompiled)
720+ 15) doctest ExUnit.DocTestTest.Invalid.t/0 (15) (ExUnit.DocTestTest.ActuallyCompiled)
727721 test/ex_unit/doc_test_test.exs:#{ doctest_line }
728722 Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 75 } :6: syntax error before: '*'
729723 #{ line_placeholder ( starting_line + 75 ) } |
@@ -735,6 +729,12 @@ defmodule ExUnit.DocTestTest do
735729 stacktrace:
736730 test/ex_unit/doc_test_test.exs:#{ starting_line + 75 } : ExUnit.DocTestTest.Invalid (module)
737731 """
732+
733+ assert output =~ "16) doctest ExUnit.DocTestTest.Invalid.raising_inspect/0"
734+ assert output =~ "iex> ExUnit.DocTestTest.Haiku.new(:this, :is, {:not, :a, :haiku})"
735+
736+ assert output =~
737+ "test/ex_unit/doc_test_test.exs:#{ starting_line + 82 } : ExUnit.DocTestTest.Invalid (module)"
738738 end
739739
740740 test "pattern matching assertions in doctests" do
@@ -900,24 +900,7 @@ defmodule ExUnit.DocTestTest do
900900 end
901901 end
902902
903- test "fails when testing single function not found" do
904- message = """
905- test/ex_unit/doc_test_test\. exs: undefined or private function given to doctest:
906-
907- ExUnit.DocTestTest.SomewhatGoodModuleWithOnly.three/0
908-
909- """
910-
911- assert_raise ExUnit.DocTest.Error , message , fn ->
912- defmodule NeverCompiled do
913- import ExUnit.DocTest
914-
915- doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly , only: [ three: 0 ] , import: true
916- end
917- end
918- end
919-
920- test "fails when testing multiple functions not found" do
903+ test "fails when testing functions are not found" do
921904 message = """
922905 test/ex_unit/doc_test_test\. exs: undefined or private functions given to doctest:
923906
@@ -989,6 +972,16 @@ defmodule ExUnit.DocTestTest do
989972 end
990973 end
991974
975+ test "doctest direct invocation" do
976+ defmodule Direct do
977+ use ExUnit.Case , register: false
978+ doctest ExUnit.DocTestTest.GoodModule , import: true
979+ end
980+
981+ [ head | _ ] = Direct . __ex_unit__ ( ) . tests
982+ assert apply ( Direct , head . name , [ % { } ] ) == { :ok , 2 }
983+ end
984+
992985 defp line_placeholder ( line_number ) do
993986 digits =
994987 line_number
0 commit comments