]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - t/20-good.t
Switch to qw<>
[perl/modules/indirect.git] / t / 20-good.t
index d428d1fdf600d79f0ea08d7d9c12f93ab5fe33d5..97c874c7500c393400df9691eac8153dcc65d8bb 100644 (file)
@@ -9,11 +9,26 @@ package main;
 use strict;
 use warnings;
 
-use Test::More tests => 52 * 4;
+use Test::More tests => 101 * 8;
+
+BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
 
 my ($obj, $pkg, $cb, $x, @a);
-our $y;
+our ($y, $meth);
 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;
+   skip "$_: $skip" => 8 if eval $skip;
 
-   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
-
-   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';
+   }
   }
  }
 }
@@ -86,6 +108,14 @@ $obj = Hlagh   ->
   ,    bar     
                =>        $obj       );
 ####
+$obj = new->new;
+####
+$obj = new->new; # new new
+####
+$obj = new->newnew;
+####
+$obj = newnew->new;
+####
 $obj = Hlagh->$cb;
 ####
 $obj = Hlagh->$cb();
@@ -94,6 +124,12 @@ $obj = Hlagh->$cb($pkg);
 ####
 $obj = Hlagh->$cb(sub { 'foo' },  bar => $obj);
 ####
+$obj = Hlagh->$meth;
+####
+$obj =   Hlagh
+   -> 
+          $meth   ( 1,   2   );
+####
 $obj = $pkg->new   ;
 ####
 $obj = $pkg  ->   new  (   );
@@ -119,22 +155,31 @@ $obj = $pkg    ->   ($cb)   ();
 ####
 $obj = $pkg->$cb( $obj  );
 ####
-$obj = $pkg->$cb(qw/foo bar baz/);
+$obj = $pkg->$cb(qw<foo bar baz>);
 ####
-$obj = new { $x };
+$obj = $pkg->$meth;
 ####
-$obj = new
-  {
-     $x  }
-  ();
+$obj 
+ =
+    $pkg
+          ->
+              $meth
+  ( 1 .. 10 );
 ####
-$obj = new {
-  $x  } qq/foo/;
+$obj = $y->$cb;
 ####
-$obj = new
-   {
-      $x
-    }(qw/bar baz/);
+$obj =  $y
+  ->          $cb   (
+  'foo', 1, 2, 'bar'
+);
+####
+$obj = $y->$meth;
+####
+$obj =
+  $y->
+      $meth   (
+ qr(hello),
+);
 ####
 meh;
 ####
@@ -172,9 +217,83 @@ print STDOUT "bananananananana\n";
 ####
 $x->foo($pkg->$cb)
 ####
-$obj = "apple ${\(new Hlagh)} pear"
+$obj = "apple ${\($x->new)} pear"
+####
+$obj = "apple @{[$x->new]} pear"
+####
+$obj = "apple ${\($y->new)} pear"
 ####
-$obj = "apple @{[new Hlagh]} pear"
+$obj = "apple @{[$y->new]} pear"
+####
+$obj = "apple ${\($x->$cb)} pear"
+####
+$obj = "apple @{[$x->$cb]} pear"
+####
+$obj = "apple ${\($y->$cb)} pear"
+####
+$obj = "apple @{[$y->$cb]} pear"
+####
+$obj = "apple ${\($x->$meth)} pear"
+####
+$obj = "apple @{[$x->$meth]} pear"
+####
+$obj = "apple ${\($y->$meth)} pear"
+####
+$obj = "apple @{[$y->$meth]} pear"
+#### # local $_ = "foo";
+s/foo/return; Hlagh->new/e;
+#### # local $_ = "bar";
+s/foo/return; Hlagh->new/e;
+#### # local $_ = "foo";
+s/foo/return; Hlagh->$cb/e;
+#### # local $_ = "bar";
+s/foo/return; Hlagh->$cb/e;
+#### # local $_ = "foo";
+s/foo/return; Hlagh->$meth/e;
+#### # local $_ = "bar";
+s/foo/return; Hlagh->$meth/e;
+#### # local $_ = "foo";
+s/foo/return; $x->new/e;
+#### # local $_ = "bar";
+s/foo/return; $x->new/e;
+#### # local $_ = "foo";
+s/foo/return; $x->$cb/e;
+#### # local $_ = "bar";
+s/foo/return; $x->$cb/e;
+#### # local $_ = "foo";
+s/foo/return; $x->$meth/e;
+#### # local $_ = "bar";
+s/foo/return; $x->$meth/e;
+#### # local $_ = "foo";
+s/foo/return; $y->new/e;
+#### # local $_ = "bar";
+s/foo/return; $y->new/e;
+#### # local $_ = "foo";
+s/foo/return; $y->$cb/e;
+#### # local $_ = "bar";
+s/foo/return; $y->$cb/e;
+#### # local $_ = "foo";
+s/foo/return; $y->$meth/e;
+#### # local $_ = "bar";
+s/foo/return; $y->$meth/e;
+####
+"foo" =~ /(?{Hlagh->new})/;
+####
+"foo" =~ /(?{Hlagh->$cb})/;
+####
+"foo" =~ /(?{Hlagh->$meth})/;
+####
+"foo" =~ /(?{$x->new})/;
+####
+"foo" =~ /(?{$x->$cb})/;
+####
+"foo" =~ /(?{$x->$meth})/;
+####
+"foo" =~ /(?{$y->new})/;
+####
+"foo" =~ /(?{$y->$cb})/;
+####
+"foo" =~ /(?{$y->$meth})/;
 ####
 exec $x $x, @a;
 ####
@@ -183,3 +302,11 @@ exec { $a[0] } @a;
 system $x $x, @a;
 ####
 system { $a[0] } @a;
+####
+zap { };
+####
+zap { 1; };
+####
+zap { 1; 1; };
+####
+zap { zap { }; 1; };