5 use Test::More tests => 7;
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");
22 # now the same, but with an offset into the file. Use the database that's
23 # embedded in the test for the DATA filehandle. First, find the database ...
24 open(FILE, "t/28_DATA.t") || die("Can't open t/28_DATA.t\n");
25 while(my $line = <FILE>) {
26 last if($line =~ /^__DATA__/);
28 my $offset = tell(FILE);
31 open(FILE, '<', "t/28_DATA.t");
32 ok(($db = DBM::Deep->new(fh => *FILE, file_offset => $offset)), "open db in filehandle with offset");
33 ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
35 ok( !$db->{foo}, "foo doesn't exist yet" );
38 } qr/Cannot write to a readonly filehandle/, "Can't write to a read-only filehandle";
39 ok( !$db->{foo}, "foo doesn't exist yet" );