Add PSForEach and PSWhere as aliases for the PowerShell intrinsic methods Where and Foreach (#25511)

This commit is contained in:
Staffan Gustafsson
2025-05-05 17:13:02 -07:00
committed by GitHub
parent af831cde4a
commit 9cbbb8ff32
3 changed files with 30 additions and 7 deletions
@@ -200,6 +200,11 @@ Describe "Adapter Tests" -tags "CI" {
# TODO: dynamic method calls
}
It "Can use PSForEach as an alias for the Foreach magic method" {
$x = 5
$x.PSForEach({$_}) | Should -Be 5
}
}
Context "Where Magic Method Adapter Tests" {
@@ -240,6 +245,11 @@ Describe "Adapter Tests" -tags "CI" {
} -PassThru -Force
$x.Where(5) | Should -Be 10
}
It "Can use PSWhere as an alias for the Where magic method" {
$x = 5
$x.PSWhere{$true} | Should -Be 5
}
}
}