make the missing data handler exception slightly more useful
[catagits/Catalyst-Runtime.git] / t / bad_warnings.t
1 use warnings;
2 use strict;
3 use Test::More;
4 use HTTP::Request::Common;
5
6 # In DEBUG mode, we get not a number warnigs 
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
23   sub infinity :Chained(root) PathPart('test') Args { 
24     my ($self, $c) = @_;
25     $c->response->body("This is the body");
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;
39   }
40
41   sub local :Local Args {
42     my ($self, $c) = @_;
43     $c->response->body("This is the body");
44     Test::More::is $c->action->comparable_arg_number, ~0;
45   }
46
47
48   package MyApp;
49   use Catalyst;
50
51   sub debug { 1 }
52
53   $SIG{__WARN__} = sub { $error = shift };
54
55   MyApp->setup;
56 }
57
58 use Catalyst::Test 'MyApp';
59
60 request GET '/root/test/a/b/c';
61 request GET '/root/local/a/b/c';
62 request GET '/root/11/endpoint/22';
63
64
65 if($error) {
66   unlike($error, qr[Argument ""Int"" isn't numeric in repeat]);
67 } else {
68   ok 1;
69 }
70
71 done_testing(6);