mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
The following experimental features are made stable: - PSNativeWindowsTildeExpansion - PSRedirectToVariable - PSSubsystemPluginModel
33 lines
1.3 KiB
PowerShell
33 lines
1.3 KiB
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
Describe 'Native Windows tilde expansion tests' -tags "CI" {
|
|
BeforeAll {
|
|
$originalDefaultParams = $PSDefaultParameterValues.Clone()
|
|
$PSDefaultParameterValues["it:skip"] = -Not $IsWindows
|
|
}
|
|
|
|
AfterAll {
|
|
$global:PSDefaultParameterValues = $originalDefaultParams
|
|
}
|
|
|
|
# Test ~ expansion
|
|
It 'Tilde should be replaced by the filesystem provider home directory' {
|
|
cmd /c echo ~ | Should -BeExactly ($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)
|
|
}
|
|
# Test ~ expansion with a path fragment (e.g. ~/foo)
|
|
It '~/foo should be replaced by the <filesystem provider home directory>/foo' {
|
|
cmd /c echo ~/foo | Should -BeExactly "$($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)/foo"
|
|
cmd /c echo ~\foo | Should -BeExactly "$($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)\foo"
|
|
}
|
|
|
|
It '~ should not be replaced when quoted' {
|
|
cmd /c echo '~' | Should -BeExactly '~'
|
|
cmd /c echo "~" | Should -BeExactly '~'
|
|
cmd /c echo '~/foo' | Should -BeExactly '~/foo'
|
|
cmd /c echo "~/foo" | Should -BeExactly '~/foo'
|
|
cmd /c echo '~\foo' | Should -BeExactly '~\foo'
|
|
cmd /c echo "~\foo" | Should -BeExactly '~\foo'
|
|
}
|
|
}
|