X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F016-trigger.t;h=dc331c70cb918293e406599a5c33bbba5f032f6b;hb=2b09160967a78fa6891b553eb6ae90340c6565cb;hp=68a7b8926f57299772681c72a6a7802d6bcab2a6;hpb=d0566009e6a9eee9a27c21261f00915f9737a33e;p=gitmo%2FMouse.git diff --git a/t/016-trigger.t b/t/016-trigger.t index 68a7b89..dc331c7 100644 --- a/t/016-trigger.t +++ b/t/016-trigger.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 21; use Test::Exception; my @trigger; @@ -97,3 +97,22 @@ is_deeply([splice @trigger], [ ['after', $child, 20, Child->meta->get_attribute('attr')], ]); +my $parent = Parent->new(attr => 2); +is_deeply([splice @trigger], [ + ['before', $parent, 2, Parent->meta->get_attribute('attr')], + ['around-before', $parent, 2, Parent->meta->get_attribute('attr')], + ['around-after', $parent, 2, Parent->meta->get_attribute('attr')], + ['after', $parent, 8, Parent->meta->get_attribute('attr')], +]); + +is($parent->attr, 8, "reader"); +is(@trigger, 0, "trigger not called on reader"); + +is($parent->attr(10), 40, "writer"); +is_deeply([splice @trigger], [ + ['before', $parent, 10, Parent->meta->get_attribute('attr')], + ['around-before', $parent, 10, Parent->meta->get_attribute('attr')], + ['around-after', $parent, 10, Parent->meta->get_attribute('attr')], + ['after', $parent, 40, Parent->meta->get_attribute('attr')], +]); +