Tests: move some tests to diagnostics
This commit is contained in:
committed by
Space Team
parent
b3b9ffaea9
commit
bad7fa597b
+6
@@ -24624,6 +24624,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
public void testKotlinInheritsJava() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/kotlinInheritsJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noWarningOnJavaKotlinInheritance.kt")
|
||||
public void testNoWarningOnJavaKotlinInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/noWarningOnJavaKotlinInheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -24624,6 +24624,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
public void testKotlinInheritsJava() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/kotlinInheritsJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noWarningOnJavaKotlinInheritance.kt")
|
||||
public void testNoWarningOnJavaKotlinInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/noWarningOnJavaKotlinInheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -24624,6 +24624,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
public void testKotlinInheritsJava() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/kotlinInheritsJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noWarningOnJavaKotlinInheritance.kt")
|
||||
public void testNoWarningOnJavaKotlinInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/noWarningOnJavaKotlinInheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -24630,6 +24630,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
public void testKotlinInheritsJava() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/kotlinInheritsJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noWarningOnJavaKotlinInheritance.kt")
|
||||
public void testNoWarningOnJavaKotlinInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/noWarningOnJavaKotlinInheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -72,6 +72,12 @@ public class FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated extends Abstra
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspensionPointInMonitor.kt")
|
||||
public void testSuspensionPointInMonitor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -72,6 +72,12 @@ public class FirPsiDiagnosticsTestWithJvmIrBackendGenerated extends AbstractFirP
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspensionPointInMonitor.kt")
|
||||
public void testSuspensionPointInMonitor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
public interface JavaInterface {
|
||||
void foo(int javaName);
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// Simple inheritance. Checks that there's no PARAMETER_NAME_CHANGED_ON_OVERRIDE warning
|
||||
|
||||
class SimpleSubclass : JavaInterface {
|
||||
override fun foo(kotlinName: Int) {}
|
||||
}
|
||||
|
||||
|
||||
// Class extends both Java and Kotlin traits. Checks that there's no DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES warning
|
||||
|
||||
interface KotlinTrait {
|
||||
public fun foo(someOtherName: Int) {}
|
||||
}
|
||||
|
||||
class BothTraitsSubclass : JavaInterface, KotlinTrait {
|
||||
override fun foo(someOtherName: Int) {
|
||||
super.foo(someOtherName)
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
val lock = Any()
|
||||
|
||||
inline fun inlineMe(c: () -> Unit) {
|
||||
synchronized(lock) {
|
||||
c()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun monitorInFinally(a: () -> Unit, b: () -> Unit) {
|
||||
try {
|
||||
a()
|
||||
} finally {
|
||||
synchronized(lock) {
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/suspensionPointInMonitor/source.kt:8:13: error: a suspension point at SourceKt$test$1.invokeSuspend(source.kt:10) is inside a critical section
|
||||
builder {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/suspensionPointInMonitor/source.kt:14:13: error: a suspension point at SourceKt$test$2.invokeSuspend(source.kt:17) is inside a critical section
|
||||
builder {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/suspensionPointInMonitor/source.kt:49:1: error: a suspension point at SourceKt$test$3$invokeSuspend$$inlined$withCrossinline$2.invokeSuspend(source.kt:60) is inside a critical section
|
||||
inline fun withCrossinline(crossinline a: suspend () -> Unit): suspend () -> Unit {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/suspensionPointInMonitor/source.kt:50:34: error: a suspension point at SourceKt$withCrossinline$c$1.invokeSuspend(source.kt:52) is inside a critical section
|
||||
val c : suspend () -> Unit = {
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: lib
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
public interface JavaInterface {
|
||||
void foo(int javaName);
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: test.kt
|
||||
|
||||
// Simple inheritance. Checks that there's no PARAMETER_NAME_CHANGED_ON_OVERRIDE warning
|
||||
|
||||
class SimpleSubclass : JavaInterface {
|
||||
override fun foo(kotlinName: Int) {}
|
||||
}
|
||||
|
||||
// Class extends both Java and Kotlin interfaces. Checks that there's no DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES warning
|
||||
|
||||
interface KotlinInterface {
|
||||
public fun foo(someOtherName: Int) {}
|
||||
}
|
||||
|
||||
class BothTraitsSubclass : JavaInterface, KotlinInterface {
|
||||
override fun foo(someOtherName: Int) {
|
||||
super.foo(someOtherName)
|
||||
}
|
||||
}
|
||||
+36
-8
@@ -1,3 +1,31 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
val lock = Any()
|
||||
|
||||
inline fun inlineMe(c: () -> Unit) {
|
||||
synchronized(lock) {
|
||||
c()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun monitorInFinally(a: () -> Unit, b: () -> Unit) {
|
||||
try {
|
||||
a()
|
||||
} finally {
|
||||
synchronized(lock) {
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
fun builder(c: suspend () -> Unit) {}
|
||||
|
||||
private val lock = Any()
|
||||
@@ -5,18 +33,18 @@ private val lock = Any()
|
||||
suspend fun suspensionPoint() {}
|
||||
|
||||
fun test() {
|
||||
builder {
|
||||
builder <!SUSPENSION_POINT_INSIDE_MONITOR!>{
|
||||
inlineMe {
|
||||
suspensionPoint()
|
||||
}
|
||||
}
|
||||
}<!>
|
||||
|
||||
builder {
|
||||
builder <!SUSPENSION_POINT_INSIDE_MONITOR!>{
|
||||
monitorInFinally(
|
||||
{},
|
||||
{ suspensionPoint() }
|
||||
)
|
||||
}
|
||||
}<!>
|
||||
|
||||
builder {
|
||||
withCrossinline {}
|
||||
@@ -46,11 +74,11 @@ interface SuspendRunnable {
|
||||
}
|
||||
|
||||
|
||||
inline fun withCrossinline(crossinline a: suspend () -> Unit): suspend () -> Unit {
|
||||
val c : suspend () -> Unit = {
|
||||
<!SUSPENSION_POINT_INSIDE_MONITOR!>inline fun withCrossinline(crossinline a: suspend () -> Unit): suspend () -> Unit {
|
||||
val c : suspend () -> Unit = <!SUSPENSION_POINT_INSIDE_MONITOR!>{
|
||||
inlineMe {
|
||||
a()
|
||||
}
|
||||
}
|
||||
}<!>
|
||||
return c
|
||||
}
|
||||
}<!>
|
||||
Generated
+6
@@ -25696,6 +25696,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
public void testKotlinInheritsJava() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/kotlinInheritsJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noWarningOnJavaKotlinInheritance.kt")
|
||||
public void testNoWarningOnJavaKotlinInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/override/parameterNames/noWarningOnJavaKotlinInheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -73,6 +73,12 @@ public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnostic
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspensionPointInMonitor.kt")
|
||||
public void testSuspensionPointInMonitor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJvmBackend/suspensionPointInMonitor.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
-32
@@ -8,9 +8,6 @@ package org.jetbrains.kotlin.jvm.compiler
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
@@ -129,15 +126,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
compileKotlin("main.kt", tmpdir, listOf(compileLibrary("library")))
|
||||
}
|
||||
|
||||
fun testSuspensionPointInMonitor() {
|
||||
compileKotlin(
|
||||
"source.kt",
|
||||
tmpdir,
|
||||
listOf(compileLibrary("library", additionalOptions = listOf("-Xskip-metadata-version-check"))),
|
||||
additionalOptions = listOf("-Xskip-metadata-version-check")
|
||||
)
|
||||
}
|
||||
|
||||
fun testDuplicateObjectInBinaryAndSources() {
|
||||
val allDescriptors = analyzeAndGetAllDescriptors(compileLibrary("library"))
|
||||
assertEquals(allDescriptors.toString(), 2, allDescriptors.size)
|
||||
@@ -161,26 +149,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
doTestBrokenLibrary("library", "a/E.class")
|
||||
}
|
||||
|
||||
fun testNoWarningsOnJavaKotlinInheritance() {
|
||||
// This test checks that there are no PARAMETER_NAME_CHANGED_ON_OVERRIDE or DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES
|
||||
// warnings when subclassing in Kotlin from Java binaries (in case when no parameter names are available for Java classes)
|
||||
|
||||
val library = compileLibrary("library")
|
||||
val environment = createEnvironment(listOf(library))
|
||||
|
||||
val ktFile = KotlinTestUtils.loadKtFile(environment.project, getTestDataFileWithExtension("kt"))
|
||||
val result = JvmResolveUtil.analyze(ktFile, environment)
|
||||
result.throwIfError()
|
||||
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
result.bindingContext.diagnostics,
|
||||
PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false),
|
||||
renderInternalDiagnosticName = false
|
||||
)
|
||||
|
||||
assertEquals("There should be no diagnostics", 0, result.bindingContext.diagnostics.count())
|
||||
}
|
||||
|
||||
fun testIncompleteHierarchyInJava() {
|
||||
doTestBrokenLibrary("library", "test/Super.class")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user