Throw correct exceptions expected by stdlib tests
This commit is contained in:
committed by
Pavel Punegov
parent
bb44fdda88
commit
57d21f9a38
@@ -134,7 +134,7 @@ public actual open class AssertionError : Error {
|
|||||||
|
|
||||||
actual constructor()
|
actual constructor()
|
||||||
|
|
||||||
constructor(message: String?) : super(message)
|
constructor(cause: Throwable?) : super(cause)
|
||||||
|
|
||||||
actual constructor(message: Any?) : super(message.toString())
|
actual constructor(message: Any?) : super(message.toString())
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ actual class ArrayList<E> private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun remove() {
|
override fun remove() {
|
||||||
|
check(lastIndex != -1) { "Call next() or previous() before removing element from the iterator." }
|
||||||
list.removeAt(lastIndex)
|
list.removeAt(lastIndex)
|
||||||
index = lastIndex
|
index = lastIndex
|
||||||
lastIndex = -1
|
lastIndex = -1
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ actual class HashMap<K, V> private constructor(
|
|||||||
|
|
||||||
internal class KeysItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<K> {
|
internal class KeysItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<K> {
|
||||||
override fun next(): K {
|
override fun next(): K {
|
||||||
if (index >= map.length) throw IndexOutOfBoundsException()
|
if (index >= map.length) throw NoSuchElementException()
|
||||||
lastIndex = index++
|
lastIndex = index++
|
||||||
val result = map.keysArray[lastIndex]
|
val result = map.keysArray[lastIndex]
|
||||||
initNext()
|
initNext()
|
||||||
@@ -563,7 +563,7 @@ actual class HashMap<K, V> private constructor(
|
|||||||
|
|
||||||
internal class ValuesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<V> {
|
internal class ValuesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<V> {
|
||||||
override fun next(): V {
|
override fun next(): V {
|
||||||
if (index >= map.length) throw IndexOutOfBoundsException()
|
if (index >= map.length) throw NoSuchElementException()
|
||||||
lastIndex = index++
|
lastIndex = index++
|
||||||
val result = map.valuesArray!![lastIndex]
|
val result = map.valuesArray!![lastIndex]
|
||||||
initNext()
|
initNext()
|
||||||
@@ -574,7 +574,7 @@ actual class HashMap<K, V> private constructor(
|
|||||||
internal class EntriesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map),
|
internal class EntriesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map),
|
||||||
MutableIterator<MutableMap.MutableEntry<K, V>> {
|
MutableIterator<MutableMap.MutableEntry<K, V>> {
|
||||||
override fun next(): EntryRef<K, V> {
|
override fun next(): EntryRef<K, V> {
|
||||||
if (index >= map.length) throw IndexOutOfBoundsException()
|
if (index >= map.length) throw NoSuchElementException()
|
||||||
lastIndex = index++
|
lastIndex = index++
|
||||||
val result = EntryRef(map, lastIndex)
|
val result = EntryRef(map, lastIndex)
|
||||||
initNext()
|
initNext()
|
||||||
@@ -582,7 +582,7 @@ actual class HashMap<K, V> private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun nextHashCode(): Int {
|
internal fun nextHashCode(): Int {
|
||||||
if (index >= map.length) throw IndexOutOfBoundsException()
|
if (index >= map.length) throw NoSuchElementException()
|
||||||
lastIndex = index++
|
lastIndex = index++
|
||||||
val result = map.keysArray[lastIndex].hashCode() xor map.valuesArray!![lastIndex].hashCode()
|
val result = map.keysArray[lastIndex].hashCode() xor map.valuesArray!![lastIndex].hashCode()
|
||||||
initNext()
|
initNext()
|
||||||
@@ -590,7 +590,7 @@ actual class HashMap<K, V> private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun nextAppendString(sb: StringBuilder) {
|
fun nextAppendString(sb: StringBuilder) {
|
||||||
if (index >= map.length) throw IndexOutOfBoundsException()
|
if (index >= map.length) throw NoSuchElementException()
|
||||||
lastIndex = index++
|
lastIndex = index++
|
||||||
val key = map.keysArray[lastIndex]
|
val key = map.keysArray[lastIndex]
|
||||||
if (key == map) sb.append("(this Map)") else sb.append(key)
|
if (key == map) sb.append("(this Map)") else sb.append(key)
|
||||||
|
|||||||
Reference in New Issue
Block a user