In 5.8.x, fast stdio places still do use stdio.
[p5sagit/p5-mst-13.2.git] / ext / Digest / MD5 / t / badfile.t
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
4 print "1..3\n";
5
6 use Digest::MD5 ();
7 use Config;
8
9 $md5 = Digest::MD5->new;
10
11 eval {
12    use vars qw(*FOO);
13    $md5->addfile(*FOO);
14 };
15 print "not " unless $@ =~ /^Bad filehandle: FOO at/;
16 print "ok 1\n";
17
18 open(BAR, "no-existing-file.$$");
19 eval {
20     $md5->addfile(*BAR);
21 };
22 print "not " unless $@ =~ /^No filehandle passed at/;
23 print "ok 2\n";
24
25 open(BAR, ">no-existing-file.$$") || die;
26 eval {
27     $md5->addfile(*BAR);
28 };
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.
32 my $stdio = !exists  $Config{useperlio} ||
33             !defined $Config{useperlio} ||
34             (exists $ENV{PERLIO} && $ENV{PERLIO} eq 'stdio') ||
35             defined $Config{usefaststdio};
36 print "not " unless $@ =~ /^Reading from filehandle failed at/ || $stdio;
37 print "ok 3\n";
38
39 close(BAR);
40 unlink("no-existing-file.$$");