From: Arthur Axel 'fREW' Schmidt Date: Wed, 21 Apr 2010 04:50:38 +0000 (-0500) Subject: DwarnL + wa X-Git-Tag: v2.000~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6746e6495d3aae4e1f13f763a5ab2c39682fde1;p=p5sagit%2FData-Dumper-Concise.git DwarnL + wa --- diff --git a/lib/Data/Dumper/Concise/Sugar.pm b/lib/Data/Dumper/Concise/Sugar.pm index addd8e2..7405ba8 100644 --- a/lib/Data/Dumper/Concise/Sugar.pm +++ b/lib/Data/Dumper/Concise/Sugar.pm @@ -7,9 +7,11 @@ use Data::Dumper::Concise (); BEGIN { @ISA = qw(Exporter) } -@EXPORT = qw(Dwarn DwarnS); +@EXPORT = qw(Dwarn DwarnS DwarnL); -sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ } +sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } + +sub DwarnL { warn Data::Dumper::Concise::Dumper @_; @_ } sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } diff --git a/t/dwarn.t b/t/dwarn.t index 32fc41b..240f9e4 100644 --- a/t/dwarn.t +++ b/t/dwarn.t @@ -5,6 +5,6 @@ use Devel::Dwarn; use Test::More qw(no_plan); -can_ok __PACKAGE__, qw{Dwarn DwarnS}; +can_ok __PACKAGE__, qw{Dwarn DwarnS DwarnL}; -can_ok 'Devel::Dwarn', qw{Dwarn DwarnS}; +can_ok 'Devel::Dwarn', qw{Dwarn DwarnS DwarnL}; diff --git a/t/sugar.t b/t/sugar.t index 4ca2ecc..7375415 100644 --- a/t/sugar.t +++ b/t/sugar.t @@ -14,11 +14,26 @@ BEGIN { } } -my @foo = Dwarn 'warn', 'friend'; -is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns'; +DWARNL: { + my @foo = DwarnL 'warn', 'friend'; + is $warned_string,qq{"warn"\n"friend"\n}, 'DwarnL warns'; -ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes through correctly'; + ok eq_array(\@foo, ['warn','friend']), 'DwarnL passes through correctly'; +} + +DWARNS: { + my $bar = DwarnS 'robot',2,3; + is $warned_string,qq{"robot"\n}, 'DwarnS warns'; + is $bar, 'robot', 'DwarnS passes through correctly'; +} -my $bar = DwarnS 'robot',2,3; -is $warned_string,qq{"robot"\n}, 'DwarnS warns'; -is $bar, 'robot', 'DwarnS passes through correctly'; +DWARN: { + my @foo = Dwarn 'warn', 'friend'; + is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns lists'; + + ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes lists through correctly'; + + my $bar = Dwarn 'robot',2,3; + is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly'; + is $bar, 'robot', 'Dwarn passes scalars through correctly'; +}