From: Vincent Pit Date: Tue, 19 Apr 2011 00:00:24 +0000 (+0200) Subject: Replace some code from t/03-fallback.t by Test::Leaner::TestImport X-Git-Tag: v0.03~3 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Leaner.git;a=commitdiff_plain;h=929c8bab7d9cc5a7247006772efa931797016d59 Replace some code from t/03-fallback.t by Test::Leaner::TestImport --- diff --git a/t/02-import-arg.t b/t/02-import-arg.t index 6470c83..9a27428 100644 --- a/t/02-import-arg.t +++ b/t/02-import-arg.t @@ -6,6 +6,6 @@ use warnings; BEGIN { delete $ENV{PERL_TEST_LEANER_USES_TEST_MORE} } use lib 't/lib'; -use Test::Leaner::TestImport; +use Test::Leaner::TestImport 'test_import_arg'; test_import_arg; diff --git a/t/03-fallback.t b/t/03-fallback.t index 93129ae..9c2451e 100644 --- a/t/03-fallback.t +++ b/t/03-fallback.t @@ -28,49 +28,16 @@ BEGIN { Test::More::is($loaded, 1, 'Test::More has been loaded'); } -sub get_subroutine { - my ($stash, $name) = @_; - - my $glob = $stash->{$name}; - return undef unless $glob; - - return *$glob{CODE}; -} - -sub has_module_version { - my ($module, $version) = @_; - - local $@; - eval qq{ - require $module; - "$module"->VERSION(\$version); - 1; - } -} - -sub has_test_more_version { has_module_version 'Test::More', @_ } +use lib 't/lib'; +use Test::Leaner::TestImport qw< + get_subroutine has_test_more_version default_exports +>; my $leaner_stash = \%Test::Leaner::; my $more_stash = \%Test::More::; my $this_stash = \%main::; -my @exported = qw< - plan - skip - done_testing - pass - fail - ok - is - isnt - like - unlike - cmp_ok - is_deeply - diag - note - BAIL_OUT ->; +my @exported = default_exports; for (@exported) { my $more_variant = get_subroutine($more_stash, $_); diff --git a/t/04-fallback-import-arg.t b/t/04-fallback-import-arg.t index 8e676f9..e0b3e4e 100644 --- a/t/04-fallback-import-arg.t +++ b/t/04-fallback-import-arg.t @@ -6,6 +6,6 @@ use warnings; BEGIN { $ENV{PERL_TEST_LEANER_USES_TEST_MORE} = 1 } use lib 't/lib'; -use Test::Leaner::TestImport; +use Test::Leaner::TestImport 'test_import_arg'; test_import_arg; diff --git a/t/lib/Test/Leaner/TestImport.pm b/t/lib/Test/Leaner/TestImport.pm index fd70030..0c55681 100644 --- a/t/lib/Test/Leaner/TestImport.pm +++ b/t/lib/Test/Leaner/TestImport.pm @@ -51,6 +51,8 @@ my @default_exports = qw< BAIL_OUT >; +sub default_exports { @default_exports } + sub check_imports { my %imported = map { $_ => 1 } @{ $_[0] || [] }; my @not_imported = @{ $_[1] || [] }; @@ -185,7 +187,12 @@ sub test_import_arg { } } -our @EXPORT = qw< +our @EXPORT_OK = qw< + get_subroutine + has_module_version + has_test_more_version + has_exporter_version + default_exports test_import_arg >;