Remove register_implementation, warn about future deprecation
[gitmo/MooseX-AttributeHelpers.git] / t / 208_trait_bool.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 8;
7 use MooseX::AttributeHelpers;
8
9 {
10     package Room;
11     use Moose;
12     has 'is_lit' => (
13         traits    => ['MooseX::AttributeHelpers::Trait::Bool'],
14         is        => 'rw',
15         isa       => 'Bool',
16         default   => sub { 0 },
17         provides  => {
18             set     => 'illuminate',
19             unset   => 'darken',
20             toggle  => 'flip_switch',
21             not     => 'is_dark'
22         }
23     )
24 }
25
26 my $room = Room->new;
27 $room->illuminate;
28 ok $room->is_lit, 'set is_lit to 1 using ->illuminate';
29 ok !$room->is_dark, 'check if is_dark does the right thing';
30
31 $room->darken;
32 ok !$room->is_lit, 'set is_lit to 0 using ->darken';
33 ok $room->is_dark, 'check if is_dark does the right thing';
34
35 $room->flip_switch;
36 ok $room->is_lit, 'toggle is_lit back to 1 using ->flip_switch';
37 ok !$room->is_dark, 'check if is_dark does the right thing';
38
39 $room->flip_switch;
40 ok !$room->is_lit, 'toggle is_lit back to 0 again using ->flip_switch';
41 ok $room->is_dark, 'check if is_dark does the right thing';
42