);
}
+ if ($part =~ m(^/)) {
+ Catalyst::Exception->throw(
+ "Absolute parameters to PathPart not allowed registering ${action}"
+ );
+ }
+
$action->attributes->{PartPath} = [ $part ];
unshift(@{ $children->{$part} ||= [] }, $action);
--- /dev/null
+package TestAppChainedAbsolutePathPart;
+
+use strict;
+use Catalyst qw/
+ Test::Errors
+ Test::Headers
+/;
+use Catalyst::Utils;
+
+our $VERSION = '0.01';
+
+TestAppChainedAbsolutePathPart
+ ->config(
+ name => 'TestAppChainedAbsolutePathPart',
+ root => '/some/dir'
+ );
+
+TestAppChainedAbsolutePathPart->setup;
+
+1;
--- /dev/null
+package TestAppChainedRecursive;
+
+use strict;
+use Catalyst qw/
+ Test::Errors
+ Test::Headers
+/;
+use Catalyst::Utils;
+
+our $VERSION = '0.01';
+
+TestAppChainedRecursive->config(
+ name => 'TestAppChainedRecursive',
+ root => '/some/dir'
+);
+
+TestAppChainedRecursive->setup;
+
+1;
--- /dev/null
+package TestAppChainedRecursive::Controller::Foo;
+
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller/;
+
+sub foo : Chained('bar') CaptureArgs(1) { }
+sub bar : Chained('foo') CaptureArgs(1) { }
+
+1;
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
-use Test::More tests => 99*$iters;
+use Test::More tests => 101*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
}
else {
for ( 1 .. $iters ) {
- run_tests();
+ run_tests($_);
}
}
sub run_tests {
+ my ($run_number) = @_;
#
# This is a simple test where the parent and child actions are
$expected, 'Executed actions' );
is( $response->content, '1; 2', 'Content OK' );
}
+
+ #
+ # Test interception of recursive chains. This test was added because at
+ # one point during the :Chained development, Catalyst used to hang on
+ # recursive chains.
+ #
+ {
+ eval { require 'TestAppChainedRecursive.pm' };
+ pass( "Interception of recursive chains" );
+ }
+
+ #
+ # Test failure of absolute path part arguments.
+ #
+ {
+ eval { require 'TestAppChainedAbsolutePathPart.pm' };
+ if ($run_number == 1) {
+ like( $@, qr(foo/foo),
+ "Usage of absolute path part argument emits error" );
+ }
+ else { pass( "Error on absolute path part arguments already tested" ) }
+ }
}