diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index 652fdb818..985925e07 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -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); diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputModifier.java b/src/tests/com/puppycrawl/tools/checkstyle/InputModifier.java new file mode 100644 index 000000000..ab54c5265 --- /dev/null +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputModifier.java @@ -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(); + } +} diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputSimple.java b/src/tests/com/puppycrawl/tools/checkstyle/InputSimple.java index 68667def2..0f1b60782 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/InputSimple.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputSimple.java @@ -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.*$" + }