J2K: AbstractBytecodeTextTest.java fix compile errors
(cherry picked from commit 02b59be)
This commit is contained in:
committed by
Nikolay Krasko
parent
32dff799ff
commit
019ba77e2b
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.io.FileUtil
|
|||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||||
import org.jetbrains.kotlin.utils.rethrow
|
import org.jetbrains.kotlin.utils.rethrow
|
||||||
|
import org.junit.Assert
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Matcher
|
import java.util.regex.Matcher
|
||||||
@@ -52,8 +53,8 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
val generated = generateEachFileToText()
|
val generated = generateEachFileToText()
|
||||||
for (expectedOutputFile in expectedOccurrencesByOutputFile.keys) {
|
for (expectedOutputFile in expectedOccurrencesByOutputFile.keys) {
|
||||||
assertTextWasGenerated(expectedOutputFile, generated)
|
assertTextWasGenerated(expectedOutputFile, generated)
|
||||||
val generatedText = generated[expectedOutputFile]
|
val generatedText = generated[expectedOutputFile]!!
|
||||||
val expectedOccurrences = expectedOccurrencesByOutputFile[expectedOutputFile]
|
val expectedOccurrences = expectedOccurrencesByOutputFile[expectedOutputFile]!!
|
||||||
checkGeneratedTextAgainstExpectedOccurrences(generatedText, expectedOccurrences)
|
checkGeneratedTextAgainstExpectedOccurrences(generatedText, expectedOccurrences)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,15 +74,14 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class OccurrenceInfo private constructor(private val numberOfOccurrences: Int, private val needle: String) {
|
class OccurrenceInfo constructor(private val numberOfOccurrences: Int, private val needle: String) {
|
||||||
|
|
||||||
fun getActualOccurrence(text: String): String? {
|
fun getActualOccurrence(text: String): String? {
|
||||||
val actualCount = StringUtil.findMatches(text, Pattern.compile("($needle)")).size
|
val actualCount = StringUtil.findMatches(text, Pattern.compile("($needle)")).size
|
||||||
return actualCount + " " + needle
|
return "$actualCount $needle"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return numberOfOccurrences + " " + needle
|
return "$numberOfOccurrences $needle"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +99,8 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
return kotlinFiles > 1
|
return kotlinFiles > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun checkGeneratedTextAgainstExpectedOccurrences(
|
fun checkGeneratedTextAgainstExpectedOccurrences(text: String,
|
||||||
text: String,
|
expectedOccurrences: List<OccurrenceInfo>) {
|
||||||
expectedOccurrences: List<OccurrenceInfo>) {
|
|
||||||
val expected = StringBuilder()
|
val expected = StringBuilder()
|
||||||
val actual = StringBuilder()
|
val actual = StringBuilder()
|
||||||
|
|
||||||
@@ -111,7 +110,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TestCase.assertEquals(text, expected.toString(), actual.toString())
|
Assert.assertEquals(text, expected.toString(), actual.toString())
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
println(text)
|
println(text)
|
||||||
@@ -127,7 +126,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
for (generatedFile in generated.keys) {
|
for (generatedFile in generated.keys) {
|
||||||
failMessage.append(generatedFile).append(" ")
|
failMessage.append(generatedFile).append(" ")
|
||||||
}
|
}
|
||||||
TestCase.fail(failMessage.toString())
|
Assert.fail(failMessage.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user