* Moose::Autobox::String
- fixed rindex method
- * Moose::Autobox::Ref
+ * Moose::Autobox::Item
+ - moved &dump from ::Ref to ::Item, so that it can be used
+ for the other types too
+
- added &perl method which is an alias for &dump for symmetry
with Perl6's .perl
-
+
+ * Moose::Autobox::Scalar/Array/Hash
+ - added &print/&say to SCALAR, ARRAY and HASH
+
+
0.03 Thurs. Aug 17, 2006
* Moose::Autobox
return Perl6::Junction::One->one(@$array);
}
+## Print
+
+sub print { CORE::print @{$_[0]} }
+sub say { CORE::print @{$_[0]}, "\n" }
+
1;
__END__
=item B<meta>
+=item B<print>
+
+=item B<say>
+
=back
=head1 BUGS
[ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
}
+sub print { CORE::print %{$_[0]} }
+sub say { CORE::print %{$_[0]}, "\n" }
+
1;
__END__
=item B<meta>
+=item B<print>
+
+=item B<say>
+
=back
=head1 BUGS
requires 'defined';
+sub dump {
+ my $self = shift;
+ require Data::Dumper;
+ return Data::Dumper::Dumper($self);
+}
+
+*perl = *dump;
+
1;
__END__
=item B<meta>
+=item B<dump>
+
+Calls Data::Dumper::Dumper.
+
+=item B<perl>
+
+Same as B<dump>. For symmetry with Perl6's .perl method.
+
+Like &print with newline.
+
+=item B<print2>
+
=back
=head1 REQUIRED METHODS
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
with 'Moose::Autobox::Defined';
-sub dump {
- my $self = shift;
- require Data::Dumper;
- return Data::Dumper::Dumper($self);
-}
-
-*perl = *dump;
-
1;
__END__
=item B<meta>
-=item B<dump>
-
-Calls Data::Dumper::Dumper.
-
-=item B<perl>
-
-Same as B<dump>. For symmetry with Perl6's .perl method.
-
=back
=head1 BUGS
with 'Moose::Autobox::String',
'Moose::Autobox::Number';
+sub print { CORE::print $_[0] }
+sub say { CORE::print $_[0], "\n" }
1;
__END__
=item B<meta>
+=item B<print>
+
+=item B<say>
+
=back
=head1 BUGS
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
use strict;
use warnings;
-use Test::More tests => 58;
+use Test::More tests => 62;
BEGIN {
use_ok('Moose::Autobox');
use Moose::Autobox;
+my $VAR1; # for eval of dumps
+
# SCALAR & UNDEF
my $s;
$s = 5;
ok($s->defined, '... got a defined value');
+eval $s->dump;
+is($VAR1, 5 , '... eval of SCALAR->dump works');
+
+eval $s->perl;
+is($s->perl, $s->dump, '... SCALAR->dump equals SCALAR->perl');
+
# CODE
my $f1 = sub { @_ };
[ 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;
+eval($a->dump);
+is_deeply( $VAR1,
+ [ 15, 20, 30, 10, 2, 6, 78, 101, 2, 10, 15, 20, 30 ],
+ '... the value is correctly dumped');
-like( $a->dump,
- $expected_dump,
- '... the value is correctly dumped' );
is( $a->dump,
$a->perl,
'... the value is correctly dumped with perl()' );
{ one => 1, two => 2, three => 33, four => 44 },
'... got the hashes merged correctly');
+eval($h->dump);
+is_deeply( $VAR1,
+ { one => 1, two => 2, three => 3 },
+ '... the value is correctly dumped');
+
+is( $h->dump,
+ $h->perl,
+ '... the value is correctly dumped with perl()' );
use strict;
use warnings;
-use Test::More tests => 18;
+use Test::More tests => 20;
use Test::Exception;
BEGIN {
use Moose::Autobox;
+my $VAR1; # for eval of dumps
+
is('Hello World'->lc, 'hello world', '... $str->lc');
is('Hello World'->uc, 'HELLO WORLD', '... $str->uc');
is('Hello World, Hello'->rindex('Hello', 6), 0, '... got the correct right index');
+eval 'Hello World, Hello'->dump;
+is($VAR1, 'Hello World, Hello' , '... eval of &dump works');
+
+eval 'Hello World, Hello'->perl;
+is($VAR1, 'Hello World, Hello' , '... eval of &perl works');
+