From 21befde56b881fd8d06729bad3bebd487f30e945 Mon Sep 17 00:00:00 2001 From: sabiwara Date: Fri, 17 Jan 2025 10:38:26 +0900 Subject: [PATCH 1/4] Fix whitespace in iex> docstrings --- lib/elixir/lib/access.ex | 8 ++++---- lib/elixir/lib/calendar/date.ex | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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 From 1957eda495db09cda9f1cdaf228eab74cf2e7b65 Mon Sep 17 00:00:00 2001 From: sabiwara Date: Fri, 17 Jan 2025 10:45:30 +0900 Subject: [PATCH 2/4] Fix type warning in test --- lib/elixir/test/elixir/version_test.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/elixir/test/elixir/version_test.exs b/lib/elixir/test/elixir/version_test.exs index c960c3f05f2..bd3c6cb4851 100644 --- a/lib/elixir/test/elixir/version_test.exs +++ b/lib/elixir/test/elixir/version_test.exs @@ -317,8 +317,10 @@ defmodule VersionTest do {:ok, req} = Version.parse_requirement("1.2.3") assert req == Version.compile_requirement(req) + string = Process.get(:unused, "~> 1.2.3") + assert_raise(FunctionClauseError, fn -> - Version.compile_requirement("~> 1.2.3") + Version.compile_requirement(string) end) end From 5e709b9b0ea2d77f346f238f7667b057fa3899d6 Mon Sep 17 00:00:00 2001 From: sabiwara Date: Fri, 17 Jan 2025 10:53:53 +0900 Subject: [PATCH 3/4] Fix negative step warning in test compilation --- lib/elixir/test/elixir/calendar/date_range_test.exs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 = %{ From 1c37b16862ef0a7cbb3a691b6510e09d8e845d6e Mon Sep 17 00:00:00 2001 From: sabiwara Date: Fri, 17 Jan 2025 19:46:02 +0900 Subject: [PATCH 4/4] Remove raise assertion --- lib/elixir/test/elixir/version_test.exs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/elixir/test/elixir/version_test.exs b/lib/elixir/test/elixir/version_test.exs index bd3c6cb4851..c3ff15143ca 100644 --- a/lib/elixir/test/elixir/version_test.exs +++ b/lib/elixir/test/elixir/version_test.exs @@ -316,12 +316,6 @@ defmodule VersionTest do test "compile_requirement/1" do {:ok, req} = Version.parse_requirement("1.2.3") assert req == Version.compile_requirement(req) - - string = Process.get(:unused, "~> 1.2.3") - - assert_raise(FunctionClauseError, fn -> - Version.compile_requirement(string) - end) end test "compile requirement" do