KT-274 Enumeration.iterator()

This commit is contained in:
Alex Tkachman
2012-02-07 16:40:14 +02:00
parent 1d88960a19
commit adfce7e22d
4 changed files with 23 additions and 2 deletions
@@ -29,6 +29,9 @@ import java.util.jar.JarOutputStream;
public class ForTestCompileStdlib {
private static File stdlibJarFile;
private ForTestCompileStdlib() {
}
private static File doCompile() throws Exception {
File tmpDir = JetTestUtils.tmpDir("stdlibjar");
@@ -85,7 +85,7 @@ public class StdlibTest extends CodegenTestCase {
}
public void testKt274 () {
// blackBoxFile("regressions/kt274.kt");
blackBoxFile("regressions/kt274.kt");
}
//from ClassGenTest
+1 -1
View File
@@ -20,7 +20,7 @@ inline fun <T> java.util.Iterator<T>.iterator() = this
/*
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
get() = hasMoreElements()
+18
View File
@@ -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)
}
}