Commit | Line | Data |
356e7503 |
1 | use warnings; |
2 | use strict; |
3 | use Test::More; |
4 | use HTTP::Request::Common; |
5 | |
88e5a8b0 |
6 | # In DEBUG mode, we get not a number warnigs |
356e7503 |
7 | |
8 | my $error; |
9 | |
10 | { |
11 | package MyApp::Controller::Root; |
12 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
13 | |
14 | use base 'Catalyst::Controller'; |
15 | |
16 | sub root :Chained(/) PathPrefix CaptureArgs(0) { } |
17 | |
18 | sub test :Chained(root) Args('"Int"') { |
19 | my ($self, $c) = @_; |
20 | $c->response->body("This is the body"); |
21 | } |
22 | |
88e5a8b0 |
23 | sub infinity :Chained(root) PathPart('test') Args { |
356e7503 |
24 | my ($self, $c) = @_; |
25 | $c->response->body("This is the body"); |
5dd46e24 |
26 | Test::More::is $c->action->comparable_arg_number, ~0; |
27 | } |
28 | |
29 | sub midpoint :Chained(root) PathPart('') CaptureArgs('"Int"') { |
30 | my ($self, $c) = @_; |
31 | Test::More::is $c->action->number_of_captures, 1; |
32 | #Test::More::is $c->action->number_of_captures_constraints, 1; |
33 | } |
34 | |
35 | sub endpoint :Chained('midpoint') Args('"Int"') { |
36 | my ($self, $c) = @_; |
37 | Test::More::is $c->action->comparable_arg_number, 1; |
38 | Test::More::is $c->action->normalized_arg_number, 1; |
356e7503 |
39 | } |
40 | |
41 | sub local :Local Args { |
42 | my ($self, $c) = @_; |
43 | $c->response->body("This is the body"); |
5dd46e24 |
44 | Test::More::is $c->action->comparable_arg_number, ~0; |
356e7503 |
45 | } |
46 | |
47 | |
48 | package MyApp; |
49 | use Catalyst; |
50 | |
51 | sub debug { 1 } |
52 | |
53 | $SIG{__WARN__} = sub { $error = shift }; |
54 | |
53c7cc10 |
55 | MyApp->setup('-Log=fatal'); |
356e7503 |
56 | } |
57 | |
58 | use Catalyst::Test 'MyApp'; |
59 | |
60 | request GET '/root/test/a/b/c'; |
61 | request GET '/root/local/a/b/c'; |
5dd46e24 |
62 | request GET '/root/11/endpoint/22'; |
63 | |
356e7503 |
64 | |
65 | if($error) { |
66 | unlike($error, qr[Argument ""Int"" isn't numeric in repeat]); |
67 | } else { |
68 | ok 1; |
69 | } |
70 | |
5dd46e24 |
71 | done_testing(6); |