[MPP] Add default parameter tests for ^KT-50120
This commit is contained in:
committed by
Space
parent
3598ba1d45
commit
017aacba44
+29
@@ -0,0 +1,29 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Ok(x: Int, y: String = "")
|
||||
|
||||
expect class FailX(x: Int, y: String = "")
|
||||
|
||||
expect class FailY(x: Int, y: String = "")
|
||||
|
||||
fun test() {
|
||||
Ok()
|
||||
Ok(42)
|
||||
Ok(42, "OK")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual class Ok actual constructor(x: Int, y: String)
|
||||
|
||||
actual class FailX actual constructor(x: Int = 0, y: String)
|
||||
|
||||
actual class FailY actual constructor(x: Int, y: String = "")
|
||||
|
||||
fun testJvm() {
|
||||
Ok()
|
||||
Ok(42)
|
||||
Ok(42, "OK")
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Ok(x: Int, y: String = "")
|
||||
|
||||
expect class FailX(x: Int, y: String = "")
|
||||
|
||||
expect class FailY(x: Int, y: String = "")
|
||||
|
||||
fun test() {
|
||||
Ok(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
Ok(42)
|
||||
Ok(42, "OK")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual class Ok actual constructor(x: Int, y: String)
|
||||
|
||||
actual class FailX actual constructor(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = 0<!>, y: String)
|
||||
|
||||
actual class FailY actual constructor(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = ""<!>)
|
||||
|
||||
fun testJvm() {
|
||||
Ok(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
Ok(42)
|
||||
Ok(42, "OK")
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final expect class FailX {
|
||||
public constructor FailX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final expect class FailY {
|
||||
public constructor FailY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final expect class Ok {
|
||||
public constructor Ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun testJvm(): kotlin.Unit
|
||||
|
||||
public final actual class FailX {
|
||||
public constructor FailX(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final actual class FailY {
|
||||
public constructor FailY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final actual class Ok {
|
||||
public constructor Ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
import A.Companion.companionExtensionFunction
|
||||
|
||||
expect class A() {
|
||||
fun memberFunction(x: Int, y: String = "ok")
|
||||
companion object {
|
||||
fun companionFunction(x: Int, y: String = "ok")
|
||||
fun String.companionExtensionFunction(x: Int, y: String = "ok")
|
||||
}
|
||||
}
|
||||
|
||||
expect fun topLevelFunction(x: Int, y: String = "ok")
|
||||
|
||||
expect fun String.topLevelExtensionFunction(x: Int, y: String = "ok")
|
||||
|
||||
fun test() {
|
||||
A().memberFunction()
|
||||
A().memberFunction(42)
|
||||
A().memberFunction(42, "ok")
|
||||
|
||||
topLevelFunction()
|
||||
topLevelFunction(42)
|
||||
topLevelFunction(42, "ok")
|
||||
|
||||
"".topLevelExtensionFunction()
|
||||
"".topLevelExtensionFunction(42)
|
||||
"".topLevelExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
fun A.test() {
|
||||
"".companionExtensionFunction()
|
||||
"".companionExtensionFunction(42)
|
||||
"".companionExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
import A.Companion.companionExtensionFunction
|
||||
|
||||
actual class A {
|
||||
actual fun memberFunction(x: Int, y: String) = Unit
|
||||
actual companion object {
|
||||
actual fun companionFunction(x: Int, y: String) = Unit
|
||||
actual fun String.companionExtensionFunction(x: Int, y: String) = Unit
|
||||
}
|
||||
}
|
||||
|
||||
actual fun topLevelFunction(x: Int, y: String) = Unit
|
||||
|
||||
actual fun String.topLevelExtensionFunction(x: Int, y: String) = Unit
|
||||
|
||||
fun testJvm() {
|
||||
A().memberFunction()
|
||||
A().memberFunction(42)
|
||||
A().memberFunction(42, "ok")
|
||||
|
||||
topLevelFunction()
|
||||
topLevelFunction(42)
|
||||
topLevelFunction(42, "ok")
|
||||
|
||||
"".topLevelExtensionFunction()
|
||||
"".topLevelExtensionFunction(42)
|
||||
"".topLevelExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
fun A.testJvm() {
|
||||
"".companionExtensionFunction()
|
||||
"".companionExtensionFunction(42)
|
||||
"".companionExtensionFunction(42, "ok")
|
||||
}
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
import A.Companion.companionExtensionFunction
|
||||
|
||||
expect class A() {
|
||||
fun memberFunction(x: Int, y: String = "ok")
|
||||
companion object {
|
||||
fun companionFunction(x: Int, y: String = "ok")
|
||||
fun String.companionExtensionFunction(x: Int, y: String = "ok")
|
||||
}
|
||||
}
|
||||
|
||||
expect fun topLevelFunction(x: Int, y: String = "ok")
|
||||
|
||||
expect fun String.topLevelExtensionFunction(x: Int, y: String = "ok")
|
||||
|
||||
fun test() {
|
||||
A().memberFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
A().memberFunction(42)
|
||||
A().memberFunction(42, "ok")
|
||||
|
||||
topLevelFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
topLevelFunction(42)
|
||||
topLevelFunction(42, "ok")
|
||||
|
||||
"".topLevelExtensionFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
"".topLevelExtensionFunction(42)
|
||||
"".topLevelExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
fun A.test() {
|
||||
"".companionExtensionFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
"".companionExtensionFunction(42)
|
||||
"".companionExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
import A.Companion.companionExtensionFunction
|
||||
|
||||
actual class A {
|
||||
actual fun memberFunction(x: Int, y: String) = Unit
|
||||
actual companion object {
|
||||
actual fun companionFunction(x: Int, y: String) = Unit
|
||||
actual fun String.companionExtensionFunction(x: Int, y: String) = Unit
|
||||
}
|
||||
}
|
||||
|
||||
actual fun topLevelFunction(x: Int, y: String) = Unit
|
||||
|
||||
actual fun String.topLevelExtensionFunction(x: Int, y: String) = Unit
|
||||
|
||||
fun testJvm() {
|
||||
A().memberFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
A().memberFunction(42)
|
||||
A().memberFunction(42, "ok")
|
||||
|
||||
topLevelFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
topLevelFunction(42)
|
||||
topLevelFunction(42, "ok")
|
||||
|
||||
"".topLevelExtensionFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
"".topLevelExtensionFunction(42)
|
||||
"".topLevelExtensionFunction(42, "ok")
|
||||
}
|
||||
|
||||
fun A.testJvm() {
|
||||
"".companionExtensionFunction(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
"".companionExtensionFunction(42)
|
||||
"".companionExtensionFunction(42, "ok")
|
||||
}
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
public expect fun topLevelFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public fun A.test(): kotlin.Unit
|
||||
public expect fun kotlin.String.topLevelExtensionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
|
||||
public final expect class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final expect fun memberFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public expect companion object Companion {
|
||||
public final expect fun companionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final expect fun kotlin.String.companionExtensionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
}
|
||||
}
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun testJvm(): kotlin.Unit
|
||||
public actual fun topLevelFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public fun A.testJvm(): kotlin.Unit
|
||||
public actual fun kotlin.String.topLevelExtensionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
|
||||
public final actual class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final actual fun memberFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public actual companion object Companion {
|
||||
private constructor Companion()
|
||||
public final actual fun companionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final actual fun kotlin.String.companionExtensionFunction(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.test.runners;
|
||||
|
||||
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 GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DiagnosticsWithMultiplatformCompositeAnalysisTestGenerated extends AbstractDiagnosticsWithMultiplatformCompositeAnalysisTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithMultiplatformCompositeAnalysis() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultArguments {
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultArguments() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis/defaultArguments"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis/defaultArguments/constructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithMultiplatformCompositeAnalysis/defaultArguments/function.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user