diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/java14.g b/src/checkstyle/com/puppycrawl/tools/checkstyle/java14.g index 897ae9dcb..837a9bcbb 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/java14.g +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/java14.g @@ -53,7 +53,13 @@ assertStatement[int[] aType, MyCommonAST[] aCurlies] final MyCommonAST[] stmtBraces = new MyCommonAST[2]; stmtType[0] = STMT_OTHER; } - : ASSERT^ expression ( COLON! expression )? SEMI! + : asrt:ASSERT^ expression ( c:COLON! expression )? SEMI! + { + ver.verifyWSAroundBegin(asrt.getLine(), asrt.getColumn(), asrt.getText()); + if (c != null) { + ver.verifyWSAroundBegin(c.getLine(), c.getColumn(), c.getText()); + } + } ; class GeneratedJava14Lexer extends GeneratedJavaLexer; diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index 135d43a1b..6420f817f 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -141,6 +141,9 @@ public class CheckerTest filepath + ":129: '.' is followed by whitespace.", filepath + ":136: '.' is preceeded with whitespace.", filepath + ":136: '.' is followed by whitespace.", + filepath + ":153: 'assert' is not followed by whitespace.", + filepath + ":156: ':' is not preceeded with whitespace.", + filepath + ":156: ':' is not followed by whitespace.", }; verify(c, filepath, expected); } @@ -202,6 +205,9 @@ public class CheckerTest filepath + ":129: '.' is followed by whitespace.", filepath + ":136: '.' is preceeded with whitespace.", filepath + ":136: '.' is followed by whitespace.", + filepath + ":153: 'assert' is not followed by whitespace.", + filepath + ":156: ':' is not preceeded with whitespace.", + filepath + ":156: ':' is not followed by whitespace.", }; verify(c, filepath, expected); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java b/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java index ad4a8be66..050b50053 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java @@ -149,12 +149,10 @@ class InputWhitespace // evil colons, should be OK assert "OK".equals(null) ? false : true : "Whups"; - // WS tests for assert not implemented yet - // missing WS around assert - // assert(true); + assert(true); // missing WS around colon - // assert true:"Whups"; + assert true:"Whups"; } }