5 use Test::More tests => 9;
10 open(FILE, "t/27_filehandle.t.db") || die("Can't open t/27_filehandle.t.db\n");
14 # test if we can open and read a db using its filehandle
16 ok(($db = DBM::Deep->new(fh => *FILE)), "open db in filehandle");
17 ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
20 } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle";
21 ok( !$db->exists( 'foo' ), "foo doesn't exist" );
26 # now the same, but with an offset into the file. Use the database that's
27 # embedded in the test for the DATA filehandle. First, find the database ...
28 open(FILE, "t/28_DATA.t") || die("Can't open t/28_DATA.t\n");
29 while(my $line = <FILE>) {
30 last if($line =~ /^__DATA__/);
32 my $offset = tell(FILE);
35 open(FILE, "t/28_DATA.t");
36 ok(($db = DBM::Deep->new(fh => *FILE, file_offset => $offset)), "open db in filehandle with offset");
37 ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
39 ok( !$db->exists( 'foo' ), "foo doesn't exist yet" );
42 } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle";
43 ok( !$db->exists( 'foo' ), "foo doesn't exist" );