6 BEGIN { $ENV{PERL_TEST_LEANER_USES_TEST_MORE} = 1 }
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 local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1;
42 my %imported = map { $_ => 1 } @{ $_[0] || [] };
43 my @not_imported = @{ $_[1] || [] };
44 for (@not_imported, grep !$imported{$_}, @default_exports) {
45 Test::More::ok(!exists $this_stash->{$_}, "$_ was not imported");
47 for (grep $imported{$_}, @default_exports) {
48 my $code = get_subroutine($this_stash, $_);
49 Test::More::ok($code, "$_ was imported");
51 delete $this_stash->{$_} for @default_exports, keys %imported, @not_imported;
54 Test::More::plan(tests => 9 * @default_exports + 8 + 3);
61 Test::Leaner->import(import => [ ]);
63 Test::More::is($@, '', 'empty import does not croak');
64 check_imports(\@default_exports);
70 Test::Leaner->import(import => [ 'nonexistent' ]);
72 Test::More::like($@, qr/^"nonexistent" is not exported by the Test::More module/, 'import "nonexistent" croaks');
73 check_imports([ ], [ 'nonexistent' ]);
79 Test::Leaner->import(import => [ 'use_ok' ]);
81 Test::More::like($@, qr/^"use_ok" is not exported by the Test::Leaner module/, 'import "use_ok" croaks');
82 check_imports([ ], [ 'use_ok' ]);
88 Test::Leaner->import(import => [ 'ok' ]);
90 Test::More::is($@, '', 'import "ok" does not croak');
91 check_imports([ 'ok' ], [ ]);
98 import => [ qw<like unlike> ],
99 import => [ qw<diag note> ],
102 Test::More::is($@, '', 'import "like", "unlike", "diag" and "note" does not croak');
103 check_imports([ qw<like unlike diag note> ], [ ]);
109 Test::Leaner->import(import => [ '!fail' ]);
111 Test::More::is($@, '', 'import "!fail" does not croak');
112 check_imports([ grep $_ ne 'fail', @default_exports ], [ 'fail' ]);
118 Test::Leaner->import(import => [ 'pass' ], import => [ '!fail' ]);
120 Test::More::is($@, '', 'import "pass", "!fail" does not croak');
121 check_imports([ 'pass' ], [ ]);
127 Test::Leaner->import(import => [ 'fail' ], import => [ '!fail' ]);
129 Test::More::is($@, '', 'import "fail", "!fail" does not croak');