@@ -28,22 +28,38 @@ defmodule ExUnit.DocTest do
2828 doctest MyModule
2929 end
3030
31- The `doctest` macro is going to loop all functions and macros
32- defined in `MyModule`, parsing their documentation in search for
33- code examples.
31+ The `doctest` macro is going to loop through all functions and
32+ macros defined in `MyModule`, parsing their documentation in
33+ search for code examples.
3434
3535 A very basic example is:
3636
3737 iex> 1+1
3838 2
3939
40- Multiline is also supported:
40+ Expressions on multiple lines are also supported:
4141
4242 iex> Enum.map [1,2,3], fn(x) ->
4343 ...> x * 2
4444 ...> end
4545 [2,4,6]
4646
47+ Multiple results can be checked within the same test:
48+
49+ iex> a = 1
50+ 1
51+ iex> a + 1
52+ 2
53+
54+ If you want to keep any two tests separate from each other,
55+ add an empty line between them:
56+
57+ iex> a = 1
58+ 1
59+
60+ iex> a + 1 # will fail with a "function a/0 undefined" error
61+ 2
62+
4763 Similarly to iex you can use numbers in your "prompts":
4864
4965 iex(1)> [1+2,
@@ -56,7 +72,7 @@ defmodule ExUnit.DocTest do
5672 * Copy-pasting examples from an actual iex sessions
5773
5874 We also allow you to select or skip some functions when calling
59- `doctest`. See its documentation documentation for more info.
75+ `doctest`. See its documentation for more info.
6076
6177 ## Exceptions
6278
@@ -90,18 +106,16 @@ defmodule ExUnit.DocTest do
90106 @ doc """
91107 This macro is used to generate ExUnit test cases for doctests.
92108
93- There are three ways this macro can be used:
94-
95- * `doctest(Module)` — will generate tests for all doctests found
96- in the module `Module`
109+ Calling `doctest(Module)` will generate tests for all doctests found
110+ in the module `Module`
97111
98112 Options can also be supplied:
99113
100114 * `:except` — generate tests for all functions except those listed
101115 (list of `{function, arity}` tuples)
102116
103- * `:only` — generate tests only forfunctions listed
104- (list of `{function, arity}` tuples)
117+ * `:only` — generate tests only forfunctions listed
118+ (list of `{function, arity}` tuples)
105119
106120 * `:import` — when true, one can test a function defined in the module
107121 without referring to the module name. However, this is not
@@ -113,7 +127,7 @@ defmodule ExUnit.DocTest do
113127
114128 doctest MyModule, except: [trick_fun: 1]
115129
116- This macro is auto-imported into every `ExUnit.Case`.
130+ This macro is auto-imported with every `ExUnit.Case`.
117131 """
118132 defmacro doctest ( mod , opts // [ ] ) do
119133 quote do
0 commit comments