X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F007-attributes.t;h=ae538e6bf487f963980107a1254909963ceb58b9;hb=8cbcbb47d0f02077d07873c553494a884d9c085f;hp=140d0db818c61d9bceeee37405e229aa373346df;hpb=3118622d182add6c88792d5de3b4af047e8a7c8c;p=gitmo%2FMouse.git diff --git a/t/007-attributes.t b/t/007-attributes.t index 140d0db..ae538e6 100644 --- a/t/007-attributes.t +++ b/t/007-attributes.t @@ -1,14 +1,19 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 10; -use t::Exception; +use Test::More tests => 18; +use Test::Exception; + +use lib 't/lib'; +use Test::Mouse; do { package Class; use Mouse; - has 'x'; + has 'x' => ( + is => 'bare', + ); has 'y' => ( is => 'ro', @@ -17,11 +22,21 @@ do { has 'z' => ( is => 'rw', ); + + has 'attr' => ( + accessor => 'rw_attr', + reader => 'read_attr', + writer => 'write_attr', + ); }; ok(!Class->can('x'), "No accessor is injected if 'is' has no value"); can_ok('Class', 'y', 'z'); +has_attribute_ok 'Class', 'x'; +has_attribute_ok 'Class', 'y'; +has_attribute_ok 'Class', 'z'; + my $object = Class->new; ok(!$object->can('x'), "No accessor is injected if 'is' has no value"); @@ -39,3 +54,11 @@ is($object->z, undef); is($object->z(10), 10); is($object->z, 10); +can_ok($object, qw(rw_attr read_attr write_attr)); +$object->write_attr(42); +is $object->rw_attr, 42; +is $object->read_attr, 42; +$object->rw_attr(100); +is $object->rw_attr, 100; +is $object->read_attr, 100; +