From: Arthur Axel 'fREW' Schmidt Date: Sat, 13 Feb 2010 20:20:53 +0000 (-0600) Subject: add tests for the most excellent _only subs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20fc51ea50eb4375f6c03d6e5530ee3dfa2dd1dc;p=p5sagit%2FData-Dumper-Concise.git add tests for the most excellent _only subs --- 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'; +}