File: dead_load_bad_args.t

package info (click to toggle)
libcatalyst-perl 5.90075-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,712 kB
  • ctags: 1,428
  • sloc: perl: 12,388; makefile: 7
file content (65 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use strict;
use warnings;
use lib 't/lib';

use Test::More;

use Catalyst::Test 'TestApp';

for my $fail (
    "(' ')",
    "('')",
    "('1.23')",
    "(-1)",
) {
    for my $type (qw(Args CaptureArgs)) {
        eval <<"END";
            package TestApp::Controller::Action::Chained;
            no warnings 'redefine';
            sub should_fail : Chained('/') ${type}${fail} {}
END
        ok(!$@);

        eval { TestApp->setup_actions };
        like($@, qr/Invalid \Q${type}${fail}\E/,
             "Bad ${type}${fail} attribute makes action setup fail");
    }
}

for my $ok (
    "()",
    "(0)",
    "(1)",
    "('0')",
    "",
) {
    for my $type (qw(Args CaptureArgs)) {
        eval <<"END";
            package TestApp::Controller::Action::Chained;
            no warnings 'redefine';
            sub should_fail : Chained('/') ${type}${ok} {}
END
        ok(!$@);
        eval { TestApp->setup_actions };
        ok(!$@, "${type}${ok} works");
    }
}

for my $first (qw(Args CaptureArgs)) {
    for my $second (qw(Args CaptureArgs)) {
        eval <<"END";
            package TestApp::Controller::Action::Chained;
            no warnings 'redefine';
            sub should_fail :Chained('/') $first $second {}
END
        ok(!$@);
        eval { TestApp->setup_actions };
        my $msg = $first eq $second
           ? "Multiple $first"
           : "Combining Args and CaptureArgs";
        like($@, qr/$msg attributes not supported registering/,
             "$first + $second attribute makes action setup fail");
    }
}

done_testing();