Add TODO tests for recursion bug with method modifiers on App->setup drolsky/setup-recursion-bug
Dave Rolsky [Wed, 9 Mar 2011 21:02:09 +0000 (15:02 -0600)]
t/aggregate/unit_core_setup.t
t/lib/TestAppSetupRecursion.pm [new file with mode: 0644]
t/lib/TestAppSetupRecursionImmutable.pm [new file with mode: 0644]

index c0e6230..c980b3c 100644 (file)
@@ -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 (file)
index 0000000..8eb50d1
--- /dev/null
@@ -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 (file)
index 0000000..a16c762
--- /dev/null
@@ -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;