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