@@ -143,4 +143,75 @@ $x = 1
143
143
$violations.Count | Should Be 0
144
144
}
145
145
}
146
- }
146
+
147
+ Context " When a comma is not followed by a space" {
148
+ BeforeAll {
149
+ $ruleConfiguration.CheckOpenBrace = $false
150
+ $ruleConfiguration.CheckOpenParen = $false
151
+ $ruleConfiguration.CheckOperator = $false
152
+ $ruleConfiguration.CheckSeparator = $true
153
+ }
154
+
155
+ It " Should find a violation" {
156
+ $def = @'
157
+ $x = @(1,2)
158
+ '@
159
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
160
+ $violations.Count | Should Be 1
161
+ }
162
+
163
+ It " Should not find a violation if a space follows a comma" {
164
+ $def = @'
165
+ $x = @(1, 2)
166
+ '@
167
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
168
+ $violations.Count | Should Be 0
169
+ }
170
+ }
171
+
172
+ Context " When a semi-colon is not followed by a space" {
173
+ BeforeAll {
174
+ $ruleConfiguration.CheckOpenBrace = $false
175
+ $ruleConfiguration.CheckOpenParen = $false
176
+ $ruleConfiguration.CheckOperator = $false
177
+ $ruleConfiguration.CheckSeparator = $true
178
+ }
179
+
180
+ It " Should find a violation" {
181
+ $def = @'
182
+ $x = @{a=1;b=2}
183
+ '@
184
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
185
+ $violations.Count | Should Be 1
186
+ }
187
+
188
+ It " Should not find a violation if a space follows a semi-colon" {
189
+ $def = @'
190
+ $x = @{a=1; b=2}
191
+ '@
192
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
193
+ $violations.Count | Should Be 0
194
+ }
195
+
196
+ It " Should not find a violation if a new-line follows a semi-colon" {
197
+ $def = @'
198
+ $x = @{
199
+ a=1;
200
+ b=2
201
+ }
202
+ '@
203
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
204
+ $violations.Count | Should Be 0
205
+ }
206
+
207
+ It " Should not find a violation if a end of input follows a semi-colon" {
208
+ $def = @'
209
+ $x = "abc";
210
+ '@
211
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
212
+ $violations.Count | Should Be 0
213
+ }
214
+
215
+
216
+ }
217
+ }
0 commit comments