Implemented isInitialized for lateinit properties + tests

This commit is contained in:
Igor Chevdar
2018-02-20 13:30:33 +03:00
parent adf8614889
commit 91bd565972
10 changed files with 129 additions and 30 deletions
+10
View File
@@ -1058,6 +1058,16 @@ task lateinit_localCapturedNotInitialized(type: RunKonanTest) {
source = "codegen/lateinit/localCapturedNotInitialized.kt"
}
task lateinit_isInitialized(type: RunKonanTest) {
goldValue = "false\ntrue\n"
source = "codegen/lateinit/isInitialized.kt"
}
task lateinit_globalIsInitialized(type: RunKonanTest) {
goldValue = "false\ntrue\n"
source = "codegen/lateinit/globalIsInitialized.kt"
}
task kclass0(type: RunKonanTest) {
source = "codegen/kclass/kclass0.kt"
}
@@ -0,0 +1,15 @@
package codegen.lateinit.globalIsInitialized
import kotlin.test.*
lateinit var s: String
fun foo() {
println(::s.isInitialized)
}
@Test fun runTest() {
foo()
s = "zzz"
foo()
}
@@ -0,0 +1,18 @@
package codegen.lateinit.isInitialized
import kotlin.test.*
class A {
lateinit var s: String
fun foo() {
println(::s.isInitialized)
}
}
@Test fun runTest() {
val a = A()
a.foo()
a.s = "zzz"
a.foo()
}