4 use Test::More tests => 11;
17 my ($self, $value, $attr) = @_;
18 push @trigger, [$self, $value, $attr];
27 } "it's no longer an error to have trigger on a readonly attribute";
34 } qr/Trigger must be a CODE ref on attribute \(error\)/;
37 can_ok(Class => 'attr');
39 my $object = Class->new;
40 is(@trigger, 0, "trigger not called yet");
42 is($object->attr, 10, "default value");
43 is(@trigger, 0, "trigger not called on read");
45 is($object->attr(50), 50, "setting the value");
46 is(@trigger, 1, "trigger was called on read");
47 is_deeply([splice @trigger], [[$object, 50, undef]], "correct arguments to trigger in the accessor");
49 my $object2 = Class->new(attr => 100);
50 is(@trigger, 1, "trigger was called on new with the attribute specified");
51 is_deeply([splice @trigger], [[$object2, 100, undef]], "correct arguments to trigger in the constructor");