[Catalyst-commits] r13271 - in Catalyst-Runtime/5.80/trunk/t: aggregate lib

jhannah at dev.catalyst.perl.org jhannah at dev.catalyst.perl.org
Wed May 19 22:36:21 GMT 2010


Author: jhannah
Date: 2010-05-19 23:36:21 +0100 (Wed, 19 May 2010)
New Revision: 13271

Added:
   Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_ctx_attr.t
Modified:
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm
Log:
We appear to have a bug where if lazy => 1 isn't set an exception
occurs.


Added: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_ctx_attr.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_ctx_attr.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_ctx_attr.t	2010-05-19 22:36:21 UTC (rev 13271)
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$FindBin::Bin/../lib";
+use Test::More;
+use URI;
+
+use_ok('TestApp');
+
+my $request = Catalyst::Request->new( {
+                base => URI->new('http://127.0.0.1/foo')
+              } );
+my $dispatcher = TestApp->dispatcher;
+my $context = TestApp->new( {
+                request => $request,
+                namespace => 'yada',
+              } );
+
+is(        $context->hello_lazy,    'hello there', '$context->hello_lazy');
+eval { is( $context->hello_notlazy, 'hello there', '$context->hello_notlazy') };
+if ($@) {
+   fail('$context->hello_notlazy');
+   warn $@;
+}
+
+done_testing;
+

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm	2010-05-18 05:57:34 UTC (rev 13270)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm	2010-05-19 22:36:21 UTC (rev 13271)
@@ -16,6 +16,30 @@
 use Moose;
 use namespace::autoclean;
 
+# -----------
+# t/aggregate/unit_core_ctx_attr.t pukes until lazy is true
+package Greeting;
+use Moose;
+sub hello_notlazy { 'hello there' }
+sub hello_lazy    { 'hello there' }
+
+package TestApp;
+has 'my_greeting_obj_notlazy' => (
+   is      => 'ro',
+   isa     => 'Greeting',
+   default => sub { Greeting->new() },
+   handles => [ qw( hello_notlazy ) ],
+   lazy    => 0,
+);
+has 'my_greeting_obj_lazy' => (
+   is      => 'ro',
+   isa     => 'Greeting',
+   default => sub { Greeting->new() },
+   handles => [ qw( hello_lazy ) ],
+   lazy    => 1,
+);
+# -----------
+
 our $VERSION = '0.01';
 
 TestApp->config( name => 'TestApp', root => '/some/dir', use_request_uri_for_path => 1 );




More information about the Catalyst-commits mailing list