Skip to content

Commit 70a2477

Browse files
committed
Remove redundant tests
1 parent 7be9618 commit 70a2477

7 files changed

Lines changed: 8 additions & 71 deletions

File tree

lib/elixir/lib/access.ex

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,6 @@ defmodule Access do
873873
...> end)
874874
{[], [%{name: "john", salary: 10}, %{name: "francine", salary: 30}]}
875875
876-
An error is raised if the predicate is not a function or is of the incorrect arity:
877-
878-
iex> get_in([], [Access.filter(5)])
879-
** (FunctionClauseError) no function clause matching in Access.filter/1
880-
881876
An error is raised if the accessed structure is not a list:
882877
883878
iex> get_in(%{}, [Access.filter(fn a -> a == 10 end)])
@@ -1154,11 +1149,6 @@ defmodule Access do
11541149
...> end)
11551150
{nil, [%{name: "john", salary: 10}, %{name: "francine", salary: 30}]}
11561151
1157-
An error is raised if the predicate is not a function or is of the incorrect arity:
1158-
1159-
iex> get_in([], [Access.find(5)])
1160-
** (FunctionClauseError) no function clause matching in Access.find/1
1161-
11621152
An error is raised if the accessed structure is not a list:
11631153
11641154
iex> get_in(%{}, [Access.find(fn a -> a == 10 end)])

lib/elixir/lib/exception.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,8 +1930,8 @@ defmodule FunctionClauseError do
19301930
19311931
For example:
19321932
1933-
iex> URI.parse(:wrong_argument)
1934-
** (FunctionClauseError) no function clause matching in URI.parse/1
1933+
iex> List.duplicate(:ok, -3)
1934+
** (FunctionClauseError) no function clause matching in List.duplicate/2
19351935
19361936
The following fields of this exception are public and can be accessed freely:
19371937

lib/elixir/lib/list.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@ defmodule List do
187187
"""
188188
@spec duplicate(any, 0) :: []
189189
@spec duplicate(elem, pos_integer) :: [elem, ...] when elem: var
190-
def duplicate(elem, n) do
191-
:lists.duplicate(n, elem)
192-
end
190+
def duplicate(elem, n) when is_integer(n) and n >= 0, do: duplicate(n, elem, [])
191+
192+
defp duplicate(0, _elem, acc), do: acc
193+
defp duplicate(n, elem, acc), do: duplicate(n - 1, elem, [elem | acc])
193194

194195
@doc """
195196
Flattens the given `list` of nested lists.

lib/elixir/test/elixir/inspect/algebra_test.exs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ defmodule Inspect.AlgebraTest do
5050
# Consistent with definitions
5151
assert break("break") == {:doc_break, "break", :strict}
5252
assert break("") == {:doc_break, "", :strict}
53-
54-
# Wrong argument type
55-
assert_raise FunctionClauseError, fn -> break(42) end
56-
53+
Fun
5754
# Consistent formatting
5855
assert render(break("_"), 80) == "_"
5956
assert render(glue("foo", " ", glue("bar", " ", "baz")), 10) == "foo\nbar\nbaz"
@@ -64,9 +61,6 @@ defmodule Inspect.AlgebraTest do
6461
assert flex_break("break") == {:doc_break, "break", :flex}
6562
assert flex_break("") == {:doc_break, "", :flex}
6663

67-
# Wrong argument type
68-
assert_raise FunctionClauseError, fn -> flex_break(42) end
69-
7064
# Consistent formatting
7165
assert render(flex_break("_"), 80) == "_"
7266
assert render(flex_glue("foo", " ", flex_glue("bar", " ", "baz")), 10) == "foo bar\nbaz"
@@ -76,9 +70,6 @@ defmodule Inspect.AlgebraTest do
7670
# Consistent with definitions
7771
assert glue("a", "->", "b") == ["a", {:doc_break, "->", :strict} | "b"]
7872
assert glue("a", "b") == glue("a", " ", "b")
79-
80-
# Wrong argument type
81-
assert_raise FunctionClauseError, fn -> glue("a", 42, "b") end
8273
end
8374

8475
test "flex glue doc" do
@@ -87,9 +78,6 @@ defmodule Inspect.AlgebraTest do
8778
["a", {:doc_break, "->", :flex} | "b"]
8879

8980
assert flex_glue("a", "b") == flex_glue("a", " ", "b")
90-
91-
# Wrong argument type
92-
assert_raise FunctionClauseError, fn -> flex_glue("a", 42, "b") end
9381
end
9482

9583
test "binary doc" do
@@ -115,9 +103,6 @@ defmodule Inspect.AlgebraTest do
115103
assert nest(empty(), 1) == {:doc_nest, empty(), 1, :always}
116104
assert nest(empty(), 0) == []
117105

