X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F016-trigger.t;h=06f0aff809389df997ff4f03b3edaad05b497c78;hb=f262f14e4f739820c2a6d43b63041c68cf411774;hp=4ba0743381197b17bd0bc4f4191e1baf52afdb3e;hpb=3b5febd3d53867abcaba658628c3302fd9d52261;p=gitmo%2FMouse.git diff --git a/t/016-trigger.t b/t/016-trigger.t index 4ba0743..06f0aff 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 t::Exception; 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,39 +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 Class2; - use Mouse; - - has attr => ( - is => 'rw', - default => 10, - trigger => { - before => sub { - push @trigger, ['before', @_]; - }, - after => sub { - push @trigger, ['after', @_]; - }, - around => sub { - my $code = shift; - push @trigger, ['around-before', @_]; - $code->(); - push @trigger, ['around-after', @_]; - }, - }, - ); -}; - -my $o2 = Class2->new; -is(@trigger, 0, "trigger not called on constructor with default"); - -is($o2->attr, 10, "reader"); -is(@trigger, 0, "trigger not called on reader"); - -is($o2->attr(5), 5, "writer"); -is_deeply([splice @trigger], [ - ['before', $o2, 5, $o2->meta->get_attribute('attr')], - ['after', $o2, 5, $o2->meta->get_attribute('attr')], -]); -