[LL FIR] AbstractInBlockModificationTest: add more tests

^KT-60518
This commit is contained in:
Dmitrii Gridin
2023-07-18 15:30:58 +02:00
committed by Space Team
parent f0d8a1cbe9
commit 5f24ad114c
16 changed files with 157 additions and 0 deletions
@@ -0,0 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun foo(block: () -> Unit) {
<expr>kotlin.contracts.contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}</expr>
block()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,3 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
fun doo() <expr>{}</expr>
@@ -0,0 +1,6 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] fun doo(): R|kotlin/Unit| {
}
AFTER MODIFICATION:
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] fun doo(): R|kotlin/Unit| { LAZY_BLOCK }
@@ -0,0 +1,4 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
val i: Int
get() <expr>{}</expr>
@@ -0,0 +1,8 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] val i: R|kotlin/Int|
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| {
}
AFTER MODIFICATION:
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val i: R|kotlin/Int|
public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] get(): R|kotlin/Int| { LAZY_BLOCK }
@@ -0,0 +1,3 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtConstantExpression
val i: Int = <expr>42</expr>
@@ -0,0 +1,7 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] val i: R|kotlin/Int| = Int(42)
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
AFTER MODIFICATION:
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val i: R|kotlin/Int| = LAZY_EXPRESSION
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
@@ -0,0 +1,4 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtBlockExpression
var i: Int = 4
set(value) <expr>{}</expr>
@@ -0,0 +1,10 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] var i: R|kotlin/Int| = Int(4)
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
public [ResolvedTo(BODY_RESOLVE)] set([ResolvedTo(BODY_RESOLVE)] value: R|kotlin/Int|): R|kotlin/Unit| {
}
AFTER MODIFICATION:
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] var i: R|kotlin/Int| = Int(4)
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] set([ResolvedTo(BODY_RESOLVE)] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK }
@@ -0,0 +1,9 @@
import kotlin.contracts.InvocationKind
inline fun foo(block: () -> Unit) {
kotlin.contracts.contract {
<expr>callsInPlace</expr>(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -0,0 +1,7 @@
class MyProducer {
fun produce(): Int = 4
}
fun MyProducer.testFun(param1: Int = <expr>produce</expr>()) {
42
}
@@ -0,0 +1 @@
IN-BLOCK MODIFICATION IS NOT APPLICABLE FOR THIS PLACE
@@ -30,6 +30,36 @@ public class OutOfContentRootInBlockModificationTestGenerated extends AbstractOu
runTest("analysis/low-level-api-fir/testdata/inBlockModification/contract.kt");
}
@Test
@TestMetadata("entireContract.kt")
public void testEntireContract() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireContract.kt");
}
@Test
@TestMetadata("entireFunctionBody.kt")
public void testEntireFunctionBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireFunctionBody.kt");
}
@Test
@TestMetadata("entireGetterBody.kt")
public void testEntireGetterBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireGetterBody.kt");
}
@Test
@TestMetadata("entireInitializer.kt")
public void testEntireInitializer() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireInitializer.kt");
}
@Test
@TestMetadata("entireSetterBody.kt")
public void testEntireSetterBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireSetterBody.kt");
}
@Test
@TestMetadata("extensionWithDefaultParameters.kt")
public void testExtensionWithDefaultParameters() throws Exception {
@@ -42,6 +72,18 @@ public class OutOfContentRootInBlockModificationTestGenerated extends AbstractOu
runTest("analysis/low-level-api-fir/testdata/inBlockModification/functionWithDefaultParameters.kt");
}
@Test
@TestMetadata("insideContract.kt")
public void testInsideContract() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/insideContract.kt");
}
@Test
@TestMetadata("insideDefaultParameter.kt")
public void testInsideDefaultParameter() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/insideDefaultParameter.kt");
}
@Test
@TestMetadata("memberFunWithBodyWithContract.kt")
public void testMemberFunWithBodyWithContract() throws Exception {
@@ -30,6 +30,36 @@ public class SourceInBlockModificationTestGenerated extends AbstractSourceInBloc
runTest("analysis/low-level-api-fir/testdata/inBlockModification/contract.kt");
}
@Test
@TestMetadata("entireContract.kt")
public void testEntireContract() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireContract.kt");
}
@Test
@TestMetadata("entireFunctionBody.kt")
public void testEntireFunctionBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireFunctionBody.kt");
}
@Test
@TestMetadata("entireGetterBody.kt")
public void testEntireGetterBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireGetterBody.kt");
}
@Test
@TestMetadata("entireInitializer.kt")
public void testEntireInitializer() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireInitializer.kt");
}
@Test
@TestMetadata("entireSetterBody.kt")
public void testEntireSetterBody() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/entireSetterBody.kt");
}
@Test
@TestMetadata("extensionWithDefaultParameters.kt")
public void testExtensionWithDefaultParameters() throws Exception {
@@ -42,6 +72,18 @@ public class SourceInBlockModificationTestGenerated extends AbstractSourceInBloc
runTest("analysis/low-level-api-fir/testdata/inBlockModification/functionWithDefaultParameters.kt");
}
@Test
@TestMetadata("insideContract.kt")
public void testInsideContract() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/insideContract.kt");
}
@Test
@TestMetadata("insideDefaultParameter.kt")
public void testInsideDefaultParameter() throws Exception {
runTest("analysis/low-level-api-fir/testdata/inBlockModification/insideDefaultParameter.kt");
}
@Test
@TestMetadata("memberFunWithBodyWithContract.kt")
public void testMemberFunWithBodyWithContract() throws Exception {