1use Test::More tests => 12; 2 3{ 4 package Room; 5 use Mouse; 6 use MouseX::AttributeHelpers; 7 8 has 'is_lit' => ( 9 metaclass => 'Bool', 10 is => 'rw', 11 isa => 'Bool', 12 default => 0, 13 provides => { 14 set => 'illuminate', 15 unset => 'darken', 16 toggle => 'flip_switch', 17 not => 'is_dark' 18 } 19 ) 20} 21 22my $room = Room->new; 23 24my @providers = qw(illuminate darken flip_switch is_dark); 25for my $provider (@providers) { 26 can_ok $room => $provider; 27} 28 29$room->illuminate; 30ok $room->is_lit, 'set and check ok'; 31ok !$room->is_dark, 'set and not op ok'; 32 33$room->darken; 34ok !$room->is_lit, 'unset and check ok'; 35ok $room->is_dark, 'unset and not op ok'; 36 37$room->flip_switch; 38ok $room->is_lit, 'toggle and check ok'; 39ok !$room->is_dark, 'toggle and not op ok'; 40 41$room->flip_switch; 42ok !$room->is_lit, 'toggle and check agein ok'; 43ok $room->is_dark, 'toggle and not op again ok'; 44