Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/elixir/lib/access.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ defmodule Access do
iex> list = [%{name: "john", salary: 10}, %{name: "francine", salary: 30}]
iex> get_in(list, [Access.find(&(&1.salary > 20)), :name])
"francine"
iex> get_and_update_in(list, [Access.find(&(&1.salary <= 40)), :name], fn prev ->
...> {prev, String.upcase(prev)}
...> end)
iex> get_and_update_in(list, [Access.find(&(&1.salary <= 40)), :name], fn prev ->
...> {prev, String.upcase(prev)}
...> end)
{"john", [%{name: "JOHN", salary: 10}, %{name: "francine", salary: 30}]}

`find/1` can also be used to pop the first found element out of a list or
Expand All @@ -1067,7 +1067,7 @@ defmodule Access do

An error is raised if the accessed structure is not a list:

iex> get_in(%{}, [Access.find(fn a -> a == 10 end)])
iex> get_in(%{}, [Access.find(fn a -> a == 10 end)])
** (RuntimeError) Access.find/1 expected a list, got: %{}
"""
@doc since: "1.17.0"
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/calendar/date.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Date do
using `Enum.min/2` and `Enum.max/2` functions to get the minimum and
maximum date of an `Enum`. For example:

iex> Enum.min([~D[2017-03-31], ~D[2017-04-01]], Date)
iex> Enum.min([~D[2017-03-31], ~D[2017-04-01]], Date)
~D[2017-03-31]

## Using epochs
Expand Down
12 changes: 11 additions & 1 deletion lib/elixir/test/elixir/calendar/date_range_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Date.RangeTest do
@asc_range_duration_2 Date.range(~D[2000-01-01], Duration.new!(year: 1), 2)
@desc_range Date.range(~D[2001-01-01], ~D[2000-01-01], -1)
@desc_range_2 Date.range(~D[2001-01-01], ~D[2000-01-01], -2)
@desc_range_duration Date.range(~D[2001-01-01], Duration.new!(year: -1))
@desc_range_duration Date.range(~D[2001-01-01], Duration.new!(year: -1), -1)
@desc_range_duration_2 Date.range(~D[2001-01-01], Duration.new!(year: -1), 2)
@empty_range Date.range(~D[2001-01-01], ~D[2000-01-01], 1)

Expand Down Expand Up @@ -182,6 +182,16 @@ defmodule Date.RangeTest do
end
end

test "warns when inferring a negative step" do
{result, captured} =
ExUnit.CaptureIO.with_io(:stderr, fn ->
Date.range(~D[2001-01-01], Duration.new!(year: -1))
end)

assert result == Date.range(~D[2001-01-01], ~D[2000-01-01], -1)
assert captured =~ "negative range was inferred for Date.range/2"
end

describe "old date ranges" do
test "inspect" do
asc = %{
Expand Down
4 changes: 0 additions & 4 deletions lib/elixir/test/elixir/version_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ defmodule VersionTest do
test "compile_requirement/1" do
{:ok, req} = Version.parse_requirement("1.2.3")
assert req == Version.compile_requirement(req)

assert_raise(FunctionClauseError, fn ->
Version.compile_requirement("~> 1.2.3")
end)
end

test "compile requirement" do
Expand Down
Loading