only invoke caller() when _HAS_SUBNAME
[p5sagit/Try-Tiny.git] / t / global_destruction_load.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 BEGIN {
7     plan skip_all => 'Capture::Tiny 0.12 required'
8         unless eval { require Capture::Tiny; Capture::Tiny->VERSION(0.12); 1 };
9     plan tests => 3;
10     Capture::Tiny->import(qw(capture_stderr));
11 }
12
13 for my $func (qw(try catch finally)) {
14     is capture_stderr {
15         system $^X, qw(-It/lib -we),
16             qq{sub DESTROY { require TryUser; TryUser->test_$func }} .
17              q{our $o; $o = bless []};
18     }, '', "$func gets installed when loading Try::Tiny during global destruction";
19 }