Files
kotlin-fork/compiler/testData/codegen/box/assert/jvm/classAssertionsForNestedClasses.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

48 lines
1.1 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// ASSERTIONS_MODE: jvm
// WITH_STDLIB
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"
}