JS: create new common directory for all generated tests, migrate several tests there
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
package foo
|
||||
|
||||
class SimpleEnumerator {
|
||||
private var counter = 0
|
||||
|
||||
fun getNext(): String {
|
||||
counter++;
|
||||
return counter.toString()
|
||||
}
|
||||
|
||||
fun hasMoreElements(): Boolean = counter < 1
|
||||
}
|
||||
|
||||
class SimpleEnumeratorWrapper(private val enumerator: SimpleEnumerator) {
|
||||
operator fun hasNext(): Boolean = enumerator.hasMoreElements()
|
||||
|
||||
operator fun next() = enumerator.getNext()
|
||||
}
|
||||
|
||||
operator fun SimpleEnumerator.iterator(): SimpleEnumeratorWrapper {
|
||||
return SimpleEnumeratorWrapper(this)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var o = ""
|
||||
val enumerator = SimpleEnumerator()
|
||||
for (s in enumerator) {
|
||||
o += s;
|
||||
}
|
||||
|
||||
if (o != "1") return "fail: $o"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user