Minor. Move tests
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import java.util.*;
|
||||
|
||||
interface A0 {
|
||||
val size: Int get() = 56
|
||||
}
|
||||
|
||||
class B0 : Collection<String>, A0 {
|
||||
override fun isEmpty() = throw UnsupportedOperationException()
|
||||
override fun contains(o: String) = throw UnsupportedOperationException()
|
||||
override fun iterator() = throw UnsupportedOperationException()
|
||||
override fun containsAll(c: Collection<String>) = throw UnsupportedOperationException()
|
||||
override val size: Int
|
||||
get() = super.size
|
||||
}
|
||||
|
||||
open class A1 {
|
||||
val size: Int = 56
|
||||
}
|
||||
|
||||
class B1 : Collection<String>, A1() {
|
||||
override fun isEmpty() = throw UnsupportedOperationException()
|
||||
override fun contains(o: String) = throw UnsupportedOperationException()
|
||||
override fun iterator() = throw UnsupportedOperationException()
|
||||
override fun containsAll(c: Collection<String>) = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
val size: Int
|
||||
}
|
||||
|
||||
val list = ArrayList<String>()
|
||||
|
||||
class B2 : ArrayList<String>(list), I2
|
||||
|
||||
interface I3<T> {
|
||||
val size: T
|
||||
}
|
||||
|
||||
class B3 : ArrayList<String>(list), I3<Int>
|
||||
|
||||
interface I4<T> {
|
||||
val size: T get() = 56 as T
|
||||
}
|
||||
|
||||
class B4 : Collection<String>, I4<Int> {
|
||||
override fun isEmpty() = throw UnsupportedOperationException()
|
||||
override fun contains(o: String) = throw UnsupportedOperationException()
|
||||
override fun iterator() = throw UnsupportedOperationException()
|
||||
override fun containsAll(c: Collection<String>) = throw UnsupportedOperationException()
|
||||
override val size: Int
|
||||
get() = super.size
|
||||
}
|
||||
|
||||
interface I5 : Collection<String> {
|
||||
override val size: Int get() = 56
|
||||
}
|
||||
|
||||
class B5 : I5 {
|
||||
override fun isEmpty() = throw UnsupportedOperationException()
|
||||
override fun contains(o: String) = throw UnsupportedOperationException()
|
||||
override fun iterator() = throw UnsupportedOperationException()
|
||||
override fun containsAll(c: Collection<String>) = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
list.add("1")
|
||||
|
||||
val b0 = B0()
|
||||
if (b0.size != 56) return "fail 0: ${b0.size}"
|
||||
var x: Collection<String> = B0()
|
||||
if (x.size != 56) return "fail 00: ${x.size}"
|
||||
val a0: A0 = b0
|
||||
if (a0.size != 56) return "fail 000: ${a0.size}"
|
||||
|
||||
val b1 = B1()
|
||||
if (b1.size != 56) return "fail 1: ${b1.size}"
|
||||
x = B1()
|
||||
if (x.size != 56) return "fail 2: ${x.size}"
|
||||
|
||||
val b2 = B2()
|
||||
if (b2.size != 1) return "fail 3: ${b2.size}"
|
||||
x = B2()
|
||||
if (x.size != 1) return "fail 4: ${x.size}"
|
||||
val i2: I2 = b2
|
||||
if (i2.size != 1) return "fail 5: ${i2.size}"
|
||||
|
||||
val b3 = B3()
|
||||
if (b3.size != 1) return "fail 6: ${b3.size}"
|
||||
x = B3()
|
||||
if (x.size != 1) return "fail 7: ${x.size}"
|
||||
val i3: I3<Int> = b3
|
||||
if (i3.size != 1) return "fail 8: ${i3.size}"
|
||||
|
||||
val b4 = B4()
|
||||
if (b4.size != 56) return "fail 9: ${b4.size}"
|
||||
x = B4()
|
||||
if (x.size != 56) return "fail 10: ${x.size}"
|
||||
|
||||
val b5 = B5()
|
||||
if (b5.size != 56) return "fail 11: ${b5.size}"
|
||||
x = B5()
|
||||
if (x.size != 56) return "fail 12: ${x.size}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
class A1 : MutableCollection<String> {
|
||||
override val size: Int
|
||||
get() = 56
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun contains(o: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun iterator(): MutableIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun containsAll(c: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun add(e: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun remove(o: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun addAll(c: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun removeAll(c: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun retainAll(c: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
class A2 : java.util.AbstractCollection<String>() {
|
||||
override val size: Int
|
||||
get() = 56
|
||||
|
||||
override fun iterator(): MutableIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
class A3 : java.util.ArrayList<String>() {
|
||||
override val size: Int
|
||||
get() = 56
|
||||
}
|
||||
|
||||
interface Sized {
|
||||
val size: Int
|
||||
}
|
||||
|
||||
class A4 : java.util.ArrayList<String>(), Sized {
|
||||
override val size: Int
|
||||
get() = 56
|
||||
}
|
||||
|
||||
fun check56(x: Collection<String>) {
|
||||
if (x.size != 56) throw java.lang.RuntimeException("fail ${x.size}")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a1 = A1()
|
||||
if (a1.size != 56) return "fail 1: ${a1.size}"
|
||||
check56(a1)
|
||||
|
||||
val a2 = A2()
|
||||
if (a2.size != 56) return "fail 2: ${a2.size}"
|
||||
check56(a2)
|
||||
|
||||
val a3 = A3()
|
||||
if (a3.size != 56) return "fail 3: ${a3.size}"
|
||||
check56(a3)
|
||||
|
||||
val a4 = A4()
|
||||
if (a4.size != 56) return "fail 4: ${a4.size}"
|
||||
check56(a4)
|
||||
|
||||
val sized: Sized = a4
|
||||
if (sized.size != 56) return "fail 5: ${a4.size}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
interface Ordinaled {
|
||||
val ordinal: Int
|
||||
}
|
||||
|
||||
enum class A : Ordinaled {
|
||||
X
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val result = (A.X as Ordinaled).ordinal
|
||||
|
||||
if (result != 0) return "fail 1: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A : java.util.ArrayList<String>() {
|
||||
override val size: Int get() = super.size + 56
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.size != 56) return "fail: ${a.size}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
interface Container {
|
||||
fun removeAt(x: Int): String
|
||||
}
|
||||
|
||||
open class ContainerImpl : Container {
|
||||
override fun removeAt(x: Int) = "abc"
|
||||
}
|
||||
|
||||
class A : ContainerImpl(), MutableList<String> {
|
||||
override fun isEmpty(): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val size: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
|
||||
override fun contains(element: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun get(index: Int): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun indexOf(element: String): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun lastIndexOf(element: String): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun add(element: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun remove(element: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun addAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun addAll(index: Int, elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun removeAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun retainAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun set(index: Int, element: String): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun add(index: Int, element: String) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun listIterator(): MutableListIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun listIterator(index: Int): MutableListIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun iterator(): MutableIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.removeAt(0) != "abc") return "fail 1"
|
||||
|
||||
val l: MutableList<String> = a
|
||||
if (l.removeAt(0) != "abc") return "fail 2"
|
||||
|
||||
val anyList: MutableList<Any?> = a as MutableList<Any?>
|
||||
if (anyList.removeAt(0) != "abc") return "fail 3"
|
||||
|
||||
val container: Container = a
|
||||
if (container.removeAt(0) != "abc") return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class A : Map<String, String> {
|
||||
override val size: Int get() = 56
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun containsKey(key: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun containsValue(value: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun get(key: String): String? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val keys: Set<String> get() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val values: Collection<String> get() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val entries: Set<Map.Entry<String, String>> get() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.size != 56) return "fail 1: ${a.size}"
|
||||
|
||||
val x: Map<String, String> = a
|
||||
if (x.size != 56) return "fail 2: ${x.size}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
throw Throwable("OK", null)
|
||||
} catch (t: Throwable) {
|
||||
if (t.cause != null) return "fail 1"
|
||||
return t.message!!
|
||||
}
|
||||
|
||||
return "fail 2"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
enum class Variants {
|
||||
O, K;
|
||||
companion object {
|
||||
val valueStr = values[0].name + Variants.values[1].name
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Variants.valueStr
|
||||
Reference in New Issue
Block a user