New J2K: Support different testData for new converter
Sometimes old testData is incorrect
This commit is contained in:
committed by
Ilya Kirillov
parent
800b09b183
commit
b530a30882
@@ -78,12 +78,16 @@ abstract class AbstractJavaToKotlinConverterSingleFileTest : AbstractJavaToKotli
|
||||
actual = createKotlinFile(actual).dumpTextWithErrors()
|
||||
}
|
||||
|
||||
val kotlinPath = javaPath.replace(".java", ".kt")
|
||||
val expectedFile = File(kotlinPath)
|
||||
|
||||
val expectedFile = provideExpectedFile(javaPath)
|
||||
compareResults(expectedFile, actual)
|
||||
}
|
||||
|
||||
open fun provideExpectedFile(javaPath: String): File {
|
||||
val kotlinPath = javaPath.replace(".java", ".kt")
|
||||
return File(kotlinPath)
|
||||
}
|
||||
|
||||
open fun compareResults(expectedFile: File, actual: String) {
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.j2k.IdeaNewJavaToKotlinServices
|
||||
import org.jetbrains.kotlin.idea.j2k.J2kPostProcessor
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractNewJavaToKotlinConverterSingleFileTest : AbstractJavaToKotlinConverterSingleFileTest() {
|
||||
|
||||
@@ -39,4 +40,8 @@ abstract class AbstractNewJavaToKotlinConverterSingleFileTest : AbstractJavaToKo
|
||||
it.text
|
||||
}.single()
|
||||
}
|
||||
|
||||
override fun provideExpectedFile(javaPath: String): File =
|
||||
File(javaPath.replace(".java", ".new.kt")).takeIf { it.exists() }
|
||||
?: super.provideExpectedFile(javaPath)
|
||||
}
|
||||
Reference in New Issue
Block a user