clean up debugger environment before testing with it
[p5sagit/namespace-clean.git] / t / 07-debugger.t
1 use Test::More;
2
3 BEGIN {
4   require namespace::clean;
5   if (
6     namespace::clean::_Util::DEBUGGER_NEEDS_CV_RENAME()
7       and
8     my $missing_xs = namespace::clean::_Util::_namer_load_error()
9   ) {
10     plan skip_all => $missing_xs;
11   }
12   else {
13     plan tests => 4;
14   }
15 }
16
17 BEGIN {
18   # shut up the debugger
19   delete $ENV{$_} for grep /^PERL5?DB/, keys %ENV;
20   delete $ENV{LOGDIR};
21   $ENV{HOME} = '.';
22   $ENV{PERLDB_OPTS} = 'NonStop noTTY';
23 }
24
25 BEGIN {
26
27 #line 1
28 #!/usr/bin/perl -d
29 #line 30
30
31 }
32
33 {
34     package Foo;
35
36     BEGIN { *baz = sub { 42 } }
37     sub foo { 22 }
38
39     use namespace::clean;
40
41     sub bar {
42         ::is(baz(), 42);
43         ::is(foo(), 22);
44     }
45 }
46
47 ok( !Foo->can("foo"), "foo cleaned up" );
48 ok( !Foo->can("baz"), "baz cleaned up" );
49
50 Foo->bar();