File tree Expand file tree Collapse file tree 1 file changed +32
-14
lines changed Expand file tree Collapse file tree 1 file changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -44,17 +44,6 @@ defmodule ExUnit.DocTestTest.ExceptionModule do
44
44
def two_exceptions_in_single_context
45
45
end
46
46
47
- defmodule ExUnit.DocTestTest.LeakCheckModule do
48
- @ doc """
49
- iex> a = 1
50
- 1
51
-
52
- iex> a + 1
53
- 2
54
- """
55
- def no_leak
56
- end
57
-
58
47
defmodule ExUnit.DocTestTest.SomewhatGoodModule do
59
48
@ doc """
60
49
iex> test_fun
@@ -111,7 +100,36 @@ defmodule ExUnit.DocTestTest do
111
100
doctest ExUnit.DocTestTest.ExceptionModule
112
101
end
113
102
114
- # FIXME: is it possible to test this?
115
- # ** (CompileError) .../doc_test_test.exs:55: function a/0 undefined
116
- #doctest ExUnit.DocTestTest.LeakCheckModule
103
+ test :var_leak do
104
+ assert "nofile:9: function '_a'/0 undefined" = format_rescue ( """
105
+ defmodule M do
106
+ @doc \" \" \"
107
+ iex> _a = 1
108
+ 1
109
+
110
+ iex> _a + 1
111
+ 2
112
+ \" \" \"
113
+ def no_leak
114
+ end
115
+
116
+ defmodule M.Test do
117
+ require ExUnit.DocTest
118
+
119
+ ExUnit.DocTest.doctest M
120
+ end
121
+ """
122
+ )
123
+ end
124
+
125
+ defp format_rescue ( expr ) do
126
+ result = try do
127
+ :elixir . eval ( to_char_list ( expr ) , [ ] )
128
+ nil
129
+ rescue
130
+ error -> error . message
131
+ end
132
+
133
+ result || raise ( ExUnit.AssertionError , message: "Expected function given to format_rescue to fail" )
134
+ end
117
135
end
You can’t perform that action at this time.
0 commit comments