From: Vincent Pit Date: Sun, 29 Jun 2008 15:52:15 +0000 (+0200) Subject: Importing Sub-Prototype-Util-0.08.tar.gz X-Git-Tag: v0.08 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Prototype-Util.git;a=commitdiff_plain;h=refs%2Ftags%2Fv0.08 Importing Sub-Prototype-Util-0.08.tar.gz --- diff --git a/Changes b/Changes index cd1307f..15a567f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Sub-Prototype-Util +0.08 2008-05-02 15:25 UTC + + Fix : "{ $func => undef }" (resp. "=> ''") should enforce no prototype + (resp. enforce an empty prototype). + 0.07 2008-04-21 09:00 UTC + Add : Forward eval() errors when compiling in wrap(). + Add : Talk about wrap() in the synopsis and samples/try.pl. diff --git a/META.yml b/META.yml index 796b2c7..dfa711f 100644 --- a/META.yml +++ b/META.yml @@ -1,11 +1,11 @@ --- #YAML:1.0 name: Sub-Prototype-Util -version: 0.07 +version: 0.08 abstract: Prototype-related utility routines. license: perl author: - Vincent Pit -generated_by: ExtUtils::MakeMaker version 6.42 +generated_by: ExtUtils::MakeMaker version 6.44 distribution_type: module requires: Carp: 0 diff --git a/Makefile.PL b/Makefile.PL index 0874b2c..6958e5b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,3 +1,5 @@ +use 5.006; + use strict; use warnings; use ExtUtils::MakeMaker; diff --git a/README b/README index 4ff0b74..316b1f6 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME Sub::Prototype::Util - Prototype-related utility routines. VERSION - Version 0.07 + Version 0.08 SYNOPSIS use Sub::Prototype::Util qw/flatten recall wrap/; diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index 531cdae..11eeb91 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -12,13 +12,13 @@ Sub::Prototype::Util - Prototype-related utility routines. =head1 VERSION -Version 0.07 +Version 0.08 =cut use vars qw/$VERSION/; -$VERSION = '0.07'; +$VERSION = '0.08'; =head1 SYNOPSIS @@ -116,15 +116,16 @@ sub _check_name { croak 'No subroutine specified' unless $name; my $proto; my $r = ref $name; - if ($r eq 'HASH') { + if (!$r) { + $proto = prototype $name; + } elsif ($r eq 'HASH') { croak 'Forced prototype hash reference must contain exactly one key/value pair' unless keys %$name == 1; ($name, $proto) = %$name; - } elsif (length $r) { + } else { croak 'Unhandled ' . $r . ' reference as first argument'; } $name =~ s/^\s+//; $name =~ s/[\s\$\@\%\*\&;].*//; - $proto = prototype $name unless $proto; return $name, $proto; } diff --git a/t/11-recall.t b/t/11-recall.t index 10c479c..916e7c5 100644 --- a/t/11-recall.t +++ b/t/11-recall.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 7 + 18 + (($^V ge v5.10.0) ? 4 : 0); +use Test::More tests => 7 + 20 + (($^V ge v5.10.0) ? 4 : 0); use Scalar::Util qw/set_prototype/; use Sub::Prototype::Util qw/recall/; @@ -35,7 +35,8 @@ my $g = [ sub { $_ > 2 }, 1 .. 5 ]; my @tests = ( [ 'main::noproto', 'no prototype', $t, $t, [ 2, 1 ] ], - [ { 'CORE::push' => undef }, 'push', [ [ 1, 2 ], 3, 5 ], [ [ 1, 2, 3, 5 ], 3, 5 ], [ 4 ] ], + [ { 'main::noproto' => undef }, 'no prototype forced', $t, $t, [ 2, 1 ] ], + [ 'CORE::push', 'push', [ [ 1, 2 ], 3, 5 ], [ [ 1, 2, 3, 5 ], 3, 5 ], [ 4 ] ], [ { 'CORE::push' => '\@$' }, 'push just one', [ [ 1, 2 ], 3, 5 ], [ [ 1, 2, 3 ], 3, 5 ], [ 3 ] ], [ { 'CORE::map' => '\&@' }, 'map', $m, $m, [ 11 .. 15 ] ], [ 'main::mytrunc', 'truncate 1', [ 1 ], [ 1 ], [ undef, 1 ] ],