[c#] CPD suppression with comments doesn't work #2551

CPD Suppressions for c# fixed
test added
This commit is contained in:
LixonLookose
2020-06-04 17:53:22 +05:30
parent bc4a1d67eb
commit c7c31be6cc
2 changed files with 13 additions and 1 deletions

View File

@@ -78,6 +78,18 @@ public class CsTokenizerTest {
assertEquals(5, tokens.size());
}
@Test
public void testIgnoreBetweenSpecialComments() {
tokenizer
.tokenize(
toSourceCode("// CPD-OFF\n" + "class Foo {\n" + " void bar() {\n" + " int a = 1 >> 2; \n"
+ " a += 1; \n" + " a++; \n" + " a /= 3e2; \n" + " float f = -3.1; \n"
+ " f *= 2; \n" + " bool b = ! (f == 2.0 || f >= 1.0 && f <= 2.0) \n"
+ " }\n" + "// CPD-ON\n" + "}"),
tokens);
assertEquals(2, tokens.size()); // "}" + EOF
}
@Test
public void testCommentsIgnored3() {
tokenizer.tokenize(toSourceCode("class Foo { /// class X /* aaa */ \n }"), tokens);