renamed helper_type => _helper_type
[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{
10 package Room;
11 use Moose;
12 has 'is_lit' => (
a41de825 13 traits => ['Bool'],
e3c07b19 14 is => 'rw',
15 isa => 'Bool',
16 default => sub { 0 },
90f26642 17 handles => {
18 illuminate => 'set',
19 darken => 'unset',
20 flip_switch => 'toggle',
21 is_dark => 'not',
22 },
e3c07b19 23 )
24}
25
26my $room = Room->new;
27$room->illuminate;
28ok $room->is_lit, 'set is_lit to 1 using ->illuminate';
29ok !$room->is_dark, 'check if is_dark does the right thing';
30
31$room->darken;
32ok !$room->is_lit, 'set is_lit to 0 using ->darken';
33ok $room->is_dark, 'check if is_dark does the right thing';
34
35$room->flip_switch;
36ok $room->is_lit, 'toggle is_lit back to 1 using ->flip_switch';
37ok !$room->is_dark, 'check if is_dark does the right thing';
38
39$room->flip_switch;
40ok !$room->is_lit, 'toggle is_lit back to 0 again using ->flip_switch';
41ok $room->is_dark, 'check if is_dark does the right thing';
42