@@ -541,11 +541,16 @@ using `
541541 It ' Should show multiple constructors in the tooltip' {
542542 $res = TabExpansion2 - inputScript ' class ConstructorTestClass{ConstructorTestClass ([string] $s){}ConstructorTestClass ([int] $i){}ConstructorTestClass ([int] $i, [bool]$b){}};[ConstructorTestClass]::new'
543543 $res.CompletionMatches | Should - HaveCount 1
544- $completionText = $res.CompletionMatches.ToolTip | Should - BeExactly @'
544+ $completionText = $res.CompletionMatches.ToolTip
545+ $completionText.replace (" `r`n " , [System.Environment ]::NewLine).trim()
546+
547+ $expected = @'
545548ConstructorTestClass(string s)
546549ConstructorTestClass(int i)
547550ConstructorTestClass(int i, bool b)
548551'@
552+ $expected.replace (" `r`n " , [System.Environment ]::NewLine).trim()
553+ $completionText.replace (" `r`n " , [System.Environment ]::NewLine).trim() | Should - BeExactly $expected
549554 }
550555
551556 It ' Should complete parameter in param block' {
@@ -1229,12 +1234,8 @@ class InheritedClassTest : System.Attribute
12291234 }
12301235
12311236 It " Tab completion UNC path" - Skip:(! $IsWindows ) {
1232- if (! $env: HOMEDRIVE ) {
1233- Set-ItResult - Skipped - Because " Homerdrive is not set"
1234- }
1235- $homeDrive = $env: HOMEDRIVE.Replace (" :" , " $" )
1236- $beforeTab = " \\localhost\$homeDrive \wind"
1237- $afterTab = " & '\\localhost\$homeDrive \Windows'"
1237+ $beforeTab = " \\localhost\ADMIN$\boo"
1238+ $afterTab = " & '\\localhost\ADMIN$\Boot'"
12381239 $res = TabExpansion2 - inputScript $beforeTab - cursorColumn $beforeTab.Length
12391240 $res.CompletionMatches.Count | Should - BeGreaterThan 0
12401241 $res.CompletionMatches [0 ].CompletionText | Should - BeExactly $afterTab
@@ -2101,7 +2102,7 @@ dir -Recurse `
21012102
21022103 Context " Tab completion help test" {
21032104 BeforeAll {
2104- if ([ System.Management.Automation.Platform ]:: IsWindows) {
2105+ if ($ IsWindows ) {
21052106 $userHelpRoot = Join-Path $HOME " Documents/PowerShell/Help/"
21062107 } else {
21072108 $userModulesRoot = [System.Management.Automation.Platform ]::SelectProductNameForDirectory([System.Management.Automation.Platform + XDG _Type ]::USER_MODULES)
@@ -2110,33 +2111,89 @@ dir -Recurse `
21102111 }
21112112
21122113 It ' Should complete about help topic' {
2113- $aboutHelpPathUserScope = Join-Path $userHelpRoot (Get-Culture ).Name
2114- $aboutHelpPathAllUsersScope = Join-Path $PSHOME (Get-Culture ).Name
2114+ $helpName = " about_Splatting"
2115+ $helpFileName = " ${helpName} .help.txt"
2116+ $inputScript = " get-help about_spla"
2117+ $culture = " en-US"
2118+ $aboutHelpPathUserScope = Join-Path $userHelpRoot $culture
2119+ $aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture
2120+ $expectedCompletionCount = 0
21152121
21162122 # # If help content does not exist, tab completion will not work. So update it first.
2117- $userScopeHelp = Test-Path (Join-Path $aboutHelpPathUserScope " about_Splatting.help.txt" )
2118- $allUserScopeHelp = Test-Path (Join-Path $aboutHelpPathAllUsersScope " about_Splatting.help.txt" )
2119- if ((-not $userScopeHelp ) -and (-not $aboutHelpPathAllUsersScope )) {
2123+ $userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName
2124+ $userScopeHelp = Test-Path $userHelpPath
2125+ if ($userScopeHelp ) {
2126+ $expectedCompletionCount ++
2127+ } else {
21202128 Update-Help - Force - ErrorAction SilentlyContinue - Scope ' CurrentUser'
2129+ if (Test-Path $userHelpPath ) {
2130+ $expectedCompletionCount ++
2131+ }
21212132 }
21222133
2123- # If help content is present on both scopes, expect 2 or else expect 1 completion.
2124- $expectedCompletions = if ($userScopeHelp -and $allUserScopeHelp ) { 2 } else { 1 }
2134+ $allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName )
2135+ if ($allUserScopeHelpPath ) {
2136+ $expectedCompletionCount ++
2137+ }
21252138
2126- $res = TabExpansion2 - inputScript ' get-help about_spla ' - cursorColumn ' get-help about_spla ' .Length
2127- $res.CompletionMatches | Should - HaveCount $expectedCompletions
2128- $res.CompletionMatches [0 ].CompletionText | Should - BeExactly ' about_Splatting '
2139+ $res = TabExpansion2 - inputScript $inputScript - cursorColumn $inputScript .Length
2140+ $res.CompletionMatches | Should - HaveCount $expectedCompletionCount
2141+ $res.CompletionMatches [0 ].CompletionText | Should - BeExactly $helpName
21292142 }
2143+
21302144 It ' Should complete about help topic regardless of culture' {
21312145 try
21322146 {
21332147 # # Save original culture and temporarily set it to da-DK because there's no localized help for da-DK.
21342148 $OriginalCulture = [cultureinfo ]::CurrentCulture
2135- [cultureinfo ]::CurrentCulture= " da-DK"
2149+ $defaultCulture = " en-US"
2150+ $culture = " da-DK"
2151+ [cultureinfo ]::CurrentCulture = $culture
2152+ $helpName = " about_Splatting"
2153+ $helpFileName = " ${helpName} .help.txt"
2154+
2155+ $aboutHelpPathUserScope = Join-Path $userHelpRoot $culture
2156+ $aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture
2157+ $expectedCompletionCount = 0
2158+
2159+ # # If help content does not exist, tab completion will not work. So update it first.
2160+ $userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName
2161+ $userScopeHelp = Test-Path $userHelpPath
2162+ if ($userScopeHelp ) {
2163+ $expectedCompletionCount ++
2164+ }
2165+ else { Update-Help - Force - ErrorAction SilentlyContinue - Scope ' CurrentUser'
2166+ if (Test-Path $userHelpPath ) {
2167+ $expectedCompletionCount ++
2168+ }
2169+ else {
2170+ $aboutHelpPathUserScope = Join-Path $userHelpRoot $defaultCulture
2171+ $aboutHelpPathAllUsersScope = Join-Path $PSHOME $defaultCulture
2172+ $userHelpDefaultPath = Join-Path $aboutHelpPathUserScope $helpFileName
2173+ $userDefaultScopeHelp = Test-Path $userHelpDefaultPath
2174+
2175+ if ($userDefaultScopeHelp ) {
2176+ $expectedCompletionCount ++
2177+ }
2178+ }
2179+ }
2180+
2181+ $allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName )
2182+ if ($allUserScopeHelpPath ) {
2183+ $expectedCompletionCount ++
2184+ }
2185+ else {
2186+ $aboutHelpPathAllUsersDefaultScope = Join-Path $PSHOME $defaultCulture
2187+ $allUsersDefaultScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersDefaultScope $helpFileName )
2188+
2189+ if ($allUsersDefaultScopeHelpPath ) {
2190+ $expectedCompletionCount ++
2191+ }
2192+ }
21362193
21372194 $res = TabExpansion2 - inputScript ' get-help about_spla' - cursorColumn ' get-help about_spla' .Length
2138- $res.CompletionMatches | Should - HaveCount 1
2139- $res.CompletionMatches [0 ].CompletionText | Should - BeExactly ' about_Splatting '
2195+ $res.CompletionMatches | Should - HaveCount $expectedCompletionCount
2196+ $res.CompletionMatches [0 ].CompletionText | Should - BeExactly $helpName
21402197 }
21412198 finally
21422199 {
@@ -2351,7 +2408,7 @@ function MyFunction ($param1, $param2)
23512408
23522409Describe " Tab completion tests with remote Runspace" - Tags Feature, RequireAdminOnWindows {
23532410 BeforeAll {
2354- if ($IsWindows ) {
2411+ if ($IsWindows -and -not ( Test-IsWinWow64 ) ) {
23552412 $session = New-RemoteSession
23562413 $powershell = [powershell ]::Create()
23572414 $powershell.Runspace = $session.Runspace
0 commit comments