1#!perl 2use strict; 3use warnings; 4 5use Data::Dumper; 6use Test::More tests => 6; 7use lib qw( ./t/lib ); 8use Testing qw( _dumptostr ); 9 10 11my $hash = { foo => 42 }; 12 13for my $useperl (0..1) { 14 my $dumper = Data::Dumper->new([$hash]); 15 $dumper->Terse(1); 16 $dumper->Indent(2); 17 $dumper->Useperl($useperl); 18 19 is $dumper->Dump, <<'WANT', "Terse(1), Indent(2), Useperl($useperl)"; 20{ 21 'foo' => 42 22} 23WANT 24} 25 26my (%dumpstr); 27my $dumper; 28 29$dumper = Data::Dumper->new([$hash]); 30$dumpstr{noterse} = _dumptostr($dumper); 31# $VAR1 = { 32# 'foo' => 42 33# }; 34 35$dumper = Data::Dumper->new([$hash]); 36$dumper->Terse(); 37$dumpstr{terse_no_arg} = _dumptostr($dumper); 38 39$dumper = Data::Dumper->new([$hash]); 40$dumper->Terse(0); 41$dumpstr{terse_0} = _dumptostr($dumper); 42 43$dumper = Data::Dumper->new([$hash]); 44$dumper->Terse(1); 45$dumpstr{terse_1} = _dumptostr($dumper); 46# { 47# 'foo' => 42 48# } 49 50$dumper = Data::Dumper->new([$hash]); 51$dumper->Terse(undef); 52$dumpstr{terse_undef} = _dumptostr($dumper); 53 54is($dumpstr{noterse}, $dumpstr{terse_no_arg}, 55 "absence of Terse is same as Terse()"); 56is($dumpstr{noterse}, $dumpstr{terse_0}, 57 "absence of Terse is same as Terse(0)"); 58isnt($dumpstr{noterse}, $dumpstr{terse_1}, 59 "absence of Terse is different from Terse(1)"); 60is($dumpstr{noterse}, $dumpstr{terse_undef}, 61 "absence of Terse is same as Terse(undef)"); 62