X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F016-trigger.t;h=29406c4f33123921df815ea05050b7169cde8461;hb=00136d64cc7c83ea95e623e045d0aa2963e7eb2a;hp=68a7b8926f57299772681c72a6a7802d6bcab2a6;hpb=de23149247d005314d08764c707e253217bb9ae3;p=gitmo%2FMouse.git diff --git a/t/016-trigger.t b/t/016-trigger.t index 68a7b89..29406c4 100644 --- a/t/016-trigger.t +++ b/t/016-trigger.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 16; -use Test::Exception; +use Test::More tests => 11; +use Mouse::Util ':test'; my @trigger; @@ -31,7 +31,7 @@ do { is => 'ro', trigger => [], ); - } qr/Trigger must be a CODE or HASH ref on attribute \(error\)/; + } qr/Trigger must be a CODE ref on attribute \(error\)/; }; can_ok(Class => 'attr'); @@ -50,50 +50,3 @@ my $object2 = Class->new(attr => 100); is(@trigger, 1, "trigger was called on new with the attribute specified"); is_deeply([splice @trigger], [[$object2, 100, $object2->meta->get_attribute('attr')]], "correct arguments to trigger in the constructor"); -do { - package Parent; - use Mouse; - - has attr => ( - is => 'rw', - trigger => { - before => sub { - push @trigger, ['before', @_]; - }, - after => sub { - push @trigger, ['after', @_]; - }, - around => sub { - my $code = shift; - my ($self, $value, $attr) = @_; - - push @trigger, ['around-before', $self, $value, $attr]; - $code->($self, 4 * $value, $attr); - push @trigger, ['around-after', $self, $value, $attr]; - }, - }, - ); - - package Child; - use Mouse; - extends 'Parent'; - - has '+attr' => ( - default => 10, - ); -}; - -my $child = Child->new; -is(@trigger, 0, "trigger not called on constructor with default"); - -is($child->attr, 10, "reader"); -is(@trigger, 0, "trigger not called on reader"); - -is($child->attr(5), 20, "writer"); -is_deeply([splice @trigger], [ - ['before', $child, 5, Child->meta->get_attribute('attr')], - ['around-before', $child, 5, Child->meta->get_attribute('attr')], - ['around-after', $child, 5, Child->meta->get_attribute('attr')], - ['after', $child, 20, Child->meta->get_attribute('attr')], -]); -