[TEST] Migrate AbstractDiagnosticsTestWithJsStdLib to new test runners
This commit is contained in:
@@ -10,4 +10,4 @@ fun test() {
|
||||
fun <T> dynamic(<!UNUSED_PARAMETER!>body<!>: dynamic.() -> T): T {
|
||||
val topLevel = null
|
||||
return topLevel.<!UNRESOLVED_REFERENCE!>body<!>()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,4 +7,4 @@ fun test(d: dynamic) {
|
||||
d["foo"] != null
|
||||
d.foo == null
|
||||
d.foo != null
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ class A {
|
||||
operator fun iterator(): Iterator<dynamic> = TODO("")
|
||||
}
|
||||
|
||||
fun bar(f: (dynamic) -> Unit): Unit = TODO("")
|
||||
fun bar(f: (dynamic) -> Unit): Unit = TODO("")
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ fun <!DYNAMIC_RECEIVER_NOT_ALLOWED!>dynamic<!>.test() {
|
||||
v5.isDynamic() // to check that anything is resolvable
|
||||
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,4 +9,4 @@ fun foo() {
|
||||
when (3) {
|
||||
<!WRONG_OPERATION_WITH_DYNAMIC!>!in<!> a -> println("ok")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ fun foo() {
|
||||
|
||||
a[0] = 23
|
||||
<!WRONG_OPERATION_WITH_DYNAMIC!>a[0, 1]<!> = 42
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ fun test(d: dynamic) {
|
||||
d.foo(1, name = "name")
|
||||
|
||||
d.foo(1, duplicate = "", <!ARGUMENT_PASSED_TWICE!>duplicate<!> = ""<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ fun foo(dn: dynamic<!REDUNDANT_NULLABLE!>?<!>, d: dynamic, dnn: dynamic<!REDUNDA
|
||||
d.foo()
|
||||
d?.foo()
|
||||
d!!.foo()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,4 +24,4 @@ class DynamicHandler {
|
||||
|
||||
class B {
|
||||
val x: dynamic by DynamicHandler()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ fun foo() {
|
||||
|
||||
class C {
|
||||
operator fun rangeTo(other: dynamic): ClosedRange<dynamic> = TODO("not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ fun test(d: dynamic) {
|
||||
bar(<!WRONG_OPERATION_WITH_DYNAMIC!>*d<!>, 23, <!WRONG_OPERATION_WITH_DYNAMIC!>*d<!>)
|
||||
}
|
||||
|
||||
fun bar(vararg x: Int): Unit = TODO("$x")
|
||||
fun bar(vararg x: Int): Unit = TODO("$x")
|
||||
|
||||
Vendored
+1
-1
@@ -71,4 +71,4 @@ class C {
|
||||
|
||||
class WithInvoke {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,21 +6,21 @@ package foo
|
||||
open class NonExportedClass
|
||||
|
||||
@JsExport
|
||||
class <!NON_EXPORTABLE_TYPE("super", "NonExportedClass")!>ExportedClass<!> : NonExportedClass()
|
||||
class <!NON_EXPORTABLE_TYPE("super; NonExportedClass")!>ExportedClass<!> : NonExportedClass()
|
||||
|
||||
interface NonExportedInterface
|
||||
|
||||
@JsExport
|
||||
class <!NON_EXPORTABLE_TYPE("super", "NonExportedInterface")!>ExportedClass2<!> : NonExportedInterface
|
||||
class <!NON_EXPORTABLE_TYPE("super; NonExportedInterface")!>ExportedClass2<!> : NonExportedInterface
|
||||
|
||||
@JsExport
|
||||
open class ExportedGenericClass<T>
|
||||
|
||||
@JsExport
|
||||
class <!NON_EXPORTABLE_TYPE("super", "ExportedGenericClass<NonExportedClass>")!>ExportedClass3<!> : ExportedGenericClass<NonExportedClass>()
|
||||
class <!NON_EXPORTABLE_TYPE("super; ExportedGenericClass<NonExportedClass>")!>ExportedClass3<!> : ExportedGenericClass<NonExportedClass>()
|
||||
|
||||
@JsExport
|
||||
interface ExportedGenericInterface<T>
|
||||
|
||||
@JsExport
|
||||
class <!NON_EXPORTABLE_TYPE("super", "ExportedGenericInterface<NonExportedClass>")!>ExportedClass4<!> : ExportedGenericInterface<NonExportedClass>
|
||||
class <!NON_EXPORTABLE_TYPE("super; ExportedGenericInterface<NonExportedClass>")!>ExportedClass4<!> : ExportedGenericInterface<NonExportedClass>
|
||||
|
||||
+12
-12
@@ -7,30 +7,30 @@ package foo
|
||||
class C
|
||||
|
||||
@JsExport
|
||||
fun foo(<!NON_EXPORTABLE_TYPE("parameter", "C")!>x: C<!>) {
|
||||
fun foo(<!NON_EXPORTABLE_TYPE("parameter; C")!>x: C<!>) {
|
||||
}
|
||||
|
||||
<!NON_EXPORTABLE_TYPE("return", "C")!>@JsExport
|
||||
<!NON_EXPORTABLE_TYPE("return; C")!>@JsExport
|
||||
fun bar()<!> = C()
|
||||
|
||||
<!NON_EXPORTABLE_TYPE("property", "C")!>@JsExport
|
||||
<!NON_EXPORTABLE_TYPE("property; C")!>@JsExport
|
||||
val x: C<!> = C()
|
||||
|
||||
<!NON_EXPORTABLE_TYPE("property", "C")!>@JsExport
|
||||
<!NON_EXPORTABLE_TYPE("property; C")!>@JsExport
|
||||
var x2: C<!>
|
||||
get() = C()
|
||||
set(value) { }
|
||||
|
||||
@JsExport
|
||||
class A(
|
||||
<!NON_EXPORTABLE_TYPE("parameter", "C"), NON_EXPORTABLE_TYPE("property", "C")!>val x: C<!>,
|
||||
<!NON_EXPORTABLE_TYPE("parameter", "C")!>y: C<!>
|
||||
<!NON_EXPORTABLE_TYPE("property; C"), NON_EXPORTABLE_TYPE("parameter; C")!>val x: C<!>,
|
||||
<!NON_EXPORTABLE_TYPE("parameter; C")!>y: C<!>
|
||||
) {
|
||||
<!NON_EXPORTABLE_TYPE("return", "C")!>fun foo(<!NON_EXPORTABLE_TYPE("parameter", "C")!>x: C<!>)<!> = x
|
||||
<!NON_EXPORTABLE_TYPE("return; C")!>fun foo(<!NON_EXPORTABLE_TYPE("parameter; C")!>x: C<!>)<!> = x
|
||||
|
||||
<!NON_EXPORTABLE_TYPE("property", "C")!>val x2: C<!> = C()
|
||||
<!NON_EXPORTABLE_TYPE("property; C")!>val x2: C<!> = C()
|
||||
|
||||
<!NON_EXPORTABLE_TYPE("property", "C")!>var x3: C<!>
|
||||
<!NON_EXPORTABLE_TYPE("property; C")!>var x3: C<!>
|
||||
get() = C()
|
||||
set(value) { }
|
||||
}
|
||||
@@ -40,7 +40,7 @@ fun foo2() {
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun foo3(<!NON_EXPORTABLE_TYPE("parameter", "Unit")!>x: Unit<!>) {
|
||||
fun foo3(<!NON_EXPORTABLE_TYPE("parameter; Unit")!>x: Unit<!>) {
|
||||
}
|
||||
|
||||
@JsExport
|
||||
@@ -48,9 +48,9 @@ fun foo4(x: () -> Unit) {
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun foo5(<!NON_EXPORTABLE_TYPE("parameter", "(Unit) -> Unit")!>x: (Unit) -> Unit<!>) {
|
||||
fun foo5(<!NON_EXPORTABLE_TYPE("parameter; (Unit) -> Unit")!>x: (Unit) -> Unit<!>) {
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun foo6(x: (A) -> A) {
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -8,10 +8,10 @@ abstract class C
|
||||
interface I
|
||||
|
||||
@JsExport
|
||||
fun <<!NON_EXPORTABLE_TYPE("upper bound", "C")!>T : C<!>>foo() { }
|
||||
fun <<!NON_EXPORTABLE_TYPE("upper bound; C")!>T : C<!>>foo() { }
|
||||
|
||||
@JsExport
|
||||
class A<<!NON_EXPORTABLE_TYPE("upper bound", "C")!>T : C<!>, <!NON_EXPORTABLE_TYPE("upper bound", "I")!>S: I<!>>
|
||||
class A<<!NON_EXPORTABLE_TYPE("upper bound; C")!>T : C<!>, <!NON_EXPORTABLE_TYPE("upper bound; I")!>S: I<!>>
|
||||
|
||||
@JsExport
|
||||
interface I2<<!NON_EXPORTABLE_TYPE("upper bound", "C"), NON_EXPORTABLE_TYPE("upper bound", "I")!>T<!>> where T : C, T : I
|
||||
interface I2<<!NON_EXPORTABLE_TYPE("upper bound; C"), NON_EXPORTABLE_TYPE("upper bound; I")!>T<!>> where T : C, T : I
|
||||
|
||||
@@ -35,8 +35,8 @@ public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <main> --
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
|
||||
+9
-4
@@ -1,9 +1,6 @@
|
||||
// -- Module: <m1> --
|
||||
package
|
||||
|
||||
package bar {
|
||||
public fun box(): kotlin.Unit
|
||||
}
|
||||
|
||||
package foo {
|
||||
|
||||
@kotlin.js.JsModule(import = "A") public external object A {
|
||||
@@ -23,3 +20,11 @@ package foo {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
// -- Module: <m2> --
|
||||
package
|
||||
|
||||
package bar {
|
||||
public fun box(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,6 @@ package foo {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m2> --
|
||||
package
|
||||
|
||||
@@ -49,3 +48,4 @@ package bar {
|
||||
package foo {
|
||||
public external fun baz(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
+18
-13
@@ -1,18 +1,6 @@
|
||||
// -- Module: <m1> --
|
||||
package
|
||||
|
||||
package bar {
|
||||
public inline fun </*0*/ reified T> boo(/*0*/ x: T): kotlin.Unit
|
||||
public fun box(): kotlin.Unit
|
||||
|
||||
public final external class DerivedB : foo.B {
|
||||
public constructor DerivedB()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
package foo {
|
||||
@kotlin.js.JsNonModule public external fun bar(): kotlin.Unit
|
||||
|
||||
@@ -40,3 +28,20 @@ package foo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- Module: <m2> --
|
||||
package
|
||||
|
||||
package bar {
|
||||
public inline fun </*0*/ reified T> boo(/*0*/ x: T): kotlin.Unit
|
||||
public fun box(): kotlin.Unit
|
||||
|
||||
public final external class DerivedB : foo.B {
|
||||
public constructor DerivedB()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,4 @@ val x: Int
|
||||
fun box(x: dynamic) {
|
||||
x.<!NAME_CONTAINS_ILLEGAL_CHARS!>`foo-bar`<!>()
|
||||
x.<!NAME_CONTAINS_ILLEGAL_CHARS!>`ba-z`<!>
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ inline fun A.foo(x: Int): String = asDynamic().foo(x)
|
||||
|
||||
inline operator fun A.get(x: Int): String = asDynamic()[x]
|
||||
|
||||
inline operator fun A.B.get(x: Int): String = asDynamic()[x]
|
||||
inline operator fun A.B.get(x: Int): String = asDynamic()[x]
|
||||
|
||||
+230
-111
File diff suppressed because it is too large
Load Diff
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.frontend.classic.handlers
|
||||
|
||||
import org.jetbrains.kotlin.checkers.CheckerDebugInfoReporter
|
||||
import org.jetbrains.kotlin.checkers.utils.DebugInfoUtil
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator.RECURSIVE_ALL
|
||||
import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumper
|
||||
import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumperImpl
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
|
||||
class DynamicCallsDumpHandler(testServices: TestServices) : ClassicFrontendAnalysisHandler(testServices) {
|
||||
companion object {
|
||||
private const val DYNAMIC_PREFIX = ".dynamic.txt"
|
||||
}
|
||||
|
||||
override val directivesContainers: List<DirectivesContainer>
|
||||
get() = listOf(DiagnosticsDirectives)
|
||||
|
||||
private val dumper: MultiModuleInfoDumper = MultiModuleInfoDumperImpl(moduleHeaderTemplate = "// -- Module: <%s> --")
|
||||
|
||||
override fun processModule(module: TestModule, info: ClassicFrontendOutputArtifact) {
|
||||
val dynamicCallDescriptors = mutableListOf<DeclarationDescriptor>()
|
||||
for (ktFile in info.ktFiles.values) {
|
||||
DebugInfoUtil.markDebugAnnotations(
|
||||
ktFile,
|
||||
info.analysisResult.bindingContext,
|
||||
CheckerDebugInfoReporter(
|
||||
dynamicCallDescriptors,
|
||||
markDynamicCalls = true,
|
||||
debugAnnotations = mutableListOf(),
|
||||
withNewInference = info.languageVersionSettings.supportsFeature(LanguageFeature.NewInference),
|
||||
platform = null
|
||||
)
|
||||
)
|
||||
}
|
||||
val serializer = RecursiveDescriptorComparator(RECURSIVE_ALL)
|
||||
val builder = dumper.builderForModule(module)
|
||||
for (descriptor in dynamicCallDescriptors) {
|
||||
builder.append(serializer.serializeRecursively(descriptor))
|
||||
}
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
|
||||
if (dumper.isEmpty()) return
|
||||
val expectedFile = testServices.moduleStructure.originalTestDataFiles.first().withExtension(DYNAMIC_PREFIX)
|
||||
if (expectedFile.exists()) {
|
||||
val resultDump = dumper.generateResultingDump()
|
||||
assertions.assertEqualsToFile(expectedFile, resultDump)
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -26,6 +26,10 @@ fun main(args: Array<String>) {
|
||||
model("diagnostics/tests", excludedPattern = excludedFirTestdataPattern)
|
||||
model("diagnostics/testsWithStdLib", excludedPattern = excludedFirTestdataPattern)
|
||||
}
|
||||
|
||||
testClass<AbstractDiagnosticsTestWithJsStdLib> {
|
||||
model("diagnostics/testsWithJsStdLib")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("compiler/tests-common-new/tests-gen", "compiler/fir/analysis-tests/testData") {
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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 org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.DeclarationsDumpHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.DynamicCallsDumpHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.OldNewInferenceMetaInfoProcessor
|
||||
import org.jetbrains.kotlin.test.model.BackendKind
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.services.AdditionalDiagnosticsSourceFilesProvider
|
||||
import org.jetbrains.kotlin.test.services.CoroutineHelpersSourceFilesProvider
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
|
||||
abstract class AbstractDiagnosticsTestWithJsStdLib : AbstractKotlinCompilerTest() {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
backend = BackendKind.NoBackend
|
||||
targetPlatform = JsPlatforms.defaultJsPlatform
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
defaultDirectives {
|
||||
+JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
|
||||
}
|
||||
|
||||
enableMetaInfoHandler()
|
||||
|
||||
useConfigurators(::JsEnvironmentConfigurator,)
|
||||
|
||||
useMetaInfoProcessors(::OldNewInferenceMetaInfoProcessor)
|
||||
useAdditionalSourceProviders(
|
||||
::AdditionalDiagnosticsSourceFilesProvider,
|
||||
::CoroutineHelpersSourceFilesProvider,
|
||||
)
|
||||
|
||||
useFrontendFacades(::ClassicFrontendFacade)
|
||||
useFrontendHandlers(
|
||||
::DeclarationsDumpHandler,
|
||||
::ClassicDiagnosticsHandler,
|
||||
::DynamicCallsDumpHandler,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -26,3 +26,9 @@ val File.firTestDataFile: File
|
||||
} else {
|
||||
parentFile.resolve("${name.removeSuffix(KT)}$FIR_KT")
|
||||
}
|
||||
|
||||
fun File.withExtension(extension: String): File {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val extension = extension.removePrefix(".")
|
||||
return parentFile.resolve("$nameWithoutExtension.$extension")
|
||||
}
|
||||
|
||||
@@ -67,10 +67,6 @@ fun main(args: Array<String>) {
|
||||
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("compiler/tests-gen", "compiler/testData") {
|
||||
testClass<AbstractDiagnosticsTestWithJsStdLib> {
|
||||
model("diagnostics/testsWithJsStdLib")
|
||||
}
|
||||
|
||||
testClass<AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation> {
|
||||
model("diagnostics/testsWithJsStdLibAndBackendCompilation")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user