24
24
25
25
class TooManyParametersCheckTest {
26
26
@ Test
27
- void testOneVariableShouldNotAddIssue () {
27
+ void testImplOkParamsShouldNotAddIssue () {
28
28
CheckVerifier .newVerifier ()
29
29
.withCheck (new TooManyParametersCheck ())
30
30
.onFile (
@@ -37,7 +37,7 @@ void testOneVariableShouldNotAddIssue() {
37
37
}
38
38
39
39
@ Test
40
- void testTooManyVariablesShouldAddIssue () {
40
+ void testImplOnlyTooManyParamsShouldAddIssue () {
41
41
CheckVerifier .newVerifier ()
42
42
.withCheck (new TooManyParametersCheck ())
43
43
.onFile (
@@ -57,4 +57,144 @@ void testTooManyVariablesShouldAddIssue() {
57
57
.appendImpl ("end;" ))
58
58
.verifyIssues ();
59
59
}
60
+
61
+ @ Test
62
+ void testImplAndDeclTooManyParamsShouldAddIssue () {
63
+ CheckVerifier .newVerifier ()
64
+ .withCheck (new TooManyParametersCheck ())
65
+ .onFile (
66
+ new DelphiTestUnitBuilder ()
67
+ .appendDecl ("procedure Foo( // Noncompliant" )
68
+ .appendDecl (" Param1: Boolean;" )
69
+ .appendDecl (" Param2: Boolean;" )
70
+ .appendDecl (" Param3: Boolean;" )
71
+ .appendDecl (" Param4: Boolean;" )
72
+ .appendDecl (" Param5: Boolean;" )
73
+ .appendDecl (" Param6: Boolean;" )
74
+ .appendDecl (" Param7: Boolean;" )
75
+ .appendDecl (" Param8: Boolean" )
76
+ .appendDecl (");" )
77
+ .appendImpl ("procedure Foo(" )
78
+ .appendImpl (" Param1: Boolean;" )
79
+ .appendImpl (" Param2: Boolean;" )
80
+ .appendImpl (" Param3: Boolean;" )
81
+ .appendImpl (" Param4: Boolean;" )
82
+ .appendImpl (" Param5: Boolean;" )
83
+ .appendImpl (" Param6: Boolean;" )
84
+ .appendImpl (" Param7: Boolean;" )
85
+ .appendImpl (" Param8: Boolean" )
86
+ .appendImpl (");" )
87
+ .appendImpl ("begin" )
88
+ .appendImpl (" // do nothing" )
89
+ .appendImpl ("end;" ))
90
+ .verifyIssues ();
91
+ }
92
+
93
+ @ Test
94
+ void testImplAndDeclOkParamsShouldNotAddIssue () {
95
+ CheckVerifier .newVerifier ()
96
+ .withCheck (new TooManyParametersCheck ())
97
+ .onFile (
98
+ new DelphiTestUnitBuilder ()
99
+ .appendDecl ("procedure Foo(" )
100
+ .appendDecl (" Param1: Boolean;" )
101
+ .appendDecl (" Param2: Boolean" )
102
+ .appendDecl (");" )
103
+ .appendImpl ("procedure Foo(" )
104
+ .appendImpl (" Param1: Boolean;" )
105
+ .appendImpl (" Param2: Boolean" )
106
+ .appendImpl (");" )
107
+ .appendImpl ("begin" )
108
+ .appendImpl (" // do nothing" )
109
+ .appendImpl ("end;" ))
110
+ .verifyNoIssues ();
111
+ }
112
+
113
+ @ Test
114
+ void testDeclOnlyTooManyParamsShouldAddIssue () {
115
+ CheckVerifier .newVerifier ()
116
+ .withCheck (new TooManyParametersCheck ())
117
+ .onFile (
118
+ new DelphiTestUnitBuilder ()
119
+ .appendDecl ("procedure Foo( // Noncompliant" )
120
+ .appendDecl (" Param1: Boolean;" )
121
+ .appendDecl (" Param2: Boolean;" )
122
+ .appendDecl (" Param3: Boolean;" )
123
+ .appendDecl (" Param4: Boolean;" )
124
+ .appendDecl (" Param5: Boolean;" )
125
+ .appendDecl (" Param6: Boolean;" )
126
+ .appendDecl (" Param7: Boolean;" )
127
+ .appendDecl (" Param8: Boolean" )
128
+ .appendDecl (");" ))
129
+ .verifyIssues ();
130
+ }
131
+
132
+ @ Test
133
+ void testInterfaceTooManyParamsShouldAddIssue () {
134
+ CheckVerifier .newVerifier ()
135
+ .withCheck (new TooManyParametersCheck ())
136
+ .onFile (
137
+ new DelphiTestUnitBuilder ()
138
+ .appendDecl ("type IMyIntf = interface" )
139
+ .appendDecl (" procedure Foo( // Noncompliant" )
140
+ .appendDecl (" Param1: Boolean;" )
141
+ .appendDecl (" Param2: Boolean;" )
142
+ .appendDecl (" Param3: Boolean;" )
143
+ .appendDecl (" Param4: Boolean;" )
144
+ .appendDecl (" Param5: Boolean;" )
145
+ .appendDecl (" Param6: Boolean;" )
146
+ .appendDecl (" Param7: Boolean;" )
147
+ .appendDecl (" Param8: Boolean" )
148
+ .appendDecl (" );" )
149
+ .appendDecl ("end;" ))
150
+ .verifyIssues ();
151
+ }
152
+
153
+ @ Test
154
+ void testConstructorTooManyParamsShouldAddIssue () {
155
+ var check = new TooManyParametersCheck ();
156
+ check .max = 9999 ;
157
+
158
+ CheckVerifier .newVerifier ()
159
+ .withCheck (new TooManyParametersCheck ())
160
+ .onFile (
161
+ new DelphiTestUnitBuilder ()
162
+ .appendDecl ("type TMyObj = class(TObject)" )
163
+ .appendDecl (" constructor Create( // Noncompliant" )
164
+ .appendDecl (" Param1: Boolean;" )
165
+ .appendDecl (" Param2: Boolean;" )
166
+ .appendDecl (" Param3: Boolean;" )
167
+ .appendDecl (" Param4: Boolean;" )
168
+ .appendDecl (" Param5: Boolean;" )
169
+ .appendDecl (" Param6: Boolean;" )
170
+ .appendDecl (" Param7: Boolean;" )
171
+ .appendDecl (" Param8: Boolean" )
172
+ .appendDecl (" );" )
173
+ .appendDecl ("end;" ))
174
+ .verifyIssues ();
175
+ }
176
+
177
+ @ Test
178
+ void testNonConstructorTooManyParamsShouldAddIssue () {
179
+ var check = new TooManyParametersCheck ();
180
+ check .constructorMax = 9999 ;
181
+
182
+ CheckVerifier .newVerifier ()
183
+ .withCheck (new TooManyParametersCheck ())
184
+ .onFile (
185
+ new DelphiTestUnitBuilder ()
186
+ .appendDecl ("type TMyObj = class(TObject)" )
187
+ .appendDecl (" procedure Create( // Noncompliant" )
188
+ .appendDecl (" Param1: Boolean;" )
189
+ .appendDecl (" Param2: Boolean;" )
190
+ .appendDecl (" Param3: Boolean;" )
191
+ .appendDecl (" Param4: Boolean;" )
192
+ .appendDecl (" Param5: Boolean;" )
193
+ .appendDecl (" Param6: Boolean;" )
194
+ .appendDecl (" Param7: Boolean;" )
195
+ .appendDecl (" Param8: Boolean" )
196
+ .appendDecl (" );" )
197
+ .appendDecl ("end;" ))
198
+ .verifyIssues ();
199
+ }
60
200
}
0 commit comments