File tree Expand file tree Collapse file tree 3 files changed +8
-10
lines changed Expand file tree Collapse file tree 3 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ sub DEMOLISHALL {
78
78
79
79
foreach my $class (@isa ) {
80
80
no strict ' refs' ;
81
+ # If a child module implements DEMOLISH and its parent does not
82
+ # then the access below can be the only reference to that parent's sub
81
83
my $demolish = do {
82
84
no warnings ' once' ;
83
85
*{" ${class} ::DEMOLISH" }{CODE };
Original file line number Diff line number Diff line change @@ -2,14 +2,8 @@ use strict;
2
2
use warnings;
3
3
4
4
use lib ' t/lib' ;
5
- use Test::More tests => 1;
6
-
7
- my @warnings ;
8
- BEGIN {
9
- $SIG {__WARN__ } = sub { push @warnings , @_ };
10
- }
5
+ use Test::More tests => 2; # Test::Warnings re-tests had_no_warnings implicitly
6
+ use Test::Requires qw( Test::Warnings) ;
11
7
12
8
use Demolition::OnceRemoved;
13
-
14
- is scalar @warnings , 0, " No warnings"
15
- or diag explain \@warnings ;
9
+ Test::Warnings::had_no_warnings(" No DEMOLISH warnings" );
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ use strict;
3
3
use warnings;
4
4
use Demolition::Demolisher;
5
5
6
+ # This variable is only in scope during the initial `use`
7
+ # As it leaves scope, Perl will call DESTROY on it
8
+ # (and Moose::Object will then go through its DEMOLISHALL method)
6
9
my $d = Demolition::Demolisher-> new;
7
- $d -> DEMOLISH;
8
10
9
11
1;
You can’t perform that action at this time.
0 commit comments