X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fpreserve-object.t;h=7b6d2c521dbf08f2b274016debad4c715d2d5d9d;hb=bf842f6325fe9a408feacf1d230f0fbf51b5cedb;hp=79d5afdb13b7788d0b69a5959131607c3895e351;hpb=9180b0193ad4fe1c6a8555e71b547604476fcd37;p=catagits%2FCatalyst-Component-ACCEPT_CONTEXT.git diff --git a/t/preserve-object.t b/t/preserve-object.t index 79d5afd..7b6d2c5 100644 --- a/t/preserve-object.t +++ b/t/preserve-object.t @@ -1,19 +1,15 @@ #!/usr/bin/env perl - use strict; use warnings; -use Test::More tests => 4; -my $app = { app => 'oh yeah' }; - -my $foo = Foo->COMPONENT($app, { args => 'yes' }); -is $foo->{args}, 'yes', 'foo created'; -is $foo->context->{app}, 'oh yeah', 'got app'; +{ + package MyApp; + use Moose; + use Catalyst; + no Moose; -my $ctx = { ctx => 'it is' }; -my $foo2 = $foo->ACCEPT_CONTEXT($ctx); -is $foo, $foo2, 'foo and foo2 are the same ref'; -is $foo->context->{ctx}, 'it is', 'got ctx'; + sub _is_this_the_app { 'oh yeah' } +} { package Foo; @@ -23,5 +19,19 @@ is $foo->context->{ctx}, 'it is', 'got ctx'; my $class = shift; return $class->next::method(@_); } - } + +use Test::More tests => 4; +use Scalar::Util qw/refaddr/; + +my $app_class = 'MyApp'; + +my $foo = Foo->COMPONENT($app_class, { args => 'yes' }); +is $foo->{args}, 'yes', 'foo created'; +is $foo->context->_is_this_the_app, 'oh yeah', 'got app'; + +my $ctx = { }; +my $foo2 = $foo->ACCEPT_CONTEXT($ctx); +is refaddr($foo), refaddr($foo2), 'foo and foo2 are the same ref'; +is refaddr($foo->context), refaddr($ctx), 'got ctx'; +