Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions 45 Tests/Rules/PlaceCloseBrace.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,49 @@ if ($true) {
$violations.Count | Should -Be 0
}
}

Context "When formatting presets handle if/else" {
BeforeAll {
$AllmanDefinition = @"
if (`$true)
{
'yes'
}
else
{
'no'
}
"@
$OTBSDefinition = @"
if (`$true) {
'yes'
} else {
'no'
}
"@
$StroustrupDefinition = @"
if (`$true) {
'yes'
}
else {
'no'
}
"@
Comment thread
o-l-a-v marked this conversation as resolved.
}

It "Allman should have all opening and closing braces on a new line" {
Invoke-Formatter -ScriptDefinition $OTBSDefinition -Settings 'CodeFormattingAllman' | Should -Be $AllmanDefinition
Invoke-Formatter -ScriptDefinition $StroustrupDefinition -Settings 'CodeFormattingAllman' | Should -Be $AllmanDefinition
}

It "OTBS should place else on same line as the if closing bracket" {
Invoke-Formatter -ScriptDefinition $AllmanDefinition -Settings 'CodeFormattingOTBS' | Should -Be $OTBSDefinition
Invoke-Formatter -ScriptDefinition $StroustrupDefinition -Settings 'CodeFormattingOTBS' | Should -Be $OTBSDefinition
}

It "Stroustrup should place else on a new line after the if closing bracket" {
Invoke-Formatter -ScriptDefinition $AllmanDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $StroustrupDefinition
Invoke-Formatter -ScriptDefinition $OTBSDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $StroustrupDefinition
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.