work in progress
[p5sagit/Data-Dumper-Concise.git] / t / concise.t
CommitLineData
6d2a9a35 1use strict;
2use warnings;
3use Data::Dumper ();
4use Data::Dumper::Concise;
5use Test::More qw(no_plan);
ee04df67 6use Scalar::Util 'weaken';
6d2a9a35 7
8my $dd = Data::Dumper->new([])
9 ->Terse(1)
10 ->Indent(1)
11 ->Useqq(1)
12 ->Deparse(1)
13 ->Quotekeys(0)
14 ->Sortkeys(1);
15
e946236e 16foreach my $to_dump (
17 [ { foo => "bar\nbaz", quux => sub { "fleem" } } ],
18 [ 'one', 'two' ]
19) {
20
e946236e 21 $dd->Values([ @$to_dump ]);
39d55feb 22
e946236e 23 my $example = do {
24 local $Data::Dumper::Terse = 1;
25 local $Data::Dumper::Indent = 1;
26 local $Data::Dumper::Useqq = 1;
27 local $Data::Dumper::Deparse = 1;
28 local $Data::Dumper::Quotekeys = 0;
29 local $Data::Dumper::Sortkeys = 1;
30 Data::Dumper::Dumper(@$to_dump);
31 };
39d55feb 32
e946236e 33 is($example, $dd->Dump, 'Both Data::Dumper usages equivalent');
39d55feb 34
e946236e 35 is($example, Dumper(@$to_dump), 'Subroutine call usage equivalent');
36}
92264889 37
38my $out = DumperF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl";
ee04df67 39my $x = [1, 2];
40my $z = $x;
41my $y = weaken($x);
42warn Dumper($y);
43warn Dumper($x);
92264889 44is($out, qq{arr: [\n "wut",\n "HALP"\n]\n str: "gnarl"\n}, 'DumperF works!');