X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsugar.t;h=2ccc009038df9cd87306cedb3fc5028b5ec09ca7;hb=0d51197846c3fe198ef94aa255efbbad77432d02;hp=d62ed27a08afcbf1f6a6333da86bdad1eb36ef66;hpb=7194c025550913190a5c82a91f80a64118949232;p=p5sagit%2FData-Dumper-Concise.git diff --git a/t/sugar.t b/t/sugar.t index d62ed27..2ccc009 100644 --- a/t/sugar.t +++ b/t/sugar.t @@ -34,7 +34,7 @@ DWARN: { ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes lists through correctly'; my $bar = Dwarn 'robot',2,3; - is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly'; + is $warned_string,qq{"robot"\n2\n3\n}, 'Dwarn warns scalars correctly'; is $bar, 'robot', 'Dwarn passes scalars through correctly'; } @@ -45,14 +45,31 @@ DWARN_CODEREF: { ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly'; } +DWARNF: { + my @foo = DwarnF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl"; + + is($warned_string, qq{arr: [\n "wut",\n "HALP"\n]\n str: "gnarl"\n}, 'DumperF works!'); + ok eq_array($foo[0], ['wut','HALP']) && $foo[1] eq 'gnarl', 'DwarnF passes lists through correctly'; +} + DWARNN: { - my $x = [1]; - my $foo = DwarnN $x; - is $warned_string, qq{\$x => [\n 1\n]\n}, 'DwarnN warns'; + my $loaded = eval { require Devel::ArgNames; 1 }; + if ($loaded) { + my $x = [1]; + my $foo = DwarnN $x; + is $warned_string, qq{\$x => [\n 1\n]\n}, 'DwarnN warns'; - ok eq_array($foo, [1]), 'DwarnN passes through correctly'; + ok eq_array($foo, [1]), 'DwarnN passes through correctly'; + + DwarnN [1]; + is $warned_string, qq{(anon) => [\n 1\n]\n}, 'DwarnN warns'; + } +} - DwarnN [1]; - is $warned_string, qq{(anon) => [\n 1\n]\n}, 'DwarnN warns'; +DDIE: { + eval { + DdieS [ 'k', 'bar' ]; + }; + is $@, qq{[\n "k",\n "bar"\n]\n}, 'DwarnD dies output correctly'; }