Pester
                                
                                 Pester copied to clipboard
                                
                                    Pester copied to clipboard
                            
                            
                            
                        Should -HaveParameter should check DefaultParameterType
Default parameter type is figured out in the code, but parameter for it is not surfaced to Should which is unfortunate when you check $Path = (Get-DefaultPath) because our assertion will pass for both $Path = (Get-DefaultPath)  and $Path = "(Get-DefaultPath)".
But if the DefaultValueType was surfaced then we could say the the value should be Expression, not a string, and we would be able to distinguish those two.
@lipkau ^^^ would you consider PRing it? 🙂
I'll pick this up.
To clarify, do we want to require -DefaultValue <scriptblock> when the DefaultValueType is Expression? Like this?
Describe 'd' {
    It 'i' {
        function myDefault { 'my\default' }
        function myFunc {
            param(
                [string]$MyParam = '(myDefault)'
            )
        }
        # This should work
        Get-Command myFunc | Should -HaveParameter MyParam -DefaultValue {(myDefault)}
        # This shouldn't
        Get-Command myFunc | Should -HaveParameter MyParam -DefaultValue '(myDefault)'
    }
}
We still end up comparing them as strings, so it would mostly be for the optics right? If so, is it worth the breaking change? Am I missing something?
Would likely have to trim the scriptblock-text since formatter in VSCode likes to add whitespace between curly-braces and content in {content}
I think I just meant that we will always compare them as strings, but we will have additional -DefaultValueType parameter which can would be the actual type of the default value:
$Path = (Get-DefaultPath) == -DefaultValue "(Get-DefaultPath)" and -DefaultValueType ScriptBlock $Path = (Get-DefaultPath) != -DefaultValue "(Get-DefaultPath)" and -DefaultValueType String
(or whatever is the name of the type on the default value, is that Expression?)