@@ -635,18 +635,17 @@ defmodule ExUnit.DocTestTest do
635
635
"""
636
636
637
637
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)
639
639
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 ) } | ^
644
644
doctest:
645
- iex> 1 + 2
646
- 3
647
- ```
645
+ iex> 1 + * 1
646
+ 1
648
647
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)
650
649
"""
651
650
652
651
assert output =~ """
@@ -680,15 +679,30 @@ defmodule ExUnit.DocTestTest do
680
679
"""
681
680
682
681
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)
684
698
test/ex_unit/doc_test_test.exs:#{ doctest_line }
685
699
Doctest did not compile, got: (UnicodeConversionError) invalid encoding starting at <<255, 34, 41>>
686
700
stacktrace:
687
701
test/ex_unit/doc_test_test.exs:#{ starting_line + 63 } : ExUnit.DocTestTest.Invalid (module)
688
702
"""
689
703
690
704
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)
692
706
test/ex_unit/doc_test_test.exs:#{ doctest_line }
693
707
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 } )
694
708
#{ line_placeholder ( starting_line + 69 ) } |
@@ -702,28 +716,8 @@ defmodule ExUnit.DocTestTest do
702
716
test/ex_unit/doc_test_test.exs:#{ starting_line + 69 } : ExUnit.DocTestTest.Invalid (module)
703
717
"""
704
718
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
-
711
719
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)
727
721
test/ex_unit/doc_test_test.exs:#{ doctest_line }
728
722
Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{ starting_line + 75 } :6: syntax error before: '*'
729
723
#{ line_placeholder ( starting_line + 75 ) } |
@@ -735,6 +729,12 @@ defmodule ExUnit.DocTestTest do
735
729
stacktrace:
736
730
test/ex_unit/doc_test_test.exs:#{ starting_line + 75 } : ExUnit.DocTestTest.Invalid (module)
737
731
"""
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)"
738
738
end
739
739
740
740
test "pattern matching assertions in doctests" do
@@ -900,24 +900,7 @@ defmodule ExUnit.DocTestTest do
900
900
end
901
901
end
902
902
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
921
904
message = """
922
905
test/ex_unit/doc_test_test\. exs: undefined or private functions given to doctest:
923
906
@@ -989,6 +972,16 @@ defmodule ExUnit.DocTestTest do
989
972
end
990
973
end
991
974
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
+
992
985
defp line_placeholder ( line_number ) do
993
986
digits =
994
987
line_number
0 commit comments