NavigateToLibrarySourceTestGenerated: add tests for projects with kotlin/jvm and kotlin/js modules
This commit is contained in:
@@ -411,6 +411,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
testClass(javaClass<AbstractNavigateToLibrarySourceTest>()) {
|
||||
model("decompiler/navigation/usercode")
|
||||
model("decompiler/navigation/usercode", testClassName="UsercodeWithJSModule", testMethod = "doWithJSModuleTest")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractKotlinGotoImplementationTest>()) {
|
||||
|
||||
+34
-13
@@ -22,14 +22,32 @@ import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.idea.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinCodeInsightTestCase
|
||||
import org.jetbrains.kotlin.idea.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.navigation.NavigationTestUtils
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.testUtils.ModuleKind
|
||||
import org.jetbrains.kotlin.idea.testUtils.configureAs
|
||||
import org.jetbrains.kotlin.test.JetTestUtils
|
||||
import java.io.File
|
||||
import java.util.LinkedHashMap
|
||||
|
||||
public abstract class AbstractNavigateToLibrarySourceTest : AbstractNavigateToLibraryTest() {
|
||||
protected fun doTest(path: String) {
|
||||
myFixture.configureByFile(path)
|
||||
public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTestCase() {
|
||||
|
||||
protected fun doTest(path: String): Unit = doTestEx(path)
|
||||
|
||||
protected fun doWithJSModuleTest(path: String): Unit = doTestEx(path) {
|
||||
val jsModule = this.createModule("js-module")
|
||||
jsModule.configureAs(ModuleKind.KOTLIN_JAVASCRIPT)
|
||||
}
|
||||
|
||||
protected fun doTestEx(path: String, additionalConfig: (() -> Unit)? = null) {
|
||||
configureByFile(path)
|
||||
getModule().configureAs(getProjectDescriptor())
|
||||
|
||||
if (additionalConfig != null) {
|
||||
additionalConfig()
|
||||
}
|
||||
|
||||
checkAnnotatedLibraryCode(false)
|
||||
checkAnnotatedLibraryCode(true)
|
||||
@@ -40,15 +58,18 @@ public abstract class AbstractNavigateToLibrarySourceTest : AbstractNavigateToLi
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
override fun getTestDataPath(): String =
|
||||
JetTestUtils.getHomeDirectory() + File.separator
|
||||
|
||||
private fun checkAnnotatedLibraryCode(forceResolve: Boolean) {
|
||||
JetSourceNavigationHelper.setForceResolve(forceResolve)
|
||||
val actualCode = NavigationTestUtils.getNavigateElementsText(myFixture.getProject(), collectInterestingNavigationElements())
|
||||
val actualCode = NavigationTestUtils.getNavigateElementsText(getProject(), collectInterestingNavigationElements())
|
||||
val expectedCode = getExpectedAnnotatedLibraryCode()
|
||||
UsefulTestCase.assertSameLines(expectedCode, actualCode)
|
||||
}
|
||||
|
||||
private fun collectInterestingReferences(): Collection<JetReference> {
|
||||
val psiFile = myFixture.getFile()
|
||||
val psiFile = getFile()
|
||||
val referenceContainersToReferences = LinkedHashMap<PsiElement, JetReference>()
|
||||
for (offset in 0..psiFile.getTextLength() - 1) {
|
||||
val ref = psiFile.findReferenceAt(offset)
|
||||
@@ -71,18 +92,18 @@ public abstract class AbstractNavigateToLibrarySourceTest : AbstractNavigateToLi
|
||||
}
|
||||
|
||||
private fun collectInterestingNavigationElements() =
|
||||
collectInterestingReferences().map {
|
||||
val target = it.resolve()
|
||||
TestCase.assertNotNull(target)
|
||||
target!!.getNavigationElement()
|
||||
}
|
||||
collectInterestingReferences().map {
|
||||
val target = it.resolve()
|
||||
TestCase.assertNotNull(target)
|
||||
target!!.getNavigationElement()
|
||||
}
|
||||
|
||||
private fun getExpectedAnnotatedLibraryCode(): String {
|
||||
val document = myFixture.getDocument(myFixture.getFile())
|
||||
val document = getDocument(getFile())
|
||||
TestCase.assertNotNull(document)
|
||||
return JetTestUtils.getLastCommentedLines(document)
|
||||
}
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor =
|
||||
JdkAndMockLibraryProjectDescriptor(AbstractNavigateToLibraryTest.TEST_DATA_PATH + "/library", true)
|
||||
private fun getProjectDescriptor(): LightProjectDescriptor =
|
||||
JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/decompiler/navigation/library", true)
|
||||
}
|
||||
+173
-73
@@ -28,95 +28,195 @@ import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/decompiler/navigation/usercode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@InnerTestClasses({
|
||||
NavigateToLibrarySourceTestGenerated.Usercode.class,
|
||||
NavigateToLibrarySourceTestGenerated.UsercodeWithJSModule.class,
|
||||
})
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class NavigateToLibrarySourceTestGenerated extends AbstractNavigateToLibrarySourceTest {
|
||||
public void testAllFilesPresentInUsercode() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/decompiler/navigation/usercode"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
@TestMetadata("idea/testData/decompiler/navigation/usercode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Usercode extends AbstractNavigateToLibrarySourceTest {
|
||||
public void testAllFilesPresentInUsercode() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/decompiler/navigation/usercode"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObject.kt")
|
||||
public void testClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Constructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Enum.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionProperty.kt")
|
||||
public void testExtensionProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GenericFunctionWithExplicitlyDeclaredTypeArguments.kt")
|
||||
public void testGenericFunctionWithExplicitlyDeclaredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithExplicitlyDeclaredTypeArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GenericFunctionWithInferredTypeArguments.kt")
|
||||
public void testGenericFunctionWithInferredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithInferredTypeArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GlobalFunction.kt")
|
||||
public void testGlobalFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GlobalProperty.kt")
|
||||
public void testGlobalProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedObject.kt")
|
||||
public void testNamedObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/NamedObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("OverloadedFunWithTypeParam.kt")
|
||||
public void testOverloadedFunWithTypeParam() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/OverloadedFunWithTypeParam.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Property.kt")
|
||||
public void testProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Property.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SameNameInDifferentSources.kt")
|
||||
public void testSameNameInDifferentSources() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/SameNameInDifferentSources.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeWithSameShortName.kt")
|
||||
public void testTypeWithSameShortName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/TypeWithSameShortName.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObject.kt")
|
||||
public void testClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("idea/testData/decompiler/navigation/usercode")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class UsercodeWithJSModule extends AbstractNavigateToLibrarySourceTest {
|
||||
public void testAllFilesPresentInUsercodeWithJSModule() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/decompiler/navigation/usercode"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Constructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("ClassObject.kt")
|
||||
public void testClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ClassObject.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Enum.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("Constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Constructor.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("Enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Enum.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionProperty.kt")
|
||||
public void testExtensionProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("ExtensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionFunction.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GenericFunctionWithExplicitlyDeclaredTypeArguments.kt")
|
||||
public void testGenericFunctionWithExplicitlyDeclaredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithExplicitlyDeclaredTypeArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("ExtensionProperty.kt")
|
||||
public void testExtensionProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/ExtensionProperty.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GenericFunctionWithInferredTypeArguments.kt")
|
||||
public void testGenericFunctionWithInferredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithInferredTypeArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("GenericFunctionWithExplicitlyDeclaredTypeArguments.kt")
|
||||
public void testGenericFunctionWithExplicitlyDeclaredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithExplicitlyDeclaredTypeArguments.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GlobalFunction.kt")
|
||||
public void testGlobalFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("GenericFunctionWithInferredTypeArguments.kt")
|
||||
public void testGenericFunctionWithInferredTypeArguments() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GenericFunctionWithInferredTypeArguments.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GlobalProperty.kt")
|
||||
public void testGlobalProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("GlobalFunction.kt")
|
||||
public void testGlobalFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalFunction.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedObject.kt")
|
||||
public void testNamedObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/NamedObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("GlobalProperty.kt")
|
||||
public void testGlobalProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/GlobalProperty.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("OverloadedFunWithTypeParam.kt")
|
||||
public void testOverloadedFunWithTypeParam() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/OverloadedFunWithTypeParam.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("NamedObject.kt")
|
||||
public void testNamedObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/NamedObject.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Property.kt")
|
||||
public void testProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Property.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("OverloadedFunWithTypeParam.kt")
|
||||
public void testOverloadedFunWithTypeParam() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/OverloadedFunWithTypeParam.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SameNameInDifferentSources.kt")
|
||||
public void testSameNameInDifferentSources() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/SameNameInDifferentSources.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
@TestMetadata("Property.kt")
|
||||
public void testProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/Property.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeWithSameShortName.kt")
|
||||
public void testTypeWithSameShortName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/TypeWithSameShortName.kt");
|
||||
doTest(fileName);
|
||||
@TestMetadata("SameNameInDifferentSources.kt")
|
||||
public void testSameNameInDifferentSources() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/SameNameInDifferentSources.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeWithSameShortName.kt")
|
||||
public void testTypeWithSameShortName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/navigation/usercode/TypeWithSameShortName.kt");
|
||||
doWithJSModuleTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user