Fix array iterators to adhere to Iterator contract

#KT-17453 Fixed

Change expected exceptions in tests.
This commit is contained in:
Ilya Gorbunov
2017-04-17 23:49:43 +03:00
parent 2380e0bacc
commit 4a5d8534c1
6 changed files with 46 additions and 28 deletions
@@ -29,7 +29,7 @@ class GenerateArrayIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) {
out.println("private class Array${s}Iterator(private val array: ${s}Array) : ${s}Iterator() {")
out.println(" private var index = 0")
out.println(" override fun hasNext() = index < array.size")
out.println(" override fun next$s() = array[index++]")
out.println(" override fun next$s() = try { array[index++] } catch (e: ArrayIndexOutOfBoundsException) { throw NoSuchElementException(e.message) }")
out.println("}")
out.println()
}