Skip to content

Commit 6e3de5f

Browse files
authored
Fix warning in tests and some doctest whitespace (#14194)
* Fix whitespace in iex> docstrings * Fix type warning in test * Fix negative step warning in test compilation * Remove raise assertion
1 parent 2716bb6 commit 6e3de5f

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

lib/elixir/lib/access.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,9 @@ defmodule Access do
10401040
iex> list = [%{name: "john", salary: 10}, %{name: "francine", salary: 30}]
10411041
iex> get_in(list, [Access.find(&(&1.salary > 20)), :name])
10421042
"francine"
1043-
iex> get_and_update_in(list, [Access.find(&(&1.salary <= 40)), :name], fn prev ->
1044-
...> {prev, String.upcase(prev)}
1045-
...> end)
1043+
iex> get_and_update_in(list, [Access.find(&(&1.salary <= 40)), :name], fn prev ->
1044+
...> {prev, String.upcase(prev)}
1045+
...> end)
10461046
{"john", [%{name: "JOHN", salary: 10}, %{name: "francine", salary: 30}]}
10471047
10481048
`find/1` can also be used to pop the first found element out of a list or
@@ -1069,7 +1069,7 @@ defmodule Access do
10691069
10701070
An error is raised if the accessed structure is not a list:
10711071
1072-
iex> get_in(%{}, [Access.find(fn a -> a == 10 end)])
1072+
iex> get_in(%{}, [Access.find(fn a -> a == 10 end)])
10731073
** (RuntimeError) Access.find/1 expected a list, got: %{}
10741074
"""
10751075
@doc since: "1.17.0"

lib/elixir/lib/calendar/date.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Date do
3636
using `Enum.min/2` and `Enum.max/2` functions to get the minimum and
3737
maximum date of an `Enum`. For example:
3838
39-
iex> Enum.min([~D[2017-03-31], ~D[2017-04-01]], Date)
39+
iex> Enum.min([~D[2017-03-31], ~D[2017-04-01]], Date)
4040
~D[2017-03-31]
4141
4242
## Using epochs

lib/elixir/test/elixir/calendar/date_range_test.exs

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule Date.RangeTest do
1010
@asc_range_duration_2 Date.range(~D[2000-01-01], Duration.new!(year: 1), 2)
1111
@desc_range Date.range(~D[2001-01-01], ~D[2000-01-01], -1)
1212
@desc_range_2 Date.range(~D[2001-01-01], ~D[2000-01-01], -2)
13-
@desc_range_duration Date.range(~D[2001-01-01], Duration.new!(year: -1))
13+
@desc_range_duration Date.range(~D[2001-01-01], Duration.new!(year: -1), -1)
1414
@desc_range_duration_2 Date.range(~D[2001-01-01], Duration.new!(year: -1), 2)
1515
@empty_range Date.range(~D[2001-01-01], ~D[2000-01-01], 1)
1616

@@ -182,6 +182,16 @@ defmodule Date.RangeTest do
182182
end
183183
end
184184

185+
test "warns when inferring a negative step" do
186+
{result, captured} =
187+
ExUnit.CaptureIO.with_io(:stderr, fn ->
188+
Date.range(~D[2001-01-01], Duration.new!(year: -1))
189+
end)
190+
191+
assert result == Date.range(~D[2001-01-01], ~D[2000-01-01], -1)
192+
assert captured =~ "negative range was inferred for Date.range/2"
193+
end
194+
185195
describe "old date ranges" do
186196
test "inspect" do
187197
asc = %{

lib/elixir/test/elixir/version_test.exs

-4
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ defmodule VersionTest do
316316
test "compile_requirement/1" do
317317
{:ok, req} = Version.parse_requirement("1.2.3")
318318
assert req == Version.compile_requirement(req)
319-
320-
assert_raise(FunctionClauseError, fn ->
321-
Version.compile_requirement("~> 1.2.3")
322-
end)
323319
end
324320

325321
test "compile requirement" do

0 commit comments

Comments
 (0)