Effects: add diagnostic tests on functions from stdlib

==========
Introduction of EffectSystem: 18/18
This commit is contained in:
Dmitry Savvinov
2017-10-03 17:06:44 +03:00
parent fb03656e99
commit d4d7946e6a
12 changed files with 320 additions and 0 deletions
@@ -0,0 +1,28 @@
// !LANGUAGE: +ReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testCheckSmartcast(x: Any?) {
check(x is String)
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
fun testCheckUnreachableCode() {
check(false)
// Can't be reported without notion of 'iff'
println("Can't get here!")
}
fun testCheckWithMessage(x: Any?) {
check(x is String) { "x is not String!" }
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
fun testCheckWithFailingMessage(x: Any?) {
check(x is String) { throw kotlin.IllegalStateException("What a strange idea") }
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
fun tesCheckNotNullWithMessage(x: Int?) {
checkNotNull(x) { "x is null!"}
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
}