summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksei Magusev <lexmag@me.com>2018-04-30 20:50:44 +0200
committerAleksei Magusev <lexmag@me.com>2018-05-01 16:49:18 +0200
commitc0859c8714841897dcbec514a6eb2037e4cbf587 (patch)
tree1054f97b4ffa3db282a4facf5b5dd0b4115a8671
parent4cf0c8c9dbd07c0400ae1d9c1a8bc87047cff447 (diff)
downloadelixir-c0859c8714841897dcbec514a6eb2037e4cbf587.tar.gz
Improve test names and regroup assertions in Inspect.BitStringTest
-rw-r--r--lib/elixir/lib/exception.ex2
-rw-r--r--lib/elixir/test/elixir/inspect_test.exs34
2 files changed, 15 insertions, 21 deletions
diff --git a/lib/elixir/lib/exception.ex b/lib/elixir/lib/exception.ex
index ad926a352..0b09a673c 100644
--- a/lib/elixir/lib/exception.ex
+++ b/lib/elixir/lib/exception.ex
@@ -91,7 +91,6 @@ defmodule Exception do
"""
@spec normalize(:error, any, stacktrace) :: t
@spec normalize(non_error_kind, payload, stacktrace) :: payload when payload: var
-
@deprecated "Use normalize/3 with an explicit stacktrace instead"
def normalize(kind, payload, stacktrace \\ nil)
@@ -150,7 +149,6 @@ defmodule Exception do
(as they are retrieved as messages without stacktraces).
"""
@spec format(kind, any, stacktrace | nil) :: String.t()
-
@deprecated "Use format/3 with an explicit stacktrace instead"
def format(kind, payload, stacktrace \\ nil)
diff --git a/lib/elixir/test/elixir/inspect_test.exs b/lib/elixir/test/elixir/inspect_test.exs
index 6675839c8..30a20285a 100644
--- a/lib/elixir/test/elixir/inspect_test.exs
+++ b/lib/elixir/test/elixir/inspect_test.exs
@@ -116,21 +116,21 @@ defmodule Inspect.BitStringTest do
assert inspect(<<?a, ?b, ?c>>) == "\"abc\""
end
- test "escape" do
+ test "escaping" do
assert inspect("f\no") == "\"f\\no\""
assert inspect("f\\o") == "\"f\\\\o\""
assert inspect("f\ao") == "\"f\\ao\""
+
+ assert inspect("\a\b\d\e\f\n\r\s\t\v") == "\"\\a\\b\\d\\e\\f\\n\\r \\t\\v\""
end
test "UTF-8" do
assert inspect(" ゆんゆん") == "\" ゆんゆん\""
+ # BOM
+ assert inspect("\uFEFFhello world") == "\"\\uFEFFhello world\""
end
- test "all escapes" do
- assert inspect("\a\b\d\e\f\n\r\s\t\v") == "\"\\a\\b\\d\\e\\f\\n\\r \\t\\v\""
- end
-
- test "opt infer" do
+ test "infer" do
assert inspect(<<"john", 193, "doe">>, binaries: :infer) ==
~s(<<106, 111, 104, 110, 193, 100, 111, 101>>)
@@ -138,44 +138,40 @@ defmodule Inspect.BitStringTest do
assert inspect(<<193>>, binaries: :infer) == ~s(<<193>>)
end
- test "opt as strings" do
+ test "as strings" do
assert inspect(<<"john", 193, "doe">>, binaries: :as_strings) == ~s("john\\xC1doe")
assert inspect(<<"john">>, binaries: :as_strings) == ~s("john")
assert inspect(<<193>>, binaries: :as_strings) == ~s("\\xC1")
end
- test "opt as binaries" do
+ test "as binaries" do
assert inspect(<<"john", 193, "doe">>, binaries: :as_binaries) ==
"<<106, 111, 104, 110, 193, 100, 111, 101>>"
assert inspect(<<"john">>, binaries: :as_binaries) == "<<106, 111, 104, 110>>"
assert inspect(<<193>>, binaries: :as_binaries) == "<<193>>"
- # any base other than :decimal implies binaries: :as_binaries
+ # Any base other than :decimal implies "binaries: :as_binaries"
assert inspect("abc", base: :hex) == "<<0x61, 0x62, 0x63>>"
assert inspect("abc", base: :octal) == "<<0o141, 0o142, 0o143>>"
- # size is still represented as decimal
+ # Size is still represented as decimal
assert inspect(<<10, 11, 12::4>>, base: :hex) == "<<0xA, 0xB, 0xC::size(4)>>"
end
- test "unprintable with opts" do
+ test "unprintable with limit" do
assert inspect(<<193, 193, 193, 193>>, limit: 3) == "<<193, 193, 193, ...>>"
end
test "printable limit" do
assert inspect("hello world", printable_limit: 4) == ~s("hell" <> ...)
- # non printable characters after the limit don't matter
+ # Non-printable characters after the limit don't matter
assert inspect("hello world" <> <<0>>, printable_limit: 4) == ~s("hell" <> ...)
- # non printable strings aren't affected by printable limit
+ # Non printable strings aren't affected by printable limit
assert inspect(<<0, 1, 2, 3, 4>>, printable_limit: 3) == ~s(<<0, 1, 2, 3, 4>>)
end
-
- test "utf-8 BOM" do
- assert inspect("\uFEFFhello world") == "\"\\uFEFFhello world\""
- end
end
defmodule Inspect.NumberTest do
@@ -277,9 +273,9 @@ defmodule Inspect.ListTest do
test "printable limit" do
assert inspect('hello world', printable_limit: 4) == ~s('hell' ++ ...)
- # non printable characters after the limit don't matter
+ # Non printable characters after the limit don't matter
assert inspect('hello world' ++ [0], printable_limit: 4) == ~s('hell' ++ ...)
- # non printable strings aren't affected by printable limit
+ # Non printable strings aren't affected by printable limit
assert inspect([0, 1, 2, 3, 4], printable_limit: 3) == ~s([0, 1, 2, 3, 4])
end