7 use lib "$FindBin::Bin/../../../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
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
40 my $expected = join( ", ", @expected );
42 ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' );
43 is( $response->header('X-Catalyst-Executed'),
44 $expected, 'Executed actions' );
45 is( $response->content, 'one', 'Content OK' );
51 TestApp::Controller::Action::Auto->begin
52 TestApp::Controller::Action::Auto->auto
53 TestApp::Controller::Action::Auto->default
56 my $expected = join( ", ", @expected );
58 ok( my $response = request('http://localhost/action/auto/anything'), 'auto + default' );
59 is( $response->header('X-Catalyst-Executed'),
60 $expected, 'Executed actions' );
61 is( $response->content, 'default', 'Content OK' );
64 # test auto + auto + local
67 TestApp::Controller::Action::Auto::Deep->begin
68 TestApp::Controller::Action::Auto->auto
69 TestApp::Controller::Action::Auto::Deep->auto
70 TestApp::Controller::Action::Auto::Deep->one
73 my $expected = join( ", ", @expected );
75 ok( my $response = request('http://localhost/action/auto/deep/one'), 'auto + auto + local' );
76 is( $response->header('X-Catalyst-Executed'),
77 $expected, 'Executed actions' );
78 is( $response->content, 'deep one', 'Content OK' );
81 # test auto + auto + default
84 TestApp::Controller::Action::Auto::Deep->begin
85 TestApp::Controller::Action::Auto->auto
86 TestApp::Controller::Action::Auto::Deep->auto
87 TestApp::Controller::Action::Auto::Deep->default
90 my $expected = join( ", ", @expected );
92 ok( my $response = request('http://localhost/action/auto/deep/anything'), 'auto + auto + default' );
93 is( $response->header('X-Catalyst-Executed'),
94 $expected, 'Executed actions' );
95 is( $response->content, 'deep default', 'Content OK' );
98 # test auto + failing auto + local + end
101 TestApp::Controller::Action::Auto::Abort->begin
102 TestApp::Controller::Action::Auto->auto
103 TestApp::Controller::Action::Auto::Abort->auto
104 TestApp::Controller::Action::Auto::Abort->end
107 my $expected = join( ", ", @expected );
109 ok( my $response = request('http://localhost/action/auto/abort/one'), 'auto + failing auto + local' );
110 is( $response->header('X-Catalyst-Executed'),
111 $expected, 'Executed actions' );
112 is( $response->content, 'abort end', 'Content OK' );
115 # test auto + failing auto + default + end
118 TestApp::Controller::Action::Auto::Abort->begin
119 TestApp::Controller::Action::Auto->auto
120 TestApp::Controller::Action::Auto::Abort->auto
121 TestApp::Controller::Action::Auto::Abort->end
124 my $expected = join( ", ", @expected );
126 ok( my $response = request('http://localhost/action/auto/abort/anything'), 'auto + failing auto + default' );
127 is( $response->header('X-Catalyst-Executed'),
128 $expected, 'Executed actions' );
129 is( $response->content, 'abort end', 'Content OK' );