File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -383,4 +383,49 @@ if ($true) {
383383 $violations.Count | Should -Be 0
384384 }
385385 }
386+
387+ Context "When formatting presets handles if else" {
388+ BeforeAll {
389+ $AllmanDefinition = @"
390+ if (`$true)
391+ {
392+ 'yes'
393+ }
394+ else
395+ {
396+ 'no'
397+ }
398+ "@
399+ $OTBSDefinition = @"
400+ if (`$true) {
401+ 'yes'
402+ } else {
403+ 'no'
404+ }
405+ "@
406+ $StroustrupDefinition = @"
407+ if (`$true) {
408+ 'yes'
409+ }
410+ else {
411+ 'no'
412+ }
413+ "@
414+ }
415+
416+ It "Allman should have all opening and closing braces on a new line" {
417+ Invoke-Formatter -ScriptDefinition $OTBSDefinition -Settings 'CodeFormattingAllman' | Should -Be $AllmanDefinition
418+ Invoke-Formatter -ScriptDefinition $StroustrupDefinition -Settings 'CodeFormattingAllman' | Should -Be $AllmanDefinition
419+ }
420+
421+ It "OTBS should place else on same line as the if closing bracket" {
422+ Invoke-Formatter -ScriptDefinition $AllmanDefinition -Settings 'CodeFormattingOTBS' | Should -Be $OTBSDefinition
423+ Invoke-Formatter -ScriptDefinition $StroustrupDefinition -Settings 'CodeFormattingOTBS' | Should -Be $OTBSDefinition
424+ }
425+
426+ It "Stroustrup should place else on a new line after the if closing bracket" {
427+ Invoke-Formatter -ScriptDefinition $AllmanDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $StroustrupDefinition
428+ Invoke-Formatter -ScriptDefinition $OTBSDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $StroustrupDefinition
429+ }
430+ }
386431}
You can’t perform that action at this time.
0 commit comments