You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an issue that is probably best illustrated with code, below. I'm not sure if I'm just using the class wrong, or if this is a bug in the Mock::Quick package:
Investigating further, it looks like this issue only occurs when the mocked sub is invoked as a plain function (e.g. Foo::bar()). The issue does not occur when the mocked sub is invoked as an object method (e.g. Foo->new()->bar()), as shown in the code below.
slightlytwisted
changed the title
Implemented classes are not fully unloaded, causing side effects
Mocked subs invoked as plain functions are not being unloaded
Mar 29, 2017
Doing some more investigation. It seems that calling undef(*{"$package\::"}) (as on Mock::Quick::Class line 241), causes some unexpected behavior. Consider the following:
#!/usr/bin/env perlno warnings 'redefine';
*{'Foo::Bar'} = sub { saySTDOUT'test1' };
Foo::Bar();
undef(*{'Foo::'});
*{'Foo::Bar'} = sub { saySTDOUT'test2' };
Foo::Bar();
Which outputs the following:
test1
test1
Removing the line undef(*{'Foo::'}) or replacing it with undef(*{'Foo::Bar'}) yields the expected (at least to me) behavior of outputting test1\ntest2.
I'm running into an issue that is probably best illustrated with code, below. I'm not sure if I'm just using the class wrong, or if this is a bug in the Mock::Quick package:
Expected output:
Actual output:
Mock::Quick version: 1.111
Perl Version: 5.22.1
The text was updated successfully, but these errors were encountered: