[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,75 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
import kotlin.contracts.*
fun <T> runTwice(block: () -> T): T {
contract {
<!INAPPLICABLE_CANDIDATE!>callsInPlace<!>(block, InvocationKind.AT_LEAST_ONCE)
}
block()
return block();
};
fun <T> runOnce(block: () -> T): T {
contract {
<!INAPPLICABLE_CANDIDATE!>callsInPlace<!>(block, InvocationKind.EXACTLY_ONCE)
}
return block();
};
fun valueReassignment() {
val x: Int
x.inc()
runTwice { x = 42 }
x.inc()
}
fun shadowing() {
val x: Int
runTwice { val x: Int; x = 42; x.inc() }
x.inc()
}
fun branchingFlow(a: Any?) {
val x: Int
x.inc()
if (a is String) {
runTwice { x = 42 }
}
else {
x = 43
}
x.inc()
}
fun branchingFlowWithMissingBranches(a: Any?) {
val x: Int
if (a is String) {
runTwice { x = 42 }
}
x.inc()
}
fun repeatingFlow(n: Int) {
val x: Int
x.inc()
for (i in 1..n) {
runTwice { x = 42 }
}
x.inc()
}
fun repeatingFlow2(n: Int) {
val x: Int
for (i in 1..n) {
runTwice { x = 42 }
}
x.inc()
}
@@ -0,0 +1,31 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
import kotlin.contracts.*
fun <T> runTwice(block: () -> T): T {
contract {
<!INAPPLICABLE_CANDIDATE!>callsInPlace<!>(block, InvocationKind.AT_LEAST_ONCE)
}
block()
return block();
};
fun testInitialization() {
var x: Int
x.inc()
runTwice { x = 42 }
x.inc()
x = 43
x.inc()
}
fun repeatingFlow(n: Int) {
var x: Int
for (i in 1..n) {
runTwice { x = 42 }
}
x.inc()
}
@@ -0,0 +1,29 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
import kotlin.contracts.*
fun <T> runTwice(block: () -> T): T {
contract {
<!INAPPLICABLE_CANDIDATE!>callsInPlace<!>(block, InvocationKind.AT_LEAST_ONCE)
}
block()
return block();
};
fun <T> funWithUnknownInvocations(block: () -> T) = block()
fun indefiniteFlow() {
var x: Int
funWithUnknownInvocations { runTwice { x = 42 } }
x.inc()
}
fun shadowing() {
var x: Int
runTwice { val x: Int; x = 42; x.inc() }
x.inc()
}