X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F04-fallback-import-arg.t;h=968a7509da5025034f4859e3ed05027aac94919f;hb=523282cb37776bafbd208da07fde9a150d8f3e71;hp=ee2bbd5ee9e14d8a83b621cfd63dc37131238fe3;hpb=7b03c18e358942c3388e3ba4d93319333a25b9cf;p=perl%2Fmodules%2FTest-Leaner.git diff --git a/t/04-fallback-import-arg.t b/t/04-fallback-import-arg.t index ee2bbd5..968a750 100644 --- a/t/04-fallback-import-arg.t +++ b/t/04-fallback-import-arg.t @@ -40,19 +40,27 @@ my @default_exports = qw< sub check_imports { my %imported = map { $_ => 1 } @{ $_[0] || [] }; my @not_imported = @{ $_[1] || [] }; - for (@not_imported, grep !$imported{$_}, @default_exports) { - Test::More::ok(!exists $this_stash->{$_}, "$_ was not imported"); - } - for (grep $imported{$_}, @default_exports) { - my $code = get_subroutine($this_stash, $_); - Test::More::ok($code, "$_ was imported"); + +SKIP: + { + local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1; + Test::More::skip($_[2] => @not_imported + @default_exports) if defined $_[2]; + + for (@not_imported, grep !$imported{$_}, @default_exports) { + Test::More::ok(!exists $this_stash->{$_}, "$_ was not imported"); + } + for (grep $imported{$_}, @default_exports) { + my $code = get_subroutine($this_stash, $_); + Test::More::ok($code, "$_ was imported"); + } } + delete $this_stash->{$_} for @default_exports, keys %imported, @not_imported; } -Test::More::plan(tests => 8 * @default_exports + 7 + 2); +Test::More::plan(tests => 9 * @default_exports + 8 + 3); -check_imports(); +check_imports([ ], [ ], $Test::More::VERSION > 0.51 ? undef : 'Test::More::plan exports stuff on Test::More <= 0.51'); { local $@; @@ -72,6 +80,15 @@ check_imports(); check_imports([ ], [ 'nonexistent' ]); } +{ + local $@; + eval { + Test::Leaner->import(import => [ 'use_ok' ]); + }; + Test::More::like($@, qr/^"use_ok" is not exported by the Test::Leaner module/, 'import "use_ok" croaks'); + check_imports([ ], [ 'use_ok' ]); +} + { local $@; eval {