From 43a1b6510d52ab528b948b917a8872c9a31cab62 Mon Sep 17 00:00:00 2001 From: Kip Cole Date: Thu, 2 May 2024 05:39:00 +1000 Subject: [PATCH] Fix warnings for Elixir 1.17 --- CHANGELOG.md | 8 ++++++++ lib/cldr/utils/digits.ex | 4 ++-- lib/cldr/utils/math.ex | 2 +- mix.exs | 2 +- test/http_test.exs | 13 ++++++++----- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4d2a0..134759a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ **Cldr Utils from version 2.18.0 requires Elixir 1.11 or later** +## Cldr Utils version 2.26.0 + +This is the changelog for Cldr Utils v2.25.0 released on March 20th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_utils/tags) + +### Bug Fixes + +* Fix warnings on Elixir 1.17. This primarily relates to charlists constants now required to use `sigil_c` to avoid warnings. As a result, tests will only work on Elixir 1.16 and later even though support for the library is for Elixir 1.11 and later. + ## Cldr Utils version 2.25.0 This is the changelog for Cldr Utils v2.25.0 released on March 20th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_utils/tags) diff --git a/lib/cldr/utils/digits.ex b/lib/cldr/utils/digits.ex index 7e01872..8022223 100644 --- a/lib/cldr/utils/digits.ex +++ b/lib/cldr/utils/digits.ex @@ -100,7 +100,7 @@ defmodule Cldr.Digits do iex> Cldr.Digits.number_of_digits(1234.56789098765) 15 - iex> Cldr.Digits.number_of_digits '12345' + iex> Cldr.Digits.number_of_digits(~c"12345") 5 """ @@ -151,7 +151,7 @@ defmodule Cldr.Digits do iex> Cldr.Digits.number_of_integer_digits(1234.456) 4 - iex> Cldr.Digits.number_of_integer_digits '12345' + iex> Cldr.Digits.number_of_integer_digits(~c"12345") 5 """ diff --git a/lib/cldr/utils/math.ex b/lib/cldr/utils/math.ex index 248b75c..876d4e3 100644 --- a/lib/cldr/utils/math.ex +++ b/lib/cldr/utils/math.ex @@ -250,7 +250,7 @@ defmodule Cldr.Math do # When checking if a decimal is in a range it is only # valid if there are no decimal places - def within(number, first..last) when is_float(number) do + def within(number, %{first: first, last: last}) when is_float(number) do number == trunc(number) && number >= first && number <= last end diff --git a/mix.exs b/mix.exs index 063f281..91885e1 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Utils.MixProject do use Mix.Project - @version "2.25.0" + @version "2.26.0-dev" @source_url "https://github.com/elixir-cldr/cldr_utils" def project do diff --git a/test/http_test.exs b/test/http_test.exs index 921e39c..1a853d8 100644 --- a/test/http_test.exs +++ b/test/http_test.exs @@ -2,6 +2,9 @@ defmodule Cldr.Http.Test do use ExUnit.Case import ExUnit.CaptureLog + @accept_language String.to_charlist("Accept-Language") + @any String.to_charlist("*") + test "Downloading an https url" do assert {:ok, _body} = Cldr.Http.get("https://google.com") end @@ -17,15 +20,15 @@ defmodule Cldr.Http.Test do end test "Request with headers" do - assert {:ok, _body} = Cldr.Http.get({"https://google.com", [{'Accept-Language', '*'}]}) + assert {:ok, _body} = Cldr.Http.get({"https://google.com", [{@accept_language, @any}]}) end test "Request with headers and no peer verification" do - assert {:ok, _body} = Cldr.Http.get({"https://google.com", [{'Accept-Language', '*'}]}, verify_peer: false) + assert {:ok, _body} = Cldr.Http.get({"https://google.com", [{@accept_language, @any}]}, verify_peer: false) end test "Request with headers returning headers" do - assert {:ok, _headers, _body} = Cldr.Http.get_with_headers({"https://google.com", [{'Accept-Language', '*'}]}) + assert {:ok, _headers, _body} = Cldr.Http.get_with_headers({"https://google.com", [{@accept_language, @any}]}) end if Version.compare(System.version(), "1.14.9") == :gt do @@ -34,7 +37,7 @@ defmodule Cldr.Http.Test do assert capture_log(fn -> assert {:error, :connection_timeout} = - Cldr.Http.get_with_headers({"https://google.com", [{'Accept-Language', '*'}]}, options) + Cldr.Http.get_with_headers({"https://google.com", [{@accept_language, @any}]}, options) end) =~ "Timeout connecting to ~c\"google.com\"" end @@ -43,7 +46,7 @@ defmodule Cldr.Http.Test do assert capture_log(fn -> assert {:error, :timeout} = - Cldr.Http.get_with_headers({"https://google.com", [{'Accept-Language', '*'}]}, options) + Cldr.Http.get_with_headers({"https://google.com", [{@accept_language, @any}]}, options) end) =~ "Timeout downloading from ~c\"https://google.com\". Request exceeded #{inspect options[:timeout]}ms." end end