Permalink
Browse files

Add the value to the incorrect argument message.

That will help users debug their problem.

For #149
  • Loading branch information...
1 parent 9f64b2e commit f035722d940d2aba3304491d0f669a35df0628c3 @schwern schwern committed Nov 25, 2011
Showing with 6 additions and 6 deletions.
  1. +2 −2 lib/perl5i/2/ARRAY.pm
  2. +2 −2 t/popn.t
  3. +2 −2 t/shiftn.t
View
@@ -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
@@ -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
View
@@ -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"; {
View
@@ -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"; {

0 comments on commit f035722

Please sign in to comment.