Introduce RandomAccess to JS.

Make EmptyList support RandomAccess.
#KT-10794
This commit is contained in:
Ilya Gorbunov
2016-02-10 21:23:35 +03:00
parent 6ba98f7fe6
commit ab68b49a70
4 changed files with 15 additions and 3 deletions
@@ -854,4 +854,11 @@ class CollectionTest {
// we need toString() inside pattern because of KT-8666
assertEquals("[1, a, null, ${Long.MAX_VALUE.toString()}]", listOf(1, "a", null, Long.MAX_VALUE).toString())
}
@test fun randomAccess() {
assertTrue(arrayListOf(1) is RandomAccess, "ArrayList is RandomAccess")
assertTrue(listOf(1, 2) is RandomAccess, "Default read-only list implementation is RandomAccess")
assertTrue(listOf(1) is RandomAccess, "Default singleton list is RandomAccess")
assertTrue(emptyList<Int>() is RandomAccess, "Empty list is RandomAccess")
}
}