Supported "count()"

This commit is contained in:
Valentin Kipyatkov
2016-04-20 16:34:49 +03:00
parent 53e3a67a7f
commit db53794663
14 changed files with 200 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
var count = 0
<caret>for (s in list) {
if (s.isNotBlank()) {
count++
}
}
return count
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
<caret>val count = list.count { it.isNotBlank() }
return count
}
+9
View File
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count()'"
fun foo(list: Iterable<String>): Int {
var count = 0
<caret>for (s in list) {
count++
}
return count
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count()'"
fun foo(list: Iterable<String>): Int {
<caret>val count = list.count()
return count
}
+11
View File
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo(list: List<String>): Long {
var count = 0L
<caret>for (s in list) {
if (s.length > 10) {
count++
}
}
return count
}
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
var count = bar()
<caret>for (s in list) {
if (s.isNotBlank()) {
count++
}
}
return count
}
fun bar(): Int = 0
@@ -0,0 +1,8 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
<caret>val count = bar() + list.count { it.isNotBlank() }
return count
}
fun bar(): Int = 0
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
var count = 1
<caret>for (s in list) {
if (s.isNotBlank()) {
count++
}
}
return count
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
<caret>val count = 1 + list.count { it.isNotBlank() }
return count
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
var count = 0
<caret>for (s in list) {
if (s.isNotBlank()) {
++count
}
}
return count
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'count{}'"
fun foo(list: List<String>): Int {
<caret>val count = list.count { it.isNotBlank() }
return count
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo(list: List<String>): Int {
var count = 0
<caret>for (s in list) {
if (s.length > count) {
count++
}
}
return count
}