3 use Data::Dumper::Concise::Sugar;
5 use Data::Dumper::Concise ();
7 use Test::More qw(no_plan);
12 $SIG{'__WARN__'} = sub {
13 $warned_string = $_[0]
18 my @foo = DwarnL 'warn', 'friend';
19 is $warned_string,qq{"warn"\n"friend"\n}, 'DwarnL warns';
21 ok eq_array(\@foo, ['warn','friend']), 'DwarnL passes through correctly';
25 my $bar = DwarnS 'robot',2,3;
26 is $warned_string,qq{"robot"\n}, 'DwarnS warns';
27 is $bar, 'robot', 'DwarnS passes through correctly';
31 my @foo = Dwarn 'warn', 'friend';
32 is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns lists';
34 ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes lists through correctly';
36 my $bar = Dwarn 'robot',2,3;
37 is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly';
38 is $bar, 'robot', 'Dwarn passes scalars through correctly';
42 my $foo = ['warn', 'friend']->$Dwarn;
43 is $warned_string,qq{[\n "warn",\n "friend"\n]\n}, 'Dwarn warns lists';
45 ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly';
49 my @foo = DwarnF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl";
51 is($warned_string, qq{arr: [\n "wut",\n "HALP"\n]\n str: "gnarl"\n}, 'DumperF works!');
52 ok eq_array($foo[0], ['wut','HALP']) && $foo[1] eq 'gnarl', 'DwarnF passes lists through correctly';
56 my $loaded = eval { require Devel::ArgNames; 1 };
60 is $warned_string, qq{\$x => [\n 1\n]\n}, 'DwarnN warns';
62 ok eq_array($foo, [1]), 'DwarnN passes through correctly';
65 is $warned_string, qq{(anon) => [\n 1\n]\n}, 'DwarnN warns';
73 is $@, qq{[\n "k",\n "bar"\n]\n}, 'DwarnD dies output correctly';