In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/bc150b6ce0f4272607b4e7ce03d2abbf81418215?hp=718ac8a2e5fd26fa68078f057e7c332594ebebf6>
- Log ----------------------------------------------------------------- commit bc150b6ce0f4272607b4e7ce03d2abbf81418215 Author: darksuji <[email protected]> Date: Tue Apr 7 18:44:48 2015 -0700 Make behavior of $Carp::MaxArgNums match docs $Carp::MaxArgNums is supposed to be the number of arguments to display. For a long time, Carp has instead shown $Carp::MaxArgNums + 1 arguments. Correct the behavior by making it match the documentation. Also update tests to make what's being tested more obvious. ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + dist/Carp/lib/Carp.pm | 7 ++++--- dist/Carp/lib/Carp/Heavy.pm | 2 +- dist/Carp/t/Carp.t | 24 ++++++++++++++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3ef8499..b5ef912 100644 --- a/AUTHORS +++ b/AUTHORS @@ -63,6 +63,7 @@ Alex Solovey <[email protected]> Alex Vandiver <[email protected]> Alex Waugh <[email protected]> Alexander Bluhm <[email protected]> +Alexander D'Archangel <[email protected]> Alexander Gernler <[email protected]> Alexander Gough <[email protected]> Alexander Klimov <[email protected]> diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm index 5b191eb..61192b8 100644 --- a/dist/Carp/lib/Carp.pm +++ b/dist/Carp/lib/Carp.pm @@ -87,7 +87,7 @@ BEGIN { } } -our $VERSION = '1.36'; +our $VERSION = '1.37'; our $MaxEvalLen = 0; our $Verbose = 0; @@ -229,7 +229,7 @@ sub caller_info { my $overflow; if ( $MaxArgNums and @args > $MaxArgNums ) { # More than we want to show? - $#args = $MaxArgNums; + $#args = $MaxArgNums - 1; $overflow = 1; } @@ -783,7 +783,8 @@ Defaults to C<64>. =head2 $Carp::MaxArgNums This variable determines how many arguments to each function to show. -Use a value of C<0> to show all arguments to a function call. +Use a false value to show all arguments to a function call. To suppress all +arguments, use C<-1> or C<'0 but true'>. Defaults to C<8>. diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm index a602297..ed446c5 100644 --- a/dist/Carp/lib/Carp/Heavy.pm +++ b/dist/Carp/lib/Carp/Heavy.pm @@ -2,7 +2,7 @@ package Carp::Heavy; use Carp (); -our $VERSION = '1.36'; +our $VERSION = '1.37'; # Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions # after this point are not significant and can be ignored. diff --git a/dist/Carp/t/Carp.t b/dist/Carp/t/Carp.t index 3d707a1..c86f5ff 100644 --- a/dist/Carp/t/Carp.t +++ b/dist/Carp/t/Carp.t @@ -3,7 +3,7 @@ no warnings "once"; use Config; use IPC::Open3 1.0103 qw(open3); -use Test::More tests => 60; +use Test::More tests => 65; sub runperl { my(%args) = @_; @@ -237,16 +237,28 @@ sub w { cluck @_ } # $Carp::MaxArgNums { - my $i = 0; my $aref = [ - qr/1234 at \S*(?i:carp.t) line \d+\.\n\s*main::w\(1, 2, 3, 4\) called at \S*(?i:carp.t) line \d+/, - qr/1234 at \S*(?i:carp.t) line \d+\.\n\s*main::w\(1, 2, \.\.\.\) called at \S*(?i:carp.t) line \d+/, + [ -1 => '(...)' ], + [ 0 => '(1, 2, 3, 4)' ], + [ '0 but true' => '(...)' ], + [ 1 => '(1, ...)' ], + [ 3 => '(1, 2, 3, ...)' ], + [ 4 => '(1, 2, 3, 4)' ], + [ 5 => '(1, 2, 3, 4)' ], ]; for (@$aref) { - local $Carp::MaxArgNums = $i++; + my ($arg_count, $expected_signature) = @$_; + + my $expected = join('', + '1234 at \S*(?i:carp.t) line \d+\.\n\s*main::w', + quotemeta $expected_signature, + ' called at \S*(?i:carp.t) line \d+' + ); + + local $Carp::MaxArgNums = $arg_count; local $SIG{__WARN__} = sub { - like "@_", $_, 'MaxArgNums'; + like "@_", qr/$expected/, "MaxArgNums=$arg_count"; }; package Z; -- Perl5 Master Repository
