[LL FIR] add script tests for AbstractNonLocalDeclarationAnchorTest
^KT-60728
This commit is contained in:
committed by
Space Team
parent
60dc0ace47
commit
aa36e2ef5b
+15
@@ -0,0 +1,15 @@
|
||||
class A constructor(a: Int) {
|
||||
fun boo() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val i: Int = 42
|
||||
|
||||
init {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/* anchor --> *//* anchor --> */class A /* anchor --> */constructor(/* anchor --> */a: Int/* <-- */)/* <-- */ {
|
||||
/* anchor --> */fun boo() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}/* <-- */
|
||||
|
||||
/* anchor --> */val i: Int = 42/* <-- */
|
||||
|
||||
/* anchor --> */init {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}/* <-- */
|
||||
}/* <-- */
|
||||
/* <-- */
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package one
|
||||
|
||||
class A constructor(a: Int) {
|
||||
fun boo() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val i: Int = 42
|
||||
|
||||
init {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
package one/* anchor --> */
|
||||
|
||||
/* anchor --> */class A /* anchor --> */constructor(/* anchor --> */a: Int/* <-- */)/* <-- */ {
|
||||
/* anchor --> */fun boo() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}/* <-- */
|
||||
|
||||
/* anchor --> */val i: Int = 42/* <-- */
|
||||
|
||||
/* anchor --> */init {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}/* <-- */
|
||||
}/* <-- */
|
||||
/* <-- */
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
class Builder {
|
||||
var version: String = ""
|
||||
|
||||
fun execute() {
|
||||
println(version)
|
||||
}
|
||||
}
|
||||
|
||||
fun build(action: Builder.() -> Unit) = Builder().apply(action)
|
||||
|
||||
build {
|
||||
version = "123"
|
||||
class A {
|
||||
fun doo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
execute()
|
||||
}
|
||||
|
||||
val builder = build {
|
||||
version = "321"
|
||||
}
|
||||
|
||||
builder.execute()
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/* anchor --> *//* anchor --> */class Builder {
|
||||
/* anchor --> */var version: String = ""/* <-- */
|
||||
|
||||
/* anchor --> */fun execute() {
|
||||
println(version)
|
||||
}/* <-- */
|
||||
}/* <-- */
|
||||
|
||||
fun build(/* anchor --> */action: Builder.() -> Unit/* <-- */) = Builder().apply(action)
|
||||
|
||||
build {
|
||||
version = "123"
|
||||
class A {
|
||||
fun doo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
execute()
|
||||
}
|
||||
|
||||
val builder = build {
|
||||
version = "321"
|
||||
}
|
||||
|
||||
builder.execute()
|
||||
/* <-- */
|
||||
+10
-3
@@ -11,6 +11,7 @@ import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirScriptTestConfigurator
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
@@ -22,9 +23,7 @@ import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractFirNonLocalDeclarationAnchorTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override val configurator: AnalysisApiTestConfigurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
|
||||
|
||||
abstract class AbstractNonLocalDeclarationAnchorTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val anchors = hashSetOf<KtDeclaration>()
|
||||
ktFile.forEachDescendantOfType<PsiElement> {
|
||||
@@ -65,3 +64,11 @@ abstract class AbstractFirNonLocalDeclarationAnchorTest : AbstractLowLevelApiSin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractSourceNonLocalDeclarationAnchorTest : AbstractNonLocalDeclarationAnchorTest() {
|
||||
override val configurator: AnalysisApiTestConfigurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
|
||||
}
|
||||
|
||||
abstract class AbstractScriptNonLocalDeclarationAnchorTest : AbstractNonLocalDeclarationAnchorTest() {
|
||||
override val configurator: AnalysisApiTestConfigurator get() = AnalysisApiFirScriptTestConfigurator
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.analysis.api.GenerateAnalysisApiTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ScriptNonLocalDeclarationAnchorTestGenerated extends AbstractScriptNonLocalDeclarationAnchorTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInNonLocalDeclarationAnchors() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors"), Pattern.compile("^(.+)\\.(kts)$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classWithMembersScript.kts")
|
||||
public void testClassWithMembersScript() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersScript.kts");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classWithMembersWithPackage.kts")
|
||||
public void testClassWithMembersWithPackage() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersWithPackage.kts");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("statements.kts")
|
||||
public void testStatements() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/statements.kts");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -18,10 +18,10 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirNonLocalDeclarationAnchorTestGenerated extends AbstractFirNonLocalDeclarationAnchorTest {
|
||||
public class SourceNonLocalDeclarationAnchorTestGenerated extends AbstractSourceNonLocalDeclarationAnchorTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInNonLocalDeclarationAnchors() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors"), Pattern.compile("^(.+)\\.(kt)$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
+6
-2
@@ -123,8 +123,12 @@ internal fun TestGroupSuite.generateFirLowLevelApiTests() {
|
||||
model("fileBasedDeclarationProvider", pattern = TestGeneratorUtil.KT_OR_KTS)
|
||||
}
|
||||
|
||||
testClass<AbstractFirNonLocalDeclarationAnchorTest> {
|
||||
model("nonLocalDeclarationAnchors")
|
||||
testClass<AbstractSourceNonLocalDeclarationAnchorTest> {
|
||||
model("nonLocalDeclarationAnchors", pattern = TestGeneratorUtil.KT)
|
||||
}
|
||||
|
||||
testClass<AbstractScriptNonLocalDeclarationAnchorTest> {
|
||||
model("nonLocalDeclarationAnchors", pattern = TestGeneratorUtil.KTS)
|
||||
}
|
||||
|
||||
testClass<AbstractSourceClassIdTest> {
|
||||
|
||||
Reference in New Issue
Block a user