From: John Napiorkowski Date: Mon, 22 Feb 2016 17:24:17 +0000 (-0600) Subject: use normalized args to silence warnings in DEBUG mode X-Git-Tag: 5.90105~7^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=356e750347c4dd4bfe56a3b142252fbbf4c345b7 use normalized args to silence warnings in DEBUG mode --- diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index 7351f39..3497e21 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -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, } } diff --git a/t/bad_warnings.t b/t/bad_warnings.t new file mode 100644 index 0000000..2aabc28 --- /dev/null +++ b/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);