Skip Menu |

This queue is for tickets about the DBM-Deep CPAN distribution.

Report information
The Basics
Id: 60391
Status: resolved
Priority: 0/
Queue: DBM-Deep

People
Owner: Nobody in particular
Requestors: prbrenan [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



#!perl -w # Possible discrepancy between DBM::Deep and Perl's handling of exists() use feature ':5.12'; use Test::More; use strict; my $h; ok !exists $h->{a}; is $h->{a}, undef(); ok !exists $h->{a}; $h->{a} = undef(); ok exists $h->{a}; # From DBM::Deep 02_hash.t my $db; ok( !exists $db->{key4}, "exists() function works for keys that aren't there" ); is( $db->{key4}, undef, "Autovivified key4" ); ok( exists $db->{key4}, "Autovivified key4 now exists" ) or diag "DBM::Deep thinks this should succeed"; # From DBM::Deep 03_bighash.t my $foo; ok( !exists $foo->{does_not_exist}, "EXISTS works on large hashes for non-existent keys" ); is( $foo->{does_not_exist}, undef, "autovivification works on large hashes" ); ok( exists $foo->{does_not_exist}, "EXISTS works on large hashes for newly-existent keys" ) or diag "DBM::Deep thinks this should succeed";; done_testing;
On Mon Aug 16 09:56:38 2010, PRBRENAN wrote: Show quoted text
> #!perl -w > # Possible discrepancy between DBM::Deep and Perl's handling of exists() > use feature ':5.12'; > use Test::More; > use strict; > > my $h; > > ok !exists $h->{a}; > is $h->{a}, undef(); > ok !exists $h->{a}; > $h->{a} = undef(); > ok exists $h->{a}; > > # From DBM::Deep 02_hash.t > > my $db; > ok( !exists $db->{key4}, "exists() function works for keys that > aren't there" ); > is( $db->{key4}, undef, "Autovivified key4" ); > ok( exists $db->{key4}, "Autovivified key4 now exists" ) or > diag "DBM::Deep thinks this should succeed"; > > # From DBM::Deep 03_bighash.t > > my $foo; > ok( !exists $foo->{does_not_exist}, "EXISTS works on large hashes for > non-existent keys" ); > is( $foo->{does_not_exist}, undef, "autovivification works on large > hashes" ); > ok( exists $foo->{does_not_exist}, "EXISTS works on large hashes for > newly-existent keys" ) or diag "DBM::Deep thinks this should succeed";; > > done_testing;
I’ve been tripped up by this before (when reading a read-only database), but it didn’t occur to me that it was a bug. I resorted to using Tie::Hash::ReadonlyStack around the DB at the time. Anyway, thank you for your report. This has been fixed in 2.0001.