Skip to content

Commit c08c0a3

Browse files
committed
Add tests for edge cases that are broken
1 parent 68336bd commit c08c0a3

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Tests/Rules/UseConsistentCasing.tests.ps1

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ Describe "UseConsistentCasing" {
4343

4444
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
4545
$violations.Count | Should -Be 2
46-
$violations[1].Extent.Text | Should -Be "-Split"
47-
$violations[1].SuggestedCorrections.Text | Should -Be "-split"
48-
$violations[0].Extent.Text | Should -Be "-Join"
49-
$violations[0].SuggestedCorrections.Text | Should -Be "-join"
46+
$violations[0].Extent.Text | Should -Be "-Split"
47+
$violations[0].SuggestedCorrections.Text | Should -Be "-split"
48+
$violations[1].Extent.Text | Should -Be "-Join"
49+
$violations[1].SuggestedCorrections.Text | Should -Be "-join"
5050
}
5151
}
5252

@@ -97,5 +97,32 @@ function Test-Case {
9797

9898
Invoke-FormatterAssertion @Formatter
9999
}
100+
101+
It "Handles -ISplit correctly" {
102+
$InconsistentlyCasedScript = '-Split "Hello World"'
103+
$ConsistentlyCasedScript = '-split "Hello World"'
104+
105+
$Formatter = @{
106+
Script = $InconsistentlyCasedScript
107+
Expected = $ConsistentlyCasedScript
108+
ViolationCount = 1
109+
Settings = $settings
110+
}
111+
112+
Invoke-FormatterAssertion @Formatter
113+
}
114+
It "[Regression] Does not break PlusPlus or MinusMinus" {
115+
$InconsistentlyCasedScript = '$A++; $B--'
116+
$ConsistentlyCasedScript = '$A++; $B--'
117+
118+
$Formatter = @{
119+
Script = $InconsistentlyCasedScript
120+
Expected = $ConsistentlyCasedScript
121+
ViolationCount = 0
122+
Settings = $settings
123+
}
124+
125+
Invoke-FormatterAssertion @Formatter
126+
}
100127
}
101128
}

0 commit comments

Comments
 (0)