Details
-
Type:
Test
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: groovy-jdk
-
Labels:None
-
Environment:Max OS X 10.4
-
Testcase included:yes
-
Number of attachments :
Description
I added some additional unit tests and javadoc for IntRange.
I also fixed a few minor problems.
IntRange.hashCode() was computing a hash code using only "reverse," "from," and "to." This results in hash codes that are inconsistent with the contract specified by List.hashCode(). As a result, range.equals(list) was true but range.hashCode() == list.hashCode() was false. I removed IntRange.hashCode() so it uses AbstractList.hashCode() instead. This fixes this problem although it is less efficient for large ranges.
I added a checks for null in IntRange.equals(Object) and IntRange.equals(List). equals(null) should return false rather than throwing a NullPointerException.
I made IntRange.subList(i, i) return an empty list instead of a single element list. subList() is from a to b, exclusive, so it should return an empty list in this case.
With these test, IntRange has 100% test coverage.
This issue is superseded by
GROOVY-1553.GROOVY-1553.