Skip to content

Commit 4dacd82

Browse files
matthewhughes934geofffranks
authored andcommitted
Add warning when 'unmock' called without arguments
1 parent b20dc7c commit 4dacd82

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/Test/MockModule.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ sub original {
157157
sub unmock {
158158
my $self = shift;
159159

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

t/mockmodule.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ like($@, qr/Invalid package name/, ' ... croaks if package is undefined');
103103
$mcgi->unmock('Vars');
104104
like($warn, qr/ was not mocked/, "... warns if a subroutine isn't mocked");
105105

106+
$mcgi->unmock();
107+
like($warn, qr/Nothing to unmock/, '... warns if no arguments passed to unmock');
108+
106109
$mcgi->unmock('param');
107110
is(\&{"ExampleModule::param"}, $orig_param, '... restores the original subroutine');
108111

0 commit comments

Comments
 (0)