Changelogging
[gitmo/Mouse.git] / t / 070_native_traits / 208_trait_bool.t
CommitLineData
fde8e43f 1#!/usr/bin/perl
2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
5
6use strict;
7use warnings;
8
9use Test::More;
10
11{
12 package Room;
13 use Mouse;
14
15 has 'is_lit' => (
16 traits => ['Bool'],
17 is => 'rw',
18 isa => 'Bool',
19 default => 0,
20 handles => {
21 illuminate => 'set',
22 darken => 'unset',
23 flip_switch => 'toggle',
24 is_dark => 'not',
25 },
26 )
27}
28
29my $room = Room->new;
30$room->illuminate;
31ok( $room->is_lit, 'set is_lit to 1 using ->illuminate' );
32ok( !$room->is_dark, 'check if is_dark does the right thing' );
33
34$room->darken;
35ok( !$room->is_lit, 'set is_lit to 0 using ->darken' );
36ok( $room->is_dark, 'check if is_dark does the right thing' );
37
38$room->flip_switch;
39ok( $room->is_lit, 'toggle is_lit back to 1 using ->flip_switch' );
40ok( !$room->is_dark, 'check if is_dark does the right thing' );
41
42$room->flip_switch;
43ok( !$room->is_lit, 'toggle is_lit back to 0 again using ->flip_switch' );
44ok( $room->is_dark, 'check if is_dark does the right thing' );
45
46done_testing;