Minor. Code clean
This commit is contained in:
+12
-17
@@ -5,13 +5,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.jvm.compiler
|
package org.jetbrains.kotlin.jvm.compiler
|
||||||
|
|
||||||
import com.google.common.io.Files
|
|
||||||
import org.jetbrains.kotlin.codegen.CodegenTestCase
|
import org.jetbrains.kotlin.codegen.CodegenTestCase
|
||||||
import org.jetbrains.kotlin.utils.sure
|
import org.jetbrains.kotlin.utils.sure
|
||||||
import org.jetbrains.org.objectweb.asm.*
|
import org.jetbrains.org.objectweb.asm.*
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.charset.Charset
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.MatchResult
|
import java.util.regex.MatchResult
|
||||||
|
|
||||||
@@ -19,12 +17,10 @@ abstract class AbstractWriteSignatureTest : CodegenTestCase() {
|
|||||||
|
|
||||||
|
|
||||||
override fun doMultiFileTest(wholeFile: File, files: MutableList<TestFile>, javaFilesDir: File?) {
|
override fun doMultiFileTest(wholeFile: File, files: MutableList<TestFile>, javaFilesDir: File?) {
|
||||||
//setupLanguageVersionSettingsForCompilerTests(text, environment!!)
|
|
||||||
compile(files, javaFilesDir)
|
compile(files, javaFilesDir)
|
||||||
try {
|
try {
|
||||||
parseExpectations(wholeFile).check()
|
parseExpectations(wholeFile).check()
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
println(classFileFactory.createText())
|
println(classFileFactory.createText())
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
@@ -62,7 +58,7 @@ abstract class AbstractWriteSignatureTest : CodegenTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class PackageExpectationsSuite() {
|
private inner class PackageExpectationsSuite {
|
||||||
private val classSuitesByClassName = LinkedHashMap<String, ClassExpectationsSuite>()
|
private val classSuitesByClassName = LinkedHashMap<String, ClassExpectationsSuite>()
|
||||||
|
|
||||||
fun getOrCreateClassSuite(className: String): ClassExpectationsSuite =
|
fun getOrCreateClassSuite(className: String): ClassExpectationsSuite =
|
||||||
@@ -150,7 +146,7 @@ abstract class AbstractWriteSignatureTest : CodegenTestCase() {
|
|||||||
private fun parseExpectations(ktFile: File): PackageExpectationsSuite {
|
private fun parseExpectations(ktFile: File): PackageExpectationsSuite {
|
||||||
val expectations = PackageExpectationsSuite()
|
val expectations = PackageExpectationsSuite()
|
||||||
|
|
||||||
val lines = Files.readLines(ktFile, Charset.forName("utf-8"))
|
val lines = ktFile.readLines()
|
||||||
var lineNo = 0
|
var lineNo = 0
|
||||||
while (lineNo < lines.size) {
|
while (lineNo < lines.size) {
|
||||||
val line = lines[lineNo]
|
val line = lines[lineNo]
|
||||||
@@ -199,11 +195,11 @@ abstract class AbstractWriteSignatureTest : CodegenTestCase() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun formatSignature(header: String, jvmSignature: String?, genericSignature: String): String {
|
fun formatSignature(header: String, jvmSignature: String?, genericSignature: String): String {
|
||||||
return listOf(
|
return listOfNotNull(
|
||||||
header,
|
header,
|
||||||
jvmSignature?.let { "jvm signature: $it" },
|
jvmSignature?.let { "jvm signature: $it" },
|
||||||
"generic signature: $genericSignature"
|
"generic signature: $genericSignature"
|
||||||
).filterNotNull().joinToString("\n") { "// $it" }
|
).joinToString("\n") { "// $it" }
|
||||||
}
|
}
|
||||||
|
|
||||||
val expectationRegex = Regex("^// (class|method|field): *([^:]+)(::(.+))? *(//.*)?")
|
val expectationRegex = Regex("^// (class|method|field): *([^:]+)(::(.+))? *(//.*)?")
|
||||||
@@ -212,11 +208,10 @@ abstract class AbstractWriteSignatureTest : CodegenTestCase() {
|
|||||||
|
|
||||||
fun Regex.matchExact(input: String): MatchResult? {
|
fun Regex.matchExact(input: String): MatchResult? {
|
||||||
val matcher = this.toPattern().matcher(input)
|
val matcher = this.toPattern().matcher(input)
|
||||||
if (matcher.matches()) {
|
return if (matcher.matches()) {
|
||||||
return matcher.toMatchResult()
|
matcher.toMatchResult()
|
||||||
}
|
} else {
|
||||||
else {
|
null
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user