Provide no-op members in JS ArrayList to work with capacity.
#KT-14637
This commit is contained in:
@@ -21,6 +21,10 @@ public open class ArrayList<E> internal constructor(private var array: Array<Any
|
||||
public constructor(capacity: Int = 0) : this(emptyArray()) {}
|
||||
public constructor(elements: Collection<E>) : this(elements.toTypedArray<Any?>()) {}
|
||||
|
||||
/** Does nothing in this ArrayList implementation. */
|
||||
public fun trimToSize() {}
|
||||
/** Does nothing in this ArrayList implementation. */
|
||||
public fun ensureCapacity(minCapacity: Int) {}
|
||||
|
||||
override val size: Int get() = array.size
|
||||
override fun get(index: Int): E = array[rangeCheck(index)] as E
|
||||
|
||||
@@ -37,6 +37,13 @@ class JsCollectionsTest {
|
||||
snapshotDoesNotCreateView(arrayOf<Any>("first", "last"), { arrayListOf(*it) })
|
||||
}
|
||||
|
||||
@test fun arrayListCapacity() {
|
||||
val list = ArrayList<Any>(20)
|
||||
list.ensureCapacity(100)
|
||||
list.trimToSize()
|
||||
assertTrue(list.isEmpty())
|
||||
}
|
||||
|
||||
@test fun listEqualsOperatesOnAny() {
|
||||
assertFalse(listOf(1, 2, 3).equals(object {}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user