Add more test cases

This commit is contained in:
Juan Martín Sotuyo Dodero
2019-02-05 22:49:53 -03:00
parent 709f9ed4ea
commit 58b52a4fd8

View File

@@ -1446,6 +1446,46 @@ public final class Test {
public String bar() throws Exception {
throw new Exception();
}
}
]]></code>
</test-code>
<test-code>
<description>Consecutive literal append over try</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>4</expected-linenumbers>
<code><![CDATA[
public final class Test {
public String foo() {
final StringBuilder sb = new StringBuilder();
sb.append("foo"); // violation here
try {
sb.append("bar");
final String res = methodThatMightThrow();
sb.append(res);
} catch (IOException ioe) {
// noop
}
}
}
]]></code>
</test-code>
<test-code>
<description>literal appends over lambdas</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public final class Test {
public String foo() {
final StringBuilder sb = new StringBuilder();
Runnable r = () -> sb.append("foo");
Runnable r2 = () -> sb.append("bar");
r.run();
System.out.println(sb.toString());
r2.run();
return sb.toString();
}
}
]]></code>
</test-code>