-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix function definition in parameter filter #1293
Fix function definition in parameter filter #1293
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clcaldwell Thanks for adding the implementation. As @nohwnd mentioned before just change the block variable case
Describe 'Mocking using ParameterFilter with scriptblock' { | ||
$filter = [scriptblock]::Create( ('$Path -eq ''C:\Windows''') ) | ||
Mock -CommandName 'Test-Path' -ParameterFilter $filter | ||
Describe 'Mocking using ParameterFilter' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clcaldwell Some of these tests seem to be very similar. They could be candidate to be refactored using the TestCases option
1. Fix bug where function definition ( ${function:} ) pass to -ParameterFilter breaks upon AST.
Fix #1291
This is a small fix to to the 'New-BlockWithoutParameterAliases' function. When a function definition was passed to -ParameterFilter and internally passed to 'New-BlockWithoutParameterAliases', the AST would fail because it was expecting a true scriptblock, so the AST was in a different location than expected.
It now checks to see if the passed scriptblock is a FunctionDefinitionAst or ScriptBlockAst and handles the AST appropriately.
Tests included.