diff --git a/lib/Test/MockModule.pm b/lib/Test/MockModule.pm index 73954f7..9082d71 100644 --- a/lib/Test/MockModule.pm +++ b/lib/Test/MockModule.pm @@ -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); diff --git a/t/mockmodule.t b/t/mockmodule.t index 03d9026..f0bf5c7 100644 --- a/t/mockmodule.t +++ b/t/mockmodule.t @@ -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');