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