summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEksperimental <eksperimental@users.noreply.github.com>2017-05-25 05:06:51 -0500
committerAndrea Leopardi <an.leopardi@gmail.com>2017-05-25 12:06:51 +0200
commit9a44ce6d539106c609721456dd06d0b332c9ed43 (patch)
tree721a862ec8f7619e46d03c3cade611626ab84770
parentefe9451b4f4e17aac944434a8c7809e9abe92c3a (diff)
downloadelixir-9a44ce6d539106c609721456dd06d0b332c9ed43.tar.gz
Show specific description for dont_display_result atom in i/1 helper (#6137)
:"do not show this result in output" is the returned value of functions that print to screen and do not want to show their returned value on screen. This commit adds information about that particular atom to the i/1 IEx helper.
-rw-r--r--lib/iex/lib/iex/info.ex12
-rw-r--r--lib/iex/test/iex/helpers_test.exs15
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/iex/lib/iex/info.ex b/lib/iex/lib/iex/info.ex
index 45f9780ab..d5f2b28c7 100644
--- a/lib/iex/lib/iex/info.ex
+++ b/lib/iex/lib/iex/info.ex
@@ -23,7 +23,17 @@ defimpl IEx.Info, for: Atom do
true ->
info_atom(atom)
end
- ["Data type": "Atom"] ++ specific_info
+
+ description =
+ if atom == IEx.dont_display_result() do
+ ["Description": """
+ This atom is returned by IEx when a function that should not print its
+ return value on screen is executed.
+ """]
+ else
+ []
+ end
+ ["Data type": "Atom"] ++ description ++ specific_info
end
defp info_module(mod) do
diff --git a/lib/iex/test/iex/helpers_test.exs b/lib/iex/test/iex/helpers_test.exs
index 2059754c3..4a99fb9ab 100644
--- a/lib/iex/test/iex/helpers_test.exs
+++ b/lib/iex/test/iex/helpers_test.exs
@@ -484,7 +484,7 @@ defmodule IEx.HelpersTest do
end
end
- test "i helper" do
+ test "i/1 helper" do
output = capture_io fn -> i(:ok) end
assert output =~ String.trim_trailing("""
Term
@@ -496,6 +496,19 @@ defmodule IEx.HelpersTest do
""")
end
+ test "i/1 helper on functions that don't display result" do
+ output = capture_io fn -> i(IEx.dont_display_result()) end
+ assert output =~ String.trim_trailing("""
+ Term
+ :"do not show this result in output"
+ Data type
+ Atom
+ Description
+ This atom is returned by IEx when a function that should not print its
+ return value on screen is executed.
+ """)
+ end
+
defp test_module_code do
"""
defmodule Sample do