Fix function definition in parameter filter#1293
Merged
nohwnd merged 7 commits intopester:masterfrom May 1, 2019
clcaldwell:FixFunctionDefinitionInParameterFilter
Merged
Fix function definition in parameter filter#1293nohwnd merged 7 commits intopester:masterfrom clcaldwell:FixFunctionDefinitionInParameterFilter
nohwnd merged 7 commits intopester:masterfrom
clcaldwell:FixFunctionDefinitionInParameterFilter
Conversation
nohwnd
requested changes
Apr 23, 2019
renehernandez
suggested changes
Apr 23, 2019
Contributor
There was a problem hiding this comment.
@clcaldwell Thanks for adding the implementation. As @nohwnd mentioned before just change the block variable case
renehernandez
approved these changes
Apr 25, 2019
nohwnd
approved these changes
Apr 25, 2019
| Describe 'Mocking using ParameterFilter with scriptblock' { | ||
| $filter = [scriptblock]::Create( ('$Path -eq ''C:\Windows''') ) | ||
| Mock -CommandName 'Test-Path' -ParameterFilter $filter | ||
| Describe 'Mocking using ParameterFilter' { |
Contributor
There was a problem hiding this comment.
@clcaldwell Some of these tests seem to be very similar. They could be candidate to be refactored using the TestCases option
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.