- remove Dumper() returning object
+ - add DwarnN
- add DwarnL
- make Dwarn contextual
- document ::Dwarn idiom
use Exporter ();
use Data::Dumper::Concise ();
+use Devel::ArgNames;
BEGIN { @ISA = qw(Exporter) }
-@EXPORT = qw(Dwarn DwarnS DwarnL);
+@EXPORT = qw(Dwarn DwarnS DwarnL DwarnN);
sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
+sub DwarnN ($) {
+ my $x = arg_names();
+ warn(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]); $_[0]
+}
+
=head1 NAME
Data::Dumper::Concise::Sugar - return Dwarn @return_value
use Test::More qw(no_plan);
-can_ok __PACKAGE__, qw{Dwarn DwarnS DwarnL};
+can_ok __PACKAGE__, qw{Dwarn DwarnS DwarnL DwarnN};
-can_ok 'Devel::Dwarn', qw{Dwarn DwarnS DwarnL};
+can_ok 'Devel::Dwarn', qw{Dwarn DwarnS DwarnL DwarnN};
is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly';
is $bar, 'robot', 'Dwarn passes scalars through correctly';
}
+
+DWARNN: {
+ my $x = [1];
+ my $foo = DwarnN $x;
+ is $warned_string, qq{\$x => [\n 1\n]\n}, 'DwarnN warns';
+
+ ok eq_array($foo, [1]), 'DwarnN passes through correctly';
+
+ DwarnN [1];
+ is $warned_string, qq{(anon) => [\n 1\n]\n}, 'DwarnN warns';
+}
+