Files
kotlin-fork/compiler/testData/codegen/box/classes/propertyDelegation.kt
T
Alexander Udalov 41a416da60 Move blackBoxFile() testData to box/ directory
Delete all test methods (and empty test classes), since they'll be
auto-generated
2013-01-28 18:20:17 +04:00

34 lines
681 B
Kotlin

open class Base() {
val plain = 239
public val read : Int
get() = 239
public var readwrite : Int = 0
get() = $readwrite + 1
set(n : Int) {
$readwrite = n
}
}
trait Abstract {}
class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {}
fun code(s : Base) : Int {
if (s.plain != 239) return 1
if (s.read != 239) return 2
s.readwrite = 238
if (s.readwrite != 239) return 3
return 0
}
fun test(s : Base) : Boolean = code(s) == 0
fun box() : String {
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
return "OK"
}