diff --git a/libraries/stdlib/test/js/JsCollectionsTest.kt b/libraries/stdlib/test/js/JsCollectionsTest.kt index 071c16cedfa..e72ee320454 100644 --- a/libraries/stdlib/test/js/JsCollectionsTest.kt +++ b/libraries/stdlib/test/js/JsCollectionsTest.kt @@ -60,6 +60,30 @@ class JsCollectionsTest { snapshotDoesNotCreateView(arrayOf("first", "last"), { arrayListOf(*it) }) } + @test fun listEqualsOperatesOnAny() { + assertFalse(listOf(1, 2, 3).equals(object {})) + } + + @test fun arrayListValidatesIndexRange() { + val list = mutableListOf(1) + for (index in listOf(-1, 1, 3)) { + if (index != list.size) { // size is a valid position index + assertFailsWith { list.add(index, 2) } + assertFailsWith { list.addAll(index, listOf(3, 0)) } + assertFailsWith { list.listIterator(index) } + } + assertFailsWith { list.removeAt(index) } + assertFailsWith { list[index] } + assertFailsWith { list.subList(index, index + 2) } // tests ranges [-1, 1), [1, 3) and [3, 5) + } + assertEquals(listOf(1), list) + } + + @test fun mutableIteratorRemove() { + val a = mutableListOf(1, 2, 3) + val it = a.iterator() + assertFailsWith { it.remove() } + } private fun snapshotDoesNotCreateView(array: Array, snapshot: (Array) -> List) { val first = array.first()