[FE] Convert ClassId.java to Kotlin
This commit is contained in:
committed by
Space Team
parent
a3bcac00e4
commit
a43cb721ba
+6
-6
@@ -31,7 +31,7 @@ class KotlinOnlyClasspathSnapshotterTest : ClasspathSnapshotTestCommon() {
|
||||
fun testSimpleClass() {
|
||||
val sourceFile = getSourceFile("testSimpleClass", "com/example/SimpleClass.kt")
|
||||
val actualSnapshot = sourceFile.compileAndSnapshot().toGson()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotFile().readText()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotText()
|
||||
|
||||
assertEquals(expectedSnapshot, actualSnapshot)
|
||||
|
||||
@@ -55,7 +55,7 @@ class KotlinOnlyClasspathSnapshotterTest : ClasspathSnapshotTestCommon() {
|
||||
val sourceFile = getSourceFile("testSimpleClass", "com/example/SimpleClass.kt")
|
||||
val classFile = sourceFile.compileSingle()
|
||||
val actualSnapshot = classFile.snapshot(ClassSnapshotGranularity.CLASS_LEVEL).toGson()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotFile(ClassSnapshotGranularity.CLASS_LEVEL).readText()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotText(ClassSnapshotGranularity.CLASS_LEVEL)
|
||||
|
||||
assertEquals(expectedSnapshot, actualSnapshot)
|
||||
|
||||
@@ -103,7 +103,7 @@ class JavaOnlyClasspathSnapshotterTest : ClasspathSnapshotTestCommon() {
|
||||
fun testSimpleClass() {
|
||||
val sourceFile = getSourceFile("testSimpleClass", "com/example/SimpleClass.java")
|
||||
val actualSnapshot = sourceFile.compileAndSnapshot().toGson()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotFile().readText()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotText()
|
||||
|
||||
assertEquals(expectedSnapshot, actualSnapshot)
|
||||
|
||||
@@ -126,7 +126,7 @@ class JavaOnlyClasspathSnapshotterTest : ClasspathSnapshotTestCommon() {
|
||||
val sourceFile = getSourceFile("testSimpleClass", "com/example/SimpleClass.java")
|
||||
val classFile = sourceFile.compileSingle()
|
||||
val actualSnapshot = classFile.snapshot(ClassSnapshotGranularity.CLASS_LEVEL).toGson()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotFile(ClassSnapshotGranularity.CLASS_LEVEL).readText()
|
||||
val expectedSnapshot = sourceFile.getExpectedSnapshotText(ClassSnapshotGranularity.CLASS_LEVEL)
|
||||
|
||||
assertEquals(expectedSnapshot, actualSnapshot)
|
||||
|
||||
@@ -135,10 +135,10 @@ class JavaOnlyClasspathSnapshotterTest : ClasspathSnapshotTestCommon() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun TestSourceFile.getExpectedSnapshotFile(granularity: ClassSnapshotGranularity? = null): File {
|
||||
private fun TestSourceFile.getExpectedSnapshotText(granularity: ClassSnapshotGranularity? = null): String {
|
||||
val relativePath = sourceFile.unixStyleRelativePath.substringBeforeLast(".") + ".json"
|
||||
val expectedSnapshotDirName = if (granularity == null) "expected-snapshot" else "expected-snapshot-${granularity.name}"
|
||||
return sourceFile.baseDir.resolve("../$expectedSnapshotDirName/$relativePath")
|
||||
return sourceFile.baseDir.resolve("../$expectedSnapshotDirName/$relativePath").readText().trimEnd()
|
||||
}
|
||||
|
||||
private fun String.assertContains(vararg elements: String) {
|
||||
|
||||
Reference in New Issue
Block a user