mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Move to .NET 5 preview.1 (#12140)
This commit is contained in:
@@ -296,7 +296,6 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' {
|
||||
${array}?.length | Should -Be 3
|
||||
${hash}?.a | Should -Be 1
|
||||
|
||||
(Get-Process -Id $PID)?.Name | Should -BeLike "pwsh*"
|
||||
(Get-Item $TestDrive)?.EnumerateFiles()?.Name | Should -BeExactly 'testfile.txt'
|
||||
|
||||
[int32]::MaxValue?.ToString() | Should -BeExactly '2147483647'
|
||||
@@ -360,8 +359,8 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' {
|
||||
|
||||
It 'Use ?. on a dynamic property name' {
|
||||
$testContent = @'
|
||||
$propName = 'Name'
|
||||
(Get-Process -Id $PID)?.$propName | Should -BeLike 'pwsh*'
|
||||
$propName = 'SI'
|
||||
(Get-Process -Id $PID)?.$propName | Should -Be (Get-Process -id $PID).SessionId
|
||||
|
||||
${doesNotExist}?.$propName() | Should -BeNullOrEmpty
|
||||
'@
|
||||
|
||||
@@ -22,7 +22,7 @@ Describe "Using of ternary operator" -Tags CI {
|
||||
@{ Script = { @{name = 'name'}.Contains('name') ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { (Test-Path Env:\NonExist) ? 'true' : 'false' }; ExpectedValue = 'false' }
|
||||
@{ Script = { (Test-Path Env:\PSModulePath) ? 'true' : 'false' }; ExpectedValue = 'true' }
|
||||
@{ Script = { $($p = Get-Process -Id $PID; $p.Name -eq 'pwsh') ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { $($p = Get-Process -Id $PID; $p.Id -eq $PID) ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { ($a = 1) ? 2 : 3 }; ExpectedValue = 2 }
|
||||
@{ Script = { $($a = 1) ? 2 : 3 }; ExpectedValue = 3 }
|
||||
@{ Script = { (Write-Warning -Message warning -WarningAction SilentlyContinue) ? 1 : 2 }; ExpectedValue = 2 }
|
||||
@@ -31,7 +31,7 @@ Describe "Using of ternary operator" -Tags CI {
|
||||
## Condition: unary and binary expression expressions
|
||||
@{ Script = { -not $IsCoreCLR ? 'Desktop' : 'Core' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { $PSEdition -eq 'Core' ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { $IsCoreCLR -and (Get-Process -Id $PID).Name -eq 'pwsh' ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { $IsCoreCLR -and (Get-Process -Id $PID).Id -eq $PID ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { $IsCoreCLR -and 'pwsh' -match 'p.*h' ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
@{ Script = { 1,2,3 -contains 2 ? 'Core' : 'Desktop' }; ExpectedValue = 'Core' }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user