From: Dave Rolsky Date: Wed, 9 Mar 2011 21:02:09 +0000 (-0600) Subject: Add TODO tests for recursion bug with method modifiers on App->setup X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=refs%2Fheads%2Fdrolsky%2Fsetup-recursion-bug Add TODO tests for recursion bug with method modifiers on App->setup --- diff --git a/t/aggregate/unit_core_setup.t b/t/aggregate/unit_core_setup.t index c0e6230..c980b3c 100644 --- a/t/aggregate/unit_core_setup.t +++ b/t/aggregate/unit_core_setup.t @@ -3,7 +3,11 @@ use warnings; use Class::MOP; use Catalyst::Runtime; -use Test::More tests => 29; +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Test::More tests => 34; +use Test::Exception; { # Silence the log. @@ -86,3 +90,34 @@ my $log_meta = Class::MOP::Class->create_anon_class( ok my $c = TestAppWithOwnLogger->new, 'Get with own logger app object'; ok $c->debug, '$c->debug is true'; +local $TODO + = 'These tests will not pass until Catalyst stops supporting old (NEXT-using) plugins'; + +{ + local $SIG{__WARN__} = sub { + my $warn = join '', @_; + die $warn if $warn =~ /Deep recursion/; + warn $warn; + }; + + use_ok 'TestAppSetupRecursion'; + + no warnings 'once'; + is $TestAppSetupRecursion::AfterCount, 1, 'setup modifier was only called once'; +} + +{ + local $SIG{__WARN__} = sub { + my $warn = join '', @_; + die $warn if $warn =~ /Deep recursion/; + warn $warn; + }; + + use_ok 'TestAppSetupRecursionImmutable'; + + no warnings 'once'; + is $TestAppSetupRecursionImmutable::AfterCount, 1, 'setup modifier was only called once'; + + ok( TestAppSetupRecursionImmutable->meta->is_immutable, + 'package is still immutable after setup is called'); +} diff --git a/t/lib/TestAppSetupRecursion.pm b/t/lib/TestAppSetupRecursion.pm new file mode 100644 index 0000000..8eb50d1 --- /dev/null +++ b/t/lib/TestAppSetupRecursion.pm @@ -0,0 +1,15 @@ +package TestAppSetupRecursion; + +use Moose; +use namespace::autoclean; + +extends 'Catalyst'; + +our $SetupCount = 0; +# Content of the sub is irrelevant, the bug is that it's existence triggers +# infinite recursion. +after setup => sub { + $SetupCount++; +}; + +__PACKAGE__->setup; diff --git a/t/lib/TestAppSetupRecursionImmutable.pm b/t/lib/TestAppSetupRecursionImmutable.pm new file mode 100644 index 0000000..a16c762 --- /dev/null +++ b/t/lib/TestAppSetupRecursionImmutable.pm @@ -0,0 +1,17 @@ +package TestAppSetupRecursionImmutable; + +use Moose; +use namespace::autoclean; + +extends 'Catalyst'; + +our $SetupCount = 0; +# Content of the sub is irrelevant, the bug is that it's existence triggers +# infinite recursion. +after setup => sub { + $SetupCount++; +}; + +__PACKAGE__->meta->make_immutable( replace_constructor => 1 ); + +__PACKAGE__->setup;