[LL FIR] AbstractFirLazyBodiesCalculatorTest: add ability to suppress test
We have inconsistency in lazy body calculator, but only tests are affected, because in the production we recreated bodies anyway ^KT-62840
This commit is contained in:
committed by
Space Team
parent
256d83b005
commit
c0f4f7fefd
+13
@@ -20,10 +20,17 @@ import org.jetbrains.kotlin.fir.renderer.FirRenderer
|
|||||||
import org.jetbrains.kotlin.fir.scopes.kotlinScopeProvider
|
import org.jetbrains.kotlin.fir.scopes.kotlinScopeProvider
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||||
|
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
import org.jetbrains.kotlin.test.services.TestServices
|
import org.jetbrains.kotlin.test.services.TestServices
|
||||||
|
|
||||||
abstract class AbstractFirLazyBodiesCalculatorTest : AbstractAnalysisApiBasedTest() {
|
abstract class AbstractFirLazyBodiesCalculatorTest : AbstractAnalysisApiBasedTest() {
|
||||||
|
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||||
|
super.configureTest(builder)
|
||||||
|
builder.useDirectives(Directives)
|
||||||
|
}
|
||||||
|
|
||||||
private val lazyChecker = object : FirVisitorVoid() {
|
private val lazyChecker = object : FirVisitorVoid() {
|
||||||
override fun visitElement(element: FirElement) {
|
override fun visitElement(element: FirElement) {
|
||||||
TestCase.assertFalse("${FirLazyBlock::class.qualifiedName} should not present in the tree", element is FirLazyBlock)
|
TestCase.assertFalse("${FirLazyBlock::class.qualifiedName} should not present in the tree", element is FirLazyBlock)
|
||||||
@@ -33,6 +40,8 @@ abstract class AbstractFirLazyBodiesCalculatorTest : AbstractAnalysisApiBasedTes
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
|
override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
|
||||||
|
if (Directives.IGNORE_BODY_CALCULATOR in mainModule.directives) return
|
||||||
|
|
||||||
resolveWithClearCaches(mainFile) { firResolveSession ->
|
resolveWithClearCaches(mainFile) { firResolveSession ->
|
||||||
val session = firResolveSession.useSiteFirSession
|
val session = firResolveSession.useSiteFirSession
|
||||||
val provider = session.kotlinScopeProvider
|
val provider = session.kotlinScopeProvider
|
||||||
@@ -58,6 +67,10 @@ abstract class AbstractFirLazyBodiesCalculatorTest : AbstractAnalysisApiBasedTes
|
|||||||
TestCase.assertEquals(/* expected = */ fullFirFileDump, /* actual = */ laziedFirFileDump)
|
TestCase.assertEquals(/* expected = */ fullFirFileDump, /* actual = */ laziedFirFileDump)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object Directives : SimpleDirectivesContainer() {
|
||||||
|
val IGNORE_BODY_CALCULATOR by stringDirective("Ignore body calculator")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AbstractFirSourceLazyBodiesCalculatorTest : AbstractFirLazyBodiesCalculatorTest() {
|
abstract class AbstractFirSourceLazyBodiesCalculatorTest : AbstractFirLazyBodiesCalculatorTest() {
|
||||||
|
|||||||
+5
@@ -1,10 +1,15 @@
|
|||||||
// IGNORE_TREE_ACCESS: KT-64899
|
// IGNORE_TREE_ACCESS: KT-64899
|
||||||
|
// IGNORE_BODY_CALCULATOR
|
||||||
package util
|
package util
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
@DestrAnno("destr 1 $prop")
|
@DestrAnno("destr 1 $prop")
|
||||||
val (@LeftAnno("a $prop") a, @RightAnno("b $prop") b) = 0 to 1
|
val (@LeftAnno("a $prop") a, @RightAnno("b $prop") b) = 0 to 1
|
||||||
|
|
||||||
|
run {
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
|
||||||
@Destr2Anno("destr 1 $prop")
|
@Destr2Anno("destr 1 $prop")
|
||||||
val (@SecondLeftAnno("c $prop") c, @SecondRightAnno("d $prop") d) = 2 to 3
|
val (@SecondLeftAnno("c $prop") c, @SecondRightAnno("d $prop") d) = 2 to 3
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -7,6 +7,7 @@ FILE: scriptStatementLevelDestructuringWithAnnotationAsLastStatement.kts
|
|||||||
@DestrAnno(LAZY_EXPRESSION) lval <destruct>: <implicit> = IntegerLiteral(0).to#(IntegerLiteral(1))
|
@DestrAnno(LAZY_EXPRESSION) lval <destruct>: <implicit> = IntegerLiteral(0).to#(IntegerLiteral(1))
|
||||||
@LeftAnno(LAZY_EXPRESSION) lval a: <implicit> = R|<local>/<destruct>|.component1#()
|
@LeftAnno(LAZY_EXPRESSION) lval a: <implicit> = R|<local>/<destruct>|.component1#()
|
||||||
@RightAnno(LAZY_EXPRESSION) lval b: <implicit> = R|<local>/<destruct>|.component2#()
|
@RightAnno(LAZY_EXPRESSION) lval b: <implicit> = R|<local>/<destruct>|.component2#()
|
||||||
|
run#(<L> = LAZY_EXPRESSION)
|
||||||
@Destr2Anno(LAZY_EXPRESSION) lval <destruct>: <implicit> = IntegerLiteral(2).to#(IntegerLiteral(3))
|
@Destr2Anno(LAZY_EXPRESSION) lval <destruct>: <implicit> = IntegerLiteral(2).to#(IntegerLiteral(3))
|
||||||
@SecondLeftAnno(LAZY_EXPRESSION) lval c: <implicit> = R|<local>/<destruct>|.component1#()
|
@SecondLeftAnno(LAZY_EXPRESSION) lval c: <implicit> = R|<local>/<destruct>|.component1#()
|
||||||
@SecondRightAnno(LAZY_EXPRESSION) lval d: <implicit> = R|<local>/<destruct>|.component2#()
|
@SecondRightAnno(LAZY_EXPRESSION) lval d: <implicit> = R|<local>/<destruct>|.component2#()
|
||||||
|
|||||||
+4
@@ -7,6 +7,10 @@ FILE: scriptStatementLevelDestructuringWithAnnotationAsLastStatement.kts
|
|||||||
@DestrAnno(<strcat>(String(destr 1 ), prop#)) lval <destruct>: <implicit> = IntegerLiteral(0).to#(IntegerLiteral(1))
|
@DestrAnno(<strcat>(String(destr 1 ), prop#)) lval <destruct>: <implicit> = IntegerLiteral(0).to#(IntegerLiteral(1))
|
||||||
@LeftAnno(<strcat>(String(a ), prop#)) lval a: <implicit> = R|<local>/<destruct>|.component1#()
|
@LeftAnno(<strcat>(String(a ), prop#)) lval a: <implicit> = R|<local>/<destruct>|.component1#()
|
||||||
@RightAnno(<strcat>(String(b ), prop#)) lval b: <implicit> = R|<local>/<destruct>|.component2#()
|
@RightAnno(<strcat>(String(b ), prop#)) lval b: <implicit> = R|<local>/<destruct>|.component2#()
|
||||||
|
run#(<L> = run@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
|
||||||
|
println#()
|
||||||
|
}
|
||||||
|
)
|
||||||
@Destr2Anno(<strcat>(String(destr 1 ), prop#)) lval <destruct>: <implicit> = IntegerLiteral(2).to#(IntegerLiteral(3))
|
@Destr2Anno(<strcat>(String(destr 1 ), prop#)) lval <destruct>: <implicit> = IntegerLiteral(2).to#(IntegerLiteral(3))
|
||||||
@SecondLeftAnno(<strcat>(String(c ), prop#)) lval c: <implicit> = R|<local>/<destruct>|.component1#()
|
@SecondLeftAnno(<strcat>(String(c ), prop#)) lval c: <implicit> = R|<local>/<destruct>|.component1#()
|
||||||
@SecondRightAnno(<strcat>(String(d ), prop#)) lval d: <implicit> = R|<local>/<destruct>|.component2#()
|
@SecondRightAnno(<strcat>(String(d ), prop#)) lval d: <implicit> = R|<local>/<destruct>|.component2#()
|
||||||
|
|||||||
Reference in New Issue
Block a user