failing test for generic extension function

This commit is contained in:
Dmitry Jemerov
2011-06-30 15:09:06 +02:00
parent 48f23a0ca1
commit b847fd1d09
2 changed files with 25 additions and 0 deletions
@@ -0,0 +1,21 @@
import java.util.*
fun <T> ArrayList<T>.findAll(predicate: {(T) : Boolean}): ArrayList<T> {
val result = ArrayList<T>()
for(val t in this) {
if (predicate(t)) result.add(t)
}
return result
}
fun box(): String {
val list: ArrayList<String> = ArrayList<String>()
list.add("Prague")
list.add("St.Petersburg")
list.add("Moscow")
list.add("Munich")
val m: ArrayList<String> = list.findAll({(name: String) => name.startsWith("M")})
return if (m.size() == 2) "OK" else "fail"
}
@@ -23,4 +23,8 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
Method foo = generateFunction("foo");
assertThrows(foo, Exception.class, null, new StringBuilder());
}
public void _testGeneric() throws Exception {
blackBoxFile("extensionFunctions/generic.jet");
}
}