Split test cases for granularity

This commit is contained in:
Juan Martín Sotuyo Dodero
2019-02-09 13:10:41 -03:00
parent 74d45a90f0
commit 189c5990f4
2 changed files with 23 additions and 8 deletions

View File

@ -2110,7 +2110,7 @@ which makes the code also more readable.
**This rule is defined by the following XPath expression:**
``` xpath
//VariableInitializer
//VariableInitializer[preceding-sibling::VariableDeclaratorId[1]/@TypeInferred="false"]
//PrimaryExpression[not(PrimarySuffix)]
[not(ancestor::ArgumentList)]
/PrimaryPrefix/AllocationExpression[ClassOrInterfaceType[@AnonymousClass='false']/TypeArguments//ReferenceType[not(.//TypeArguments)]]

View File

@ -61,18 +61,33 @@ public class Foo {
</test-code>
<test-code>
<description>#1624[java] UseDiamondOperator doesn't work with var</description>
<expected-problems>2</expected-problems>
<expected-linenumbers>6,7</expected-linenumbers>
<expected-problems>1</expected-problems>
<expected-linenumbers>6</expected-linenumbers>
<code><![CDATA[
import java.util.ArrayList;
public class Buzz {
public void buzz() {
var f = new ArrayList<String>();
f = new ArrayList<>();
f = new ArrayList<String>(); // flagged by rule
List<String> foo, bar = new ArrayList<String>(), baz = new ArrayList<>(); //flagged only once
var f = new ArrayList<String>(); // ok
f = new ArrayList<>(); // ok
f = new ArrayList<String>(); // flagged by rule
}
}
]]></code>
</test-code>
</test-data>
<test-code>
<description>Multiple initializations in a single declaration</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>6</expected-linenumbers>
<code><![CDATA[
import java.util.ArrayList;
import java.util.List;
public class Buzz {
public void buzz() {
List<String> foo,
bar = new ArrayList<String>(), // flagged
baz = new ArrayList<>(); // ok
}
}
]]></code>
</test-code>
</test-data>