Skip to content

Commit 7951f73

Browse files
committed
Update the tests for l and r helpers
1 parent a79d965 commit 7951f73

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lib/iex/test/iex/helpers_test.exs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ defmodule IEx.HelpersTest do
171171
end
172172

173173
test "c helper multiple modules" do
174+
assert_raise UndefinedFunctionError, "undefined function: Helpers_test_module.run/0", fn ->
175+
Helpers_test_module.run
176+
end
177+
174178
File.write! "test-module-code.ex", test_module_code <> "\n" <> another_test_module
175179
assert c("test-module-code.ex") |> Enum.sort == [Another_test_module,Helpers_test_module]
176180
assert Helpers_test_module.run == :run
@@ -187,6 +191,10 @@ defmodule IEx.HelpersTest do
187191
end
188192

189193
test "c helper list" do
194+
assert_raise UndefinedFunctionError, "undefined function: Helpers_test_module.run/0", fn ->
195+
Helpers_test_module.run
196+
end
197+
190198
File.write! "test-module-code-1.ex", test_module_code
191199
File.write! "test-module-code-2.ex", another_test_module
192200
assert c(["test-module-code-1.ex", "test-module-code-2.ex"]) |> Enum.sort
@@ -207,13 +215,24 @@ defmodule IEx.HelpersTest do
207215
end
208216

209217
test "l helper" do
218+
assert_raise UndefinedFunctionError, "undefined function: Helpers_test_module.run/0", fn ->
219+
Helpers_test_module.run
220+
end
221+
210222
assert l(:non_existent_module) == {:error,:nofile}
211223
212224
File.write! "test-module-code.ex", test_module_code
213225
assert c("test-module-code.ex") == [Helpers_test_module]
214-
#File.write! "test-module-code.ex", "defmodule Helpers_test_module do end"
215-
assert l(Helpers_test_module) == {:module, Helpers_test_module}
216226
assert Helpers_test_module.run == :run
227+
228+
File.write! "test-module-code.ex", "defmodule Helpers_test_module do end"
229+
# FIXME: is there another way to compile a file without loading its module?
230+
System.cmd "elixirc test-module-code.ex"
231+
232+
assert l(Helpers_test_module) == {:module, Helpers_test_module}
233+
assert_raise UndefinedFunctionError, fn ->
234+
Helpers_test_module.run
235+
end
217236
after
218237
File.rm "test-module-code.ex"
219238
File.rm! "Elixir.Helpers_test_module.beam"
@@ -225,15 +244,20 @@ defmodule IEx.HelpersTest do
225244
end
226245
227246
test "r helper" do
247+
assert_raise UndefinedFunctionError, "undefined function: Helpers_test_module.run/0", fn ->
248+
Helpers_test_module.run
249+
end
250+
228251
assert r == []
229252
assert r(Kernel) == :nosource
230253
assert_raise UndefinedFunctionError, "undefined function: :non_existent_module.module_info/1", fn ->
231254
r :non_existent_module
232255
end
233256

234257
File.write! "test-module-code.ex", test_module_code
235-
# FIXME: `r Helpers_test_module` returns :nosource
236258
assert c("test-module-code.ex") == [Helpers_test_module]
259+
assert Helpers_test_module.run == :run
260+
# FIXME: `r Helpers_test_module` returns :nosource
237261
assert r(Helpers_test_module) == [Helpers_test_module]
238262

239263
assert r == [Helpers_test_module]

0 commit comments

Comments
 (0)