Skip to content

Commit

Permalink
use normalized args to silence warnings in DEBUG mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jjn1056 committed Feb 22, 2016
1 parent ed60d91 commit 356e750
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Catalyst/Action.pm
Expand Up @@ -461,7 +461,7 @@ sub scheme {
sub list_extra_info {
my $self = shift;
return {
Args => $self->attributes->{Args}[0],
Args => $self->normalized_arg_number,
CaptureArgs => $self->number_of_captures,
}
}
Expand Down
57 changes: 57 additions & 0 deletions t/bad_warnings.t
@@ -0,0 +1,57 @@
use warnings;
use strict;
use Test::More;
use HTTP::Request::Common;

# In DEBUG mode, we get not a number warnigs

my $error;

{
package MyApp::Controller::Root;
$INC{'MyApp/Controller/Root.pm'} = __FILE__;

use base 'Catalyst::Controller';

sub root :Chained(/) PathPrefix CaptureArgs(0) { }
sub test :Chained(root) Args('"Int"') {
my ($self, $c) = @_;
$c->response->body("This is the body");
}
sub infinity :Chained(root) PathPart('test') Args {
my ($self, $c) = @_;
$c->response->body("This is the body");
Test::More::is $c->action->normalized_arg_number, ~0;
}
sub local :Local Args {
my ($self, $c) = @_;
$c->response->body("This is the body");
Test::More::is $c->action->normalized_arg_number, ~0;
}
package MyApp;
use Catalyst;
sub debug { 1 }
$SIG{__WARN__} = sub { $error = shift };
MyApp->setup;
}
use Catalyst::Test 'MyApp';
request GET '/root/test/a/b/c';
request GET '/root/local/a/b/c';
if($error) {
unlike($error, qr[Argument ""Int"" isn't numeric in repeat]);
} else {
ok 1;
}
done_testing(3);

0 comments on commit 356e750

Please sign in to comment.