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