In 5.8.x, fast stdio places still do use stdio.
[p5sagit/p5-mst-13.2.git] / ext / Digest / MD5 / t / badfile.t
CommitLineData
3357b1b1 1# Digest::MD5 2.07 and older used to trigger a core dump when
2# passed an illegal file handle that failed to open.
3
ac70dec1 4print "1..3\n";
3357b1b1 5
6use Digest::MD5 ();
42a96e2f 7use Config;
3357b1b1 8
9$md5 = Digest::MD5->new;
10
11eval {
12 use vars qw(*FOO);
13 $md5->addfile(*FOO);
14};
ac70dec1 15print "not " unless $@ =~ /^Bad filehandle: FOO at/;
3357b1b1 16print "ok 1\n";
17
ac70dec1 18open(BAR, "no-existing-file.$$");
19eval {
20 $md5->addfile(*BAR);
21};
22print "not " unless $@ =~ /^No filehandle passed at/;
3357b1b1 23print "ok 2\n";
ac70dec1 24
25open(BAR, ">no-existing-file.$$") || die;
26eval {
27 $md5->addfile(*BAR);
28};
42a96e2f 29# Some stdio implementations don't find reading from
30# write-only filehandle to be a problem. Therefore we
31# cannot expect this to fail reliably with stdio.
32my $stdio = !exists $Config{useperlio} ||
33 !defined $Config{useperlio} ||
72c58aaf 34 (exists $ENV{PERLIO} && $ENV{PERLIO} eq 'stdio') ||
35 defined $Config{usefaststdio};
42a96e2f 36print "not " unless $@ =~ /^Reading from filehandle failed at/ || $stdio;
ac70dec1 37print "ok 3\n";
38
39close(BAR);
40unlink("no-existing-file.$$");