[Moose-commits] r7795 - in MooseX-AttributeHelpers/trunk:
lib/MooseX/AttributeHelpers/MethodProvider t
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Thu Feb 26 16:06:08 GMT 2009
Author: autarch
Date: 2009-02-26 08:06:08 -0800 (Thu, 26 Feb 2009)
New Revision: 7795
Modified:
MooseX-AttributeHelpers/trunk/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm
MooseX-AttributeHelpers/trunk/t/002_basic_array.t
Log:
splice was totally broken, add tests and fix it
Modified: MooseX-AttributeHelpers/trunk/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm
===================================================================
--- MooseX-AttributeHelpers/trunk/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm 2009-02-26 15:57:15 UTC (rev 7794)
+++ MooseX-AttributeHelpers/trunk/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm 2009-02-26 16:06:08 UTC (rev 7795)
@@ -125,13 +125,13 @@
my ( $self, $i, $j, @elems ) = @_;
($container_type_constraint->check($_))
|| confess "Value " . (defined($_) ? $_ : 'undef') . " did not pass container type constraint" for @elems;
- CORE::splice @{$self->$reader()}, $i, $j, @elems;
+ CORE::splice @{$reader->($self)}, $i, $j, @elems;
};
}
else {
return sub {
my ( $self, $i, $j, @elems ) = @_;
- CORE::splice @{$self->$reader()}, $i, $j, @elems;
+ CORE::splice @{$reader->($self)}, $i, $j, @elems;
};
}
}
Modified: MooseX-AttributeHelpers/trunk/t/002_basic_array.t
===================================================================
--- MooseX-AttributeHelpers/trunk/t/002_basic_array.t 2009-02-26 15:57:15 UTC (rev 7794)
+++ MooseX-AttributeHelpers/trunk/t/002_basic_array.t 2009-02-26 16:06:08 UTC (rev 7795)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 62;
+use Test::More tests => 64;
use Test::Exception;
BEGIN {
@@ -29,6 +29,7 @@
'count' => 'num_options',
'empty' => 'has_options',
'clear' => 'clear_options',
+ 'splice' => 'splice_options',
'sort_in_place' => 'sort_options_in_place',
},
curries => {
@@ -152,12 +153,26 @@
$stuff->add_options_with_speed('compatible', 'safe');
} '... add options with speed okay';
-is_deeply($stuff->options, [qw/tree funrolls funbuns compatible safe/]);
+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';
+$stuff->clear_options;
+$stuff->add_options( 1, 2 );
+
+lives_ok {
+ $stuff->splice_options( 1, 0, 'foo' );
+} '... splice_options works';
+
+is_deeply(
+ $stuff->options, [ 1, 'foo', 2 ],
+ 'splice added expected option'
+);
+
+
## check some errors
#dies_ok {
@@ -207,6 +222,7 @@
'count' => 'num_options',
'empty' => 'has_options',
'clear' => 'clear_options',
+ 'splice' => 'splice_options',
'sort_in_place' => 'sort_options_in_place',
}, '... got the right provides mapping');
More information about the Moose-commits
mailing list