From 2e6c22a86c2dce91f16d77652c6c7b3e1222a955 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Sat, 3 Sep 2016 03:24:53 +0200 Subject: [PATCH] fix negative values in switch/cases, fixes #280 --- src/checkstyle/token/TokenStream.hx | 2 +- test/checks/whitespace/OperatorWhitespaceCheckTest.hx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/checkstyle/token/TokenStream.hx b/src/checkstyle/token/TokenStream.hx index 3ccae0da..524ad70d 100644 --- a/src/checkstyle/token/TokenStream.hx +++ b/src/checkstyle/token/TokenStream.hx @@ -196,7 +196,7 @@ class TokenStream { var prevTok:Token = tokens[previous]; switch (prevTok.tok) { case Binop(_), Unop(_), BkOpen, POpen, Comma, DblDot, IntInterval(_), Question: - case Kwd(KwdReturn), Kwd(KwdIf), Kwd(KwdElse), Kwd(KwdWhile), Kwd(KwdDo), Kwd(KwdFor): + case Kwd(KwdReturn), Kwd(KwdIf), Kwd(KwdElse), Kwd(KwdWhile), Kwd(KwdDo), Kwd(KwdFor), Kwd(KwdCase): default: return new TokenTree(tok.tok, tok.pos, tok.index); } diff --git a/test/checks/whitespace/OperatorWhitespaceCheckTest.hx b/test/checks/whitespace/OperatorWhitespaceCheckTest.hx index 6ddbeacb..0f5fde9a 100644 --- a/test/checks/whitespace/OperatorWhitespaceCheckTest.hx +++ b/test/checks/whitespace/OperatorWhitespaceCheckTest.hx @@ -193,6 +193,11 @@ abstract OperatorWhitespaceCheckTests(String) to String { z: 20 * 10 }; var y:Array = []; + + switch int() { + case -1: + default: + } } }