]> 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 0f482a55cf0a3bce2d3026b11fa39457e8215261..353949893fe4d9fdb2117ba5b4c393638fe5e9ec 100644 (file)
@@ -9,12 +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 try (&);
+sub zap (&);
+
+my @warns;
+
+sub try {
+ my ($code) = @_;
+
+ @warns = ();
+ {
+  local $SIG{__WARN__} = sub { push @warns, @_ };
+  eval $code;
+ }
+}
 
 {
  local $/ = "####";
@@ -29,23 +43,30 @@ sub try (&);
 
 SKIP:
   {
-   skip "$_: $skip" => 4 if eval $skip;
-
-   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
-
-   eval "die qq{ok\\n}; $prefix; use indirect; $_";
-   is($@, "ok\n", "use indirect: $_");
-
-   eval "die qq{ok\n}; $prefix; no indirect; $_";
-   is($@, "ok\n", "no indirect: $_");
-
-   s/Hlagh/Dongs/g;
-
-   eval "die qq{ok\\n}; $prefix; use indirect; $_";
-   is($@, "ok\n", "use indirect, defined: $_");
-
-   eval "die qq{ok\\n}; $prefix; no indirect; $_";
-   is($@, "ok\n", "no indirect, defined: $_");
+   skip "$_: $skip" => 8 if eval $skip;
+
+   {
+    try "return; $prefix; use indirect; $_";
+    is $@,     '', "use indirect: $_";
+    is @warns, 0,  'no reports';
+
+    try "return; $prefix; no indirect; $_";
+    is $@,     '', "no indirect: $_";
+    is @warns, 0,  'no reports';
+   }
+
+   {
+    local $_ = $_;
+    s/Hlagh/Dongs/g;
+
+    try "return; $prefix; use indirect; $_";
+    is $@,     '', "use indirect, defined: $_";
+    is @warns, 0,  'no reports';
+
+    try "return; $prefix; no indirect; $_";
+    is $@,     '', "no indirect, defined: $_";
+    is @warns, 0,  'no reports';
+   }
   }
  }
 }
@@ -178,10 +199,10 @@ system $x $x, @a;
 ####
 system { $a[0] } @a;
 ####
-try { };
+zap { };
 ####
-try { 1; };
+zap { 1; };
 ####
-try { 1; 1; };
+zap { 1; 1; };
 ####
-try { try { }; 1; };
+zap { zap { }; 1; };