StreamToLoop tests grouped

This commit is contained in:
Tagir Valeev
2017-01-27 17:38:37 +07:00
parent babce0b78c
commit fb6ba726e5
307 changed files with 2749 additions and 4686 deletions

View File

@@ -1,6 +1,10 @@
// "Replace Stream API chain with loop" "true"
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.ArrayList;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Main {
@@ -15,7 +19,63 @@ public class Main {
return stat;
}
public static List<String> testUseName() {
/*limit*/
List<String> list = new ArrayList<>();
long limit = 20;
for (String x = ""; ; x = x /* add "a" */ + "a") {
if (limit-- == 0) break;
list.add(x);
}
return list;
}
public static IntSummaryStatistics testNested() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (int limit = 0; limit < 20; limit++) {
long limitInner = limit;
for (String x = ""; ; x = x + limit) {
if (limitInner-- == 0) break;
int length = x.length();
stat.accept(length);
}
}
return stat;
}
private static List<String> testNestedUseName() {
List<String> list = new ArrayList<>();
for (int x = 0; x < 20; x++) {
Integer integer = x;
long limit = integer;
for (String str = ""; ; str = "a" + str) {
if (limit-- == 0) break;
list.add(str);
}
}
return list;
}
public static IntSummaryStatistics testNestedRename() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (int x = 0; x < 20; x++) {
if (x > 2) {
long limit = x;
for (String s = String.valueOf(x); ; s = s + x) {
if (limit-- == 0) break;
int length = s.length();
stat.accept(length);
}
}
}
return stat;
}
public static void main(String[] args) {
System.out.println(test());
System.out.println(testUseName());
System.out.println(testNested());
System.out.println(testNestedRename());
System.out.println(String.join("|", testNestedUseName()).length());
}
}