use strict;
use warnings;
-require q(./test.pl); plan(tests => 12);
+require q(./test.pl); plan(tests => 18);
{
package MRO_A;
# XXX TODO (when there's a way to backtrack through a glob's aliases)
# push(@MRO_M::ISA, 'MRO_TestOtherBase');
# is(eval { MRO_N->testfunctwo() }, 321);
+
+# Simple DESTROY Baseline
+{
+ my $x = 0;
+ my $obj;
+
+ {
+ package DESTROY_MRO_Baseline;
+ sub new { bless {} => shift }
+ sub DESTROY { $x++ }
+
+ package DESTROY_MRO_Baseline_Child;
+ our @ISA = qw/DESTROY_MRO_Baseline/;
+ }
+
+ $obj = DESTROY_MRO_Baseline->new();
+ undef $obj;
+ is($x, 1);
+
+ $obj = DESTROY_MRO_Baseline_Child->new();
+ undef $obj;
+ is($x, 2);
+}
+
+# Dynamic DESTROY
+{
+ my $x = 0;
+ my $obj;
+
+ {
+ package DESTROY_MRO_Dynamic;
+ sub new { bless {} => shift }
+
+ package DESTROY_MRO_Dynamic_Child;
+ our @ISA = qw/DESTROY_MRO_Dynamic/;
+ }
+
+ $obj = DESTROY_MRO_Dynamic->new();
+ undef $obj;
+ is($x, 0);
+
+ $obj = DESTROY_MRO_Dynamic_Child->new();
+ undef $obj;
+ is($x, 0);
+
+ no warnings 'once';
+ *DESTROY_MRO_Dynamic::DESTROY = sub { $x++ };
+
+ $obj = DESTROY_MRO_Dynamic->new();
+ undef $obj;
+ is($x, 1);
+
+ $obj = DESTROY_MRO_Dynamic_Child->new();
+ undef $obj;
+ is($x, 2);
+}