Tests for renamed fields
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
class Test(val prop: String) {
|
||||
|
||||
class object {
|
||||
public val prop : String = "CO";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
val obj = Test("OK");
|
||||
|
||||
if (Test.prop != "CO") return "fail1";
|
||||
|
||||
return obj.prop;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
public open class TestDelegate<T: Any>(private val initializer: () -> T) {
|
||||
private volatile var value: T? = null
|
||||
|
||||
public open fun get(thisRef: Any?, desc: PropertyMetadata): T {
|
||||
if (value == null) {
|
||||
value = initializer()
|
||||
}
|
||||
return value!!
|
||||
}
|
||||
|
||||
public open fun set(thisRef: Any?, desc: PropertyMetadata, svalue : T) {
|
||||
value = svalue
|
||||
}
|
||||
}
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
public val A.s: String by TestDelegate( {"OK2"})
|
||||
public val B.s: String by TestDelegate( {"OK"})
|
||||
|
||||
fun box() : String {
|
||||
if (A().s != "OK2") return "fail1"
|
||||
|
||||
return B().s
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
public class MPair<out A> (
|
||||
public val first: A
|
||||
) {
|
||||
fun equals(o: Any?): Boolean {
|
||||
val t = o as MPair<*>
|
||||
return first == t.first
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = MPair("O")
|
||||
a.equals(a)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class A { }
|
||||
class B { }
|
||||
|
||||
public val A.prop: Int = 0;
|
||||
public val B.prop: String = "1111";
|
||||
public val prop: Double = 0.1;
|
||||
|
||||
public fun doTest() : String {
|
||||
if (A().prop != 0) return "fail1"
|
||||
if (B().prop != "1111") return "fail2"
|
||||
if (prop != 0.1) return "fail3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return doTest()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class A { }
|
||||
class B { }
|
||||
|
||||
class Test {
|
||||
|
||||
public val A.prop: Int = 0;
|
||||
public val B.prop: String = "1111";
|
||||
public val prop: Double = 0.1;
|
||||
|
||||
public fun doTest() : String {
|
||||
if (A().prop != 0) return "fail1"
|
||||
if (B().prop != "1111") return "fail2"
|
||||
if (prop != 0.1) return "fail3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
return Test().doTest()
|
||||
}
|
||||
Reference in New Issue
Block a user