chmod -x test scripts
[catagits/Catalyst-Runtime.git] / t / dead_load_bad_args.t
1 use strict;
2 use warnings;
3 use lib 't/lib';
4
5 use Test::More;
6
7 # This test needs to be rewritten (and the code it was using as well) since
8 # when we added the arg and capturearg type constraint support, we now allow
9 # non integer values.  however we could probably support some additional sanity
10 # testing on the values, so this is a nice TODO for someone -jnap
11
12 plan skip_all => 'Removing this test because constraint arg types allow this';
13
14 use Catalyst::Test 'TestApp';
15
16 for my $fail (
17     "(' ')",
18     "('')",
19     "('1.23')",
20     "(-1)",
21 ) {
22     for my $type (qw(Args CaptureArgs)) {
23         eval <<"END";
24             package TestApp::Controller::Action::Chained;
25             no warnings 'redefine';
26             sub should_fail : Chained('/') ${type}${fail} {}
27 END
28         ok(!$@);
29
30         eval { TestApp->setup_actions };
31         like($@, qr/Invalid \Q${type}${fail}\E/,
32              "Bad ${type}${fail} attribute makes action setup fail");
33     }
34 }
35
36 for my $ok (
37     "()",
38     "(0)",
39     "(1)",
40     "('0')",
41     "",
42 ) {
43     for my $type (qw(Args CaptureArgs)) {
44         eval <<"END";
45             package TestApp::Controller::Action::Chained;
46             no warnings 'redefine';
47             sub should_fail : Chained('/') ${type}${ok} {}
48 END
49         ok(!$@);
50         eval { TestApp->setup_actions };
51         ok(!$@, "${type}${ok} works");
52     }
53 }
54
55 for my $first (qw(Args CaptureArgs)) {
56     for my $second (qw(Args CaptureArgs)) {
57         eval <<"END";
58             package TestApp::Controller::Action::Chained;
59             no warnings 'redefine';
60             sub should_fail :Chained('/') $first $second {}
61 END
62         ok(!$@);
63         eval { TestApp->setup_actions };
64         my $msg = $first eq $second
65            ? "Multiple $first"
66            : "Combining Args and CaptureArgs";
67         like($@, qr/$msg attributes not supported registering/,
68              "$first + $second attribute makes action setup fail");
69     }
70 }
71
72 done_testing();