mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 00:21:29 +00:00
45 lines
1.1 KiB
Kotlin
Vendored
45 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(): Boolean {
|
|
class Local {
|
|
var hit = false
|
|
init {
|
|
assert({ hit = true; true}())
|
|
}
|
|
}
|
|
return Local().hit
|
|
}
|
|
}
|
|
|
|
class ShouldBeDisabled {
|
|
fun checkFalse(): Boolean {
|
|
class Local {
|
|
var hit = false
|
|
init {
|
|
assert({ hit = true; true}())
|
|
}
|
|
}
|
|
return Local().hit
|
|
}
|
|
}
|
|
|
|
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"
|
|
}
|