Trying to help confound and Sartak. jhannah newb alert!
jhannah [Thu, 25 Jun 2009 19:53:39 +0000 (15:53 -0400)]
t/070_attribute_helpers/001_basic_counter.t
t/070_attribute_helpers/002_basic_array.t
t/070_attribute_helpers/003_basic_hash.t
t/070_attribute_helpers/004_basic_number.t
t/070_attribute_helpers/005_basic_list.t

index b4fb826..5bb0622 100644 (file)
@@ -18,11 +18,11 @@ BEGIN {
         is        => 'ro',
         isa       => 'Int',
         default   => sub { 0 },
-        provides  => {
-            inc   => 'inc_counter',
-            dec   => 'dec_counter',
-            reset => 'reset_counter',
-            set   => 'set_counter'
+        handles  => {
+            inc_counter   => 'inc',
+            dec_counter   => 'dec',
+            reset_counter => 'reset',
+            set_counter   => 'set'
         }
     );
 }
@@ -69,10 +69,10 @@ is($counter->helper_type, 'Num', '... got the expected helper type');
 
 is($counter->type_constraint->name, 'Int', '... got the expected type constraint');
 
-is_deeply($counter->provides, {
-    inc   => 'inc_counter',
-    dec   => 'dec_counter',
-    reset => 'reset_counter',
-    set   => 'set_counter'
-}, '... got the right provides methods');
+is_deeply($counter->handles, {
+    inc_counter   => 'inc',
+    dec_counter   => 'dec',
+    reset_counter => 'reset',
+    set_counter   => 'set'
+}, '... got the right handles methods');
 
index 5bddc1f..7c091fd 100644 (file)
@@ -19,28 +19,25 @@ BEGIN {
         is        => 'ro',
         isa       => 'ArrayRef[Str]',
         default   => sub { [] },
-        provides => {
-            'push'          => 'add_options',
-            'pop'           => 'remove_last_option',
-            'shift'         => 'remove_first_option',
-            'unshift'       => 'insert_options',
-            'get'           => 'get_option_at',
-            'set'           => 'set_option_at',
-            'count'         => 'num_options',
-            'empty'         => 'has_options',
-            'clear'         => 'clear_options',
-            'splice'        => 'splice_options',
-            'sort_in_place' => 'sort_options_in_place',
-            'accessor'      => 'option_accessor',
-            },
-        curries   => {
-            'push'    => {
-                add_options_with_speed => ['funrolls', 'funbuns']
-            },
-            'unshift'  => {
-                prepend_prerequisites_along_with => ['first', 'second']
-            },
-            'sort_in_place' => { descending_options => [ sub { $_[1] <=> $_[0] } ],
+        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_optons_with_speed' => 
+               [ 'push' => ['funrolls', 'funbuns'] ],
+            'prepend_prerequisites_along_with' => 
+               [ 'unshift' => ['first', 'second'] ],
+            'descending_options' => 
+               [ 'sort_in_place' => [ sub { $_[1] <=> $_[0] } ] ],
             },
         }
     );
@@ -226,19 +223,19 @@ dies_ok {
 my $options = $stuff->meta->get_attribute('options');
 isa_ok($options, 'Moose::AttributeHelpers::Collection::Array');
 
-is_deeply($options->provides, {
-    'push'    => 'add_options',
-    'pop'     => 'remove_last_option',
-    'shift'   => 'remove_first_option',
-    'unshift' => 'insert_options',
-    'get'     => 'get_option_at',
-    'set'     => 'set_option_at',
-    'count'   => 'num_options',
-    'empty'   => 'has_options',
-    'clear'   => 'clear_options',
-    'splice'  => 'splice_options',
-    'sort_in_place' => 'sort_options_in_place',
-    'accessor' => 'option_accessor',
-}, '... got the right provides mapping');
+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',
+}, '... got the right handles mapping');
 
 is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
index ae3a6a1..0c0bcd3 100644 (file)
@@ -20,24 +20,20 @@ BEGIN {
         is        => 'ro',
         isa       => 'HashRef[Str]',
         default   => sub { {} },
-        provides  => {
-            'set'      => 'set_option',
-            'get'      => 'get_option',
-            'empty'    => 'has_options',
-            'count'    => 'num_options',
-            'clear'    => 'clear_options',
-            'delete'   => 'delete_option',
-            'exists'   => 'has_option',
-            'defined'  => 'is_defined',
-            'accessor' => 'option_accessor',
-            'kv'       => 'key_value',
-            'elements' => 'options_elements',
+        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'] ],
         },
-        curries   => {
-            'accessor' => {
-                quantity => ['quantity'],
-            },
-        }
     );
 }
 
