added test for rfe 537107, "public" in interface method

moved test input for "order of modifiers" to InputModifiers
to keep InputSimple simple
This commit is contained in:
Lars Kühne 2002-04-21 21:06:42 +00:00
parent caf539ded2
commit 206ff56be6
3 changed files with 57 additions and 17 deletions

View File

@ -378,9 +378,8 @@ public class CheckerTest
final String filepath = getPath("InputSimple.java");
assertNotNull(c);
final String[] expected = {
filepath + ":1: file length is 156 lines (max allowed is 20).",
filepath + ":1: file length is 146 lines (max allowed is 20).",
filepath + ":3: Line does not match expected header line of '// Created: 2001'.",
filepath + ":16: 'final' modifier out of order with the JLS suggestions.",
filepath + ":18: line longer than 80 characters",
filepath + ":19: line contains a tab character",
filepath + ":25: variable 'badConstant' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'.",
@ -406,9 +405,22 @@ public class CheckerTest
filepath + ":131: '{' should be on the previous line.",
filepath + ":132: variable 'InnerBlockVariable' must match pattern '^[a-z][a-zA-Z0-9]*$'.",
filepath + ":137: method name 'ALL_UPPERCASE_METHOD' must match pattern '^[a-z][a-zA-Z0-9]*$'.",
filepath + ":142: 'private' modifier out of order with the JLS suggestions.",
filepath + ":148: 'private' modifier out of order with the JLS suggestions.",
filepath + ":153: variable 'BAD__NAME' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'.",
filepath + ":142: variable 'BAD__NAME' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'.",
};
verify(c, filepath, expected);
}
public void testModifierChecks()
throws Exception
{
final Checker c = createChecker();
final String filepath = getPath("InputModifier.java");
assertNotNull(c);
final String[] expected = {
filepath + ":14: 'final' modifier out of order with the JLS suggestions.",
filepath + ":18: 'private' modifier out of order with the JLS suggestions.",
filepath + ":24: 'private' modifier out of order with the JLS suggestions.",
filepath + ":32: redundant 'public' modifier.",
};
verify(c, filepath, expected);
}
@ -494,6 +506,7 @@ public class CheckerTest
throws Exception
{
mConfig.setJavadocScope(Scope.PUBLIC);
mConfig.setIgnorePublicInInterface(true);
final Checker c = createChecker();
final String filepath = getPath("InputScopeInnerInterfaces.java");
assertNotNull(c);

View File

@ -0,0 +1,37 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
/**
* Test case for Modifier checks:
* - order of modifiers
* - use of 'public' in interface definition
* @author lkuehne
*/
strictfp final class InputModifier // illegal order of modifiers for class
{
/** Illegal order of modifiers for variables */
static private boolean sModifierOrderVar = false;
/**
* Illegal order of modifiers for methods. Make sure that the
* first and last modifier from the JLS sequence is used.
*/
strictfp private void doStuff()
{
}
/** holder for redundant 'public' modifier check. */
public interface InputRedundantPublicModifier
{
/** redundant 'public' modifier */
public void a();
/** all OK */
void b();
}
}

View File

@ -13,7 +13,7 @@ package com.puppycrawl.tools.checkstyle;
* - Order of modifiers
* @author Oliver Burn
**/
strictfp final class InputSimple // illegal order of modifiers for class
final class InputSimple
{
// Long line ----------------------------------------------------------------
// Contains a tab -> <-
@ -138,19 +138,9 @@ strictfp final class InputSimple // illegal order of modifiers for class
{
}
/** check illegal order of modifiers for variables */
static private boolean sModifierOrderVar = false;
/**
check illegal order of modifiers for methods, make sure that the
first and last modifier from the JLS sequence is used.
*/
strictfp private void doStuff()
{
}
/** test illegal constant **/
private static final int BAD__NAME = 3;
// A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$"
}