]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - lib/Test/Leaner.pm
Croak when importing symbols from Test::More that aren't in Test::Leaner
[perl/modules/Test-Leaner.git] / lib / Test / Leaner.pm
index 72531845aac4a400a729807632de6ae37213c3ca..f43be92145f520bd3ea16c3251c2c161d0d352e7 100644 (file)
@@ -165,14 +165,13 @@ if ($ENV{PERL_TEST_LEANER_USES_TEST_MORE}) {
  my $leaner_stash = \%Test::Leaner::;
  my $more_stash   = \%Test::More::;
 
- my %valid_imports;
+ my %stubbed;
 
  for (@EXPORT) {
   my $replacement = exists $more_stash->{$_} ? *{$more_stash->{$_}}{CODE}
                                              : undef;
-  if (defined $replacement) {
-   $valid_imports{$_} = 1;
-  } else {
+  unless (defined $replacement) {
+   $stubbed{$_}++;
    $replacement = sub {
     @_ = ("$_ is not implemented in this version of Test::More");
     goto &croak;
@@ -183,18 +182,21 @@ if ($ENV{PERL_TEST_LEANER_USES_TEST_MORE}) {
  }
 
  my $import = sub {
-  shift;
+  my $class = shift;
 
   my @imports = &_handle_import_args;
-  @imports = @EXPORT unless @imports;
+  @imports    = @EXPORT unless @imports;
   my @test_more_imports;
   for (@imports) {
-   if ($valid_imports{$_}) {
-    push @test_more_imports, $_;
-   } else {
+   if ($stubbed{$_}) {
     my $pkg = caller;
     no strict 'refs';
     *{$pkg."::$_"} = $leaner_stash->{$_};
+   } elsif (/^!/ or !exists $more_stash->{$_} or exists $leaner_stash->{$_}) {
+    push @test_more_imports, $_;
+   } else {
+    # Croak for symbols in Test::More but not in Test::Leaner
+    Exporter::import($class, $_);
    }
   }