Exploder98 opened a new pull request #1553: URL: https://github.com/apache/groovy/pull/1553
[JIRA Issue](https://issues.apache.org/jira/browse/GROOVY-9649) This Pull request implements the above feature and adds test cases related to left- and full-open ranges. We have also added documentation. This change *should* be backwards-compatible, as old right-exclusive ranges work as before. We have tried to preserve all old constructors and methods so that this change would be as backwards-compatible as possible. A few things to note: - ranges like `0<..<1` where to and from differ by one, the range is full exclusive and to and from share the same sign (positive numbers and zero are considered to have the same sign) are created as `EmptyRange`s. This is because ranges like `0<..<-1` can still be used to index into lists. - while testing, we noticed that the following equality test produces different results when the operands are switched: ```groovy IntRange r1 = new IntRange(false, 1, 10) // "Inclusive-aware" range IntRange r2 = new IntRange(1, 10) // Non-inclusive-aware range r1.equals(r2) // Returns false r2.equals(r1) // Returns true ``` we have not changed this behaviour. While implementing the feature, we noticed some inconsistencies between different ranges, which we have not altered due to backwards compatibility: - `NumberRange` and `IntRange` contain information about their inclusivity, but `ObjectRange` inclusivity is taken into account when the range is created - in `IntRange`, the `getFrom` and `getTo` methods return the actual bounds of that range, whereas `NumberRange`'s corresponging methods return the bounds that the object was created with, even if the bounds are not actually included in the range This PR was a joint effort by 4 people: @Exploder98 @iiroki @OttoVayrynen @EricssonWilli -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
