Move JVM8 box test to common
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
public interface BaseKotlin : Base {
|
||||
}
|
||||
|
||||
|
||||
class Fail : BaseKotlin {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z = object : BaseKotlin by Fail() {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
return z.test()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
public interface BaseKotlin : Base {
|
||||
override fun getValue() = "OK"
|
||||
|
||||
override fun test(): String {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
class OK : BaseKotlin {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val ok = object : BaseKotlin by OK() {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
return ok.test()
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FULL_JDK
|
||||
|
||||
class MapWithBadDefaults : HashMap<String, String>() {
|
||||
override fun getOrDefault(key: String, defaultValue: String): String {
|
||||
throw RuntimeException("Shouldn't be executed")
|
||||
}
|
||||
|
||||
override fun remove(key: String, value: String): Boolean {
|
||||
throw RuntimeException("Shouldn't be executed")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Test(map: MutableMap<String, String>) : MutableMap<String, String> by map
|
||||
|
||||
fun box(): String {
|
||||
val test = Test(MapWithBadDefaults())
|
||||
test.put("O", "K")
|
||||
if (!test.containsKey("O")) return "fail 1: can't find value for key 'O'"
|
||||
if (!test.remove("O", "K")) return "fail 2: entry wasn't removed"
|
||||
|
||||
return test.getOrDefault("absent", "OK")
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Base2.java
|
||||
public interface Base2 extends Base {
|
||||
|
||||
default String test() {
|
||||
return "O" + getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface KBase : Base
|
||||
|
||||
interface Derived : KBase, Base2
|
||||
|
||||
class Fail : Derived {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z = object : Derived by Fail() {
|
||||
override fun getValue() = "K"
|
||||
}
|
||||
return z.test()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test()
|
||||
{
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Base2.java
|
||||
public interface Base2 extends Base {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface KBase : Base {
|
||||
override fun test() = "O" + getValue()
|
||||
}
|
||||
|
||||
interface Derived : KBase, Base2
|
||||
|
||||
class K : Derived {
|
||||
override fun getValue() = "K"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z = object : Derived by K() {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
return z.test()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Fail : Base {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
|
||||
class Derived : Base by Fail() {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Derived().test()
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base extends KBase {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
interface KBase {
|
||||
fun getValue(): String
|
||||
|
||||
fun test(): String
|
||||
}
|
||||
|
||||
class Fail : Base {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z1 = object : KBase by Fail() {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
if (z1.test() != "Fail") return "fail 1"
|
||||
|
||||
val z2 = object : Base by Fail() {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
return z2.test()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Fail : Base {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z = object : Base by Fail() {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
return z.test()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// LANGUAGE_VERSION: 1.0
|
||||
// FILE: Base.java
|
||||
|
||||
public interface Base {
|
||||
String getValue();
|
||||
|
||||
default String test() {
|
||||
return getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class OK : Base {
|
||||
override fun getValue() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z = object : Base by OK() {
|
||||
override fun getValue() = "Fail"
|
||||
}
|
||||
return z.test()
|
||||
}
|
||||
Reference in New Issue
Block a user