Added tests on lateinit properties
This commit is contained in:
@@ -734,6 +734,16 @@ task propertyCallableReference_linkTest(type: LinkKonanTest) {
|
||||
lib = "codegen/propertyCallableReference/linkTest_lib.kt"
|
||||
}
|
||||
|
||||
task lateinit_initialized(type: RunKonanTest) {
|
||||
goldValue = "zzz\n"
|
||||
source = "codegen/lateinit/initialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_notInitialized(type: RunKonanTest) {
|
||||
goldValue = "OK\n"
|
||||
source = "codegen/lateinit/notInitialized.kt"
|
||||
}
|
||||
|
||||
task array0(type: RunKonanTest) {
|
||||
goldValue = "5\n6\n7\n8\n9\n10\n11\n12\n13\n"
|
||||
source = "runtime/collections/array0.kt"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() = s
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = A()
|
||||
a.s = "zzz"
|
||||
println(a.foo())
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() = s
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = A()
|
||||
try {
|
||||
println(a.foo())
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
println("OK")
|
||||
return
|
||||
}
|
||||
println("Fail")
|
||||
}
|
||||
Reference in New Issue
Block a user