[PATCH] Removing example layers from MIME::QuotedPrint
[p5sagit/p5-mst-13.2.git] / ext / PerlIO / t / fail.t
CommitLineData
0cff2cf3 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require "../t/test.pl";
7 skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
d96fb286 8 plan (15);
0cff2cf3 9}
10
11use warnings 'layer';
12my $warn;
13my $file = "fail$$";
14$SIG{__WARN__} = sub { $warn = shift };
15
16END { 1 while unlink($file) }
17
18ok(open(FH,">",$file),"Create works");
19close(FH);
20ok(open(FH,"<",$file),"Normal open works");
21
22$warn = ''; $! = 0;
23ok(!binmode(FH,":-)"),"All punctuation fails binmode");
d96fb286 24print "# $!\n";
25isnt($!,0,"Got errno");
0cff2cf3 26like($warn,qr/in layer/,"Got warning");
27
28$warn = ''; $! = 0;
29ok(!binmode(FH,":nonesuch"),"Bad package fails binmode");
d96fb286 30print "# $!\n";
31isnt($!,0,"Got errno");
0cff2cf3 32like($warn,qr/nonesuch/,"Got warning");
33close(FH);
34
35$warn = ''; $! = 0;
36ok(!open(FH,"<:-)",$file),"All punctuation fails open");
d96fb286 37print "# $!\n";
0cff2cf3 38isnt($!,"","Got errno");
d96fb286 39like($warn,qr/in layer/,"Got warning");
0cff2cf3 40
41$warn = ''; $! = 0;
42ok(!open(FH,"<:nonesuch",$file),"Bad package fails open");
d96fb286 43print "# $!\n";
44isnt($!,0,"Got errno");
0cff2cf3 45like($warn,qr/nonesuch/,"Got warning");
46
47ok(open(FH,"<",$file),"Normal open (still) works");
48close(FH);