- Moose::Autobox::Ref perl() as alias to dump()
[gitmo/Moose-Autobox.git] / t / 001_basic.t
index beb218c..aeeb86e 100644 (file)
@@ -3,14 +3,13 @@
 use strict;
 use warnings;
 
-use Test::More tests => 55;
+use Test::More tests => 58;
 
 BEGIN {
     use_ok('Moose::Autobox');
-    use_ok('Moose::Autobox::Undef');
 }
 
-use autobox UNDEF => 'Moose::Autobox::Undef';
+use Moose::Autobox;
 
 # SCALAR & UNDEF
 
@@ -93,6 +92,12 @@ is_deeply($a, [ 4, 2, 6, 78, 101, 2 ], '... original value is now changed');
 is($a->shift(), 4, '... got the right unshift-ed value');
 is_deeply($a, [ 2, 6, 78, 101, 2 ], '... original value is now changed');
 
+
+is_deeply(
+$a->slice([ 1, 2, 4 ]), 
+[ 6, 78, 2 ], 
+'... got the right sliced value');
+
 is_deeply(
 $a->unshift(10), 
 [ 10, 2, 6, 78, 101, 2 ], 
@@ -169,6 +174,16 @@ $a,
 [ 15, 20, 30, 10, 2, 6, 78, 101, 2, 10, 15, 20, 30 ], 
 '... the value is correctly put');
 
+my $expected_dump = qr/^\$VAR1\s*=\s*\[\s*15,\s*20,\s*30,\s*10,\s*2,\s*6,\s*78,\s*101,\s*2,\s*10,\s*15,\s*20,\s*30\s*\]\s*;\s*$/msx;
+
+like( $a->dump,
+      $expected_dump,
+      '... the value is correctly dumped' );
+is( $a->dump,
+    $a->perl,
+    '... the value is correctly dumped with perl()' );
+
+
 # Hash
 
 my $h = { one => 1, two => 2, three => 3 };
@@ -207,4 +222,9 @@ $h,
 { one => 1, two => 2, three => 3 },
 '... got the value deleted correctly');
 
+is_deeply(
+$h->merge({ three => 33, four => 44 }),
+{ one => 1, two => 2, three => 33, four => 44 },
+'... got the hashes merged correctly');
+