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:
Zalim Bashorov
2014-12-29 14:28:41 +03:00
parent 480f990c1d
commit 7668f44655
4 changed files with 75 additions and 5 deletions
@@ -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"
}