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.
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');
+}
--- /dev/null
+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;
--- /dev/null
+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;