From: Yuval Kogman Date: Sun, 18 Jun 2006 12:12:15 +0000 (+0000) Subject: Simplify and expand the context propagation test X-Git-Tag: 0_09_03~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cffe13adc85993b08f0db6b406e0a7579744eec9;p=gitmo%2FMoose.git Simplify and expand the context propagation test --- diff --git a/t/017_wrapped_method_context_propagation.t b/t/017_wrapped_method_context_propagation.t index 85750e1..8e97669 100644 --- a/t/017_wrapped_method_context_propagation.t +++ b/t/017_wrapped_method_context_propagation.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 8; BEGIN { use_ok('Moose'); @@ -13,7 +13,6 @@ BEGIN { package TouchyBase; use Moose; - has string_ref => ( is => 'rw', default => sub { my $x = "moose fruit"; \$x } ); has x => ( is => 'rw', default => 0 ); sub inc { $_[0]->x( 1 + $_[0]->x ) } @@ -22,27 +21,16 @@ BEGIN { wantarray ? (qw/a b c/) : "x"; } - sub array_arity { - split(/\s+/,"foo bar gorch baz la"); - } - sub void { die "this must be void context" if defined wantarray; } - sub substr_lvalue : lvalue { - my $self = shift; - my $string_ref = $self->string_ref; - my $lvalue_ref = \substr($$string_ref, 0, 5); - $$lvalue_ref; - } - package AfterSub; use Moose; extends "TouchyBase"; - after qw/scalar_or_array array_arity void substr_lvalue/ => sub { + after qw/scalar_or_array void/ => sub { my $self = shift; $self->inc; } @@ -64,5 +52,9 @@ foreach my $obj ( $base, $after ) { eval { $obj->void }; ok( !$@, "void context ($class)" ); } + + if ( $obj->isa("AfterSub") ) { + is( $obj->x, 3, "methods were wrapped" ); + } }