Tests: extract scripts testdata for light classes in ide to separate test
For compiled scripts there is AbstractIdeCompiledLightClassTest For now there is a difference in light classes constructed from source and from compiled class (missing baseClass and constructor parameter for script class) But it doesn't affect users because calling script class from Java isn't supported yet testData for AbstractIdeLightClassTest and AbstractIdeLightClassForScriptTest can be merged when the difference will be fixed
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
public class HelloWorld {
|
||||
public static final void main(java.lang.String[] p) { /* compiled code */ }
|
||||
|
||||
public HelloWorld() { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// HelloWorld
|
||||
|
||||
println("Hello world!")
|
||||
|
||||
// LAZINESS:NoLaziness
|
||||
@@ -0,0 +1,24 @@
|
||||
public class InnerClasses {
|
||||
public static final void main(java.lang.String[] p) { /* compiled code */ }
|
||||
|
||||
public InnerClasses() { /* compiled code */ }
|
||||
|
||||
public static final class Bar {
|
||||
private final int b;
|
||||
private final int a;
|
||||
|
||||
public final int getB() { /* compiled code */ }
|
||||
|
||||
public final int getAPlusB() { /* compiled code */ }
|
||||
|
||||
public final int getA() { /* compiled code */ }
|
||||
|
||||
public Bar(int a) { /* compiled code */ }
|
||||
|
||||
public static final class Baz {
|
||||
public final void doSomething() { /* compiled code */ }
|
||||
|
||||
public Baz() { /* compiled code */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// InnerClasses
|
||||
|
||||
class Bar(val a: Int) {
|
||||
val b: Int = { 0 }()
|
||||
|
||||
fun getAPlusB() = a + b
|
||||
|
||||
class Baz {
|
||||
fun doSomething() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LAZINESS:NoLaziness
|
||||
@@ -919,7 +919,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassTest> {
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassForScriptTest> {
|
||||
model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractUltraLightClassSanityTest> {
|
||||
|
||||
@@ -867,7 +867,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassTest> {
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassForScriptTest> {
|
||||
model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractUltraLightClassSanityTest> {
|
||||
|
||||
@@ -841,7 +841,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassTest> {
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassForScriptTest> {
|
||||
model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeCompiledLightClassTest> {
|
||||
|
||||
@@ -837,7 +837,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassTest> {
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassForScriptTest> {
|
||||
model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeCompiledLightClassTest> {
|
||||
|
||||
@@ -837,7 +837,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassTest> {
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeLightClassForScriptTest> {
|
||||
model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractIdeCompiledLightClassTest> {
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.idea.caches.resolve
|
||||
|
||||
abstract class AbstractIdeLightClassForScriptTest : AbstractIdeLightClassTest() {
|
||||
override val fileExtension = ".kts"
|
||||
}
|
||||
@@ -47,8 +47,7 @@ abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase
|
||||
fun doTest(testDataPath: String) {
|
||||
forceUsingOldLightClassesForTest()
|
||||
val extraFilePath = when {
|
||||
testDataPath.endsWith(".kt") -> testDataPath.replace(".kt", ".extra.kt")
|
||||
testDataPath.endsWith(".kts") -> testDataPath.replace(".kts", ".extra.kts")
|
||||
testDataPath.endsWith(fileExtension) -> testDataPath.replace(fileExtension, ".extra" + fileExtension)
|
||||
else -> error("Invalid test data extension")
|
||||
}
|
||||
|
||||
@@ -79,6 +78,8 @@ abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase
|
||||
}
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
open val fileExtension = ".kt"
|
||||
}
|
||||
|
||||
abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase() {
|
||||
|
||||
Generated
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.idea.caches.resolve;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/asJava/script/ide")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class IdeLightClassForScriptTestGenerated extends AbstractIdeLightClassForScriptTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIde() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/script/ide"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("HelloWorld.kts")
|
||||
public void testHelloWorld() throws Exception {
|
||||
runTest("compiler/testData/asJava/script/ide/HelloWorld.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("InnerClasses.kts")
|
||||
public void testInnerClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/script/ide/InnerClasses.kts");
|
||||
}
|
||||
}
|
||||
+1
-24
@@ -26,7 +26,7 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLightClasses() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), TargetBackend.ANY, true, "delegation");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), TargetBackend.ANY, true, "delegation", "script");
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedParameterInEnumConstructor.kt")
|
||||
@@ -486,27 +486,4 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
||||
runTest("compiler/testData/asJava/lightClasses/publicField/Simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/asJava/lightClasses/script")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Script extends AbstractIdeLightClassTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInScript() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses/script"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("HelloWorld.kts")
|
||||
public void testHelloWorld() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/script/HelloWorld.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("InnerClasses.kts")
|
||||
public void testInnerClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/script/InnerClasses.kts");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user