From: rkinyon Date: Wed, 1 Mar 2006 16:01:46 +0000 (+0000) Subject: Added better tests of existence around failure to write to readonly handle X-Git-Tag: 0-99_01~106 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7a99be5061a028cfb0c8c749b6885dffec101131;p=dbsrgits%2FDBM-Deep.git Added better tests of existence around failure to write to readonly handle --- diff --git a/t/27_filehandle.t b/t/27_filehandle.t index ac4736c..67e7b71 100644 --- a/t/27_filehandle.t +++ b/t/27_filehandle.t @@ -2,7 +2,7 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 7; +use Test::More tests => 9; use Test::Exception; use DBM::Deep; @@ -15,6 +15,10 @@ my $db; ok(($db = DBM::Deep->new(fh => *FILE)), "open db in filehandle"); ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database"); +throws_ok { + $db->{foo} = 1; +} qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle"; +ok( !$db->exists( 'foo' ), "foo doesn't exist" ); undef $db; close(FILE); @@ -28,12 +32,12 @@ while(my $line = ) { my $offset = tell(FILE); close(FILE); -open(FILE, '<', "t/28_DATA.t"); +open(FILE, "t/28_DATA.t"); ok(($db = DBM::Deep->new(fh => *FILE, file_offset => $offset)), "open db in filehandle with offset"); ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database"); -ok( !$db->{foo}, "foo doesn't exist yet" ); +ok( !$db->exists( 'foo' ), "foo doesn't exist yet" ); throws_ok { $db->{foo} = 1; } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle"; -ok( !$db->{foo}, "foo doesn't exist yet" ); +ok( !$db->exists( 'foo' ), "foo doesn't exist" );