Java inspection: Added lambda expression tests for "Move return to computation" inspection (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-08 16:22:07 +03:00
parent 898ab196d9
commit 9d7e978baf
5 changed files with 131 additions and 0 deletions
@@ -0,0 +1,17 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
if (b) return 1;
return n;
});
}
void g(I i) {
i.call();
}
}
@@ -0,0 +1,24 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
while (true) {
if (h()) {
return 1;
}
}
});
}
void g(I i) {
i.call();
}
boolean h() {
return true;
}
}
@@ -0,0 +1,17 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
if (b) n = 1;
ret<caret>urn n;
});
}
void g(I i) {
i.call();
}
}
@@ -0,0 +1,26 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
while (true) {
if (h()) {
n = 1;
break;
}
}
ret<caret>urn n;
});
}
void g(I i) {
i.call();
}
boolean h() {
return true;
}
}