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] || [] };
43 for (@not_imported, grep !$imported{$_}, @default_exports) {
44 Test::More::ok(!exists $this_stash->{$_}, "$_ was not imported");
46 for (grep $imported{$_}, @default_exports) {
47 my $code = get_subroutine($this_stash, $_);
48 Test::More::ok($code, "$_ was imported");
50 delete $this_stash->{$_} for @default_exports, keys %imported, @not_imported;
53 Test::More::plan(tests => 9 * @default_exports + 8 + 3);
60 Test::Leaner->import(import => [ ]);
62 Test::More::is($@, '', 'empty import does not croak');
63 check_imports(\@default_exports);
69 Test::Leaner->import(import => [ 'nonexistent' ]);
71 Test::More::like($@, qr/^"nonexistent" is not exported by the Test::Leaner module/, 'import "nonexistent" croaks');
72 check_imports([ ], [ 'nonexistent' ]);
78 Test::Leaner->import(import => [ 'use_ok' ]);
80 Test::More::like($@, qr/^"use_ok" is not exported by the Test::Leaner module/, 'import "use_ok" croaks');
81 check_imports([ ], [ 'use_ok' ]);
87 Test::Leaner->import(import => [ 'ok' ]);
89 Test::More::is($@, '', 'import "ok" does not croak');
90 check_imports([ 'ok' ], [ ]);
97 import => [ qw<like unlike> ],
98 import => [ qw<diag note> ],
101 Test::More::is($@, '', 'import "like", "unlike", "diag" and "note" does not croak');
102 check_imports([ qw<like unlike diag note> ], [ ]);
108 Test::Leaner->import(import => [ '!fail' ]);
110 Test::More::is($@, '', 'import "!fail" does not croak');
111 check_imports([ grep $_ ne 'fail', @default_exports ], [ 'fail' ]);
117 Test::Leaner->import(import => [ 'pass' ], import => [ '!fail' ]);
119 Test::More::is($@, '', 'import "pass", "!fail" does not croak');
120 check_imports([ 'pass' ], [ ]);
126 Test::Leaner->import(import => [ 'fail' ], import => [ '!fail' ]);
128 Test::More::is($@, '', 'import "fail", "!fail" does not croak');