Skip to content

Commit

Permalink
Fix warnings for Elixir 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed May 1, 2024
1 parent bb4c5b6 commit 43a1b65
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/utils/digits.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/utils/math.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 8 additions & 5 deletions test/http_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 43a1b65

Please sign in to comment.