diff --git a/Functions/It.ps1 b/Functions/It.ps1 index 80cd873d7..a4cf139cf 100644 --- a/Functions/It.ps1 +++ b/Functions/It.ps1 @@ -157,12 +157,26 @@ function ItImpl if ($null -eq $test) { $test = {} } #mark empty Its as Pending - #[String]::IsNullOrWhitespace is not available in .NET version used with PowerShell 2 - if ($PSCmdlet.ParameterSetName -eq 'Normal' -and - [String]::IsNullOrEmpty((Remove-Comments $test.ToString()) -replace "\s")) + if ($PSVersionTable.PSVersion.Major -le 2 -and + $PSCmdlet.ParameterSetName -eq 'Normal' -and + [String]::IsNullOrEmpty((Remove-Comments $test.ToString()) -replace "\s")) { $Pending = $true } + elseIf ($PSVersionTable.PSVersion.Major -gt 2) + { + #[String]::IsNullOrWhitespace is not available in .NET version used with PowerShell 2 + # AST is not available also + $testIsEmpty = + [String]::IsNullOrEmpty($test.Ast.BeginBlock.Statements) -and + [String]::IsNullOrEmpty($test.Ast.ProcessBlock.Statements) -and + [String]::IsNullOrEmpty($test.Ast.EndBlock.Statements) + + if ($PSCmdlet.ParameterSetName -eq 'Normal' -and $testIsEmpty) + { + $Pending = $true + } + } $pendingSkip = @{}