[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,33 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testCheckSmartcast(x: Any?) {
check(x is String)
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!" }
x.length
}
fun testCheckWithFailingMessage(x: Any?) {
check(x is String) { throw kotlin.<!UNRESOLVED_REFERENCE!>IllegalStateException<!>("What a strange idea") }
x.length
}
fun testCheckNotNullWithMessage(x: Int?) {
checkNotNull(x) { "x is null!" }
x.inc()
}
fun testCheckNotNull(x: Int?) {
checkNotNull(x)
x.inc()
}
@@ -0,0 +1,110 @@
// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testRunWithUnitReturn() {
val x: Int
run { x = 42 }
println(x)
}
fun testRunWithReturnValue() {
val x: Int
val y = run {
x = 42
"hello"
}
println(x)
println(y)
}
fun testRunWithCoercionToUnit() {
val x: Int
run {
x = 42
"hello"
}
}
fun testRunWithReceiver(x: Int) {
val s: String
x.run {
s = this.toString()
}
println(s)
}
fun testWith(x: Int) {
val s: String
with(x) {
s = toString()
}
println(s)
}
fun testApply(x: Int) {
val y: Int
val z: Int = x.apply { y = 42 }
println(y)
println(z)
}
fun testAlso(x: Int) {
val y: Int
x.also { y = it + 1 }
println(y)
}
fun testLet(x: Int) {
val z: Int
val y: String = x.let {
z = 42
(it + 1).toString()
}
println(z)
println(y)
}
fun testTakeIf(x: Int?) {
val y: Int
x.takeIf {
y = 42
it != null
}
println(y)
}
fun testTakeUnless(x: Int?) {
val y: Int
x.takeIf {
y = 42
it != null
}
println(y)
}
fun testRepeatOnVal(x: Int) {
val y: Int
repeat(x) {
// reassignment instead of captured val initialization
y = 42
}
println(y)
}
fun testRepeatOnVar(x: Int) {
var y: Int
repeat(x) {
// no reassignment reported
y = 42
}
// but here we still unsure if 'y' was initialized
println(y)
}
fun testRepeatOnInitializedVar(x: Int) {
var y: Int = 24
repeat(x) {
y = 42
}
println(y)
}
@@ -0,0 +1,20 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testIsNullOrBlank(x: String?) {
if (x.isNullOrBlank()) {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
else {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
}
fun testIsNotNullOrBlank(x: String?) {
if (!x.isNullOrBlank()) {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
@@ -0,0 +1,20 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testIsNullOrEmpty(x: String?) {
if (x.isNullOrEmpty()) {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
else {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
}
fun testIsNotNullOrEmpty(x: String?) {
if (!x.isNullOrEmpty()) {
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
x.<!INAPPLICABLE_CANDIDATE!>length<!>
}
@@ -0,0 +1,27 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testRequireSmartcast(x: Any?) {
require(x is String)
x.length
}
fun testRequireUnreachableCode() {
require(false)
println("Can't get here!")
}
fun testRequireWithMessage(x: Any?) {
require(x is String) { "x is not String!" }
x.length
}
fun testRequireWithFailingMessage(x: Any?) {
require(x is String) { throw kotlin.<!UNRESOLVED_REFERENCE!>IllegalStateException<!>("What a strange idea") }
x.length
}
fun tesRequireNotNullWithMessage(x: Int?) {
requireNotNull(x) { "x is null!"}
x.inc()
}
@@ -0,0 +1,11 @@
// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect
fun test(lock: Any) {
val x: Int
synchronized(lock) {
x = 42
}
x.inc()
}