X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsugar.t;fp=t%2Fsugar.t;h=4051338605786085d7391f33e1e81c1aca771919;hb=20fc51ea50eb4375f6c03d6e5530ee3dfa2dd1dc;hp=4ca2ecc1f936e54c8bb3140db36bcc633ec6a1c2;hpb=9991a059afc49cc162b8194dfa2d356170e96233;p=p5sagit%2FData-Dumper-Concise.git diff --git a/t/sugar.t b/t/sugar.t index 4ca2ecc..4051338 100644 --- a/t/sugar.t +++ b/t/sugar.t @@ -14,11 +14,32 @@ BEGIN { } } -my @foo = Dwarn 'warn', 'friend'; -is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns'; +DWARN: { + my @foo = Dwarn 'warn', 'friend'; + is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns'; -ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes through correctly'; + ok eq_array(\@foo, ['warn','friend']), 'Dwarn 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'; +} + +DWARNONLY: { + my @foo = Dwarn_only { $_[0] } qw(one two three); + is $warned_string,qq{"one"\n}, 'Dwarn_only warns requested data'; -my $bar = DwarnS 'robot',2,3; -is $warned_string,qq{"robot"\n}, 'DwarnS warns'; -is $bar, 'robot', 'DwarnS passes through correctly'; + ok eq_array(\@foo, [qw{one two three}]), 'Dwarn_only passes through correctly'; +} + +DWARNSONLY: { + my $bar = DwarnS_only { $_->[0] } [ qw(one two three) ]; + is $warned_string,qq{"one"\n}, 'DwarnS_only warns requested data'; + + ok $bar->[0] eq 'one' && + $bar->[1] eq 'two' && + $bar->[2] eq 'three' && + @{$bar} == 3, 'DwarnS_only passes through correctly'; +}