KT-274 Enumeration.iterator()
This commit is contained in:
@@ -29,6 +29,9 @@ import java.util.jar.JarOutputStream;
|
|||||||
public class ForTestCompileStdlib {
|
public class ForTestCompileStdlib {
|
||||||
private static File stdlibJarFile;
|
private static File stdlibJarFile;
|
||||||
|
|
||||||
|
private ForTestCompileStdlib() {
|
||||||
|
}
|
||||||
|
|
||||||
private static File doCompile() throws Exception {
|
private static File doCompile() throws Exception {
|
||||||
File tmpDir = JetTestUtils.tmpDir("stdlibjar");
|
File tmpDir = JetTestUtils.tmpDir("stdlibjar");
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class StdlibTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testKt274 () {
|
public void testKt274 () {
|
||||||
// blackBoxFile("regressions/kt274.kt");
|
blackBoxFile("regressions/kt274.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
//from ClassGenTest
|
//from ClassGenTest
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ inline fun <T> java.util.Iterator<T>.iterator() = this
|
|||||||
/*
|
/*
|
||||||
Helper to make java.util.Enumeration usable in for
|
Helper to make java.util.Enumeration usable in for
|
||||||
*/
|
*/
|
||||||
inline fun <T> java.util.Enumeration<T>.iterator(): Iterator<T> = object: Iterator<T> {
|
fun <erased T> java.util.Enumeration<T>.iterator(): Iterator<T> = object: Iterator<T> {
|
||||||
override val hasNext: Boolean
|
override val hasNext: Boolean
|
||||||
get() = hasMoreElements()
|
get() = hasMoreElements()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import java.util.Vector
|
||||||
|
import junit.framework.TestCase
|
||||||
|
import stdhack.test.assertEquals
|
||||||
|
|
||||||
|
class EnumerationIteratorTest() : TestCase() {
|
||||||
|
fun testIteration () {
|
||||||
|
val v = Vector<Int>()
|
||||||
|
for(i in 1..5)
|
||||||
|
v.add(i)
|
||||||
|
|
||||||
|
var sum = 0
|
||||||
|
for(k in v.elements())
|
||||||
|
sum += k
|
||||||
|
|
||||||
|
assertEquals(15, sum)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user