failing test for generic extension function
This commit is contained in:
@@ -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");
|
Method foo = generateFunction("foo");
|
||||||
assertThrows(foo, Exception.class, null, new StringBuilder());
|
assertThrows(foo, Exception.class, null, new StringBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void _testGeneric() throws Exception {
|
||||||
|
blackBoxFile("extensionFunctions/generic.jet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user