fix parens and use eq_array
[p5sagit/Data-Dumper-Concise.git] / t / sugar.t
CommitLineData
884bc377 1use strict;
2use warnings;
3use Data::Dumper::Concise::Sugar;
4
5use Data::Dumper::Concise ();
6
7use Test::More qw(no_plan);
884bc377 8
caf571f8 9my $warned_string;
884bc377 10
caf571f8 11BEGIN {
12 $SIG{'__WARN__'} = sub {
13 $warned_string = $_[0]
14 }
15}
884bc377 16
20fc51ea 17DWARN: {
18 my @foo = Dwarn 'warn', 'friend';
e2d59441 19 is( $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns' );
884bc377 20
e2d59441 21 ok( eq_array(\@foo, ['warn','friend']), 'Dwarn passes through correctly' );
20fc51ea 22}
23
24DWARNS: {
25 my $bar = DwarnS 'robot',2,3;
e2d59441 26 is( $warned_string,qq{"robot"\n}, 'DwarnS warns' );
27 is( $bar, 'robot', 'DwarnS passes through correctly' );
20fc51ea 28}
29
30DWARNONLY: {
31 my @foo = Dwarn_only { $_[0] } qw(one two three);
e2d59441 32 is( $warned_string,qq{"one"\n}, 'Dwarn_only warns requested data' );
caf571f8 33
e2d59441 34 ok( eq_array(\@foo, [qw{one two three}]), 'Dwarn_only passes through correctly' );
20fc51ea 35}
36
37DWARNSONLY: {
38 my $bar = DwarnS_only { $_->[0] } [ qw(one two three) ];
e2d59441 39 is( $warned_string,qq{"one"\n}, 'DwarnS_only warns requested data' );
20fc51ea 40
e2d59441 41 ok( eq_array( $bar, [ qw{one two three} ] ), 'DwarnS_only passes through correctly' );
20fc51ea 42}