Add more tests for -Xassertions=jvm corner cases
This commit is contained in:
committed by
max-kammerer
parent
3e25166832
commit
d11344ce2e
@@ -0,0 +1,41 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
class ShouldBeEnabled {
|
||||
fun checkTrue() = Inner().hit
|
||||
|
||||
inner class Inner {
|
||||
var hit = false
|
||||
init {
|
||||
assert({ hit = true; true }())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ShouldBeDisabled {
|
||||
fun checkFalse() = Inner().hit
|
||||
|
||||
inner class Inner {
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user