File: 01_basic.t

package info (click to toggle)
libdevel-globaldestruction-perl 0.06-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 272 kB
  • sloc: perl: 47; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 887 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use strict;
use warnings;

BEGIN {
    if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) {
        require DynaLoader;
        no warnings 'redefine';
        my $orig = \&DynaLoader::bootstrap;
        *DynaLoader::bootstrap = sub {
            die 'no XS' if $_[0] eq 'Devel::GlobalDestruction';
            goto $orig;
        };
    }
}

BEGIN {
    package Test::Scope::Guard;
    sub new { my ($class, $code) = @_; bless [$code], $class; }
    sub DESTROY { my $self = shift; $self->[0]->() }
}

print "1..4\n";

sub ok ($$) {
    print "not " if !$_[0];
    print "ok";
    print " - $_[1]" if defined $_[1];
    print "\n";
}

ok( eval "use Devel::GlobalDestruction; 1", "use Devel::GlobalDestruction" );

ok( defined &in_global_destruction, "exported" );

ok( !in_global_destruction(), "not in GD" );

our $sg = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "in GD" ) });