Skip to content

Commit 649ee46

Browse files
k-asmbitwalker
authored andcommitted
use Range.new/3 explicitly passing the step of -1
1 parent 17806a9 commit 649ee46

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1212
- Added `cycled` option for `Timex.between?/4` to support time-range checks that pass through midnight
1313
- Add Croatian translation
1414
- Changed charlists from the deprecated `''` to `~c""`
15+
- Changed negative range to pass the step of default value for suppressing deprecation warnings
1516

1617
### Fixed
1718

lib/parse/datetime/helpers.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ defmodule Timex.Parse.DateTime.Helpers do
159159

160160
case {padding, min_width, max_width} do
161161
{:zeroes, _, nil} -> Text.integer()
162-
{:zeroes, min, max} -> choice(Enum.map(max..min, &fixed_integer(&1)))
162+
{:zeroes, min, max} -> choice(Enum.map(max..min//-1, &fixed_integer(&1)))
163163
{:spaces, -1, nil} -> skip(spaces()) |> Text.integer()
164164
{:spaces, min, nil} -> skip(spaces()) |> fixed_integer(min)
165-
{:spaces, _, max} -> skip(spaces()) |> choice(Enum.map(max..1, &fixed_integer(&1)))
165+
{:spaces, _, max} -> skip(spaces()) |> choice(Enum.map(max..1//-1, &fixed_integer(&1)))
166166
{_, -1, nil} -> Text.integer()
167167
{_, min, nil} -> fixed_integer(min)
168-
{_, min, max} -> choice(Enum.map(max..min, &fixed_integer(&1)))
168+
{_, min, max} -> choice(Enum.map(max..min//-1, &fixed_integer(&1)))
169169
end
170170
end
171171
end

test/duration_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ defmodule DurationTests do
125125

126126
# Just make sure that Timex.Duration.measure is called at least once in the tests
127127
test "measure/1" do
128-
reversed_list = Enum.to_list(100_000..1)
128+
reversed_list = Enum.to_list(100_000..1//-1)
129129

130130
assert {%Duration{} = d, ^reversed_list} =
131131
Duration.measure(fn -> Enum.reverse(1..100_000) end)

test/shift_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule ShiftTests do
1919
property "is always lower than input date for negative shift values" do
2020
check all(
2121
input_date <- PropertyHelpers.date_time_generator(:struct),
22-
shift <- StreamData.integer(-1..-1000),
22+
shift <- StreamData.integer(-1..-1000//-1),
2323
unit <- StreamData.member_of(@units)
2424
) do
2525
date = Timex.shift(input_date, [{unit, shift}])

0 commit comments

Comments
 (0)