option_accessor
];
-ok( $stuff->has_no_options, '... we have no options' );
-is( $stuff->num_options, 0, '... we have no options' );
+ok( $stuff->has_no_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';
+'set the option okay';
-ok( $stuff->is_defined('foo'), '... foo is defined' );
+ok( $stuff->is_defined('foo'), 'foo is defined' );
-ok( !$stuff->has_no_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_no_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';
+'set the option okay';
-is( $stuff->num_options, 2, '... we have 2 option(s)' );
+is( $stuff->num_options, 2, 'we have 2 option(s)' );
is_deeply( $stuff->options, { foo => 'bar', bar => 'baz' },
- '... got more options now' );
+ '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( scalar($stuff->get_option(qw( foo bar) )), "baz",
- '... got last option in scalar context');
+ 'got last option in scalar context');
lives_ok {
$stuff->set_option( oink => "blah", xxy => "flop" );
}
-'... set the option okay';
+'set the option okay';
is( $stuff->num_options, 4, "4 options" );
is_deeply( [ $stuff->get_option(qw(foo bar oink xxy)) ],
lives_ok {
$stuff->delete_option('bar');
}
-'... deleted the option okay';
+'deleted the option okay';
lives_ok {
$stuff->delete_option('oink','xxy');
}
-'... deleted multiple option okay';
+'deleted multiple 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;
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_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';
+'good constructor params';
## check some errors
dies_ok {
$stuff->set_option( bar => {} );
}
-'... could not add a hash ref where an string is expected';
+'could not add a hash ref where an string is expected';
dies_ok {
Stuff->new( options => { foo => [] } );
}
-'... bad constructor params';
+'bad constructor params';
## test the meta
'options_elements' => 'elements',
'quantity' => [ accessor => 'quantity' ],
},
- '... got the right handles mapping'
+ 'got the right handles mapping'
);
is( $options->type_constraint->type_parameter, 'Str',
- '... got the right container type' );
+ 'got the right container type' );
$stuff->set_option( oink => "blah", xxy => "flop" );
my @key_value = sort{ $a->[0] cmp $b->[0] } $stuff->key_value;
is_deeply(
\@key_value,
[ sort{ $a->[0] cmp $b->[0] } [ 'xxy', 'flop' ], [ 'quantity', 4 ], [ 'oink', 'blah' ] ],
- '... got the right key value pairs'
+ 'got the right key value pairs'
) or do{ require Data::Dumper; diag(Data::Dumper::Dumper(\@key_value)) };
my %options_elements = $stuff->options_elements;
'quantity' => 4,
'xxy' => 'flop'
},
- '... got the right hash elements'
+ 'got the right hash elements'
);