JS lib: added hasNext to Kotlin.ListIterator and fixed next.
#KT-6506 Fixed Additionally made abstract AbstractList::get and AbstractCollection::size.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package foo
|
||||
|
||||
import java.util.AbstractList
|
||||
|
||||
class MyList<T>(vararg val data: T) : AbstractList<T>() {
|
||||
override fun get(index: Int) = data[index]
|
||||
override fun size() = data.size()
|
||||
}
|
||||
|
||||
fun test<T>(expected: String, list: List<T>) {
|
||||
var s = ""
|
||||
for (e in list) {
|
||||
s += "$e,"
|
||||
}
|
||||
assertEquals(expected, s)
|
||||
|
||||
val it = list.iterator()
|
||||
s = ""
|
||||
while (it.hasNext()) {
|
||||
val e = it.next()
|
||||
s += "$e,"
|
||||
}
|
||||
assertEquals(expected, s)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
test("32,12,23,444,", MyList(32, 12, 23, 444))
|
||||
test("", MyList<Any>())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user