6 BEGIN { delete $ENV{PERL_TEST_LEANER_USES_TEST_MORE} }
12 my ($stash, $name) = @_;
14 my $glob = $stash->{$name};
15 return undef unless $glob;
20 my $this_stash = \%main::;
22 my @default_exports = qw<
41 my %imported = map { $_ => 1 } @{ $_[0] || [] };
42 my @not_imported = @{ $_[1] || [] };
46 local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1;
47 Test::More::skip($_[2] => @not_imported + @default_exports) if defined $_[2];
49 for (@not_imported, grep !$imported{$_}, @default_exports) {
50 Test::More::ok(!exists $this_stash->{$_}, "$_ was not imported");
52 for (grep $imported{$_}, @default_exports) {
53 my $code = get_subroutine($this_stash, $_);
54 Test::More::ok($code, "$_ was imported");
58 delete $this_stash->{$_} for @default_exports, keys %imported, @not_imported;
61 Test::More::plan(tests => 9 * @default_exports + 8 + 3);
63 check_imports([ ], [ ], $Test::More::VERSION > 0.51 ? undef : 'Test::More::plan exports stuff on Test::More <= 0.51');
68 Test::Leaner->import(import => [ ]);
70 Test::More::is($@, '', 'empty import does not croak');
71 check_imports(\@default_exports);
77 Test::Leaner->import(import => [ 'nonexistent' ]);
79 Test::More::like($@, qr/^"nonexistent" is not exported by the Test::Leaner module/, 'import "nonexistent" croaks');
80 check_imports([ ], [ 'nonexistent' ]);
86 Test::Leaner->import(import => [ 'use_ok' ]);
88 Test::More::like($@, qr/^"use_ok" is not exported by the Test::Leaner module/, 'import "use_ok" croaks');
89 check_imports([ ], [ 'use_ok' ]);
95 Test::Leaner->import(import => [ 'ok' ]);
97 Test::More::is($@, '', 'import "ok" does not croak');
98 check_imports([ 'ok' ], [ ]);
104 Test::Leaner->import(
105 import => [ qw<like unlike> ],
106 import => [ qw<diag note> ],
109 Test::More::is($@, '', 'import "like", "unlike", "diag" and "note" does not croak');
110 check_imports([ qw<like unlike diag note> ], [ ]);
116 Test::Leaner->import(import => [ '!fail' ]);
118 Test::More::is($@, '', 'import "!fail" does not croak');
119 check_imports([ grep $_ ne 'fail', @default_exports ], [ 'fail' ]);
125 Test::Leaner->import(import => [ 'pass' ], import => [ '!fail' ]);
127 Test::More::is($@, '', 'import "pass", "!fail" does not croak');
128 check_imports([ 'pass' ], [ ]);
134 Test::Leaner->import(import => [ 'fail' ], import => [ '!fail' ]);
136 Test::More::is($@, '', 'import "fail", "!fail" does not croak');