File size: 1,475 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe 'Parallel switch syntax' -Tags 'CI' {
Context 'Should be able to retrieve AST of parallel switch' {
BeforeAll {
$ast = [System.Management.Automation.Language.Parser]::ParseInput(
'switch -parallel ($foo) {1 {break}}', [ref] $null, [ref] $null)
}
It '$ast.EndBlock.Statements[0].Flags' {
$ast.EndBlock.Statements[0].Flags | Should -BeExactly 'Parallel'
}
}
Context 'Generates an error on invalid parameter' {
BeforeAll {
$errors = @()
$ast = [System.Management.Automation.Language.Parser]::ParseInput(
'switch -bogus ($foo) {1 {break}}', [ref]$null, [ref]$errors)
}
It '$errors.Count' {
$errors.Count | Should -Be 1
}
It '$errors[0].ErrorId' {
$errors[0].ErrorId | Should -BeExactly 'InvalidSwitchFlag'
}
}
Context 'Generate an error on -parallel' {
BeforeAll {
$errors = @()
$ast = [System.Management.Automation.Language.Parser]::ParseInput(
'switch -parallel ($foo) {1 {break}}', [ref]$null, [ref]$errors)
}
It '$errors.Count' {
$errors.Count | Should -Be 1
}
It '$errors[0].ErrorId' {
$errors[0].ErrorId | Should -Be 'KeywordParameterReservedForFutureUse'
}
}
}
|