From 828e7f87446288a42051c7dc3c001b447ed5dfc3 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sat, 20 Aug 2016 17:25:09 +0300 Subject: [PATCH] Add tests to ensure #KT-7473 and #KT-13459 and #KT-13429 are Fixed. --- libraries/stdlib/test/js/JsCollectionsTest.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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()