]> git.vpit.fr Git - perl/modules/Sub-Nary.git/commitdiff
stat() can also return no arguments if the file can't be found. Hopefully, our %ops...
authorVincent Pit <vince@profvince.com>
Tue, 5 Aug 2008 10:27:06 +0000 (12:27 +0200)
committerVincent Pit <vince@profvince.com>
Tue, 5 Aug 2008 10:27:06 +0000 (12:27 +0200)
lib/Sub/Nary.pm
t/20-return.t
t/21-list.t
t/23-branch.t

index c7792d5c3f782f1fd302526d0eab0c9aabf560a1..4a02bc2524b6c397f618e568f1870fbd3b57f16f 100644 (file)
@@ -204,7 +204,7 @@ $ops{$_} = 1      for qw/padsv/;
 $ops{$_} = 'list' for qw/padav/;
 $ops{$_} = 'list' for qw/padhv rv2hv/;
 $ops{$_} = 'list' for qw/padany flip match entereval readline/;
-$ops{stat}      = 13;
+$ops{stat}      = { 0 => 0.5, 13 => 0.5 };
 $ops{caller}    = sub { my @a = caller 0; scalar @a }->();
 $ops{localtime} = do { my @a = localtime; scalar @a };
 $ops{gmtime}    = do { my @a = gmtime; scalar @a };
@@ -255,7 +255,11 @@ sub expect_list {
  my $n = name($op);
  my $meth = $self->can('pp_' . $n);
  return $self->$meth($op) if $meth;
- return $ops{$n} => 0 if exists $ops{$n};
+ if (exists $ops{$n}) {
+  my $r = $ops{$n};
+  $r = { %$r } if ref $r eq 'HASH';
+  return $r => 0;
+ }
 
  if ($op->flags & OPf_KIDS) {
   my @res = (0);
index c4194a6b9849eebeed36a0c9b315a8063f53b1c8..b47babb997e86d08dcad4edb886cb300e065ce51 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 54;
+use Test::More tests => 53;
 
 use Sub::Nary;
 
@@ -75,7 +75,6 @@ my @tests = (
 
  [ sub { return -f $0, -r $0 }, 2 ],
 
- [ sub { return stat $0 },   13 ],
  [ sub { return caller 0 },  sub { my @a = caller 0; scalar @a }->() ],
  [ sub { return localtime }, do { my @a = localtime; scalar @a } ],
  [ sub { return gmtime },    do { my @a = gmtime; scalar @a } ],
index 80eb5ab6706ca8c1235422e9587211aaf3a8187c..4f973586ab13bba9390c0a2d48f2eaef97bdae9e 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 40;
+use Test::More tests => 39;
 
 use Sub::Nary;
 
@@ -63,7 +63,6 @@ my @tests = (
 
  [ sub { -f $0, -r $0 }, 2 ],
 
- [ sub { stat $0 },   13 ],
  [ sub { caller 0 },  sub { my @a = caller 0; scalar @a }->() ],
  [ sub { localtime }, do { my @a = localtime; scalar @a } ],
  [ sub { gmtime },    do { my @a = gmtime; scalar @a } ],
index cfc87c2f1b575eda0752b70bc29aa2dacd939680..914b975cfa319bf4541b960f32320b66a63f3863 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 15;
+use Test::More tests => 16;
 
 use Sub::Nary;
 
@@ -60,7 +60,8 @@ my @tests = (
 
  [ \&retinif, { 2 => 1 } ],
 
- [ sub { <*.*> }, { list => 1 / 3, 1 => 2 / 3 } ],
+ [ sub { <*.*> },   { list => 1 / 3, 1 => 2 / 3 } ],
+ [ sub { stat $0 }, { 0 => 0.5, 13 => 0.5 } ],
 );
 
 my $i = 1;