Get tests running under -T (cosmetics only)
[p5sagit/namespace-clean.git] / t / 05-explicit-cleanee.t
CommitLineData
fcfe7810 1use warnings;
2use strict;
3
726710b6 4use lib 't/lib';
8de3b21e 5use Test::More tests => 2019;
fcfe7810 6
7use_ok('CleaneeTarget');
8
9ok CleaneeTarget->can('IGNORED'), 'symbol in exception list still there';
10ok CleaneeTarget->can('NOTAWAY'), 'symbol after import call still there';
11ok !CleaneeTarget->can('AWAY'), 'normal symbol has disappeared';
12
13ok !CleaneeTarget->can('x_foo'), 'explicitely removed disappeared (1/2)';
14ok CleaneeTarget->can('x_bar'), 'not in explicit removal and still there';
15ok !CleaneeTarget->can('x_baz'), 'explicitely removed disappeared (2/2)';
16
17ok !CleaneeTarget->can('d_foo'), 'directly removed disappeared (1/2)';
18ok CleaneeTarget->can('d_bar'), 'not in direct removal and still there';
19ok !CleaneeTarget->can('d_baz'), 'directly removed disappeared (2/2)';
20
21my @values = qw( 23 27 17 XFOO XBAR XBAZ 7 8 9 );
22is(CleaneeTarget->summary->[ $_ ], $values[ $_ ], sprintf('testing sub in cleanee (%d/%d)', $_ + 1, scalar @values))
23 for 0 .. $#values;
8de3b21e 24
25
26# some torture
27SKIP: {
28
29 skip "This part of the test segfaults perl $] with both tie() and B::H::EOS."
30 . ' Actual code (e.g. DBIx::Class) works fine so did not investigate further',
006e9cb4 31 2000 if "$]" < 5.008003;
8de3b21e 32
33 local @INC = @INC;
34 my @code;
35 unshift @INC, sub {
36
37 if ($_[1] =~ /CleaneeTarget\/No(\d+)/) {
38 my @code = (
39 "package CleaneeTarget::No${1};",
40 "sub x_foo { 'XFOO' }",
41 "sub x_bar { 'XBAR' }",
42
43 "use CleaneeBridgeExplicit;",
44
45 "1;",
46 );
47
48 return sub { return 0 unless @code; $_ = shift @code; 1; }
49 }
50 else {
51 return ();
52 }
53 };
54
55 for (1..1000) {
56 my $pkg = "CleaneeTarget::No${_}";
57
58 my @val = require "CleaneeTarget/No${_}.pm";
59
60 ok !$pkg->can('x_foo'), 'explicitely removed disappeared';
61 ok $pkg->can('x_bar'), 'not in explicit removal and still there';
62 }
63}