diff --git a/lib/elixir/lib/access.ex b/lib/elixir/lib/access.ex index 006f3c085a2..9455120f706 100644 --- a/lib/elixir/lib/access.ex +++ b/lib/elixir/lib/access.ex @@ -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 @@ -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" diff --git a/lib/elixir/lib/calendar/date.ex b/lib/elixir/lib/calendar/date.ex index 52ef441b3a1..4886b9f279d 100644 --- a/lib/elixir/lib/calendar/date.ex +++ b/lib/elixir/lib/calendar/date.ex @@ -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 diff --git a/lib/elixir/test/elixir/calendar/date_range_test.exs b/lib/elixir/test/elixir/calendar/date_range_test.exs index 8715d307f51..009752542ad 100644 --- a/lib/elixir/test/elixir/calendar/date_range_test.exs +++ b/lib/elixir/test/elixir/calendar/date_range_test.exs @@ -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) @@ -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 = %{ diff --git a/lib/elixir/test/elixir/version_test.exs b/lib/elixir/test/elixir/version_test.exs index c960c3f05f2..c3ff15143ca 100644 --- a/lib/elixir/test/elixir/version_test.exs +++ b/lib/elixir/test/elixir/version_test.exs @@ -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