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:
Allan Caplan
2006-10-15 00:31:11 +00:00
parent a9c8f02a94
commit bb7e04f5d7

View File

@ -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) {