23 lines
1 KiB
PowerShell
23 lines
1 KiB
PowerShell
Describe 'conversion syntax' -Tags "CI" {
|
|
# these test suite covers ([<type>]<expression>).<method>() syntax.
|
|
# it mixes two purposes: casting and super-class method calls.
|
|
|
|
It 'converts array of single enum to bool' {
|
|
# This test relies on the fact that [ConsoleColor]::Black is 0 and all other values are non-zero
|
|
[bool]@([ConsoleColor]::Black) | Should Be $false
|
|
[bool]@([ConsoleColor]::Yellow) | Should Be $true
|
|
}
|
|
|
|
It 'calls virtual method non-virtually' {
|
|
([object]"abc").ToString() | Should Be "System.String"
|
|
|
|
# generate random string to avoid JIT optimization
|
|
$r = [guid]::NewGuid().Guid
|
|
([object]($r + "a")).Equals(($r + "a")) | Should Be $false
|
|
}
|
|
|
|
It 'calls method on a super-type, when conversion syntax used' {
|
|
# This test relies on the fact that there are overloads (at least 2) for ToString method.
|
|
([System.Management.Automation.ActionPreference]"Stop").ToString() | Should Be "Stop"
|
|
}
|
|
}
|