File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -383,4 +383,54 @@ 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+ $OTPSAndStroustrupDefinition = @"
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 $OTPSAndStroustrupDefinition - 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 $OTPSAndStroustrupDefinition - Settings ' CodeFormattingOTBS' | Should - Be $OTBSDefinition
424+ }
425+
426+ It " OTPS should place else on a new line after the if closing bracket" {
427+ Invoke-Formatter - ScriptDefinition $AllmanDefinition - Settings ' CodeFormattingOTPS' | Should - Be $OTPSAndStroustrupDefinition
428+ Invoke-Formatter - ScriptDefinition $OTBSDefinition - Settings ' CodeFormattingOTPS' | Should - Be $OTPSAndStroustrupDefinition
429+ }
430+
431+ It " Stroustrup should place else on a new line after the if closing bracket" {
432+ Invoke-Formatter - ScriptDefinition $AllmanDefinition - Settings ' CodeFormattingStroustrup' | Should - Be $OTPSAndStroustrupDefinition
433+ Invoke-Formatter - ScriptDefinition $OTBSDefinition - Settings ' CodeFormattingStroustrup' | Should - Be $OTPSAndStroustrupDefinition
434+ }
435+ }
386436}
You can’t perform that action at this time.
0 commit comments