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
Add option to specify correct prototype for mock method #27
Comments
Thank you for the report.
I've had a very long work day today so I won't get a chance to look at this
immediately.
Will investigate/test tomorrow or over the coming weekend.
Cheers!
Steve
…On Thu, Sep 20, 2018 at 2:18 PM sidey79 ***@***.***> wrote:
If i try to mock the following sub:
sub
foo($$$)
{
return undef;
```}
with using the mock method:
`my $foo = $mock->mock('foo');`
I get a prototype mismatch warning:
`PERL WARNING: Prototype mismatch: sub main::foo ($$$) vs none at /usr/local/share/perl/5.18.2/Mock/Sub/Child.pm line 122.`
I already tried to disable the warnings, but this has no effect.
`use Mock::Sub no_warnings => 1;`
I cant figure out, how to specify the foo sub correctly
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#27>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMcCP2x8MrZgdazIgVyZteX469-cPcTXks5udAYZgaJpZM4Wy9nr>
.
|
thank for your quick reply. |
My pleasure.
I'll keep you informed on any progress I make.
…On Thu, Sep 20, 2018 at 2:39 PM sidey79 ***@***.***> wrote:
thank for your quick reply.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMcCPxZVREu8JXiJoM67WuX1Q8X_cZOhks5udAr7gaJpZM4Wy9nr>
.
|
I've come up with a quick and dirty workaround for this issue. Essentially, you can just trap the prototype warnings and prevent them from being displayed. It's not optimal but it does work. Note though that even though the warnings are quelled, you still have to send in the proper number of parameters to the mocked sub:
Output, to ensure the mocked sub is actually the one being executed:
Let me know what you think about this workaround. If it seems sane (enough), I'll add this functionality to the If that's the way I go, I'll likely make the user send in a parameter to specify they want this functionality. Essentially, if a user runs into this issue, they can have the option to use the feature directly. I'd rather play it safe by default so the user isn't confused, and then they can silence the warnings. Best that someone knows about a potential problem and be able to selectively work around it, then hide the warnings by default which would probably confuse people. Besides, I don't like implementing sig handlers blindly particularly when 99% of users won't need it. Also, note that the |
I'll Check this later, but i think adding a method which disables the warning ist okay. |
I've tested it and it works. But i specified say full qualified, so no need to provide a use feature say.
I think, after running a test it is may be good to restore the original behaviour
|
If i try to mock the following sub:
using the mock method:
my $foo = $mock->mock('foo');
I get a prototype mismatch warning:
PERL WARNING: Prototype mismatch: sub main::foo ($$$) vs none at /usr/local/share/perl/5.18.2/Mock/Sub/Child.pm line 122.
I already tried to disable the warnings, but this has no effect.
use Mock::Sub no_warnings => 1;
I cant figure out, how to specify the foo sub correctly
The text was updated successfully, but these errors were encountered: