5 use List::Util 'first';
11 unshift @INC, sub { croak 'Shouldn\'t load Sub::Exporter' if $_[1] eq 'Sub/Exporter.pm' };
14 ok(!main->can('junk1'), 'junk1 not exported');
15 ok(!main->can('junk2'), 'junk2 not exported');
16 ok(main->can('junk3'), 'junk3 exported');
17 ok(! $INC{'Sub/Exporter.pm'}, 'Sub::Exporter not loaded');
20 package Local::Exporter;
21 use Sub::Exporter::Progressive -setup => {
22 exports => [qw/ foo bar baz /],
24 default => [qw/ foo /],
25 bb => [qw/ bar baz /],
33 $INC{'Local/Exporter.pm'} = __FILE__;
39 my ($tag, $should, $shouldnt) = @_;
40 my $pkg = 'Local::Importer' . ++$i;
41 subtest "test the '$tag' tag" => sub
43 plan tests => 1 + @$should + @$shouldnt;
48 use Local::Exporter qw( $tag );
50 }, "$pkg compiled") or diag $@;
52 ok( $pkg->can($_), "$pkg\->can(\"$_\")") for @$should;
53 ok(!$pkg->can($_), "$pkg\->can't(\"$_\")") for @$shouldnt;
57 check_tag(':default', [qw/foo/], [qw/bar baz/]);
58 check_tag('-default', [qw/foo/], [qw/bar baz/]);
59 check_tag(':default bar', [qw/foo bar/], [qw/baz/]);
60 check_tag('-default bar', [qw/foo bar/], [qw/baz/]);
61 check_tag('bar :default', [qw/foo bar/], [qw/baz/]);
62 check_tag('bar -default', [qw/foo bar/], [qw/baz/]);
63 check_tag(':bb', [qw/bar baz/], [qw/foo/]);
64 check_tag('-bb', [qw/bar baz/], [qw/foo/]);
65 check_tag(':all', [qw/foo bar baz/], []);
66 check_tag('-all', [qw/foo bar baz/], []);