Supported lateinit locals + tests
This commit is contained in:
@@ -1036,6 +1036,28 @@ task lateinit_inBaseClass(type: RunKonanTest) {
|
||||
source = "codegen/lateinit/inBaseClass.kt"
|
||||
}
|
||||
|
||||
task lateinit_localInitialized(type: RunKonanTest) {
|
||||
goldValue = "zzz\n"
|
||||
source = "codegen/lateinit/localInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_localNotInitialized(type: RunKonanTest) {
|
||||
expectedFail = (project.testTarget == 'wasm32') // Uses exceptions.
|
||||
goldValue = "OK\n"
|
||||
source = "codegen/lateinit/localNotInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_localCapturedInitialized(type: RunKonanTest) {
|
||||
goldValue = "zzz\n"
|
||||
source = "codegen/lateinit/localCapturedInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_localCapturedNotInitialized(type: RunKonanTest) {
|
||||
expectedFail = (project.testTarget == 'wasm32') // Uses exceptions.
|
||||
goldValue = "OK\n"
|
||||
source = "codegen/lateinit/localCapturedNotInitialized.kt"
|
||||
}
|
||||
|
||||
task kclass0(type: RunKonanTest) {
|
||||
source = "codegen/kclass/kclass0.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package codegen.lateinit.localCapturedInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() = s
|
||||
|
||||
s = "zzz"
|
||||
println(foo())
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package codegen.lateinit.localCapturedNotInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() = s
|
||||
|
||||
try {
|
||||
println(foo())
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
println("OK")
|
||||
return
|
||||
}
|
||||
println("Fail")
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package codegen.lateinit.localInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
lateinit var s: String
|
||||
s = "zzz"
|
||||
println(s)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package codegen.lateinit.localNotInitialized
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
lateinit var s: String
|
||||
|
||||
try {
|
||||
println(s)
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
println("OK")
|
||||
return
|
||||
}
|
||||
println("Fail")
|
||||
}
|
||||
Reference in New Issue
Block a user