From: Steffen Schwigon Date: Fri, 25 May 2007 15:19:56 +0000 (+0000) Subject: - Moose::Autobox::Ref perl() as alias to dump() X-Git-Tag: 0_04~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b2ca73cb6e813fb041f5c013c38d115236976d9;p=gitmo%2FMoose-Autobox.git - Moose::Autobox::Ref perl() as alias to dump() - tests for dump() and perl() --- diff --git a/lib/Moose/Autobox/Ref.pm b/lib/Moose/Autobox/Ref.pm index f4e397d..843d081 100644 --- a/lib/Moose/Autobox/Ref.pm +++ b/lib/Moose/Autobox/Ref.pm @@ -11,6 +11,8 @@ sub dump { return Data::Dumper::Dumper($self); } +*perl = *dump; + 1; __END__ @@ -33,6 +35,12 @@ This is a role to describes a reference value. =item B +Calls Data::Dumper::Dumper. + +=item B + +Same as B. For symmetry with Perl6's .perl method. + =back =head1 BUGS @@ -54,4 +62,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut diff --git a/t/001_basic.t b/t/001_basic.t index bff5f20..aeeb86e 100644 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 56; +use Test::More tests => 58; BEGIN { use_ok('Moose::Autobox'); @@ -174,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 };