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