Commit | Line | Data |
fcfe7810 |
1 | use warnings; |
2 | use strict; |
3 | |
726710b6 |
4 | use lib 't/lib'; |
8de3b21e |
5 | use Test::More tests => 2019; |
fcfe7810 |
6 | |
7 | use_ok('CleaneeTarget'); |
8 | |
9 | ok CleaneeTarget->can('IGNORED'), 'symbol in exception list still there'; |
10 | ok CleaneeTarget->can('NOTAWAY'), 'symbol after import call still there'; |
11 | ok !CleaneeTarget->can('AWAY'), 'normal symbol has disappeared'; |
12 | |
13 | ok !CleaneeTarget->can('x_foo'), 'explicitely removed disappeared (1/2)'; |
14 | ok CleaneeTarget->can('x_bar'), 'not in explicit removal and still there'; |
15 | ok !CleaneeTarget->can('x_baz'), 'explicitely removed disappeared (2/2)'; |
16 | |
17 | ok !CleaneeTarget->can('d_foo'), 'directly removed disappeared (1/2)'; |
18 | ok CleaneeTarget->can('d_bar'), 'not in direct removal and still there'; |
19 | ok !CleaneeTarget->can('d_baz'), 'directly removed disappeared (2/2)'; |
20 | |
21 | my @values = qw( 23 27 17 XFOO XBAR XBAZ 7 8 9 ); |
22 | is(CleaneeTarget->summary->[ $_ ], $values[ $_ ], sprintf('testing sub in cleanee (%d/%d)', $_ + 1, scalar @values)) |
23 | for 0 .. $#values; |
8de3b21e |
24 | |
25 | |
26 | # some torture |
bc62b4f7 |
27 | { |
8de3b21e |
28 | local @INC = @INC; |
29 | my @code; |
30 | unshift @INC, sub { |
31 | |
32 | if ($_[1] =~ /CleaneeTarget\/No(\d+)/) { |
33 | my @code = ( |
34 | "package CleaneeTarget::No${1};", |
35 | "sub x_foo { 'XFOO' }", |
36 | "sub x_bar { 'XBAR' }", |
37 | |
38 | "use CleaneeBridgeExplicit;", |
39 | |
40 | "1;", |
41 | ); |
42 | |
43 | return sub { return 0 unless @code; $_ = shift @code; 1; } |
44 | } |
45 | else { |
46 | return (); |
47 | } |
48 | }; |
49 | |
50 | for (1..1000) { |
51 | my $pkg = "CleaneeTarget::No${_}"; |
52 | |
bc62b4f7 |
53 | require "CleaneeTarget/No${_}.pm"; |
8de3b21e |
54 | |
55 | ok !$pkg->can('x_foo'), 'explicitely removed disappeared'; |
56 | ok $pkg->can('x_bar'), 'not in explicit removal and still there'; |
57 | } |
58 | } |