Skip to content

Commit 60774d2

Browse files
author
Kapil Borle
committed
Add test case to check indenation after backtick
1 parent 141e109 commit 60774d2

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Tests/Rules/UseConsistentIndentation.tests.ps1

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
Import-Module PSScriptAnalyzer
1+
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
2+
$testRootDirectory = Split-Path -Parent $directory
3+
4+
Import-Module PSScriptAnalyzer
5+
Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
6+
7+
$indentationUnit = ' '
8+
$indentationSize = 4
29
$settings = @{
310
IncludeRules = @("PSUseConsistentIndentation")
411
Rules = @{
@@ -143,5 +150,22 @@ select Name,Id |
143150
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
144151
$violations.Count | Should Be 3
145152
}
153+
154+
It "Should indent properly after line continuation (backtick) character" {
155+
$def = @'
156+
$x = "this " + `
157+
"Should be indented properly"
158+
'@
159+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
160+
$violations.Count | Should Be 1
161+
$params = @{
162+
RawContent = $def
163+
DiagnosticRecord = $violations[0]
164+
CorrectionsCount = 1
165+
ViolationText = "`"Should be indented properly`""
166+
CorrectionText = (New-Object -TypeName String -ArgumentList $indentationUnit,$indentationSize) + "`"Should be indented properly`""
167+
}
168+
Test-CorrectionExtentFromContent @params
169+
}
146170
}
147171
}

0 commit comments

Comments
 (0)