[Tests] Generify transforming tests method model
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ private val METHOD_GENERATORS = listOf(
|
||||
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
||||
SimpleTestMethodGenerator,
|
||||
SingleClassTestModelAllFilesPresentedMethodGenerator,
|
||||
WithoutJvmInlineTestMethodGenerator,
|
||||
TransformingTestMethodGenerator,
|
||||
)
|
||||
|
||||
object TestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.generators
|
||||
import org.jetbrains.kotlin.generators.impl.SimpleTestClassModelTestAllFilesPresentMethodGenerator
|
||||
import org.jetbrains.kotlin.generators.impl.SimpleTestMethodGenerator
|
||||
import org.jetbrains.kotlin.generators.impl.SingleClassTestModelAllFilesPresentedMethodGenerator
|
||||
import org.jetbrains.kotlin.generators.impl.WithoutJvmInlineTestMethodGenerator
|
||||
import org.jetbrains.kotlin.generators.impl.TransformingTestMethodGenerator
|
||||
import org.jetbrains.kotlin.generators.model.*
|
||||
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
@@ -26,7 +26,7 @@ private val METHOD_GENERATORS = listOf(
|
||||
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
||||
SimpleTestMethodGenerator,
|
||||
SingleClassTestModelAllFilesPresentedMethodGenerator,
|
||||
WithoutJvmInlineTestMethodGenerator,
|
||||
TransformingTestMethodGenerator,
|
||||
)
|
||||
|
||||
object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
||||
|
||||
+6
-7
@@ -8,24 +8,23 @@ package org.jetbrains.kotlin.generators.impl
|
||||
import org.jetbrains.kotlin.generators.MethodGenerator
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.model.RunTestMethodModel
|
||||
import org.jetbrains.kotlin.generators.model.WithoutJvmInlineTestMethodModel
|
||||
import org.jetbrains.kotlin.generators.model.TransformingTestMethodModel
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
object WithoutJvmInlineTestMethodGenerator : MethodGenerator<WithoutJvmInlineTestMethodModel>() {
|
||||
object TransformingTestMethodGenerator : MethodGenerator<TransformingTestMethodModel>() {
|
||||
|
||||
override val kind: MethodModel.Kind
|
||||
get() = WithoutJvmInlineTestMethodModel.Kind
|
||||
get() = TransformingTestMethodModel.Kind
|
||||
|
||||
override fun generateSignature(method: WithoutJvmInlineTestMethodModel, p: Printer) {
|
||||
override fun generateSignature(method: TransformingTestMethodModel, p: Printer) {
|
||||
generateDefaultSignature(method, p)
|
||||
}
|
||||
|
||||
override fun generateBody(method: WithoutJvmInlineTestMethodModel, p: Printer) {
|
||||
override fun generateBody(method: TransformingTestMethodModel, p: Printer) {
|
||||
with(method) {
|
||||
val filePath = KtTestUtil.getFilePath(source.file) + if (source.file.isDirectory) "/" else ""
|
||||
val replacement = if (method.withAnnotation) "@kotlin.jvm.JvmInline" else ""
|
||||
p.println("${RunTestMethodModel.METHOD_NAME}(\"$filePath\", s -> s.replaceAll(\"OPTIONAL_JVM_INLINE_ANNOTATION\", \"$replacement\"));")
|
||||
p.println("${RunTestMethodModel.METHOD_NAME}(\"$filePath\", ${method.transformer});")
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.generators.model
|
||||
|
||||
abstract class TransformingTestMethodModel(val source: SimpleTestMethodModel, val transformer: String) : MethodModel {
|
||||
override val kind: MethodModel.Kind
|
||||
get() = Kind
|
||||
abstract override val name: String
|
||||
override val dataString: String
|
||||
get() = source.dataString
|
||||
override val tags: List<String>
|
||||
get() = source.tags
|
||||
|
||||
object Kind : MethodModel.Kind()
|
||||
}
|
||||
+6
-12
@@ -6,17 +6,11 @@
|
||||
package org.jetbrains.kotlin.generators.model
|
||||
|
||||
class WithoutJvmInlineTestMethodModel(
|
||||
val source: SimpleTestMethodModel,
|
||||
source: SimpleTestMethodModel,
|
||||
val withAnnotation: Boolean
|
||||
) : MethodModel {
|
||||
object Kind : MethodModel.Kind()
|
||||
|
||||
override val kind: MethodModel.Kind
|
||||
get() = Kind
|
||||
override val name: String
|
||||
get() = source.name + if (withAnnotation) "" else "_valueClasses"
|
||||
override val dataString: String
|
||||
get() = source.dataString
|
||||
override val tags: List<String>
|
||||
get() = source.tags
|
||||
) : TransformingTestMethodModel(
|
||||
source,
|
||||
transformer = "s -> s.replaceAll(\"OPTIONAL_JVM_INLINE_ANNOTATION\", \"${if (withAnnotation) "@kotlin.jvm.JvmInline" else ""}\")"
|
||||
) {
|
||||
override val name: String = source.name + if (withAnnotation) "" else "_valueClasses"
|
||||
}
|
||||
Reference in New Issue
Block a user