Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.7
-
None
Description
Calling next() on an IntRange iterator returns null when hasNext returns false. As stated in a comment in the class, it should throw NoSuchElementException to adhere to the Iterator contract.
class IntRangeItrTest extends GroovyTestCase { void testItr() { def itr = (1..2).iterator() assert itr.next() == 1 assert itr.next() == 2 assert !itr.hasNext() shouldFail(NoSuchElementException) { itr.next() // null } } }
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-7961 ObjectRange iterator returns null instead of NoSuchElementException
- Closed
- links to