X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01_basic.t;h=c739a63f84d9920ee14220197eb90bd6e8608bc8;hb=140a3884a09b85a2f4c988ffea726455e194066d;hp=b93496a7d4ade0f60a6289f9ff85beb4ba9974d0;hpb=82ca1dd86de69da01a9f7f746785a29f6afcaa42;p=p5sagit%2FDevel-GlobalDestruction.git diff --git a/t/01_basic.t b/t/01_basic.t index b93496a..c739a63 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -25,7 +25,7 @@ BEGIN { sub DESTROY { my $self = shift; $self->[0]->() } } -print "1..6\n"; +print "1..9\n"; our $had_error; @@ -58,6 +58,10 @@ sub ok ($$) { print "\n"; } +END { + ok( ! in_global_destruction(), 'Not yet in GD while in END block 2' ) +} + ok( eval "use Devel::GlobalDestruction; 1", "use Devel::GlobalDestruction" ); ok( defined &in_global_destruction, "exported" ); @@ -66,6 +70,13 @@ ok( defined prototype \&in_global_destruction, "defined prototype" ); ok( prototype \&in_global_destruction eq "", "empty prototype" ); -ok( !in_global_destruction(), "not in GD" ); +ok( ! in_global_destruction(), "Runtime is not GD" ); + +our $sg1 = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "Final cleanup object destruction properly in GD" ) }); + +END { + ok( ! in_global_destruction(), 'Not yet in GD while in END block 1' ) +} -our $sg = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "in GD" ) }); +our $sg2 = Test::Scope::Guard->new(sub { ok( ! in_global_destruction(), "Object destruction in END not considered GD" ) }); +END { undef $sg2 }