A few Interval helper methods are missing support for reverse ranges, which are ranges where the from value is greater than the to value, which would require the by value to be negative.
Classes: Interval, IntInterval, LongInterval
The following examples throw exceptions today:
zeroTo
Interval.zeroTo(-10);
// java.lang.IllegalArgumentException: Step by is incorrect for the range
This code should result in: Interval.fromToBy(0, -10, -1)
to
Interval.from(10).to(-10);
// java.lang.IllegalArgumentException: Step by is incorrect for the range
This code should result in: Interval.fromToBy(10, -10, -1)
oneTo
Interval.oneTo(-10);
// java.lang.IllegalArgumentException: Only positive ranges allowed using oneToBy
This exception looks like it was intentional but I think if we fix the other two, this one should be changed to be consistent. This code should result in: Interval.fromToBy(1, -10, -1)
Failing tests should be written to cover all missing scenarios first. I was not exhaustive in my search, so there may be other helper methods that do not support reverse ranges.
A few
Interval
helper methods are missing support for reverse ranges, which are ranges where thefrom
value is greater than theto
value, which would require theby
value to be negative.Classes:
Interval
,IntInterval
,LongInterval
The following examples throw exceptions today:
zeroTo
This code should result in:
Interval.fromToBy(0, -10, -1)
to
This code should result in:
Interval.fromToBy(10, -10, -1)
oneTo
This exception looks like it was intentional but I think if we fix the other two, this one should be changed to be consistent. This code should result in:
Interval.fromToBy(1, -10, -1)
Failing tests should be written to cover all missing scenarios first. I was not exhaustive in my search, so there may be other helper methods that do not support reverse ranges.