forked from phoedos/pmd
Tweaking JUnit tests to be more complete
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4660 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -18,6 +18,8 @@ public class ConfusingTernaryRuleTest extends SimpleAggregatorTst {
|
||||
runTests(new TestDescriptor[]{
|
||||
new TestDescriptor(TEST1, "!=, bad", 1, rule),
|
||||
new TestDescriptor(TEST2, "==, good", 0, rule),
|
||||
new TestDescriptor(TEST3, "!= inside if, bad", 2, rule),
|
||||
new TestDescriptor(TEST4, "match && match, not confusing, OK", 0, rule),
|
||||
});
|
||||
}
|
||||
|
||||
@ -35,6 +37,24 @@ public class ConfusingTernaryRuleTest extends SimpleAggregatorTst {
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" void bar() {" + PMD.EOL +
|
||||
" if(true){" + PMD.EOL +
|
||||
" x = a != b ? c : d;" + PMD.EOL +
|
||||
" } else {" + PMD.EOL +
|
||||
" x = a != b ? c : d;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" void bar() {" + PMD.EOL +
|
||||
" x = ((x && y) ? y : z);" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
/*
|
||||
public class BadTernaries {
|
||||
public static void main(String[] args) {
|
||||
|
Reference in New Issue
Block a user