Files
kotlin/compiler/testData/codegen/box/assert/jvm/classAssertionsForNestedClasses.kt
2019-11-19 11:00:09 +03:00

49 lines
1.1 KiB
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
// WITH_RUNTIME
package classAssertions
class ShouldBeEnabled {
fun checkTrue() = A.B().hit
class A {
class B {
var hit = false
init {
assert({ hit = true; true }())
}
}
}
}
class ShouldBeDisabled {
fun checkFalse() = A.B().hit
class A {
class B {
var hit = false
init {
assert({ hit = true; true }())
}
}
}
}
class Dummy
fun box(): String {
val loader = Dummy::class.java.classLoader
loader.setClassAssertionStatus("classAssertions.ShouldBeEnabled", true)
loader.setClassAssertionStatus("classAssertions.ShouldBeDisabled", false)
val c1 = loader.loadClass("classAssertions.ShouldBeEnabled").newInstance() as ShouldBeEnabled
val c2 = loader.loadClass("classAssertions.ShouldBeDisabled").newInstance() as ShouldBeDisabled
if (!c1.checkTrue()) return "FAIL 0"
if (c2.checkFalse()) return "FAIL 1"
return "OK"
}