Merge branch 'master' into attribute_helpers
[gitmo/Moose.git] / t / 070_attribute_helpers / 202_trait_array.t
index dfd506c..e4d7fc5 100644 (file)
@@ -8,41 +8,38 @@ use Test::Exception;
 use Test::Moose 'does_ok';
 
 BEGIN {
-    use_ok('MooseX::AttributeHelpers');
+    use_ok('Moose::AttributeHelpers');
 }
 
+my $sort;
 {
     package Stuff;
     use Moose;
 
     has 'options' => (
-        traits    => [qw/MooseX::AttributeHelpers::Trait::Collection::Array/],
+        traits    => [qw/Collection::Array/],
         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_options_with_speed' =>
+               [ 'push' => ['funrolls', 'funbuns'] ],
+            'prepend_prerequisites_along_with' =>
+               [ 'unshift' => ['first', 'second'] ],
+            'descending_options' =>
+               [ 'sort_in_place' => [ $sort = sub { $_[1] <=> $_[0] } ] ],
         }
     );
 }
@@ -225,21 +222,27 @@ dies_ok {
 ## test the meta
 
 my $options = $stuff->meta->get_attribute('options');
-does_ok($options, 'MooseX::AttributeHelpers::Trait::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');
+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');