Skip to content

Commit

Permalink
Add the value to the incorrect argument message.
Browse files Browse the repository at this point in the history
That will help users debug their problem.

For #149
  • Loading branch information
schwern committed Nov 25, 2011
1 parent 9f64b2e commit f035722
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/perl5i/2/ARRAY.pm
Expand Up @@ -58,7 +58,7 @@ method grep($filter) {
method popn($times) {
Carp::croak("popn() takes the number of elements to pop")
unless defined $times;
Carp::croak("popn() takes a positive integer or zero")
Carp::croak("popn() takes a positive integer or zero, not '$times'")
unless $times->is_integer && ($times->is_positive or $times == 0);

# splice() will choke if you walk off the array, so rein it in
Expand All @@ -71,7 +71,7 @@ method popn($times) {
method shiftn($times) {
Carp::croak("shiftn() takes the number of elements to shift")
unless defined $times;
Carp::croak("shiftn() takes a positive integer or zero")
Carp::croak("shiftn() takes a positive integer or zero, not '$times'")
unless $times->is_integer && ($times->is_positive or $times == 0);

# splice() will choke if you walk off the array, so rein it in
Expand Down
4 changes: 2 additions & 2 deletions t/popn.t
Expand Up @@ -14,13 +14,13 @@ note "popn with no args"; {
note "popn with negative arg"; {
my @array = (1, 2, 3);
throws_ok { @array->popn(-20); }
qr{^\Qpopn() takes a positive integer or zero at $0 line };
qr{^\Qpopn() takes a positive integer or zero, not '-20' at $0 line };
}

note "popn with non-numerical argument"; {
my @array = (1, 2, 3);
throws_ok { @array->popn("rawr"); }
qr{^\Qpopn() takes a positive integer or zero at $0 line };
qr{^\Qpopn() takes a positive integer or zero, not 'rawr' at $0 line };
}

note "popn with arg == 0"; {
Expand Down
4 changes: 2 additions & 2 deletions t/shiftn.t
Expand Up @@ -14,13 +14,13 @@ note "shiftn with no args"; {
note "shiftn with negative arg"; {
my @array = (1, 2, 3);
throws_ok { @array->shiftn(-20); }
qr{^\Qshiftn() takes a positive integer or zero at $0 line };
qr{^\Qshiftn() takes a positive integer or zero, not '-20' at $0 line };
}

note "shiftn with non-numerical argument"; {
my @array = (1, 2, 3);
throws_ok { @array->shiftn("meow"); }
qr{^\Qshiftn() takes a positive integer or zero at $0 line };
qr{^\Qshiftn() takes a positive integer or zero, not 'meow' at $0 line };
}

note "shiftn with arg == 0"; {
Expand Down

0 comments on commit f035722

Please sign in to comment.