[Tests] Trim contents before checking for FIR_IDENTICAL
This commit is contained in:
committed by
Space Team
parent
6b919e2593
commit
10e94f90ac
-17
@@ -1,17 +0,0 @@
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun bar1(body: (String) -> String): String {
|
||||
return body("something")
|
||||
}
|
||||
|
||||
fun bar2(body: (String, Int) -> String): String {
|
||||
return body("something", 0)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
bar1(::foo)
|
||||
bar2(::foo)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
|
||||
fun <T> Array<out T>.intersect(other: Iterable<T>) {
|
||||
val set = toMutableSet()
|
||||
set.retainAll(other)
|
||||
}
|
||||
|
||||
fun <X> Array<out X>.toMutableSet(): MutableSet<X> = TODO()
|
||||
fun <Y> MutableCollection<in Y>.retainAll(elements: Iterable<Y>) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T> Array<out T>.intersect(other: Iterable<T>) {
|
||||
val set = toMutableSet()
|
||||
set.retainAll(other)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
// completion order here: X, Y, WHEN_VARIABLE
|
||||
fun <T> List<T>.optimizeReadOnlyList() = when (size) {
|
||||
0 -> emptyList() // here type variable Y will be fixed to Nothing
|
||||
1 -> listOf(this[0])
|
||||
else -> this
|
||||
}
|
||||
fun <X> listOf(element: X): List<X> = TODO()
|
||||
fun <Y> emptyList(): List<Y> = TODO()
|
||||
|
||||
|
||||
fun test(l: List<String>): List<String> {
|
||||
val foo = l.optimizeReadOnlyList()
|
||||
return foo
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// completion order here: X, Y, WHEN_VARIABLE
|
||||
fun <T> List<T>.optimizeReadOnlyList() = when (size) {
|
||||
0 -> emptyList() // here type variable Y will be fixed to Nothing
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
fun <T> foo(resources: List<T>) {
|
||||
resources.map { runCatching { it } }.mapNotNull { it.getOrNull() }
|
||||
}
|
||||
|
||||
fun <T: Any> bar(resources: List<T>) {
|
||||
resources.map { runCatching { it } }.mapNotNull { it.getOrNull() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T> foo(resources: List<T>) {
|
||||
resources.map { runCatching { it } }.mapNotNull { it.getOrNull() }
|
||||
}
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> nullable(x: T): T? = x
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun <T> select(x1: T, x2: T): T = x1
|
||||
|
||||
val test1 =
|
||||
listOf(1, 2, 3).mapNotNullTo(ArrayList()) {
|
||||
if (true) nullable(it) else null
|
||||
}
|
||||
|
||||
val test2: MutableList<Int?> =
|
||||
listOf(1, 2, 3).mapNotNullTo(ArrayList()) {
|
||||
if (true) nullable(it) else null
|
||||
}
|
||||
|
||||
val test3: MutableList<Int> =
|
||||
listOf(1, 2, 3).mapNotNullTo(ArrayList()) {
|
||||
if (true) nullable(it) else null
|
||||
}
|
||||
|
||||
val test4: Collection<Int> =
|
||||
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) {
|
||||
listOf(it)
|
||||
}
|
||||
|
||||
val test5: Collection<Int> =
|
||||
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) { // TODO
|
||||
if (true) listOf(it) else listOf(it)
|
||||
}
|
||||
|
||||
val test6: Collection<Int> =
|
||||
listOf(1, 2, 3).flatMapTo(LinkedHashSet<Int>()) {
|
||||
if (true) listOf(it) else listOf(it)
|
||||
}
|
||||
|
||||
val test7: Collection<Int> =
|
||||
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) {
|
||||
select(listOf(it), listOf(it))
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import java.util.*
|
||||
|
||||
fun <T> nullable(x: T): T? = x
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test.utils
|
||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.applyIf
|
||||
import java.io.File
|
||||
|
||||
abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) {
|
||||
@@ -32,7 +33,7 @@ abstract class FirIdenticalCheckerHelper(private val testServices: TestServices)
|
||||
|
||||
fun readContent(file: File, trimLines: Boolean): String {
|
||||
return if (trimLines) {
|
||||
file.readLines().joinToString("\n") { it.trimEnd() }.trimEnd()
|
||||
file.readLines().joinToString("\n") { it.trimEnd() }.trim()
|
||||
} else {
|
||||
file.readText()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user