5 use Test::More tests => 10;
11 open(FILE, "t/27_filehandle.t.db") || die("Can't open t/27_filehandle.t.db\n");
15 # test if we can open and read a db using its filehandle
17 ok(($db = DBM::Deep->new(fh => *FILE)), "open db in filehandle");
18 ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
21 } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle";
22 ok( !$db->exists( 'foo' ), "foo doesn't exist" );
24 my $db_obj = $db->_get_self;
25 ok( $db_obj->_root->{inode}, "The inode has been set" );
30 # now the same, but with an offset into the file. Use the database that's
31 # embedded in the test for the DATA filehandle. First, find the database ...
32 open(FILE, "t/28_DATA.t") || die("Can't open t/28_DATA.t\n");
33 while(my $line = <FILE>) {
34 last if($line =~ /^__DATA__/);
36 my $offset = tell(FILE);
40 open(FILE, "t/28_DATA.t");
44 ok(($db = DBM::Deep->new(fh => *FILE, file_offset => $offset)), "open db in filehandle with offset");
46 ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
48 ok( !$db->exists( 'foo' ), "foo doesn't exist yet" );
51 } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle";
52 ok( !$db->exists( 'foo' ), "foo doesn't exist" );