mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
58 lines
951 B
Kotlin
Vendored
58 lines
951 B
Kotlin
Vendored
class Test {
|
|
|
|
companion object {
|
|
|
|
public val prop1 : Int = 10
|
|
|
|
public var prop2 : Int = 11
|
|
private set
|
|
|
|
public val prop3: Int = 12
|
|
get() {
|
|
return field
|
|
}
|
|
|
|
var prop4 : Int = 13
|
|
|
|
fun incProp4() {
|
|
prop4++
|
|
}
|
|
|
|
|
|
public var prop5 : Int = 14
|
|
|
|
public var prop7 : Int = 20
|
|
set(i: Int) {
|
|
field++
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
fun box(): String {
|
|
val t = Test;
|
|
|
|
if (t.prop1 != 10) return "fail1";
|
|
|
|
if (t.prop2 != 11) return "fail2";
|
|
|
|
if (t.prop3 != 12) return "fail3";
|
|
|
|
if (t.prop4 != 13) return "fail4";
|
|
|
|
t.incProp4()
|
|
if (t.prop4 != 14) return "fail4.inc";
|
|
|
|
if (t.prop5 != 14) return "fail5";
|
|
|
|
t.prop5 = 1414
|
|
if (t.prop5 != 1414) return "fail6";
|
|
|
|
if (t.prop7 != 20) return "fail7";
|
|
|
|
t.prop7 = 1000000
|
|
if (t.prop7 != 21) return "fail8";
|
|
|
|
return "OK"
|
|
} |