Enable type conversion of AutomationNull to $null for assignment (#19415)

This commit is contained in:
Steve Lee
2023-04-03 09:36:36 -07:00
committed by GitHub
parent 51f55f716e
commit 04b93af4ae
2 changed files with 18 additions and 0 deletions
@@ -30,6 +30,18 @@ Describe "Scripting.Followup.Tests" -Tags "CI" {
$arraylist.Count | Should -Be 0
}
It 'AutomationNull should be same as null for type conversion' {
$result = pwsh -noprofile -command {
class Example {
[string[]]$LogMessage
}
[Example] @{ LogMessage = [System.Management.Automation.Internal.AutomationNull]::Value }
}
$result.LogMessage | Should -BeNullOrEmpty
}
## fix https://github.com/PowerShell/PowerShell/issues/17165
It "([bool] `$var = 42) should return the varaible value" {
([bool]$var = 42).GetType().FullName | Should -Be "System.Boolean"