Skip to content

Commit d961385

Browse files
AmitKumarDeoghoriaromani
authored andcommitted
Issue #13345: Enable examples tests for RegexpMultilineCheck
1 parent 7868e65 commit d961385

File tree

13 files changed

+407
-187
lines changed

13 files changed

+407
-187
lines changed

Diff for: src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckExamplesTest.java

+25-24
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
package com.puppycrawl.tools.checkstyle.checks.regexp;
2121

22-
import org.junit.jupiter.api.Disabled;
22+
import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck.MSG_ILLEGAL_REGEXP;
23+
2324
import org.junit.jupiter.api.Test;
2425

2526
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27+
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
2628

27-
@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
2829
public class RegexpMultilineCheckExamplesTest extends AbstractExamplesModuleTestSupport {
2930
@Override
3031
protected String getPackageLocation() {
@@ -33,55 +34,55 @@ protected String getPackageLocation() {
3334

3435
@Test
3536
public void testExample1() throws Exception {
36-
final String[] expected = {
37-
38-
};
39-
40-
verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
37+
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
38+
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
4139
}
4240

4341
@Test
4442
public void testExample2() throws Exception {
4543
final String[] expected = {
46-
44+
"14: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
45+
"16: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
46+
"20: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
47+
"24: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
48+
"29: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
49+
"31: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
50+
"33: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
51+
"36: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
52+
"38: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
53+
"40: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("),
4754
};
4855

49-
verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
56+
verifyWithInlineConfigParser(getPath("Example2.java"), expected);
5057
}
5158

5259
@Test
5360
public void testExample3() throws Exception {
5461
final String[] expected = {
55-
62+
"15: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.out.*?print\\("),
5663
};
5764

58-
verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
65+
verifyWithInlineConfigParser(getPath("Example3.java"), expected);
5966
}
6067

6168
@Test
6269
public void testExample4() throws Exception {
6370
final String[] expected = {
64-
71+
"40: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Test #[0-9]+:[A-Za-z ]+"),
72+
"42: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Test #[0-9]+:[A-Za-z ]+"),
6573
};
6674

67-
verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
75+
verifyWithInlineConfigParser(getPath("Example4.java"), expected);
6876
}
6977

7078
@Test
7179
public void testExample5() throws Exception {
7280
final String[] expected = {
73-
74-
};
75-
76-
verifyWithInlineConfigParser(getPath("Example5.txt"), expected);
77-
}
78-
79-
@Test
80-
public void testExample6() throws Exception {
81-
final String[] expected = {
82-
81+
"30: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Test #[0-9]+:[A-Za-z ]+"),
82+
"39: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Test #[0-9]+:[A-Za-z ]+"),
83+
"41: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Test #[0-9]+:[A-Za-z ]+"),
8384
};
8485

85-
verifyWithInlineConfigParser(getPath("Example6.txt"), expected);
86+
verifyWithInlineConfigParser(getPath("Example5.java"), expected);
8687
}
8788
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="RegexpMultiline"/>
4+
</module>
5+
*/
6+
package com.puppycrawl.tools.checkstyle.checks.regexp.regexpmultiline;
7+
8+
// xdoc section -- start
9+
class Example1 {
10+
void testMethod1() {
11+
12+
System.out.print("Example");
13+
14+
System.err.println("Example");
15+
System
16+
.out.print("Example");
17+
System
18+
.err.println("Example");
19+
System.
20+
out.print("Example");
21+
System.
22+
err.println("Example");
23+
}
24+
25+
void testMethod2() {
26+
27+
System.out.println("Test #1: this is a test string");
28+
29+
System.out.println("TeSt #2: This is a test string");
30+
31+
System.out.println("TEST #3: This is a test string");
32+
int i = 5;
33+
34+
System.out.println("Value of i: " + i);
35+
36+
System.out.println("Test #4: This is a test string");
37+
38+
System.out.println("TEst #5: This is a test string");
39+
}
40+
}
41+
// xdoc section -- end

