Skip to content

Commit

Permalink
Add warning when 'unmock' called without arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhughes934 authored and geofffranks committed Jun 12, 2020
1 parent b20dc7c commit 4dacd82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Test/MockModule.pm
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ sub original {
sub unmock {
my $self = shift;

carp 'Nothing to unmock' unless @_;
for my $name (@_) {
croak "Invalid subroutine name: $name" unless _valid_subname($name);

Expand Down
3 changes: 3 additions & 0 deletions t/mockmodule.t
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ like($@, qr/Invalid package name/, ' ... croaks if package is undefined');
$mcgi->unmock('Vars');
like($warn, qr/ was not mocked/, "... warns if a subroutine isn't mocked");

$mcgi->unmock();
like($warn, qr/Nothing to unmock/, '... warns if no arguments passed to unmock');

$mcgi->unmock('param');
is(\&{"ExampleModule::param"}, $orig_param, '... restores the original subroutine');

Expand Down

0 comments on commit 4dacd82

Please sign in to comment.