/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/powershell/engine/Api/GetNewClosure.Tests.ps1
44 строки
1 KB
Steve Lee
Update copyright notice to latest guidance (#12190)
24 мар 2020, 21:08
Не верифицирован
24 мар 2020, 21:08
b7cb335
Код
Авторство
О чём код?
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. Describe "ScriptBlock.GetNewClosure()" -tags "CI" { BeforeAll { ## No error should occur when calling GetNewClosure because: ## 1. ValidateAttributes are not evaluated on parameter default values ## 2. GetNewClosure no longer forces validation on existing variables function SimpleFunction_GetNewClosure { param([ValidateNotNull()] $Name) & { 'OK' }.GetNewClosure() } function ScriptCmdlet_GetNewClosure { [CmdletBinding()] param( [Parameter()] [ValidateNotNullOrEmpty()] [string] $Name = "", [Parameter()] [ValidateRange(1,3)] [int] $Value = 4 ) & { $Value; $Name }.GetNewClosure() } } It "Parameter attributes should not get evaluated again in GetNewClosure - SimpleFunction" { SimpleFunction_GetNewClosure | Should -BeExactly "OK" } It "Parameter attributes should not get evaluated again in GetNewClosure - ScriptCmdlet" { $result = ScriptCmdlet_GetNewClosure $result.Count | Should -Be 2 $result[0] | Should -Be 4 $result[1] | Should -BeNullOrEmpty } }