118-
# Wrong argument type
119-
assert_raise FunctionClauseError, fn -> nest("foo", empty()) end
120-
121106
# Consistent formatting
122107
assert render(nest("a", 1), 80) == "a"
123108
assert render(nest(glue("a", "b"), 1), 2) == "a\n b"
@@ -129,9 +114,6 @@ defmodule Inspect.AlgebraTest do
129114
assert nest(empty(), 1, :break) == {:doc_nest, empty(), 1, :break}
130115
assert nest(empty(), 0, :break) == []
131116

132-
# Wrong argument type
133-
assert_raise FunctionClauseError, fn -> nest("foo", empty(), :break) end
134-
135117
# Consistent formatting
136118
assert render(nest("a", 1, :break), 80) == "a"
137119
assert render(nest(glue("a", "b"), 1, :break), 2) == "a\n b"
@@ -231,10 +213,6 @@ defmodule Inspect.AlgebraTest do
231213
# Consistent with definitions
232214
assert collapse_lines(3) == {:doc_collapse, 3}
233215

234-
# Wrong argument type
235-
assert_raise FunctionClauseError, fn -> collapse_lines(0) end
236-
assert_raise FunctionClauseError, fn -> collapse_lines(empty()) end
237-
238216
# Consistent formatting
239217
doc = concat([collapse_lines(2), line(), line(), line()])
240218
assert render(doc, 10) == "\n\n"

lib/elixir/test/elixir/list_test.exs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ defmodule ListTest do
386386
refute List.improper?([[1]])
387387
refute List.improper?([1, 2])
388388
refute List.improper?([1, 2, 3])
389-
390-
assert_raise FunctionClauseError, fn ->
391-
List.improper?(%{})
392-
end
393389
end
394390

395391
describe "ascii_printable?/2" do

lib/elixir/test/elixir/string_test.exs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,6 @@ defmodule StringTest do
418418
assert String.pad_leading("---", 5, ["abc"]) == "abcabc---"
419419
assert String.pad_leading("--", 6, ["a", "bc"]) == "abcabc--"
420420

421-
assert_raise FunctionClauseError, fn ->
422-
String.pad_leading("-", -1)
423-
end
424-
425-
assert_raise FunctionClauseError, fn ->
426-
String.pad_leading("-", 1, [])
427-
end
428-
429421
message = "expected a string padding element, got: 10"
430422

431423
assert_raise ArgumentError, message, fn ->
@@ -447,14 +439,6 @@ defmodule StringTest do
447439
assert String.pad_trailing("---", 5, ["abc"]) == "---abcabc"
448440
assert String.pad_trailing("--", 6, ["a", "bc"]) == "--abcabc"
449441

450-
assert_raise FunctionClauseError, fn ->
451-
String.pad_trailing("-", -1)
452-
end
453-
454-
assert_raise FunctionClauseError, fn ->
455-
String.pad_trailing("-", 1, [])
456-
end
457-
458442
message = "expected a string padding element, got: 10"
459443

460444
assert_raise ArgumentError, message, fn ->
@@ -720,14 +704,6 @@ defmodule StringTest do
720704
assert String.at("л", -3) == nil
721705
assert String.at("Ā̀stute", 1) == "s"
722706
assert String.at("elixir", 6) == nil
723-
724-
assert_raise FunctionClauseError, fn ->
725-
String.at("elixir", 0.1)
726-
end
727-
728-
assert_raise FunctionClauseError, fn ->
729-
String.at("elixir", -0.1)
730-
end
731707
end
732708

733709
test "slice/3" do
@@ -781,10 +757,6 @@ defmodule StringTest do
781757
assert String.slice("abc", -1..14) == "c"
782758
assert String.slice("a·̀ͯ‿.⁀:", 0..-2//1) == "a·̀ͯ‿.⁀"
783759

784-
assert_raise FunctionClauseError, fn ->
785-
String.slice(nil, 0..1)
786-
end
787-
788760
assert ExUnit.CaptureIO.capture_io(:stderr, fn ->
789761
assert String.slice("elixir", 0..-2//-1) == "elixi"
790762
end) =~ "negative steps are not supported in String.slice/2, pass 0..-2//1 instead"

lib/ex_unit/lib/ex_unit/assertions.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,6 @@ defmodule ExUnit.Assertions do
11191119
@spec flunk :: no_return
11201120
@spec flunk(String.t()) :: no_return
11211121
def flunk(message \\ "Flunked!") when is_binary(message) do
1122-
assert false, message: message
1122+
raise ExUnit.AssertionError, message
11231123
end
11241124
end

0 commit comments

Comments
 (0)