groovy

additional tests and javadoc for IntRange

Details

  • Type: Test Test
  • Status: Closed Closed
  • Priority: Minor 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 :
    2

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.

  1. IntRange.patch
    04/Nov/06 8:05 AM
    11 kB
    Edwin Tellman
  2. IntRangeTest.patch
    04/Nov/06 8:05 AM
    21 kB
    Edwin Tellman

Activity

Hide
Edwin Tellman added a comment -

This issue is superseded by GROOVY-1553.

Show
Edwin Tellman added a comment - This issue is superseded by GROOVY-1553.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: