Add a thread test (just runs the basic one in a thread)
[p5sagit/Devel-GlobalDestruction.git] / t / 01_basic.t
1 use strict;
2 use warnings;
3
4 # we need to run a test in GD and this fails
5 # use Test::More tests => 3;
6 # use ok 'Devel::GlobalDestruction';
7
8 BEGIN {
9     package Test::Scope::Guard;
10     sub new { my ($class, $code) = @_; bless [$code], $class; }
11     sub DESTROY { my $self = shift; $self->[0]->() }
12 }
13
14 print "1..4\n";
15
16 sub ok ($$) {
17     print "not " if !$_[0];
18     print "ok";
19     print " - $_[1]" if defined $_[1];
20     print "\n";
21 }
22
23 ok( eval "use Devel::GlobalDestruction; 1", "use Devel::GlobalDestruction" );
24
25 ok( defined &in_global_destruction, "exported" );
26
27 ok( !in_global_destruction(), "not in GD" );
28
29 our $sg = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "in GD" ) });