Hello community,
here is the log from the commit of package perl-Test-MockModule for
openSUSE:Factory checked in at 2019-10-28 16:43:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Test-MockModule (Old)
and /work/SRC/openSUSE:Factory/.perl-Test-MockModule.new.2990 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-MockModule"
Mon Oct 28 16:43:46 2019 rev:10 rq:742094 version:0.171.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-Test-MockModule/perl-Test-MockModule.changes
2018-10-01 08:14:48.334068446 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Test-MockModule.new.2990/perl-Test-MockModule.changes
2019-10-28 16:43:50.328507968 +0100
@@ -1,0 +2,29 @@
+Mon Oct 21 14:42:00 UTC 2019 - <[email protected]>
+
+- updated to 0.171.0
+ see /usr/share/doc/packages/perl-Test-MockModule/Changes
+
+ v0.171.0
+ - 89dc5c0 Fixes #25 - mocking core::global no longer fails trying to load
the module - Geoff Franks
+ - 9bb081a update ci for fewer infinite loops - Geoff Franks
+ - 289d014 Update release notes for all the newly merged PRs - Geoff Franks
+ - fef9e74 Allow chaining of new with mock, redefine, define - Nicolas
Rochelemagne
+ - e136131 Prevent redefine() from triggering DESTROY. - Felipe Gasper
+ - 311f6b4 Adjust Travis CI configuration to use travis-perl.github.io -
Nicolas Rochelemagne
+ - 2bed3e2 Add strict mode to ban the use of noop and mock. - Todd Rinaldo
+ - 0298d8d Provide define method so the mock method is unneeded in tests. -
Todd Rinaldo
+
+ v0.171.0
+ - allow chaining of new with mock, redefine, define
+ - redefine() no longer triggers errors if the object being mocked is not a
hashref
+ - Adds a define() method for mocking new functions that do not exist. Throws
an
+ error if a function does exist.
+ - Adds `strict` mode to prevent usage of noop() and mock() functions, and
force
+ the usage of define/redefine if desired.:
+ ```
+ use Test::MockModule qw/strict/;
+ ```
+ - Mocking CORE::GLOBAL no longer throws errors indicating CORE::GLOBAL
should have
+ been installed/loaded
+
+-------------------------------------------------------------------
Old:
----
Test-MockModule-v0.170.0.tar.gz
New:
----
Test-MockModule-v0.171.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Test-MockModule.spec ++++++
--- /var/tmp/diff_new_pack.a2BDeD/_old 2019-10-28 16:43:50.716508461 +0100
+++ /var/tmp/diff_new_pack.a2BDeD/_new 2019-10-28 16:43:50.720508466 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Test-MockModule
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,11 +17,11 @@
Name: perl-Test-MockModule
-Version: 0.170.0
+Version: 0.171.0
Release: 0
%define cpan_name Test-MockModule
Summary: Override subroutines in a module for unit testing
-License: Artistic-1.0 or GPL-1.0+
+License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
Url: https://metacpan.org/release/%{cpan_name}
Source0:
https://cpan.metacpan.org/authors/id/G/GF/GFRANKS/%{cpan_name}-v%{version}.tar.gz
@@ -48,10 +48,10 @@
%prep
%setup -q -n %{cpan_name}-v%{version}
-find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
+find . -type f ! -path "*/t/*" ! -name "*.pl" ! -name "*.sh" -print0 | xargs
-0 chmod 644
%build
-%{__perl} Build.PL installdirs=vendor
+perl Build.PL installdirs=vendor
./Build build flags=%{?_smp_mflags}
%check
@@ -63,7 +63,7 @@
%files -f %{name}.files
%defattr(-,root,root,755)
-%doc Changes ci README.md
+%doc Changes README.md
%license LICENSE
%changelog
++++++ Test-MockModule-v0.170.0.tar.gz -> Test-MockModule-v0.171.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/Changes
new/Test-MockModule-v0.171.0/Changes
--- old/Test-MockModule-v0.170.0/Changes 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/Changes 2019-10-19 17:43:20.000000000
+0200
@@ -1,5 +1,28 @@
Revision history for Test::MockModule
+v0.171.0
+- 89dc5c0 Fixes #25 - mocking core::global no longer fails trying to load the
module - Geoff Franks
+- 9bb081a update ci for fewer infinite loops - Geoff Franks
+- 289d014 Update release notes for all the newly merged PRs - Geoff Franks
+- fef9e74 Allow chaining of new with mock, redefine, define - Nicolas
Rochelemagne
+- e136131 Prevent redefine() from triggering DESTROY. - Felipe Gasper
+- 311f6b4 Adjust Travis CI configuration to use travis-perl.github.io -
Nicolas Rochelemagne
+- 2bed3e2 Add strict mode to ban the use of noop and mock. - Todd Rinaldo
+- 0298d8d Provide define method so the mock method is unneeded in tests. -
Todd Rinaldo
+
+v0.171.0
+- allow chaining of new with mock, redefine, define
+- redefine() no longer triggers errors if the object being mocked is not a
hashref
+- Adds a define() method for mocking new functions that do not exist. Throws an
+ error if a function does exist.
+- Adds `strict` mode to prevent usage of noop() and mock() functions, and force
+ the usage of define/redefine if desired.:
+ ```
+ use Test::MockModule qw/strict/;
+ ```
+- Mocking CORE::GLOBAL no longer throws errors indicating CORE::GLOBAL should
have
+ been installed/loaded
+
v0.170.0
- 182d066 Fix versioning for semver conversion + PAUSE - Geoff Franks
- 4afeedf release v0.17.0 - CI Bot
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/LICENSE
new/Test-MockModule-v0.171.0/LICENSE
--- old/Test-MockModule-v0.170.0/LICENSE 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/LICENSE 2019-10-19 17:43:20.000000000
+0200
@@ -1,4 +1,4 @@
-This software is copyright (c) 2018 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
+This software is copyright (c) 2019 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@
--- The GNU General Public License, Version 1, February 1989 ---
-This software is Copyright (c) 2018 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
+This software is Copyright (c) 2019 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
This is free software, licensed under:
@@ -272,7 +272,7 @@
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2018 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
+This software is Copyright (c) 2019 by Current Maintainer: Geoff Franks
<[email protected]> & Original Author: Simon Flack <simonflk _AT_ cpan.org>.
This is free software, licensed under:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/MANIFEST
new/Test-MockModule-v0.171.0/MANIFEST
--- old/Test-MockModule-v0.170.0/MANIFEST 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/MANIFEST 2019-10-19 17:43:20.000000000
+0200
@@ -11,8 +11,11 @@
MANIFEST This list of files
MANIFEST.SKIP
README.md
+t/chaining.t
+t/define.t
t/inheritance.t
t/lib/ExampleModule.pm
+t/mock_strict.t
t/mockmodule.t
t/pod.t
t/pod_coverage.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/META.json
new/Test-MockModule-v0.171.0/META.json
--- old/Test-MockModule-v0.170.0/META.json 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/META.json 2019-10-19 17:43:20.000000000
+0200
@@ -38,7 +38,7 @@
"provides" : {
"Test::MockModule" : {
"file" : "lib/Test/MockModule.pm",
- "version" : "v0.170.0"
+ "version" : "v0.171.0"
}
},
"release_status" : "stable",
@@ -54,6 +54,6 @@
"url" : "git://github.com/geofffranks/test-mockmodule.git"
}
},
- "version" : "v0.170.0",
+ "version" : "v0.171.0",
"x_serialization_backend" : "JSON::PP version 2.27400_02"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/META.yml
new/Test-MockModule-v0.171.0/META.yml
--- old/Test-MockModule-v0.170.0/META.yml 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/META.yml 2019-10-19 17:43:20.000000000
+0200
@@ -18,7 +18,7 @@
provides:
Test::MockModule:
file: lib/Test/MockModule.pm
- version: v0.170.0
+ version: v0.171.0
requires:
Carp: '0'
SUPER: '0'
@@ -29,5 +29,5 @@
homepage: https://github.com/geofffranks/test-mockmodule
license: http://dev.perl.org/licenses/
repository: git://github.com/geofffranks/test-mockmodule.git
-version: v0.170.0
+version: v0.171.0
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/ci/pipeline.yml
new/Test-MockModule-v0.171.0/ci/pipeline.yml
--- old/Test-MockModule-v0.170.0/ci/pipeline.yml 2018-09-01
06:53:59.000000000 +0200
+++ new/Test-MockModule-v0.171.0/ci/pipeline.yml 2019-10-19
17:43:20.000000000 +0200
@@ -47,6 +47,7 @@
jobs:
- testflight
- testflight-pr
+ - pre
- rc
- shipit
- major
@@ -146,13 +147,62 @@
icon_url: (( grab meta.slack.icon ))
text_file: message/body
+ - name: pre
+ public: true
+ serial: true
+ plan:
+ - do:
+ - get: git
+ passed:
+ - testflight
+ trigger: true
+ - get: version
+ trigger: true
+ - task: release-notes
+ config:
+ platform: linux
+ image_resource:
+ type: docker-image
+ source:
+ repository: (( grab meta.image.name ))
+ tag: (( grab meta.image.tag ))
+ run:
+ path: sh
+ args:
+ - -ce
+ - |
+ cd git
+ if [ -f ci/release_notes.md ]; then
+ echo "###### RELEASE NOTES ###############"
+ echo
+ cat ci/release_notes.md
+ echo
+ echo "########################################"
+ echo
+ else
+ echo "NO RELEASE NOTES HAVE BEEN WRITTEN"
+ echo "You *might* want to do that before"
+ echo "hitting (+) on that shipit job..."
+ echo
+ fi
+ inputs:
+ - name: git
+ on_failure:
+ put: notify
+ params:
+ channel: (( grab meta.slack.channel ))
+ username: (( grab meta.slack.username ))
+ icon_url: (( grab meta.slack.icon ))
+ text: release candidate job 'pre' failed (which is unusual).
+ ok: false
+
- name: rc
public: true
plan:
- do:
- aggregate:
- - { get: git, trigger: true, passed: [testflight] }
- - { get: version, trigger: true, params: {pre: rc} }
+ - { get: git, trigger: true, passed: [pre] }
+ - { get: version, trigger: false, params: {pre: rc} }
- put: version
params: {file: version/number}
on_failure:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/lib/Test/MockModule.pm
new/Test-MockModule-v0.171.0/lib/Test/MockModule.pm
--- old/Test-MockModule-v0.170.0/lib/Test/MockModule.pm 2018-09-01
06:53:59.000000000 +0200
+++ new/Test-MockModule-v0.171.0/lib/Test/MockModule.pm 2019-10-19
17:43:20.000000000 +0200
@@ -5,8 +5,17 @@
use Scalar::Util qw/reftype weaken/;
use Carp;
use SUPER;
-$VERSION = '0.170.0';
+$VERSION = '0.171.0';
+our $STRICT_MODE;
+
+sub import {
+ my ( $class, @args ) = @_;
+
+ $STRICT_MODE = 1 if ( grep { $_ =~ m/strict/i } @args );
+
+ return;
+}
my %mocked;
sub new {
my $class = shift;
@@ -21,7 +30,7 @@
croak "Invalid package name $package";
}
- unless ($args{no_auto} || ${"$package\::VERSION"}) {
+ unless ($package eq "CORE::GLOBAL" || $args{no_auto} ||
${"$package\::VERSION"}) {
(my $load_package = "$package.pm") =~ s{::}{/}g;
TRACE("$package is empty, loading $load_package");
require $load_package;
@@ -57,8 +66,7 @@
if ( $sub_name =~ qr{^(.+)::([^:]+)$} ) {
my ( $pkg, $sub ) = ( $1, $2 );
- my $object = bless {}, $pkg;
- next if $object->can( $sub );
+ next if $pkg->can( $sub );
}
if ('CODE' ne ref $coderef) {
@@ -66,10 +74,33 @@
}
}
- return $self->mock(@_);
+ return $self->_mock(@_);
+}
+
+sub define {
+ my ($self, @mocks) = (shift, @_);
+
+ while ( my ($name, $value) = splice @mocks, 0, 2 ) {
+ my $sub_name = $self->_full_name($name);
+ my $coderef = *{$sub_name}{'CODE'};
+
+ if ('CODE' eq ref $coderef) {
+ croak "$sub_name exists!";
+ }
+ }
+
+ return $self->_mock(@_);
}
sub mock {
+ my ($self, @mocks) = (shift, @_);
+
+ croak "mock is not allowed in strict mode. Please use define or
redefine" if $STRICT_MODE;
+
+ return $self->_mock(@mocks);
+}
+
+sub _mock {
my $self = shift;
while (my ($name, $value) = splice @_, 0, 2) {
@@ -95,11 +126,18 @@
TRACE("Installing mocked $sub_name");
_replace_sub($sub_name, $code);
}
+
+ return $self;
}
sub noop {
my $self = shift;
- $self->mock($_,1) for @_;
+
+ croak "noop is not allowed in strict mode. Please use define or redefine"
if $STRICT_MODE;
+
+ $self->_mock($_,1) for @_;
+
+ return;
}
sub original {
@@ -134,6 +172,8 @@
foreach (keys %{$self->{_mocked}}) {
$self->unmock($_);
}
+
+ return;
}
sub is_mocked {
@@ -208,9 +248,21 @@
$module->mock('subroutine', sub { ... });
Module::Name::subroutine(@args); # mocked
- #Same effect, but this will die() if other_subroutine()
- #doesn't already exist, which is often desirable.
+ # Same effect, but this will die() if other_subroutine()
+ # doesn't already exist, which is often desirable.
$module->redefine('other_subroutine', sub { ... });
+
+ # This will die() if another_subroutine() is defined.
+ $module->define('another_subroutine', sub { ... });
+ }
+
+ {
+ # you can also chain new/mock/redefine/define
+
+ Test::MockModule->new('Module::Name')
+ ->mock( one_subroutine => sub { ... })
+ ->redefine( other_subroutine => sub { ... } )
+ ->define( a_new_sub => 1234 );
}
Module::Name::subroutine(@args); # original subroutine
@@ -226,6 +278,18 @@
$foo->foo(); # prints "Foo!\n"
}
+ # If you want to prevent noop and mock from working, you can
+ # load Test::MockModule in strict mode
+
+ use Test::MockModule qw/strict/;
+ my $module = Test::MockModule->new('Module::Name');
+
+ # Redefined the other_subroutine or dies if it's not there.
+ $module->redefine('other_subroutine', sub { ... });
+
+ # Dies since you specified you wanted strict mode.
+ $module->mock('subroutine', sub { ... });
+
=head1 DESCRIPTION
C<Test::MockModule> lets you temporarily redefine subroutines in other packages
@@ -265,6 +329,10 @@
can be mocked with a code reference or a scalar. A scalar will be recast as a
subroutine that returns the scalar.
+Returns the current C<Test::MockModule> object, so you can chain L<new> with
L<mock>.
+
+ my $mock = Test::MockModule->new->(...)->mock(...);
+
The following statements are equivalent:
$module->mock(purge => 'purged');
@@ -356,6 +424,26 @@
Note that redefine is also now checking if one of the parent provides the sub
and will not die if it's available in the chain.
+Returns the current C<Test::MockModule> object, so you can chain L<new> with
L<redefine>.
+
+ my $mock = Test::MockModule->new->(...)->redefine(...);
+
+=item define($subroutine)
+
+The reverse of redefine, this will fail if the passed subroutine exists.
+While this use case is rare, there are times where the perl code you are
+testing is inspecting a package and adding a missing subroutine is actually
+what you want to do.
+
+By using define, you're asserting that the subroutine you want to be mocked
+should not exist in advance.
+
+Note: define does not check for inheritance like redefine.
+
+Returns the current C<Test::MockModule> object, so you can chain L<new> with
L<define>.
+
+ my $mock = Test::MockModule->new->(...)->define(...);
+
=item original($subroutine)
Returns the original (unmocked) subroutine
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/t/chaining.t
new/Test-MockModule-v0.171.0/t/chaining.t
--- old/Test-MockModule-v0.170.0/t/chaining.t 1970-01-01 01:00:00.000000000
+0100
+++ new/Test-MockModule-v0.171.0/t/chaining.t 2019-10-19 17:43:20.000000000
+0200
@@ -0,0 +1,30 @@
+use warnings;
+use strict;
+
+use Test::More;
+use Test::Warnings;
+
+use Test::MockModule;
+
+my $mocker = Test::MockModule->new('Mockee')->mock( good => 51 )
+ ->redefine( to_redefine => sub { 42 } )->define( something => 1234 );
+
+isa_ok $mocker, 'Test::MockModule';
+
+is( Mockee::good(), 51, 'mock() works when chaining with new' );
+is( Mockee::to_redefine(), 42, 'redefine() works when chaining with new' );
+is( Mockee::something(), 1234, 'something() works when chaining with new' );
+
+done_testing();
+
+#----------------------------------------------------------------------
+
+package Mockee;
+
+our $VERSION;
+BEGIN { $VERSION = 1 }
+
+sub good { 1 }
+sub to_redefine { 1 }
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/t/define.t
new/Test-MockModule-v0.171.0/t/define.t
--- old/Test-MockModule-v0.170.0/t/define.t 1970-01-01 01:00:00.000000000
+0100
+++ new/Test-MockModule-v0.171.0/t/define.t 2019-10-19 17:43:20.000000000
+0200
@@ -0,0 +1,35 @@
+use warnings;
+use strict;
+
+use Test::More;
+use Test::Warnings;
+
+use Test::MockModule;
+
+my $mocker = Test::MockModule->new('Mockee');
+
+$mocker->define( 'doesnt_exist', 2 );
+is( Mockee::doesnt_exist(), 2, 'define() allows us to mock nonexistant
subroutines.' );
+
+eval { $mocker->define( 'existing_subroutine', 6 ) };
+like( $@, qr/Mockee::existing_subroutine exists\!/, 'exception when
define()ing an existing subroutine' );
+
+undef $mocker;
+is( Mockee->can('doesnt_exist'), undef, "the defined sub went away after
mocker is undeffed" );
+$mocker = Test::MockModule->new('Mockee');
+
+$mocker->define( 'doesnt_exist', 3 );
+is( Mockee::doesnt_exist(), 3, 'The subroutine can be defined again after the
mock object goes out of scope and is re-instantiated.' );
+
+done_testing();
+
+#----------------------------------------------------------------------
+
+package Mockee;
+
+our $VERSION;
+BEGIN { $VERSION = 1 }
+
+sub existing_subroutine { 1 }
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/t/mock_strict.t
new/Test-MockModule-v0.171.0/t/mock_strict.t
--- old/Test-MockModule-v0.170.0/t/mock_strict.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Test-MockModule-v0.171.0/t/mock_strict.t 2019-10-19
17:43:20.000000000 +0200
@@ -0,0 +1,40 @@
+use warnings;
+use strict;
+
+use Test::More;
+use Test::Warnings;
+
+use Test::MockModule qw/strict/;
+
+my $mocker = Test::MockModule->new('Mockee');
+
+is( $Test::MockModule::STRICT_MODE, 1, "use Test::MockModule qw/strict/; sets
\$STRICT_MODE to 1" );
+
+eval { $mocker->mock( 'foo', 2 ) };
+like( "$@", qr/^mock is not allowed in strict mode. Please use define or
redefine at/, "mock croaks in strict mode." );
+
+eval { $mocker->noop('foo') };
+like( "$@", qr/^noop is not allowed in strict mode. Please use define or
redefine at/, "noop croaks in strict mode." );
+
+$mocker->define( 'foo', "abc" );
+is( Mockee->foo, "abc", "define is allowed in strict mode." );
+
+$mocker->redefine( 'existing_subroutine', "def" );
+is( Mockee->existing_subroutine, "def", "redefine is allowed in strict mode."
);
+
+$Test::MockModule::STRICT_MODE = 0;
+$mocker->mock( 'foo', 123 );
+is( Mockee->foo, 123, "mock is allowed when strict mode is turned off." );
+
+done_testing();
+
+#----------------------------------------------------------------------
+
+package Mockee;
+
+our $VERSION;
+BEGIN { $VERSION = 1 }
+
+sub existing_subroutine { 1 }
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/t/mockmodule.t
new/Test-MockModule-v0.171.0/t/mockmodule.t
--- old/Test-MockModule-v0.170.0/t/mockmodule.t 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/t/mockmodule.t 2019-10-19 17:43:20.000000000
+0200
@@ -161,4 +161,7 @@
ok(!Test_Child->can('ISA') && $Test_Child::ISA[0] eq 'Test_Parent',
"restoring an undefined sub doesn't clear out the rest of the symbols");
+# ensure mocking CORE::GLOBAL works
+ok(Test::MockModule->new("CORE::GLOBAL"));
+
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-MockModule-v0.170.0/t/redefine.t
new/Test-MockModule-v0.171.0/t/redefine.t
--- old/Test-MockModule-v0.170.0/t/redefine.t 2018-09-01 06:53:59.000000000
+0200
+++ new/Test-MockModule-v0.171.0/t/redefine.t 2019-10-19 17:43:20.000000000
+0200
@@ -14,6 +14,10 @@
eval { $mocker->redefine('bad', 6) };
like( $@, qr/Mockee::bad/, 'exception when redefine()ing a nonexistent
function' );
+my $mocker2 = Test::MockModule->new('MockeeWithDestroy');
+
+eval { $mocker2->redefine('what', 2) };
+
done_testing();
#----------------------------------------------------------------------
@@ -25,4 +29,13 @@
sub good { 1 }
+#----------------------------------------------------------------------
+
+package MockeeWithDestroy;
+
+our $VERSION;
+BEGIN { $VERSION = 1 };
+
+sub DESTROY { print 'bad' if $_[0][1] };
+
1;