skip = ^perl$
; tests for optional Sub::Name stuff
skip = ^Sub::Name$
+; tests optionally require Capture::Tiny
+skip = ^Capture::Tiny$
[Prereqs]
perl = 5.006
+
+[Prereqs / TestRecommends]
+Capture::Tiny = 0.12 ; capture_stderr
--- /dev/null
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ plan skip_all => 'Capture::Tiny required'
+ unless eval { require Capture::Tiny; 1 };
+ plan tests => 3;
+ Capture::Tiny->import(qw(capture_stderr));
+}
+
+for my $func (qw(try catch finally)) {
+ is capture_stderr {
+ system $^X, qw(-It/lib -we),
+ qq{sub DESTROY { require TryUser; TryUser->test_$func }} .
+ q{our $o; $o = bless []};
+ }, '', "$func gets installed when loading Try::Tiny during global destruction";
+}
--- /dev/null
+package TryUser;
+
+use Try::Tiny;
+
+sub test_try { try { } }
+sub test_catch { try { } catch { } }
+sub test_finally { try { } finally { } }
+
+1;