Groupped tests by folders
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = ""
|
||||
|
||||
result = null
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = s
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = ""
|
||||
|
||||
<caret>result = list.firstOrNull { it.length > 0 }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s != null && s.length > 0) {
|
||||
result = bar(s)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String?): String? = s
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = s
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result: String? = list.firstOrNull { it.length > 0 }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo() {
|
||||
MainLoop@
|
||||
for (i in 1..10) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list()) {
|
||||
if (s.length > 0) {
|
||||
result = s
|
||||
break@MainLoop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun list(): List<String> = listOf()
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = s
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
result += "1"
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var <caret>result: String? = list.firstOrNull { it.length > 0 }
|
||||
|
||||
result += "1"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) { // search for first non-empty string in the list
|
||||
if (s.length > 0) { // string should be non-empty
|
||||
result = s // save it into result
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
// string should be non-empty
|
||||
// save it into result
|
||||
val result: String? = list.firstOrNull { // search for first non-empty string in the list
|
||||
it.length > 0
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s != result) {
|
||||
result = s
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list.firstOrNull { it.length > 0 }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = bar(s)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result: String? = list
|
||||
.firstOrNull { it.length > 0 }
|
||||
?.let { bar(it) }
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = s.substring(0, s.length - 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result: String? = list
|
||||
.firstOrNull { it.length > 0 }
|
||||
?.let { it.substring(0, it.length - 1) }
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
var result = ""
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
result = bar(s)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>) {
|
||||
val <caret>result = list
|
||||
.firstOrNull { it.length > 0 }
|
||||
?.let { bar(it) }
|
||||
?: ""
|
||||
}
|
||||
|
||||
fun bar(s: String): String = s
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for (s in list) {
|
||||
return s
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list.firstOrNull()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>for (s in list) {
|
||||
if (s.isNotEmpty()) {
|
||||
return s.length
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int? {
|
||||
<caret>return list
|
||||
.firstOrNull { it.isNotEmpty() }
|
||||
?.length
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>for (s in list) {
|
||||
if (s.isNotEmpty()) {
|
||||
return s.length
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): Int {
|
||||
<caret>return list
|
||||
.firstOrNull { it.isNotEmpty() }
|
||||
?.length
|
||||
?: -1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String {
|
||||
<caret>for (s in list) {
|
||||
if (s.isNotEmpty()) {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String {
|
||||
<caret>return list.firstOrNull { it.isNotEmpty() }
|
||||
?: ""
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String?>): String? {
|
||||
<caret>for (s in list) {
|
||||
if (s == null || s.isNotEmpty()) {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String?>): String? {
|
||||
list
|
||||
.filter { it == null || it.isNotEmpty() }
|
||||
.forEach { return it }
|
||||
return ""
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String?>): String? {
|
||||
list
|
||||
.asSequence()
|
||||
.filter { it == null || it.isNotEmpty() }
|
||||
.forEach { return it }
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for (s in list) {
|
||||
return s
|
||||
}
|
||||
// return null if not found
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull()'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
// return null if not found
|
||||
return list.firstOrNull()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>) {
|
||||
var result: String? = null
|
||||
<caret>for (s in list) {
|
||||
if (s != "") {
|
||||
result = s?.substring(1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>) {
|
||||
val <caret>result: String? = list
|
||||
.firstOrNull { it != "" }
|
||||
?.substring(1)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>for (s in list) {
|
||||
if (s.isEmpty()) continue
|
||||
if (s.length < 10 && s != "abc") {
|
||||
if (s == "def") continue
|
||||
return s
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String>): String? {
|
||||
<caret>return list.firstOrNull { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" }
|
||||
}
|
||||
Reference in New Issue
Block a user