From: Dagfinn Ilmari Mannsåker Date: Thu, 24 Oct 2013 22:02:43 +0000 (+0100) Subject: Test loading during global destruction X-Git-Tag: Try-Tiny-0.19~3^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ed5dea68dd61e71381ba7de2c352a0647329d1d6;p=p5sagit%2FTry-Tiny.git Test loading during global destruction --- diff --git a/dist.ini b/dist.ini index 4ed975c..f468c64 100644 --- a/dist.ini +++ b/dist.ini @@ -22,6 +22,11 @@ Git::NextVersion_version_regexp = ^Try-Tiny-(.+)$ 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 diff --git a/t/global_destruction_load.t b/t/global_destruction_load.t new file mode 100644 index 0000000..acf3a8c --- /dev/null +++ b/t/global_destruction_load.t @@ -0,0 +1,18 @@ +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"; +} diff --git a/t/lib/TryUser.pm b/t/lib/TryUser.pm new file mode 100644 index 0000000..c44d36b --- /dev/null +++ b/t/lib/TryUser.pm @@ -0,0 +1,9 @@ +package TryUser; + +use Try::Tiny; + +sub test_try { try { } } +sub test_catch { try { } catch { } } +sub test_finally { try { } finally { } } + +1;