File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -199,4 +199,59 @@ Some-Command -Param1 @{
199
199
$violations.Count | Should Be 0
200
200
}
201
201
}
202
+
203
+ Context " When a close brace should be followed by a new line" {
204
+ BeforeAll {
205
+ $ruleConfiguration .' NoEmptyLineBefore' = $false
206
+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
207
+ $ruleConfiguration .' NewLineAfter' = $false
208
+ }
209
+
210
+ It " Should find a violation if a branching statement is on a new line if open brance is on same line" {
211
+ $def = @'
212
+ if ($true) {
213
+ $true
214
+ }
215
+ else {
216
+ $false
217
+ }
218
+ '@
219
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
220
+ $violations.Count | Should Be 1
221
+ }
222
+
223
+ It " Should not find a violation if a branching statement is on a new line if open brance is not on same line" {
224
+ $def = @'
225
+ if ($true)
226
+ {
227
+ $true
228
+ }
229
+ else
230
+ {
231
+ $false
232
+ }
233
+ '@
234
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
235
+ $violations.Count | Should Be 0
236
+ }
237
+
238
+ It " Should correct violation by cuddling the else branch statement" {
239
+ $def = @'
240
+ if ($true) {
241
+ $true
242
+ }
243
+ else {
244
+ $false
245
+ }
246
+ '@
247
+ $expected = @'
248
+ if ($true) {
249
+ $true
250
+ } else {
251
+ $false
252
+ }
253
+ '@
254
+ Invoke-Formatter - ScriptDefinition $def - Settings $settings | Should Be $expected
255
+ }
256
+ }
202
257
}
You can’t perform that action at this time.
0 commit comments