Commit cb295e9c authored by Leo Gordon's avatar Leo Gordon
Browse files

bugfix: make sure Data::Dumper::Deepcopy is on

parent 510da9d5
......@@ -83,6 +83,7 @@ sub stringify {
local $Data::Dumper::Useqq = 1; # escape the \n and \t correctly
local $Data::Dumper::Pair = ' => '; # make sure we always produce Perl-parsable structures, no matter what is set externally
local $Data::Dumper::Maxdepth = 0; # make sure nobody can mess up stringification by setting a lower Maxdepth
local $Data::Dumper::Deepcopy = 1; # avoid self-references in case the same structure is reused within params
return Dumper($structure);
}
......
......@@ -37,11 +37,6 @@ my $struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');
$struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');
$structure = {
foo => 'bar',
latin => {
......@@ -70,4 +65,12 @@ isa_ok($destructure, 'ARRAY'); ## got an array
is($destructure->[0]{'alpha'}, 'beta', 'hash entry');
is($destructure->[2]{'omega'}, undef, 'undef values');
my $h = {'a' => 3, 'b' => 4};
my $all_params = { 'p1' => [$h], 'p2' => 'x', 'p3' => $h };
$struct_string = stringify $all_params;
ok($struct_string, 'returned a value');
is($struct_string, q!{"p1" => [{"a" => 3,"b" => 4}],"p2" => "x","p3" => {"a" => 3,"b" => 4}}!, 'correct deep copy');
done_testing();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment