package Foo;
use Moose;
- has 'bar' => (is => 'rw');
+ has 'bar' => ( is => 'rw' );
package Stuffed::Role;
use Moose::Role;
has 'options' => (
- traits => [ 'Collection::Array' ],
- is => 'ro',
- isa => 'ArrayRef[Foo]',
+ traits => ['Collection::Array'],
+ is => 'ro',
+ isa => 'ArrayRef[Foo]',
);
package Bulkie::Role;
use Moose::Role;
has 'stuff' => (
- traits => [ 'Collection::Array' ],
- is => 'ro',
- isa => 'ArrayRef',
- handles => {
+ traits => ['Collection::Array'],
+ is => 'ro',
+ isa => 'ArrayRef',
+ handles => {
get_stuff => 'get',
}
);
package Stuff;
use Moose;
- ::lives_ok {
- with 'Stuffed::Role';
- } '... this should work correctly';
-
- ::lives_ok {
- with 'Bulkie::Role';
- } '... this should work correctly';
+ ::lives_ok{ with 'Stuffed::Role';
+ } '... this should work correctly';
+ ::lives_ok{ with 'Bulkie::Role';
+ } '... this should work correctly';
}
package MyHomePage;
use Moose;
- has 'counter' => (traits => ['Counter']);
+ has 'counter' => ( traits => ['Counter'] );
}
my $page = MyHomePage->new();
-isa_ok($page, 'MyHomePage');
+isa_ok( $page, 'MyHomePage' );
-can_ok($page, $_) for qw[
+can_ok( $page, $_ ) for qw[
dec_counter
inc_counter
reset_counter
];
-is($page->counter, 0, '... got the default value');
+is( $page->counter, 0, '... got the default value' );
$page->inc_counter;
-is($page->counter, 1, '... got the incremented value');
+is( $page->counter, 1, '... got the incremented value' );
$page->inc_counter;
-is($page->counter, 2, '... got the incremented value (again)');
+is( $page->counter, 2, '... got the incremented value (again)' );
$page->dec_counter;
-is($page->counter, 1, '... got the decremented value');
+is( $page->counter, 1, '... got the decremented value' );
$page->reset_counter;
-is($page->counter, 0, '... got the original value');
+is( $page->counter, 0, '... got the original value' );
# check the meta ..
my $counter = $page->meta->get_attribute('counter');
-does_ok($counter, 'Moose::AttributeHelpers::Trait::Counter');
-
-is($counter->type_constraint->name, 'Num', '... got the expected default type constraint');
-
-is_deeply($counter->handles, {
- 'inc_counter' => 'inc',
- 'dec_counter' => 'dec',
- 'reset_counter' => 'reset',
- 'set_counter' => 'set',
-}, '... got the right default handles methods');
+does_ok( $counter, 'Moose::AttributeHelpers::Trait::Counter' );
+
+is( $counter->type_constraint->name, 'Num',
+ '... got the expected default type constraint' );
+
+is_deeply(
+ $counter->handles,
+ {
+ 'inc_counter' => 'inc',
+ 'dec_counter' => 'dec',
+ 'reset_counter' => 'reset',
+ 'set_counter' => 'set',
+ },
+ '... got the right default handles methods'
+);
use Moose;
has 'counter' => (
- traits => [ 'Counter' ],
- is => 'ro',
- isa => 'Int',
- default => sub { 0 },
- handles => {
+ traits => ['Counter'],
+ is => 'ro',
+ isa => 'Int',
+ default => 0,
+ handles => {
inc_counter => 'inc',
dec_counter => 'dec',
reset_counter => 'reset',
}
my $page = MyHomePage->new();
-isa_ok($page, 'MyHomePage');
+isa_ok( $page, 'MyHomePage' );
-can_ok($page, $_) for qw[
+can_ok( $page, $_ ) for qw[
counter
dec_counter
inc_counter
];
lives_ok {
- $page->meta->remove_attribute('counter')
-} '... removed the counter attribute okay';
+ $page->meta->remove_attribute('counter');
+}
+'... removed the counter attribute okay';
-ok(!$page->meta->has_attribute('counter'), '... no longer has the attribute');
+ok( !$page->meta->has_attribute('counter'),
+ '... no longer has the attribute' );
-ok(!$page->can($_), "... our class no longer has the $_ method") for qw[
+ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[
counter
dec_counter
inc_counter
reset_counter
];
-
-
-
use_ok('Moose::AttributeHelpers');
}
-package Subject;
-
-use Moose::Role;
-use Moose::AttributeHelpers;
-
-has observers => (
- traits => [ 'Collection::Array' ],
- is => 'ro',
- isa => 'ArrayRef[Observer]',
- auto_deref => 1,
- default => sub { [] },
- handles => {
- 'add_observer' => 'push',
- 'count_observers' => 'count',
- },
-);
-
-sub notify {
- my ($self) = @_;
- foreach my $observer ( $self->observers() ) {
- $observer->update($self);
+{
+ package Subject;
+
+ use Moose::Role;
+ use Moose::AttributeHelpers;
+
+ has observers => (
+ traits => ['Collection::Array'],
+ is => 'ro',
+ isa => 'ArrayRef[Observer]',
+ auto_deref => 1,
+ default => sub { [] },
+ handles => {
+ 'add_observer' => 'push',
+ 'count_observers' => 'count',
+ },
+ );
+
+ sub notify {
+ my ($self) = @_;
+ foreach my $observer ( $self->observers() ) {
+ $observer->update($self);
+ }
}
}
-###############################################################################
+{
+ package Observer;
-package Observer;
+ use Moose::Role;
-use Moose::Role;
-
-requires 'update';
-
-###############################################################################
-
-package Counter;
-
-use Moose;
-use Moose::AttributeHelpers;
-
-with 'Subject';
-
-has count => (
- traits => [ 'Counter' ],
- is => 'ro',
- isa => 'Int',
- default => 0,
- handles => {
- inc_counter => 'inc',
- dec_counter => 'dec',
- },
-);
+ requires 'update';
+}
-after qw(inc_counter dec_counter) => sub {
- my ($self) = @_;
- $self->notify();
-};
+{
+ package Counter;
+
+ use Moose;
+ use Moose::AttributeHelpers;
+
+ with 'Subject';
+
+ has count => (
+ traits => ['Counter'],
+ is => 'ro',
+ isa => 'Int',
+ default => 0,
+ handles => {
+ inc_counter => 'inc',
+ dec_counter => 'dec',
+ },
+ );
+
+ after qw(inc_counter dec_counter) => sub {
+ my ($self) = @_;
+ $self->notify();
+ };
+}
-###############################################################################
+{
-package Display;
+ package Display;
-use Test::More;
+ use Test::More;
-use Moose;
+ use Moose;
-with 'Observer';
+ with 'Observer';
-sub update {
- my ( $self, $subject ) = @_;
- like $subject->count, qr{^-?\d+$}, 'Observed number ' . $subject->count;
+ sub update {
+ my ( $self, $subject ) = @_;
+ like $subject->count, qr{^-?\d+$},
+ 'Observed number ' . $subject->count;
+ }
}
-###############################################################################
-
package main;
my $count = Counter->new();
-ok($count->can('add_observer'), 'add_observer method added');
+ok( $count->can('add_observer'), 'add_observer method added' );
-ok($count->can('count_observers'), 'count_observers method added');
+ok( $count->can('count_observers'), 'count_observers method added' );
-ok($count->can('inc_counter'), 'inc_counter method added');
+ok( $count->can('inc_counter'), 'inc_counter method added' );
-ok($count->can('dec_counter'), 'dec_counter method added');
+ok( $count->can('dec_counter'), 'dec_counter method added' );
$count->add_observer( Display->new() );
-is($count->count_observers, 1, 'Only one observer');
+is( $count->count_observers, 1, 'Only one observer' );
-is($count->count, 0, 'Default to zero');
+is( $count->count, 0, 'Default to zero' );
$count->inc_counter;
-is($count->count, 1, 'Increment to one ');
+is( $count->count, 1, 'Increment to one ' );
-$count->inc_counter for (1 .. 6);
+$count->inc_counter for ( 1 .. 6 );
-is($count->count, 7, 'Increment up to seven');
+is( $count->count, 7, 'Increment up to seven' );
$count->dec_counter;
-is($count->count, 6, 'Decrement to 6');
+is( $count->count, 6, 'Decrement to 6' );
-$count->dec_counter for (1 .. 5);
+$count->dec_counter for ( 1 .. 5 );
-is($count->count, 1, 'Decrement to 1');
+is( $count->count, 1, 'Decrement to 1' );
-$count->dec_counter for (1 .. 2);
+$count->dec_counter for ( 1 .. 2 );
-is($count->count, -1, 'Negative numbers');
+is( $count->count, -1, 'Negative numbers' );
$count->inc_counter;
-is($count->count, 0, 'Back to zero');
+is( $count->count, 0, 'Back to zero' );
use Moose;
has 'counter' => (
- traits => [qw/Counter/],
- is => 'ro',
- isa => 'Int',
- default => sub { 0 },
- handles => {
+ traits => [qw/Counter/],
+ is => 'ro',
+ isa => 'Int',
+ default => 0,
+ handles => {
inc_counter => 'inc',
dec_counter => 'dec',
reset_counter => 'reset',
}
my $page = MyHomePage->new();
-isa_ok($page, 'MyHomePage');
+isa_ok( $page, 'MyHomePage' );
-can_ok($page, $_) for qw[
+can_ok( $page, $_ ) for qw[
dec_counter
inc_counter
reset_counter
set_counter
];
-is($page->counter, 0, '... got the default value');
+is( $page->counter, 0, '... got the default value' );
$page->inc_counter;
-is($page->counter, 1, '... got the incremented value');
+is( $page->counter, 1, '... got the incremented value' );
$page->inc_counter;
-is($page->counter, 2, '... got the incremented value (again)');
+is( $page->counter, 2, '... got the incremented value (again)' );
$page->dec_counter;
-is($page->counter, 1, '... got the decremented value');
+is( $page->counter, 1, '... got the decremented value' );
$page->reset_counter;
-is($page->counter, 0, '... got the original value');
+is( $page->counter, 0, '... got the original value' );
$page->set_counter(5);
-is($page->counter, 5, '... set the value');
+is( $page->counter, 5, '... set the value' );
$page->inc_counter(2);
-is($page->counter, 7, '... increment by arg');
+is( $page->counter, 7, '... increment by arg' );
$page->dec_counter(5);
-is($page->counter, 2, '... decrement by arg');
+is( $page->counter, 2, '... decrement by arg' );
# check the meta ..
my $counter = $page->meta->get_attribute('counter');
-does_ok($counter, 'Moose::AttributeHelpers::Trait::Counter');
-
-is($counter->type_constraint->name, 'Int', '... got the expected type constraint');
-
-is_deeply($counter->handles, {
- inc_counter => 'inc',
- dec_counter => 'dec',
- reset_counter => 'reset',
- set_counter => 'set'
-}, '... got the right handles methods');
+does_ok( $counter, 'Moose::AttributeHelpers::Trait::Counter' );
+
+is( $counter->type_constraint->name, 'Int',
+ '... got the expected type constraint' );
+
+is_deeply(
+ $counter->handles,
+ {
+ inc_counter => 'inc',
+ dec_counter => 'dec',
+ reset_counter => 'reset',
+ set_counter => 'set'
+ },
+ '... got the right handles methods'
+);
}
my $sort;
+
{
+
package Stuff;
use Moose;
has 'options' => (
- traits => [qw/Collection::Array/],
- is => 'ro',
- isa => 'ArrayRef[Str]',
- default => sub { [] },
+ traits => [qw/Collection::Array/],
+ is => 'ro',
+ isa => 'ArrayRef[Str]',
+ default => sub { [] },
handles => {
'add_options' => 'push',
'remove_last_option' => 'pop',
'sort_options_in_place' => 'sort_in_place',
'option_accessor' => 'accessor',
'add_options_with_speed' =>
- [ 'push' => ['funrolls', 'funbuns'] ],
+ [ 'push' => [ 'funrolls', 'funbuns' ] ],
'prepend_prerequisites_along_with' =>
- [ 'unshift' => ['first', 'second'] ],
+ [ 'unshift' => [ 'first', 'second' ] ],
'descending_options' =>
- [ 'sort_in_place' => [ $sort = sub { $_[1] <=> $_[0] } ] ],
+ [ 'sort_in_place' => [ $sort = sub { $_[1] <=> $_[0] } ] ],
}
);
}
-my $stuff = Stuff->new(options => [ 10, 12 ]);
-isa_ok($stuff, 'Stuff');
+my $stuff = Stuff->new( options => [ 10, 12 ] );
+isa_ok( $stuff, 'Stuff' );
-can_ok($stuff, $_) for qw[
+can_ok( $stuff, $_ ) for qw[
add_options
remove_last_option
remove_first_option
option_accessor
];
-is_deeply($stuff->options, [10, 12], '... got options');
+is_deeply( $stuff->options, [ 10, 12 ], '... got options' );
-ok($stuff->has_options, '... we have options');
-is($stuff->num_options, 2, '... got 2 options');
+ok( $stuff->has_options, '... we have options' );
+is( $stuff->num_options, 2, '... got 2 options' );
-is($stuff->remove_last_option, 12, '... removed the last option');
-is($stuff->remove_first_option, 10, '... removed the last option');
+is( $stuff->remove_last_option, 12, '... removed the last option' );
+is( $stuff->remove_first_option, 10, '... removed the last option' );
-is_deeply($stuff->options, [], '... no options anymore');
+is_deeply( $stuff->options, [], '... no options anymore' );
-ok(!$stuff->has_options, '... no options');
-is($stuff->num_options, 0, '... got no options');
+ok( !$stuff->has_options, '... no options' );
+is( $stuff->num_options, 0, '... got no options' );
lives_ok {
- $stuff->add_options(1, 2, 3);
-} '... set the option okay';
+ $stuff->add_options( 1, 2, 3 );
+}
+'... set the option okay';
-is_deeply($stuff->options, [1, 2, 3], '... got options now');
+is_deeply( $stuff->options, [ 1, 2, 3 ], '... got options now' );
-ok($stuff->has_options, '... no options');
-is($stuff->num_options, 3, '... got 3 options');
+ok( $stuff->has_options, '... no options' );
+is( $stuff->num_options, 3, '... got 3 options' );
-is($stuff->get_option_at(0), 1, '... get option at index 0');
-is($stuff->get_option_at(1), 2, '... get option at index 1');
-is($stuff->get_option_at(2), 3, '... get option at index 2');
+is( $stuff->get_option_at(0), 1, '... get option at index 0' );
+is( $stuff->get_option_at(1), 2, '... get option at index 1' );
+is( $stuff->get_option_at(2), 3, '... get option at index 2' );
lives_ok {
- $stuff->set_option_at(1, 100);
-} '... set the option okay';
+ $stuff->set_option_at( 1, 100 );
+}
+'... set the option okay';
-is($stuff->get_option_at(1), 100, '... get option at index 1');
+is( $stuff->get_option_at(1), 100, '... get option at index 1' );
lives_ok {
- $stuff->add_options(10, 15);
-} '... set the option okay';
+ $stuff->add_options( 10, 15 );
+}
+'... set the option okay';
-is_deeply($stuff->options, [1, 100, 3, 10, 15], '... got more options now');
+is_deeply( $stuff->options, [ 1, 100, 3, 10, 15 ],
+ '... got more options now' );
-is($stuff->num_options, 5, '... got 5 options');
+is( $stuff->num_options, 5, '... got 5 options' );
-is($stuff->remove_last_option, 15, '... removed the last option');
+is( $stuff->remove_last_option, 15, '... removed the last option' );
-is($stuff->num_options, 4, '... got 4 options');
-is_deeply($stuff->options, [1, 100, 3, 10], '... got diff options now');
+is( $stuff->num_options, 4, '... got 4 options' );
+is_deeply( $stuff->options, [ 1, 100, 3, 10 ], '... got diff options now' );
lives_ok {
- $stuff->insert_options(10, 20);
-} '... set the option okay';
+ $stuff->insert_options( 10, 20 );
+}
+'... set the option okay';
-is($stuff->num_options, 6, '... got 6 options');
-is_deeply($stuff->options, [10, 20, 1, 100, 3, 10], '... got diff options now');
+is( $stuff->num_options, 6, '... got 6 options' );
+is_deeply( $stuff->options, [ 10, 20, 1, 100, 3, 10 ],
+ '... got diff options now' );
-is($stuff->get_option_at(0), 10, '... get option at index 0');
-is($stuff->get_option_at(1), 20, '... get option at index 1');
-is($stuff->get_option_at(3), 100, '... get option at index 3');
+is( $stuff->get_option_at(0), 10, '... get option at index 0' );
+is( $stuff->get_option_at(1), 20, '... get option at index 1' );
+is( $stuff->get_option_at(3), 100, '... get option at index 3' );
-is($stuff->remove_first_option, 10, '... getting the first option');
+is( $stuff->remove_first_option, 10, '... getting the first option' );
-is($stuff->num_options, 5, '... got 5 options');
-is($stuff->get_option_at(0), 20, '... get option at index 0');
+is( $stuff->num_options, 5, '... got 5 options' );
+is( $stuff->get_option_at(0), 20, '... get option at index 0' );
$stuff->clear_options;
is_deeply( $stuff->options, [], "... clear options" );
-$stuff->add_options(5, 1, 2, 3);
+$stuff->add_options( 5, 1, 2, 3 );
$stuff->sort_options_in_place;
-is_deeply( $stuff->options, [1, 2, 3, 5], "... sort options in place (default sort order)" );
+is_deeply( $stuff->options, [ 1, 2, 3, 5 ],
+ "... sort options in place (default sort order)" );
$stuff->sort_options_in_place( sub { $_[1] <=> $_[0] } );
-is_deeply( $stuff->options, [5, 3, 2, 1], "... sort options in place (descending order)" );
+is_deeply( $stuff->options, [ 5, 3, 2, 1 ],
+ "... sort options in place (descending order)" );
$stuff->clear_options();
-$stuff->add_options(5, 1, 2, 3);
+$stuff->add_options( 5, 1, 2, 3 );
lives_ok {
- $stuff->descending_options();
-} '... curried sort in place lives ok';
+ $stuff->descending_options();
+}
+'... curried sort in place lives ok';
-is_deeply( $stuff->options, [5, 3, 2, 1], "... sort currying" );
+is_deeply( $stuff->options, [ 5, 3, 2, 1 ], "... sort currying" );
-throws_ok { $stuff->sort_options_in_place('foo') } qr/Argument must be a code reference/,
+throws_ok { $stuff->sort_options_in_place('foo') }
+qr/Argument must be a code reference/,
'error when sort_in_place receives a non-coderef argument';
$stuff->clear_options;
lives_ok {
$stuff->add_options('tree');
-} '... set the options okay';
+}
+'... set the options okay';
lives_ok {
- $stuff->add_options_with_speed('compatible', 'safe');
-} '... add options with speed okay';
+ $stuff->add_options_with_speed( 'compatible', 'safe' );
+}
+'... add options with speed okay';
-is_deeply($stuff->options, [qw/tree funrolls funbuns compatible safe/],
- 'check options after add_options_with_speed');
+is_deeply(
+ $stuff->options, [qw/tree funrolls funbuns compatible safe/],
+ 'check options after add_options_with_speed'
+);
lives_ok {
$stuff->prepend_prerequisites_along_with();
-} '... add prerequisite options okay';
+}
+'... add prerequisite options okay';
$stuff->clear_options;
$stuff->add_options( 1, 2 );
lives_ok {
$stuff->splice_options( 1, 0, 'foo' );
-} '... splice_options works';
+}
+'... splice_options works';
is_deeply(
$stuff->options, [ 1, 'foo', 2 ],
'splice added expected option'
);
-is($stuff->option_accessor(1 => 'foo++'), 'foo++');
-is($stuff->option_accessor(1), 'foo++');
+is( $stuff->option_accessor( 1 => 'foo++' ), 'foo++' );
+is( $stuff->option_accessor(1), 'foo++' );
## check some errors
#} '... could not add a hash ref where a string is expected';
dies_ok {
- Stuff->new(options => [ undef, 10, undef, 20 ]);
-} '... bad constructor params';
+ Stuff->new( options => [ undef, 10, undef, 20 ] );
+}
+'... bad constructor params';
dies_ok {
my $stuff = Stuff->new();
$stuff->add_options(undef);
-} '... rejects push of an invalid type';
+}
+'... rejects push of an invalid type';
dies_ok {
my $stuff = Stuff->new();
$stuff->insert_options(undef);
-} '... rejects unshift of an invalid type';
+}
+'... rejects unshift of an invalid type';
dies_ok {
my $stuff = Stuff->new();
$stuff->set_option_at( 0, undef );
-} '... rejects set of an invalid type';
+}
+'... rejects set of an invalid type';
dies_ok {
my $stuff = Stuff->new();
- $stuff->sort_in_place_options( undef );
-} '... sort rejects arg of invalid type';
+ $stuff->sort_in_place_options(undef);
+}
+'... sort rejects arg of invalid type';
dies_ok {
my $stuff = Stuff->new();
$stuff->option_accessor();
-} '... accessor rejects 0 args';
+}
+'... accessor rejects 0 args';
dies_ok {
my $stuff = Stuff->new();
- $stuff->option_accessor(1, 2, 3);
-} '... accessor rejects 3 args';
+ $stuff->option_accessor( 1, 2, 3 );
+}
+'... accessor rejects 3 args';
## test the meta
my $options = $stuff->meta->get_attribute('options');
-does_ok($options, 'Moose::AttributeHelpers::Trait::Collection::Array');
-
-is_deeply($options->handles, {
- 'add_options' => 'push',
- 'remove_last_option' => 'pop',
- 'remove_first_option' => 'shift',
- 'insert_options' => 'unshift',
- 'get_option_at' => 'get',
- 'set_option_at' => 'set',
- 'num_options' => 'count',
- 'has_options' => 'empty',
- 'clear_options' => 'clear',
- 'splice_options' => 'splice',
- 'sort_options_in_place' => 'sort_in_place',
- 'option_accessor' => 'accessor',
- 'add_options_with_speed' =>
- [ 'push' => ['funrolls', 'funbuns'] ],
- 'prepend_prerequisites_along_with' =>
- [ 'unshift' => ['first', 'second'] ],
- 'descending_options' =>
- [ 'sort_in_place' => [ $sort ] ],
-}, '... got the right handles mapping');
-
-is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
+does_ok( $options, 'Moose::AttributeHelpers::Trait::Collection::Array' );
+
+is_deeply(
+ $options->handles,
+ {
+ 'add_options' => 'push',
+ 'remove_last_option' => 'pop',
+ 'remove_first_option' => 'shift',
+ 'insert_options' => 'unshift',
+ 'get_option_at' => 'get',
+ 'set_option_at' => 'set',
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'clear_options' => 'clear',
+ 'splice_options' => 'splice',
+ 'sort_options_in_place' => 'sort_in_place',
+ 'option_accessor' => 'accessor',
+ 'add_options_with_speed' =>
+ [ 'push' => [ 'funrolls', 'funbuns' ] ],
+ 'prepend_prerequisites_along_with' =>
+ [ 'unshift' => [ 'first', 'second' ] ],
+ 'descending_options' =>
+ [ 'sort_in_place' => [$sort] ],
+ },
+ '... got the right handles mapping'
+);
+
+is( $options->type_constraint->type_parameter, 'Str',
+ '... got the right container type' );
use Moose::AttributeHelpers;
has 'options' => (
- traits => [qw/Collection::Hash/],
- is => 'ro',
- isa => 'HashRef[Str]',
- default => sub { {} },
- handles => {
+ traits => [qw/Collection::Hash/],
+ is => 'ro',
+ isa => 'HashRef[Str]',
+ default => sub { {} },
+ handles => {
'set_option' => 'set',
'get_option' => 'get',
'has_options' => 'empty',
'option_accessor' => 'accessor',
'key_value' => 'kv',
'options_elements' => 'elements',
- 'quantity' => [ accessor => ['quantity'] ],
+ 'quantity' => [ accessor => ['quantity'] ],
},
);
}
my $stuff = Stuff->new();
-isa_ok($stuff, 'Stuff');
+isa_ok( $stuff, 'Stuff' );
-can_ok($stuff, $_) for qw[
+can_ok( $stuff, $_ ) for qw[
set_option
get_option
has_options
option_accessor
];
-ok(!$stuff->has_options, '... we have no options');
-is($stuff->num_options, 0, '... we have no options');
+ok( !$stuff->has_options, '... we have no options' );
+is( $stuff->num_options, 0, '... we have no options' );
-is_deeply($stuff->options, {}, '... no options yet');
-ok(!$stuff->has_option('foo'), '... we have no foo option');
+is_deeply( $stuff->options, {}, '... no options yet' );
+ok( !$stuff->has_option('foo'), '... we have no foo option' );
lives_ok {
- $stuff->set_option(foo => 'bar');
-} '... set the option okay';
+ $stuff->set_option( foo => 'bar' );
+}
+'... set the option okay';
-ok($stuff->is_defined('foo'), '... foo is defined');
+ok( $stuff->is_defined('foo'), '... foo is defined' );
-ok($stuff->has_options, '... we have options');
-is($stuff->num_options, 1, '... we have 1 option(s)');
-ok($stuff->has_option('foo'), '... we have a foo option');
-is_deeply($stuff->options, { foo => 'bar' }, '... got options now');
+ok( $stuff->has_options, '... we have options' );
+is( $stuff->num_options, 1, '... we have 1 option(s)' );
+ok( $stuff->has_option('foo'), '... we have a foo option' );
+is_deeply( $stuff->options, { foo => 'bar' }, '... got options now' );
lives_ok {
- $stuff->set_option(bar => 'baz');
-} '... set the option okay';
+ $stuff->set_option( bar => 'baz' );
+}
+'... set the option okay';
-is($stuff->num_options, 2, '... we have 2 option(s)');
-is_deeply($stuff->options, { foo => 'bar', bar => 'baz' }, '... got more options now');
+is( $stuff->num_options, 2, '... we have 2 option(s)' );
+is_deeply( $stuff->options, { foo => 'bar', bar => 'baz' },
+ '... got more options now' );
-is($stuff->get_option('foo'), 'bar', '... got the right option');
+is( $stuff->get_option('foo'), 'bar', '... got the right option' );
-is_deeply([ $stuff->get_option(qw(foo bar)) ], [qw(bar baz)], "get multiple options at once");
+is_deeply( [ $stuff->get_option(qw(foo bar)) ], [qw(bar baz)],
+ "get multiple options at once" );
lives_ok {
- $stuff->set_option(oink => "blah", xxy => "flop");
-} '... set the option okay';
+ $stuff->set_option( oink => "blah", xxy => "flop" );
+}
+'... set the option okay';
-is($stuff->num_options, 4, "4 options");
-is_deeply([ $stuff->get_option(qw(foo bar oink xxy)) ], [qw(bar baz blah flop)], "get multiple options at once");
+is( $stuff->num_options, 4, "4 options" );
+is_deeply( [ $stuff->get_option(qw(foo bar oink xxy)) ],
+ [qw(bar baz blah flop)], "get multiple options at once" );
lives_ok {
$stuff->delete_option('bar');
-} '... deleted the option okay';
+}
+'... deleted the option okay';
lives_ok {
$stuff->delete_option('oink');
-} '... deleted the option okay';
+}
+'... deleted the option okay';
lives_ok {
$stuff->delete_option('xxy');
-} '... deleted the option okay';
+}
+'... deleted the option okay';
-is($stuff->num_options, 1, '... we have 1 option(s)');
-is_deeply($stuff->options, { foo => 'bar' }, '... got more options now');
+is( $stuff->num_options, 1, '... we have 1 option(s)' );
+is_deeply( $stuff->options, { foo => 'bar' }, '... got more options now' );
$stuff->clear_options;
-is_deeply($stuff->options, { }, "... cleared options" );
+is_deeply( $stuff->options, {}, "... cleared options" );
lives_ok {
$stuff->quantity(4);
-} '... options added okay with defaults';
+}
+'... options added okay with defaults';
-is($stuff->quantity, 4, 'reader part of curried accessor works');
+is( $stuff->quantity, 4, 'reader part of curried accessor works' );
-is_deeply($stuff->options, {quantity => 4}, '... returns what we expect');
+is_deeply( $stuff->options, { quantity => 4 }, '... returns what we expect' );
lives_ok {
- Stuff->new(options => { foo => 'BAR' });
-} '... good constructor params';
+ Stuff->new( options => { foo => 'BAR' } );
+}
+'... good constructor params';
## check some errors
dies_ok {
- $stuff->set_option(bar => {});
-} '... could not add a hash ref where an string is expected';
+ $stuff->set_option( bar => {} );
+}
+'... could not add a hash ref where an string is expected';
dies_ok {
- Stuff->new(options => { foo => [] });
-} '... bad constructor params';
+ Stuff->new( options => { foo => [] } );
+}
+'... bad constructor params';
## test the meta
my $options = $stuff->meta->get_attribute('options');
-does_ok($options, 'Moose::AttributeHelpers::Trait::Collection::Hash');
-
-is_deeply($options->handles, {
- 'set_option' => 'set',
- 'get_option' => 'get',
- 'has_options' => 'empty',
- 'num_options' => 'count',
- 'clear_options' => 'clear',
- 'delete_option' => 'delete',
- 'has_option' => 'exists',
- 'is_defined' => 'defined',
- 'option_accessor' => 'accessor',
- 'key_value' => 'kv',
- 'options_elements' => 'elements',
- 'quantity' => [ accessor => ['quantity'] ],
-}, '... got the right handles mapping');
-
-is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
+does_ok( $options, 'Moose::AttributeHelpers::Trait::Collection::Hash' );
+
+is_deeply(
+ $options->handles,
+ {
+ 'set_option' => 'set',
+ 'get_option' => 'get',
+ 'has_options' => 'empty',
+ 'num_options' => 'count',
+ 'clear_options' => 'clear',
+ 'delete_option' => 'delete',
+ 'has_option' => 'exists',
+ 'is_defined' => 'defined',
+ 'option_accessor' => 'accessor',
+ 'key_value' => 'kv',
+ 'options_elements' => 'elements',
+ 'quantity' => [ accessor => ['quantity'] ],
+ },
+ '... got the right handles mapping'
+);
+
+is( $options->type_constraint->type_parameter, 'Str',
+ '... got the right container type' );
$stuff->set_option( oink => "blah", xxy => "flop" );
my @key_value = $stuff->key_value;
use Moose;
has 'integer' => (
- traits => [qw/Number/],
- is => 'ro',
- isa => 'Int',
- default => sub { 5 },
- handles => {
- set => 'set',
- add => 'add',
- sub => 'sub',
- mul => 'mul',
- div => 'div',
- mod => 'mod',
- abs => 'abs',
- inc => [ add => [ 1 ] ],
- dec => [ sub => [ 1 ] ],
- odd => [ mod => [ 2 ] ],
- cut_in_half => [ div => [ 2 ] ],
+ traits => [qw/Number/],
+ is => 'ro',
+ isa => 'Int',
+ default => 5,
+ handles => {
+ set => 'set',
+ add => 'add',
+ sub => 'sub',
+ mul => 'mul',
+ div => 'div',
+ mod => 'mod',
+ abs => 'abs',
+ inc => [ add => [1] ],
+ dec => [ sub => [1] ],
+ odd => [ mod => [2] ],
+ cut_in_half => [ div => [2] ],
},
);
}
my $real = Real->new;
-isa_ok($real, 'Real');
+isa_ok( $real, 'Real' );
-can_ok($real, $_) for qw[
+can_ok( $real, $_ ) for qw[
set add sub mul div mod abs inc dec odd cut_in_half
];
## test the meta
my $attr = $real->meta->get_attribute('integer');
-does_ok($attr, 'Moose::AttributeHelpers::Trait::Number');
-
-is_deeply($attr->handles, {
- set => 'set',
- add => 'add',
- sub => 'sub',
- mul => 'mul',
- div => 'div',
- mod => 'mod',
- abs => 'abs',
- inc => [ add => [ 1 ] ],
- dec => [ sub => [ 1 ] ],
- odd => [ mod => [ 2 ] ],
- cut_in_half => [ div => [ 2 ] ],
-}, '... got the right handles mapping');
+does_ok( $attr, 'Moose::AttributeHelpers::Trait::Number' );
+
+is_deeply(
+ $attr->handles,
+ {
+ set => 'set',
+ add => 'add',
+ sub => 'sub',
+ mul => 'mul',
+ div => 'div',
+ mod => 'mod',
+ abs => 'abs',
+ inc => [ add => [1] ],
+ dec => [ sub => [1] ],
+ odd => [ mod => [2] ],
+ cut_in_half => [ div => [2] ],
+ },
+ '... got the right handles mapping'
+);
use Moose;
has '_options' => (
- traits => [qw/Collection::List/],
- is => 'ro',
- isa => 'ArrayRef[Int]',
- init_arg => 'options',
- default => sub { [] },
+ traits => [qw/Collection::List/],
+ is => 'ro',
+ isa => 'ArrayRef[Int]',
+ init_arg => 'options',
+ default => sub { [] },
handles => {
'num_options' => 'count',
'has_options' => 'empty',
'get_first_option' => 'first',
'get_last_option' => 'last',
'sorted_options' => 'sort',
- 'less_than_five' => [ grep => [ $less = sub { $_ < 5 } ] ],
- 'up_by_one' => [ map => [ $up = sub { $_ + 1 } ] ],
- 'dashify' => [ join => [ '-' ] ],
- 'descending' => [ sort => [ $sort = sub { $_[1] <=> $_[0] } ] ],
+ 'less_than_five' => [ grep => [ $less = sub { $_ < 5 } ] ],
+ 'up_by_one' => [ map => [ $up = sub { $_ + 1 } ] ],
+ 'dashify' => [ join => ['-'] ],
+ 'descending' => [ sort => [ $sort = sub { $_[1] <=> $_[0] } ] ],
},
);
}
-my $stuff = Stuff->new(options => [ 1 .. 10 ]);
-isa_ok($stuff, 'Stuff');
+my $stuff = Stuff->new( options => [ 1 .. 10 ] );
+isa_ok( $stuff, 'Stuff' );
-can_ok($stuff, $_) for qw[
+can_ok( $stuff, $_ ) for qw[
_options
num_options
has_options
sorted_options
];
-is_deeply($stuff->_options, [1 .. 10], '... got options');
+is_deeply( $stuff->_options, [ 1 .. 10 ], '... got options' );
-ok($stuff->has_options, '... we have options');
-is($stuff->num_options, 10, '... got 2 options');
-cmp_ok($stuff->get_option_at(0), '==', 1, '... get option 0');
-cmp_ok($stuff->get_first_option, '==', 1, '... get first');
-cmp_ok($stuff->get_last_option, '==', 10, '... get last');
+ok( $stuff->has_options, '... we have options' );
+is( $stuff->num_options, 10, '... got 2 options' );
+cmp_ok( $stuff->get_option_at(0), '==', 1, '... get option 0' );
+cmp_ok( $stuff->get_first_option, '==', 1, '... get first' );
+cmp_ok( $stuff->get_last_option, '==', 10, '... get last' );
is_deeply(
-[ $stuff->filter_options(sub { $_[0] % 2 == 0 }) ],
-[ 2, 4, 6, 8, 10 ],
-'... got the right filtered values'
+ [ $stuff->filter_options( sub { $_[0] % 2 == 0 } ) ],
+ [ 2, 4, 6, 8, 10 ],
+ '... got the right filtered values'
);
is_deeply(
-[ $stuff->map_options(sub { $_[0] * 2 }) ],
-[ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 ],
-'... got the right mapped values'
+ [ $stuff->map_options( sub { $_[0] * 2 } ) ],
+ [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 ],
+ '... got the right mapped values'
);
-is($stuff->find_option(sub { $_[0] % 2 == 0 }), 2, '.. found the right option');
+is( $stuff->find_option( sub { $_[0] % 2 == 0 } ), 2,
+ '.. found the right option' );
-is_deeply([ $stuff->options ], [1 .. 10], '... got the list of options');
+is_deeply( [ $stuff->options ], [ 1 .. 10 ], '... got the list of options' );
-is($stuff->join_options(':'), '1:2:3:4:5:6:7:8:9:10', '... joined the list of options by :');
+is( $stuff->join_options(':'), '1:2:3:4:5:6:7:8:9:10',
+ '... joined the list of options by :' );
-is_deeply([ $stuff->sorted_options ], [sort (1..10)],
- '... got sorted options (default sort order)');
-is_deeply([ $stuff->sorted_options( sub { $_[1] <=> $_[0] } ) ], [sort { $b <=> $a } (1..10)],
- '... got sorted options (descending sort order) ');
+is_deeply(
+ [ $stuff->sorted_options ], [ sort ( 1 .. 10 ) ],
+ '... got sorted options (default sort order)'
+);
+is_deeply(
+ [ $stuff->sorted_options( sub { $_[1] <=> $_[0] } ) ],
+ [ sort { $b <=> $a } ( 1 .. 10 ) ],
+ '... got sorted options (descending sort order) '
+);
-throws_ok { $stuff->sorted_options('foo') } qr/Argument must be a code reference/,
+throws_ok { $stuff->sorted_options('foo') }
+qr/Argument must be a code reference/,
'error when sort receives a non-coderef argument';
# test the currying
-is_deeply([ $stuff->less_than_five() ], [1 .. 4]);
+is_deeply( [ $stuff->less_than_five() ], [ 1 .. 4 ] );
-is_deeply([ $stuff->up_by_one() ], [2 .. 11]);
+is_deeply( [ $stuff->up_by_one() ], [ 2 .. 11 ] );
-is($stuff->dashify, '1-2-3-4-5-6-7-8-9-10');
+is( $stuff->dashify, '1-2-3-4-5-6-7-8-9-10' );
-is_deeply([$stuff->descending], [reverse 1 .. 10]);
+is_deeply( [ $stuff->descending ], [ reverse 1 .. 10 ] );
## test the meta
my $options = $stuff->meta->get_attribute('_options');
-does_ok($options, 'Moose::AttributeHelpers::Trait::Collection::List');
-
-is_deeply($options->handles, {
- 'num_options' => 'count',
- 'has_options' => 'empty',
- 'map_options', => 'map',
- 'filter_options' => 'grep',
- 'find_option' => 'find',
- 'options' => 'elements',
- 'join_options' => 'join',
- 'get_option_at' => 'get',
- 'get_first_option' => 'first',
- 'get_last_option' => 'last',
- 'sorted_options' => 'sort',
- 'less_than_five' => [ grep => [ $less ] ],
- 'up_by_one' => [ map => [ $up ] ],
- 'dashify' => [ join => [ '-' ] ],
- 'descending' => [ sort => [ $sort ] ],
-}, '... got the right handles mapping');
-
-is($options->type_constraint->type_parameter, 'Int', '... got the right container type');
+does_ok( $options, 'Moose::AttributeHelpers::Trait::Collection::List' );
+
+is_deeply(
+ $options->handles,
+ {
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'map_options', => 'map',
+ 'filter_options' => 'grep',
+ 'find_option' => 'find',
+ 'options' => 'elements',
+ 'join_options' => 'join',
+ 'get_option_at' => 'get',
+ 'get_first_option' => 'first',
+ 'get_last_option' => 'last',
+ 'sorted_options' => 'sort',
+ 'less_than_five' => [ grep => [$less] ],
+ 'up_by_one' => [ map => [$up] ],
+ 'dashify' => [ join => ['-'] ],
+ 'descending' => [ sort => [$sort] ],
+ },
+ '... got the right handles mapping'
+);
+
+is( $options->type_constraint->type_parameter, 'Int',
+ '... got the right container type' );
dies_ok {
- $stuff->sort_in_place_options( undef );
-} '... sort rejects arg of invalid type';
+ $stuff->sort_in_place_options(undef);
+}
+'... sort rejects arg of invalid type';
}
{
+
package Stuff;
use Moose;
use Moose::AttributeHelpers;
has 'word_histogram' => (
- traits => [qw/Collection::Bag/],
- is => 'ro',
- handles => {
- 'add_word' => 'add',
- 'get_count_for' => 'get',
- 'has_any_words' => 'empty',
- 'num_words' => 'count',
- 'delete_word' => 'delete',
+ traits => ['Collection::Bag'],
+ is => 'ro',
+ handles => {
+ 'add_word' => 'add',
+ 'get_count_for' => 'get',
+ 'has_any_words' => 'empty',
+ 'num_words' => 'count',
+ 'delete_word' => 'delete',
}
);
}
my $stuff = Stuff->new();
-isa_ok($stuff, 'Stuff');
+isa_ok( $stuff, 'Stuff' );
-can_ok($stuff, $_) for qw[
+can_ok( $stuff, $_ ) for qw[
add_word
get_count_for
has_any_words
delete_word
];
-ok(!$stuff->has_any_words, '... we have no words');
-is($stuff->num_words, 0, '... we have no words');
+ok( !$stuff->has_any_words, '... we have no words' );
+is( $stuff->num_words, 0, '... we have no words' );
lives_ok {
$stuff->add_word('bar');
-} '... set the words okay';
+}
+'... set the words okay';
-ok($stuff->has_any_words, '... we have words');
-is($stuff->num_words, 1, '... we have 1 word(s)');
-is($stuff->get_count_for('bar'), 1, '... got words now');
+ok( $stuff->has_any_words, '... we have words' );
+is( $stuff->num_words, 1, '... we have 1 word(s)' );
+is( $stuff->get_count_for('bar'), 1, '... got words now' );
lives_ok {
$stuff->add_word('foo');
$stuff->add_word('bar') for 0 .. 3;
$stuff->add_word('baz') for 0 .. 10;
-} '... set the words okay';
+}
+'... set the words okay';
-is($stuff->num_words, 3, '... we still have 1 word(s)');
-is($stuff->get_count_for('foo'), 1, '... got words now');
-is($stuff->get_count_for('bar'), 5, '... got words now');
-is($stuff->get_count_for('baz'), 11, '... got words now');
+is( $stuff->num_words, 3, '... we still have 1 word(s)' );
+is( $stuff->get_count_for('foo'), 1, '... got words now' );
+is( $stuff->get_count_for('bar'), 5, '... got words now' );
+is( $stuff->get_count_for('baz'), 11, '... got words now' );
## test the meta
my $words = $stuff->meta->get_attribute('word_histogram');
-does_ok($words, 'Moose::AttributeHelpers::Trait::Collection::Bag');
-
-is_deeply($words->handles, {
- 'add_word' => 'add',
- 'get_count_for' => 'get',
- 'has_any_words' => 'empty',
- 'num_words' => 'count',
- 'delete_word' => 'delete',
-}, '... got the right handles mapping');
+does_ok( $words, 'Moose::AttributeHelpers::Trait::Collection::Bag' );
+
+is_deeply(
+ $words->handles,
+ {
+ 'add_word' => 'add',
+ 'get_count_for' => 'get',
+ 'has_any_words' => 'empty',
+ 'num_words' => 'count',
+ 'delete_word' => 'delete',
+ },
+ '... got the right handles mapping'
+);
use Moose;
has 'string' => (
- traits => [qw/String/],
- is => 'rw',
- isa => 'Str',
- default => sub { '' },
+ traits => [qw/String/],
+ is => 'rw',
+ isa => 'Str',
+ default => sub {''},
handles => {
- inc_string => 'inc',
- append_string => 'append',
- prepend_string => 'prepend',
- match_string => 'match',
- replace_string => 'replace',
- chop_string => 'chop',
- chomp_string => 'chomp',
- clear_string => 'clear',
- exclaim => [ append => [ '!' ] ],
- capitalize_last => [ replace => [ qr/(.)$/, $uc = sub { uc $1 } ] ],
- invalid_number => [ match => [ qr/\D/ ] ],
- },
+ inc_string => 'inc',
+ append_string => 'append',
+ prepend_string => 'prepend',
+ match_string => 'match',
+ replace_string => 'replace',
+ chop_string => 'chop',
+ chomp_string => 'chomp',
+ clear_string => 'clear',
+ exclaim => [ append => ['!'] ],
+ capitalize_last =>
+ [ replace => [ qr/(.)$/, $uc = sub { uc $1 } ] ],
+ invalid_number => [ match => [qr/\D/] ],
+ },
);
}
my $page = MyHomePage->new();
-isa_ok($page, 'MyHomePage');
+isa_ok( $page, 'MyHomePage' );
-is($page->string, '', '... got the default value');
+is( $page->string, '', '... got the default value' );
$page->string('a');
$page->inc_string;
-is($page->string, 'b', '... got the incremented value');
+is( $page->string, 'b', '... got the incremented value' );
$page->inc_string;
-is($page->string, 'c', '... got the incremented value (again)');
+is( $page->string, 'c', '... got the incremented value (again)' );
$page->append_string("foo$/");
-is($page->string, "cfoo$/", 'appended to string');
+is( $page->string, "cfoo$/", 'appended to string' );
$page->chomp_string;
-is($page->string, "cfoo", 'chomped string');
+is( $page->string, "cfoo", 'chomped string' );
$page->chomp_string;
-is($page->string, "cfoo", 'chomped is noop');
+is( $page->string, "cfoo", 'chomped is noop' );
$page->chop_string;
-is($page->string, "cfo", 'chopped string');
+is( $page->string, "cfo", 'chopped string' );
$page->prepend_string("bar");
-is($page->string, 'barcfo', 'prepended to string');
+is( $page->string, 'barcfo', 'prepended to string' );
-is_deeply( [ $page->match_string(qr/([ao])/) ], [ "a" ], "match" );
+is_deeply( [ $page->match_string(qr/([ao])/) ], ["a"], "match" );
-$page->replace_string(qr/([ao])/, sub { uc($1) });
-is($page->string, 'bArcfo', "substitution");
+$page->replace_string( qr/([ao])/, sub { uc($1) } );
+is( $page->string, 'bArcfo', "substitution" );
$page->exclaim;
-is($page->string, 'bArcfo!', 'exclaim!');
+is( $page->string, 'bArcfo!', 'exclaim!' );
$page->string('Moosex');
$page->capitalize_last;
-is($page->string, 'MooseX', 'capitalize last');
+is( $page->string, 'MooseX', 'capitalize last' );
$page->string('1234');
-ok(!$page->invalid_number, 'string "isn\'t an invalid number');
+ok( !$page->invalid_number, 'string "isn\'t an invalid number' );
$page->string('one two three four');
-ok($page->invalid_number, 'string an invalid number');
+ok( $page->invalid_number, 'string an invalid number' );
$page->clear_string;
-is($page->string, '', "clear");
+is( $page->string, '', "clear" );
# check the meta ..
my $string = $page->meta->get_attribute('string');
-does_ok($string, 'Moose::AttributeHelpers::Trait::String');
-
-is($string->type_constraint->name, 'Str', '... got the expected type constraint');
-
-is_deeply($string->handles, {
- inc_string => 'inc',
- append_string => 'append',
- prepend_string => 'prepend',
- match_string => 'match',
- replace_string => 'replace',
- chop_string => 'chop',
- chomp_string => 'chomp',
- clear_string => 'clear',
- exclaim => [ append => [ '!' ] ],
- capitalize_last => [ replace => [ qr/(.)$/, $uc ] ],
- invalid_number => [ match => [ qr/\D/ ] ],
-}, '... got the right handles methods');
+does_ok( $string, 'Moose::AttributeHelpers::Trait::String' );
+
+is(
+ $string->type_constraint->name, 'Str',
+ '... got the expected type constraint'
+);
+
+is_deeply(
+ $string->handles,
+ {
+ inc_string => 'inc',
+ append_string => 'append',
+ prepend_string => 'prepend',
+ match_string => 'match',
+ replace_string => 'replace',
+ chop_string => 'chop',
+ chomp_string => 'chomp',
+ clear_string => 'clear',
+ exclaim => [ append => ['!'] ],
+ capitalize_last => [ replace => [ qr/(.)$/, $uc ] ],
+ invalid_number => [ match => [qr/\D/] ],
+ },
+ '... got the right handles methods'
+);
use Moose::AttributeHelpers;
{
+
package Room;
use Moose;
has 'is_lit' => (
- traits => ['Bool'],
- is => 'rw',
- isa => 'Bool',
- default => sub { 0 },
- handles => {
- illuminate => 'set',
- darken => 'unset',
- flip_switch => 'toggle',
- is_dark => 'not',
- },
- )
+ traits => ['Bool'],
+ is => 'rw',
+ isa => 'Bool',
+ default => 0,
+ handles => {
+ illuminate => 'set',
+ darken => 'unset',
+ flip_switch => 'toggle',
+ is_dark => 'not',
+ },
+ )
}
my $room = Room->new;
$room->illuminate;
-ok $room->is_lit, 'set is_lit to 1 using ->illuminate';
-ok !$room->is_dark, 'check if is_dark does the right thing';
+ok( $room->is_lit, 'set is_lit to 1 using ->illuminate' );
+ok( !$room->is_dark, 'check if is_dark does the right thing' );
$room->darken;
-ok !$room->is_lit, 'set is_lit to 0 using ->darken';
-ok $room->is_dark, 'check if is_dark does the right thing';
+ok( !$room->is_lit, 'set is_lit to 0 using ->darken' );
+ok( $room->is_dark, 'check if is_dark does the right thing' );
$room->flip_switch;
-ok $room->is_lit, 'toggle is_lit back to 1 using ->flip_switch';
-ok !$room->is_dark, 'check if is_dark does the right thing';
+ok( $room->is_lit, 'toggle is_lit back to 1 using ->flip_switch' );
+ok( !$room->is_dark, 'check if is_dark does the right thing' );
$room->flip_switch;
-ok !$room->is_lit, 'toggle is_lit back to 0 again using ->flip_switch';
-ok $room->is_dark, 'check if is_dark does the right thing';
+ok( !$room->is_lit, 'toggle is_lit back to 0 again using ->flip_switch' );
+ok( $room->is_dark, 'check if is_dark does the right thing' );