From: Jay Hannah Date: Wed, 19 May 2010 22:36:21 +0000 (+0000) Subject: We appear to have a bug where if lazy => 1 isn't set an exception X-Git-Tag: 5.80025~2^2~13^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=950c7852982926188a3e716dcb52c3e1a9510936;hp=7aba3b2defff97a59aebafc5fc6f422a9d4f5439 We appear to have a bug where if lazy => 1 isn't set an exception occurs. --- diff --git a/t/aggregate/unit_core_ctx_attr.t b/t/aggregate/unit_core_ctx_attr.t new file mode 100644 index 0000000..be54c31 --- /dev/null +++ b/t/aggregate/unit_core_ctx_attr.t @@ -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; + diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index 6cd199f..d339f6e 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -16,6 +16,30 @@ use Catalyst::Utils; 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 );