@@ -153,19 +149,20 @@ dies_ok {
 my $options = $stuff->meta->get_attribute('options');
 isa_ok($options, 'Moose::AttributeHelpers::Collection::Hash');
 
-is_deeply($options->provides, {
-    'set'      => 'set_option',
-    'get'      => 'get_option',
-    'empty'    => 'has_options',
-    'count'    => 'num_options',
-    'clear'    => 'clear_options',
-    'delete'   => 'delete_option',
-    'defined'  => 'is_defined',
-    'exists'   => 'has_option',
-    'accessor' => 'option_accessor',
-    'kv'       => 'key_value',
-    'elements' => 'options_elements',
-}, '... got the right provides mapping');
+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',
+}, '... got the right handles mapping');
 
 is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
 
index 56be613..79b66fa 100644 (file)
@@ -19,7 +19,7 @@ BEGIN {
         is        => 'ro',
         isa       => 'Int',
         default   => sub { 5 },
-        provides  => {
+        handles  => {
             set       => 'set',
             add       => 'add',
             sub       => 'sub',
@@ -27,13 +27,12 @@ BEGIN {
             div       => 'div',
             mod       => 'mod',
             abs       => 'abs',
+            inc         => [ add => [ 1 ] ],
+            dec         => [ sub => [ 1 ] ],
+            odd         => [ mod => [ 2 ] ],
+            cut_in_half => [ div => [ 2 ] ],
+
         },
-        curries   => {
-            add       => {inc         => [ 1 ]},
-            sub       => {dec         => [ 1 ]},
-            mod       => {odd         => [ 2 ]},
-            div       => {cut_in_half => [ 2 ]}
-        }
     );
 }
 
@@ -97,7 +96,7 @@ is $real->integer, 12, 'dec 13';
 my $attr = $real->meta->get_attribute('integer');
 isa_ok($attr, 'Moose::AttributeHelpers::Number');
 
-is_deeply($attr->provides, {
+is_deeply($attr->handles, {
     set => 'set',
     add => 'add',
     sub => 'sub',
@@ -105,5 +104,5 @@ is_deeply($attr->provides, {
     div => 'div',
     mod => 'mod',
     abs => 'abs',
-}, '... got the right provides mapping');
+}, '... got the right handles mapping');
 
index dac87a6..cf78c11 100644 (file)
@@ -20,39 +20,34 @@ BEGIN {
         isa       => 'ArrayRef[Int]',
         init_arg  => 'options',
         default   => sub { [] },
-        provides  => {
-            'count'    => 'num_options',
-            'empty'    => 'has_options',
-            'map'      => 'map_options',
-            'grep'     => 'filter_options',
-            'find'     => 'find_option',
-            'elements' => 'options',
-            'join'     => 'join_options',
-            'get'      => 'get_option_at',
-            'first'    => 'get_first_option',
-            'last'     => 'get_last_option',
-            'sort'     => 'sorted_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 => [ sub { $_ < 5 } ] ],
+            'up_by_one'      => [ map  => [ sub { $_ + 1 } ] ],
+            'dashify'        => [ join => [ '-'            ] ],
+            'descending'     => [ sort => [ sub { $_[1] <=> $_[0] ] ],
         },
-        curries   => {
-            'grep'     => {less_than_five => [ sub { $_ < 5 } ]},
-            'map'      => {up_by_one      => [ sub { $_ + 1 } ]},
-            'join'     => {dashify        => [ '-' ]},
-            'sort'     => {descending     => [ sub { $_[1] <=> $_[0] } ]},
-        }
     );
 
     has animals => (
         is       => 'rw',
         isa      => 'ArrayRef[Str]',
         metaclass => 'Collection::List',
-        curries => {
-            grep =>  {
-                double_length_of => sub {
-                    my ($self, $body, $arg) = @_;
-
-                    $body->($self, sub { length($_) == length($arg) * 2 });
-                }
-            }
+        handles => {
+           double_length_of => [ grep => [ sub  {
+              my ($self, $body, $arg) = @_;
+              $body->($self, sub { length($_) == length($arg) * 2 });
+           } ] ],
         }
     )
 }
@@ -130,19 +125,23 @@ is_deeply([$stuff->descending], [reverse 1 .. 10]);
 my $options = $stuff->meta->get_attribute('_options');
 isa_ok($options, 'Moose::AttributeHelpers::Collection::List');
 
-is_deeply($options->provides, {
-    'map'      => 'map_options',
-    'grep'     => 'filter_options',
-    'find'     => 'find_option',
-    'count'    => 'num_options',
-    'empty'    => 'has_options',
-    'elements' => 'options',
-    'join'     => 'join_options',
-    'get'      => 'get_option_at',
-    'first'    => 'get_first_option',
-    'last'     => 'get_last_option',
-    'sort'     => 'sorted_options',
-}, '... got the right provides mapping');
+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 ],
+   'up_by_one'      => [ map  ],
+   'dashify'        => [ join ],
+   'descending'     => [ sort ],
+}, '... got the right handles mapping');
 
 is($options->type_constraint->type_parameter, 'Int', '... got the right container type');