Subject: | Undef key in first argument is ignored |
Date: | Fri, 20 Nov 2015 15:53:20 -0800 |
To: | bug-Data-Difference [...] rt.cpan.org |
From: | Peter Scott <Peter [...] PSDT.com> |
% perl -MData::Difference=data_diff -MData::Dumper -e 'print Dumper $_
for data_diff {z=>undef}, {z=>"foo"}'
% perl -MData::Difference=data_diff -MData::Dumper -e 'print Dumper $_
for data_diff {z=>"foo"}, {z=>undef}'
$VAR1 = {
'a' => 'foo',
'b' => undef,
'path' => [
'z'
]
};
The first one should produce this result but shows no difference:
$VAR1 = {
'a' => undef,
'b' => 'foo',
'path' => [
'z'
]
};
This should do it:
*** /usr/local/lib/perl5/site_perl/5.18.1/Data/Difference.pm.orig
2015-11-20 15:43:25.000000000 -0800
--- /usr/local/lib/perl5/site_perl/5.18.1/Data/Difference.pm 2015-11-20
15:52:57.000000000 -0800
***************
*** 50,56 ****
push @diff, {path => [@path, $k], a => $a->{$k}, b => $b->{$k}};
}
}
! elsif (defined $a->{$k} ? defined $b->{$k} ? $b->{$k} ne $a->{$k}
: 1 : 0) {
push @diff, {path => [@path, $k], a => $a->{$k}, b => $b->{$k}};
}
}
--- 50,56 ----
push @diff, {path => [@path, $k], a => $a->{$k}, b => $b->{$k}};
}
}
! elsif (defined $a->{$k} ? defined $b->{$k} ? $b->{$k} ne $a->{$k}
: 1 : defined $b) {
push @diff, {path => [@path, $k], a => $a->{$k}, b => $b->{$k}};
}
}
***************
*** 80,86 ****
push @diff, {path => [@path, $i], a => $a->[$i], b => $b->[$i]};
}
}
! elsif (defined $a->[$i] ? defined $b->[$i] ? $b->[$i] ne $a->[$i]
: 1 : 0) {
push @diff, {path => [@path, $i], a => $a->[$i], b => $b->[$i]};
}
}
--- 80,86 ----
push @diff, {path => [@path, $i], a => $a->[$i], b => $b->[$i]};
}
}
! elsif (defined $a->[$i] ? defined $b->[$i] ? $b->[$i] ne $a->[$i]
: 1 : defined $b->[$i]) {
push @diff, {path => [@path, $i], a => $a->[$i], b => $b->[$i]};
}
}