From: Vincent Pit Date: Fri, 8 Apr 2011 18:25:14 +0000 (+0200) Subject: Skip the first import argument test with Test::More 0.51 and lower X-Git-Tag: v0.03~8 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=523282cb37776bafbd208da07fde9a150d8f3e71;p=perl%2Fmodules%2FTest-Leaner.git Skip the first import argument test with Test::More 0.51 and lower Since its plan() function wrongly exports symbols. --- diff --git a/t/02-import-arg.t b/t/02-import-arg.t index d2181d2..ee3da6b 100644 --- a/t/02-import-arg.t +++ b/t/02-import-arg.t @@ -38,22 +38,29 @@ my @default_exports = qw< >; sub check_imports { - local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1; 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 => 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 $@; diff --git a/t/04-fallback-import-arg.t b/t/04-fallback-import-arg.t index 6e0c4bf..968a750 100644 --- a/t/04-fallback-import-arg.t +++ b/t/04-fallback-import-arg.t @@ -38,22 +38,29 @@ my @default_exports = qw< >; sub check_imports { - local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1; 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 => 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 $@;