]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - t/20-good.t
Make sure PERL_INDIRECT_PM_DISABLE is not set before running tests
[perl/modules/indirect.git] / t / 20-good.t
index 88d80603cbae021567a929cbc75fb85206526595..353949893fe4d9fdb2117ba5b4c393638fe5e9ec 100644 (file)
@@ -9,11 +9,26 @@ package main;
 use strict;
 use warnings;
 
-use Test::More tests => 56 * 4;
+use Test::More tests => 56 * 8;
+
+BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
 
 my ($obj, $pkg, $cb, $x, @a);
 our $y;
 sub meh;
+sub zap (&);
+
+my @warns;
+
+sub try {
+ my ($code) = @_;
+
+ @warns = ();
+ {
+  local $SIG{__WARN__} = sub { push @warns, @_ };
+  eval $code;
+ }
+}
 
 {
  local $/ = "####";
@@ -28,23 +43,30 @@ sub meh;
 
 SKIP:
   {
-   skip "$_: $skip" => 4 if eval $skip;
-
-   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
+   skip "$_: $skip" => 8 if eval $skip;
 
-   eval "die qq{ok\\n}; $prefix; use indirect; $_";
-   is($@, "ok\n", "use indirect: $_");
+   {
+    try "return; $prefix; use indirect; $_";
+    is $@,     '', "use indirect: $_";
+    is @warns, 0,  'no reports';
 
-   eval "die qq{ok\n}; $prefix; no indirect; $_";
-   is($@, "ok\n", "no indirect: $_");
+    try "return; $prefix; no indirect; $_";
+    is $@,     '', "no indirect: $_";
+    is @warns, 0,  'no reports';
+   }
 
-   s/Hlagh/Dongs/g;
+   {
+    local $_ = $_;
+    s/Hlagh/Dongs/g;
 
-   eval "die qq{ok\\n}; $prefix; use indirect; $_";
-   is($@, "ok\n", "use indirect, defined: $_");
+    try "return; $prefix; use indirect; $_";
+    is $@,     '', "use indirect, defined: $_";
+    is @warns, 0,  'no reports';
 
-   eval "die qq{ok\\n}; $prefix; no indirect; $_";
-   is($@, "ok\n", "no indirect, defined: $_");
+    try "return; $prefix; no indirect; $_";
+    is $@,     '', "no indirect, defined: $_";
+    is @warns, 0,  'no reports';
+   }
   }
  }
 }
@@ -129,21 +151,6 @@ $obj = $pkg->$cb( $obj  );
 ####
 $obj = $pkg->$cb(qw/foo bar baz/);
 ####
-$obj = new { $x };
-####
-$obj = new
-  {
-     $x  }
-  ();
-####
-$obj = new {
-  $x  } qq/foo/;
-####
-$obj = new
-   {
-      $x
-    }(qw/bar baz/);
-####
 meh;
 ####
 meh $_;
@@ -191,3 +198,11 @@ exec { $a[0] } @a;
 system $x $x, @a;
 ####
 system { $a[0] } @a;
+####
+zap { };
+####
+zap { 1; };
+####
+zap { 1; 1; };
+####
+zap { zap { }; 1; };