7 use lib "$FindBin::Bin/../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
13 use Test::More tests => 18*$iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
21 # 11 wallclock secs (10.14 usr + 0.20 sys = 10.34 CPU) @ 15.18/s (n=157)
22 # old dispatcher (r1486):
23 # 11 wallclock secs (10.34 usr + 0.20 sys = 10.54 CPU) @ 13.76/s (n=145)
32 # test auto + local method
35 TestApp::Controller::Action::Auto->begin
36 TestApp::Controller::Action::Auto->auto
37 TestApp::Controller::Action::Auto->one
41 my $expected = join( ", ", @expected );
43 ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' );
44 is( $response->header('X-Catalyst-Executed'),
45 $expected, 'Executed actions' );
46 is( $response->content, 'one', 'Content OK' );
52 TestApp::Controller::Action::Auto->begin
53 TestApp::Controller::Action::Auto->auto
54 TestApp::Controller::Action::Auto->default
58 my $expected = join( ", ", @expected );
60 ok( my $response = request('http://localhost/action/auto/anything'), 'auto + default' );
61 is( $response->header('X-Catalyst-Executed'),
62 $expected, 'Executed actions' );
63 is( $response->content, 'default', 'Content OK' );
66 # test auto + auto + local
69 TestApp::Controller::Action::Auto::Deep->begin
70 TestApp::Controller::Action::Auto->auto
71 TestApp::Controller::Action::Auto::Deep->auto
72 TestApp::Controller::Action::Auto::Deep->one
76 my $expected = join( ", ", @expected );
78 ok( my $response = request('http://localhost/action/auto/deep/one'), 'auto + auto + local' );
79 is( $response->header('X-Catalyst-Executed'),
80 $expected, 'Executed actions' );
81 is( $response->content, 'deep one', 'Content OK' );
84 # test auto + auto + default
87 TestApp::Controller::Action::Auto::Deep->begin
88 TestApp::Controller::Action::Auto->auto
89 TestApp::Controller::Action::Auto::Deep->auto
90 TestApp::Controller::Action::Auto::Deep->default
94 my $expected = join( ", ", @expected );
96 ok( my $response = request('http://localhost/action/auto/deep/anything'), 'auto + auto + default' );
97 is( $response->header('X-Catalyst-Executed'),
98 $expected, 'Executed actions' );
99 is( $response->content, 'deep default', 'Content OK' );
102 # test auto + failing auto + local + end
105 TestApp::Controller::Action::Auto::Abort->begin
106 TestApp::Controller::Action::Auto->auto
107 TestApp::Controller::Action::Auto::Abort->auto
108 TestApp::Controller::Action::Auto::Abort->end
111 my $expected = join( ", ", @expected );
113 ok( my $response = request('http://localhost/action/auto/abort/one'), 'auto + failing auto + local' );
114 is( $response->header('X-Catalyst-Executed'),
115 $expected, 'Executed actions' );
116 is( $response->content, 'abort end', 'Content OK' );
119 # test auto + default (bug on invocation of default twice)
122 TestApp::Controller::Action::Auto::Default->begin
123 TestApp::Controller::Action::Auto->auto
124 TestApp::Controller::Action::Auto::Default->auto
125 TestApp::Controller::Action::Auto::Default->default
126 TestApp::Controller::Action::Auto::Default->end
129 my $expected = join( ", ", @expected );
131 ok( my $response = request('http://localhost/action/auto/default/moose'), 'auto + default' );
132 is( $response->header('X-Catalyst-Executed'),
133 $expected, 'Executed actions' );
134 is( $response->content, 'default (auto: 1)', 'Content OK' );