Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,16 @@ try
}
)

$result = $data.foreach('value1')
$result = $data.ForEach('value1')
Write-Output $result

# Execute method in scriptblock of foreach operator, should throw in ConstrainedLanguage mode.
$data.foreach{[system.io.path]::GetRandomFileName().Length}
# Execute method in scriptblock of ForEach operator, should throw in ConstrainedLanguage mode.
$data.ForEach{[system.io.path]::GetRandomFileName().Length}
'@

$script3 = @'
# Method call should throw error.
(Get-Process powershell*).Foreach('GetHashCode')
(Get-Process powershell*).ForEach('GetHashCode')
'@

$script4 = @'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ Describe "Join-String" -Tags "CI" {
}

It "Should join property values SingleQuoted" {
$expected = ($testObject.Name).Foreach{"'$_'"} -join "; "
$expected = ($testObject.Name).ForEach{"'$_'"} -join "; "
$actual = $testObject | Join-String -Property Name -Separator "; " -SingleQuote
$actual | Should -BeExactly $expected
}

It "Should join property values DoubleQuoted" {
$expected = ($testObject.Name).Foreach{"""$_"""} -join "; "
$expected = ($testObject.Name).ForEach{"""$_"""} -join "; "
$actual = $testObject | Join-String -Property Name -Separator "; " -DoubleQuote
$actual | Should -BeExactly $expected
}

It "Should join property values Formatted" {
$expected = ($testObject.Name).Foreach{"[$_]"} -join "; "
$expected = ($testObject.Name).ForEach{"[$_]"} -join "; "
$actual = $testObject | Join-String -Property Name -Separator "; " -Format "[{0}]"
$actual | Should -BeExactly $expected
}
Expand All @@ -70,20 +70,20 @@ Describe "Join-String" -Tags "CI" {

It "Should join script block results SingleQuoted" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb).Foreach{"'$_'"} -join $ofs
$expected = ($testObject | ForEach-Object $sb).ForEach{"'$_'"} -join $ofs
$actual = $testObject | Join-String -Property $sb -SingleQuote
$actual | Should -BeExactly $expected
}
It "Should join script block results DoubleQuoted" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb).Foreach{"""$_"""} -join $ofs
$expected = ($testObject | ForEach-Object $sb).ForEach{"""$_"""} -join $ofs
$actual = $testObject | Join-String -Property $sb -DoubleQuote
$actual | Should -BeExactly $expected
}

It "Should join script block results with Format and separator" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb).Foreach{"[{0}]" -f $_} -join "; "
$expected = ($testObject | ForEach-Object $sb).ForEach{"[{0}]" -f $_} -join "; "
$actual = $testObject | Join-String -Property $sb -Separator "; " -Format "[{0}]"
$actual | Should -BeExactly $expected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ Describe "Measure-Object DRT basic functionality" -Tags "CI" {
}

It "Test-PropertyExpression function with a wildcard property expression should sum numbers" {
$result = (1..10).foreach{@{value = $_}} | Test-PSPropertyExpression val*
$result = (1..10).ForEach{@{value = $_}} | Test-PSPropertyExpression val*
$result | Should -Be 55
}

Expand Down Expand Up @@ -484,7 +484,7 @@ Describe "Directly test the PSPropertyExpression type" -Tags "CI" {
}

It "Test-PropertyExpression function with a wildcard property expression should sum numbers" {
$result = (1..10).foreach{@{value = $_}} | Test-PSPropertyExpression val*
$result = (1..10).ForEach{@{value = $_}} | Test-PSPropertyExpression val*
$result | Should -Be 55
}

Expand Down Expand Up @@ -558,7 +558,7 @@ Describe "Directly test the PSPropertyExpression type" -Tags "CI" {
}

It "Test-PropertyExpression function with a wildcard property expression should sum numbers" {
$result = (1..10).foreach{@{value = $_}} | Test-PSPropertyExpression val*
$result = (1..10).ForEach{@{value = $_}} | Test-PSPropertyExpression val*
$result | Should -Be 55
}

Expand Down Expand Up @@ -631,7 +631,7 @@ Describe "Directly test the PSPropertyExpression type" -Tags "CI" {
}

It "Test-PropertyExpression function with a wildcard property expression should sum numbers" {
$result = (1..10).foreach{@{value = $_}} | Test-PSPropertyExpression val*
$result = (1..10).ForEach{@{value = $_}} | Test-PSPropertyExpression val*
$result | Should -Be 55
}

Expand Down
2 changes: 1 addition & 1 deletion test/powershell/engine/ETS/Adapter.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Describe "Adapter Tests" -tags "CI" {
$x.Count | Should -Be 1
$x[0].foo | Should -BeExactly "bar"

$x = ([pscustomobject]@{ foo = 'bar' }).Foreach({$_ | Add-Member -NotePropertyName "foo2" -NotePropertyValue "bar2" -PassThru})
$x = ([pscustomobject]@{ foo = 'bar' }).ForEach({$_ | Add-Member -NotePropertyName "foo2" -NotePropertyValue "bar2" -PassThru})
$x.Count | Should -Be 1
$x[0].foo | Should -BeExactly "bar"
$x[0].foo2 | Should -BeExactly "bar2"
Expand Down