Diff for: src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/regexp/regexpmultiline/Example1.txt

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="RegexpMultiline">
4+
<property name="format" value="System\.(out)|(err)\.print(ln)?\("/>
5+
</module>
6+
</module>
7+
*/
8+
package com.puppycrawl.tools.checkstyle.checks.regexp.regexpmultiline;
9+
10+
// xdoc section -- start
11+
class Example2 {
12+
void testMethod1() {
13+
// violation below, 'Line matches the illegal pattern'
14+
System.out.print("Example");
15+
// violation below, 'Line matches the illegal pattern'
16+
System.err.println("Example");
17+
System
18+
.out.print("Example");
19+
System
20+
.err.println("Example"); // violation, 'Line matches the illegal pattern'
21+
System.
22+
out.print("Example");
23+
System.
24+
err.println("Example"); // violation, 'Line matches the illegal pattern'
25+
}
26+
27+
void testMethod2() {
28+
// violation below, 'Line matches the illegal pattern'
29+
System.out.println("Test #1: this is a test string");
30+
// violation below, 'Line matches the illegal pattern'
31+
System.out.println("TeSt #2: This is a test string");
32+
// violation below, 'Line matches the illegal pattern'
33+
System.out.println("TEST #3: This is a test string");
34+
int i = 5;
35+
// violation below, 'Line matches the illegal pattern'
36+
System.out.println("Value of i: " + i);
37+
// violation below, 'Line matches the illegal pattern'
38+
System.out.println("Test #4: This is a test string");
39+
// violation below, 'Line matches the illegal pattern'
40+
System.out.println("TEst #5: This is a test string");
41+
}
42+
}
43+
// xdoc section -- end

Diff for: src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/regexp/regexpmultiline/Example2.txt

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="RegexpMultiline">
4+
<property name="matchAcrossLines" value="true"/>
5+
<property name="format" value="System\.out.*?print\("/>
6+
</module>
7+
</module>
8+
*/
9+
package com.puppycrawl.tools.checkstyle.checks.regexp.regexpmultiline;
10+
11+
// xdoc section -- start
12+
class Example3 {
13+
void testMethod1() {
14+
// violation below, 'Line matches the illegal pattern'
15+
System.out.print("Example");
16+
17+
System.err.println("Example");
18+
System
19+
.out.print("Example");
20+
System
21+
.err.println("Example");
22+
System.
23+
out.print("Example");
24+
System.
25+
err.println("Example");
26+
}
27+
28+
void testMethod2() {
29+
30+
System.out.println("Test #1: this is a test string");
31+
32+
System.out.println("TeSt #2: This is a test string");
33+
34+
System.out.println("TEST #3: This is a test string");
35+
int i = 5;
36+
37+
System.out.println("Value of i: " + i);
38+
39+
System.out.println("Test #4: This is a test string");
40+
41+
System.out.println("TEst #5: This is a test string");
42+
}
43+
}
44+
// xdoc section -- end

Diff for: src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/regexp/regexpmultiline/Example3.txt

-27
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="RegexpMultiline">
4+
<property name="format" value="Test #[0-9]+:[A-Za-z ]+"/>
5+
<property name="ignoreCase" value="true"/>
6+
<property name="maximum" value="3"/>
7+
</module>
8+
</module>
9+
*/
10+
package com.puppycrawl.tools.checkstyle.checks.regexp.regexpmultiline;
11+
12+
// xdoc section -- start
13+
class Example4 {
14+
void testMethod1() {
15+
16+
System.out.print("Example");
17+
18+
System.err.println("Example");
19+
System
20+
.out.print("Example");
21+
System
22+
.err.println("Example");
23+
System.
24+
out.print("Example");
25+
System.
26+
err.println("Example");
27+
}
28+
29+
void testMethod2() {
30+
31+
System.out.println("Test #1: this is a test string");
32+
33+
System.out.println("TeSt #2: This is a test string");
34+
35+
System.out.println("TEST #3: This is a test string");
36+
int i = 5;
37+
38+
System.out.println("Value of i: " + i);
39+
// violation below, 'Line matches the illegal pattern'
40+
System.out.println("Test #4: This is a test string");
41+
// violation below, 'Line matches the illegal pattern'
42+
System.out.println("TEst #5: This is a test string");
43+
}
44+
}
45+
// xdoc section -- end

Diff for: src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/regexp/regexpmultiline/Example4.txt

-21
This file was deleted.

0 commit comments

Comments
 (0)