+{
+ local @main::new;
+ my (@err, @w);
+ sub cb3 { push @err, $_[0] };
+ local $SIG{__WARN__} = sub { push @w, join '', 'warn:', @_ };
+ eval <<' TESTREQUIRED3';
+ {
+ package indirect::TestRequired3Z;
+ sub new { push @main::new, __PACKAGE__ }
+ no indirect hook => \&main::cb3;
+ use indirect::TestRequired3X;
+ use indirect::TestRequired3Y;
+ new indirect::TestRequired3Z;
+ }
+ TESTREQUIRED3
+ @w = grep !/^warn:Attempt\s+to\s+free\s+unreferenced/, @w if "$]" <= 5.008003;
+ is $@, '',
+ "pragma leak when reusing callback test doesn't croak prematurely";
+ is_deeply \@w, [ ],
+ "pragma leak when reusing callback test doesn't warn";
+ is_deeply \@err, [ map "indirect::TestRequired3$_", qw<X Z> ],
+ "pragma leak when reusing callback test caught the right errors";
+ is_deeply \@main::new, [ map "indirect::TestRequired3$_", qw<X Y Z> ],
+ "pragma leak when reusing callback test ran the three constructors";
+}
+