IR test tests: use that magical '<<<' everywhere. No need for 'IR_FILE_TXT'.
This commit is contained in:
committed by
Dmitry Petrov
parent
4ccf3c3590
commit
b1af1af8a4
@@ -41,10 +41,6 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
val expectations = parseExpectations(dir, testFile)
|
||||
val irFileDump = irFile.dump()
|
||||
|
||||
expectations.irExpectedTextFile?.let { expectFile ->
|
||||
KotlinTestUtils.assertEqualsToFile(expectFile, irFileDump)
|
||||
}
|
||||
|
||||
val expected = StringBuilder()
|
||||
val actual = StringBuilder()
|
||||
for (expectation in expectations.regexps) {
|
||||
@@ -67,7 +63,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
internal class Expectations(val irExpectedTextFile: File?, val regexps: List<RegexpInText>, val irTreeFileLabels: List<IrTreeFileLabel>)
|
||||
internal class Expectations(val regexps: List<RegexpInText>, val irTreeFileLabels: List<IrTreeFileLabel>)
|
||||
|
||||
internal class RegexpInText(val numberOfOccurrences: Int, val needle: String) {
|
||||
constructor(countStr: String, needle: String) : this(Integer.valueOf(countStr), needle)
|
||||
@@ -77,11 +73,9 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
|
||||
companion object {
|
||||
private val EXPECTED_OCCURRENCES_PATTERN = Regex("""^\s*//\s*(\d+)\s*(.*)$""")
|
||||
private val IR_FILE_TXT_PATTERN = Regex("""^\s*//\s*IR_FILE_TXT\s+(.*)$""")
|
||||
private val IR_TREES_TXT_PATTERN = Regex("""// \s*<<<\s+(.*)$""")
|
||||
|
||||
internal fun parseExpectations(dir: File, testFile: TestFile): Expectations {
|
||||
var expectedTextFileName: String? = null
|
||||
val regexps = ArrayList<RegexpInText>()
|
||||
val treeFiles = ArrayList<IrTreeFileLabel>()
|
||||
|
||||
@@ -89,9 +83,6 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
EXPECTED_OCCURRENCES_PATTERN.matchEntire(line)?.let { matchResult ->
|
||||
regexps.add(RegexpInText(matchResult.groupValues[1], matchResult.groupValues[2].trim()))
|
||||
}
|
||||
?: IR_FILE_TXT_PATTERN.matchEntire(line)?.let { matchResult ->
|
||||
expectedTextFileName = matchResult.groupValues[1].trim()
|
||||
}
|
||||
?: IR_TREES_TXT_PATTERN.find(line)?.let { matchResult ->
|
||||
val fileName = matchResult.groupValues[1].trim()
|
||||
val file = createExpectedTextFile(testFile, dir, fileName)
|
||||
@@ -99,9 +90,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
val expectedTextFile: File? = expectedTextFileName?.let { createExpectedTextFile(testFile, dir, it) }
|
||||
|
||||
return Expectations(expectedTextFile, regexps, treeFiles)
|
||||
return Expectations(regexps, treeFiles)
|
||||
}
|
||||
|
||||
internal fun createExpectedTextFile(testFile: TestFile, dir: File, fileName: String): File {
|
||||
|
||||
Vendored
+1
-2
@@ -1,3 +1,2 @@
|
||||
// <<< boxOk.txt
|
||||
fun box(): String = "OK"
|
||||
|
||||
// IR_FILE_TXT boxOk.txt
|
||||
Vendored
+1
-2
@@ -1,8 +1,7 @@
|
||||
// <<< calls.txt
|
||||
fun foo(x: Int, y: Int) = x
|
||||
fun bar(x: Int) = foo(x, 1)
|
||||
fun qux(x: Int) = foo(foo(x, x), x)
|
||||
|
||||
fun Int.ext1() = this
|
||||
fun Int.ext2(x: Int) = foo(this, x)
|
||||
|
||||
// IR_FILE_TXT calls.txt
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// <<< dotQualified.txt
|
||||
fun length(s: String) = s.length
|
||||
fun lengthN(s: String?) = s?.length
|
||||
|
||||
// IR_FILE_TXT dotQualified.txt
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// <<< extensionPropertyGetterCall.txt
|
||||
val String.okext: String get() = "OK"
|
||||
fun String.test5() = okext
|
||||
|
||||
// IR_FILE_TXT extensionPropertyGetterCall.txt
|
||||
+1
-2
@@ -1,3 +1,4 @@
|
||||
// <<< references.txt
|
||||
val ok = "OK"
|
||||
val ok2 = ok
|
||||
val ok3: String get() = "OK"
|
||||
@@ -15,5 +16,3 @@ fun test4() = ok3
|
||||
|
||||
val String.okext: String get() = "OK"
|
||||
fun String.test5() = okext
|
||||
|
||||
// IR_FILE_TXT references.txt
|
||||
Vendored
+1
-2
@@ -1,3 +1,4 @@
|
||||
// <<< smoke.txt
|
||||
fun testFun(): String { return "OK" }
|
||||
val testSimpleVal = 1 // <<< smoke.testSimpleVal.txt
|
||||
val testValWithGetter: Int get() = 42
|
||||
@@ -13,5 +14,3 @@ var testVarWithAccessors: Int
|
||||
// 1 IrPropertySetter
|
||||
// 1 IrProperty public var testSimpleVar
|
||||
// 1 IrProperty public var testVarWithAccessors
|
||||
|
||||
// IR_FILE_TXT smoke.txt
|
||||
Reference in New Issue
Block a user