15 flip_switch => 'toggle',
24 my $class = Moose::Meta::Class->create(
26 superclasses => ['Moose::Object'],
29 $class->add_attribute(
36 clearer => '_clear_is_list',
41 return ( $class->name, \%handles );
46 run_tests(build_class);
47 run_tests( build_class( lazy => 1 ) );
51 my ( $class, $handles ) = @_;
53 can_ok( $class, $_ ) for sort keys %{$handles};
56 my $obj = $class->new;
59 ok( $obj->is_lit, 'set is_lit to 1 using ->illuminate' );
60 ok( !$obj->is_dark, 'check if is_dark does the right thing' );
62 throws_ok { $obj->illuminate(1) }
63 qr/Cannot call set with any arguments/,
64 'set throws an error when an argument is passed';
67 ok( !$obj->is_lit, 'set is_lit to 0 using ->darken' );
68 ok( $obj->is_dark, 'check if is_dark does the right thing' );
70 throws_ok { $obj->darken(1) }
71 qr/Cannot call unset with any arguments/,
72 'unset throws an error when an argument is passed';
75 ok( $obj->is_lit, 'toggle is_lit back to 1 using ->flip_switch' );
76 ok( !$obj->is_dark, 'check if is_dark does the right thing' );
78 throws_ok { $obj->flip_switch(1) }
79 qr/Cannot call toggle with any arguments/,
80 'toggle throws an error when an argument is passed';
84 'toggle is_lit back to 0 again using ->flip_switch' );
85 ok( $obj->is_dark, 'check if is_dark does the right thing' );