make sure we still properly decode the part name
[catagits/Catalyst-Runtime.git] / t / dead_load_bad_args.t
CommitLineData
dd97c1ac 1use strict;
2use warnings;
3use lib 't/lib';
4
5use Test::More;
6
dd97c1ac 7use Catalyst::Test 'TestApp';
8
9for my $fail (
10 "(' ')",
11 "('')",
12 "('1.23')",
2782bef2 13 "(-1)",
dd97c1ac 14) {
08f8d85c 15 for my $type (qw(Args CaptureArgs)) {
16 eval <<"END";
17 package TestApp::Controller::Action::Chained;
18 no warnings 'redefine';
19 sub should_fail : Chained('/') ${type}${fail} {}
dd97c1ac 20END
08f8d85c 21 ok(!$@);
dd97c1ac 22
08f8d85c 23 eval { TestApp->setup_actions };
24 like($@, qr/Invalid \Q${type}${fail}\E/,
25 "Bad ${type}${fail} attribute makes action setup fail");
26 }
dd97c1ac 27}
28
29for my $ok (
30 "()",
31 "(0)",
32 "(1)",
33 "('0')",
34 "",
35) {
08f8d85c 36 for my $type (qw(Args CaptureArgs)) {
37 eval <<"END";
38 package TestApp::Controller::Action::Chained;
39 no warnings 'redefine';
40 sub should_fail : Chained('/') ${type}${ok} {}
41END
42 ok(!$@);
43 eval { TestApp->setup_actions };
44 ok(!$@, "${type}${ok} works");
45 }
46}
47
48for my $first (qw(Args CaptureArgs)) {
49 for my $second (qw(Args CaptureArgs)) {
50 eval <<"END";
51 package TestApp::Controller::Action::Chained;
52 no warnings 'redefine';
53 sub should_fail :Chained('/') $first $second {}
dd97c1ac 54END
08f8d85c 55 ok(!$@);
56 eval { TestApp->setup_actions };
57 my $msg = $first eq $second
58 ? "Multiple $first"
59 : "Combining Args and CaptureArgs";
60 like($@, qr/$msg attributes not supported registering/,
61 "$first + $second attribute makes action setup fail");
62 }
dd97c1ac 63}
08f8d85c 64
65done_testing();