Move JVM8 box test to common

This commit is contained in:
Mikhael Bogdanov
2018-10-16 11:06:27 +02:00
parent b61608aba7
commit ac8e1a0124
110 changed files with 0 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_RUNTIME
import java.util.*
import java.util.function.Predicate
class MyList : AbstractCollection<String>(), MutableCollection<String> {
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
override val size: Int
get() = throw UnsupportedOperationException()
override fun removeIf(predicate: Predicate<in String>) =
predicate.test("abc")
}
fun box(): String {
val ml = mutableListOf("xyz", "abc")
if (!ml.removeIf { x -> x == "abc" }) return "fail 1"
if (ml.removeIf { x -> x == "abc" }) return "fail 2"
if (ml != listOf("xyz")) return "fail 3"
val myList = MyList()
if (!myList.removeIf { x -> x == "abc" }) return "fail 4"
if (myList.removeIf { x -> x == "xyz" }) return "fail 5"
return "OK"
}