Re: [perl #18048] read \*FH, ... returns undef but doesn' t set $! if \*FH not open
[p5sagit/p5-mst-13.2.git] / t / io / binmode.t
CommitLineData
e940ddbb 1#!./perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
69026470 5 @INC = qw(. ../lib);
b5fe5ca2 6 require './test.pl';
e940ddbb 7}
8
444e39b5 9use Config;
b5fe5ca2 10use Errno;
e940ddbb 11
b5fe5ca2 12plan(tests => 9);
69026470 13
e940ddbb 14ok( binmode(STDERR), 'STDERR made binary' );
6b5da1a3 15if (find PerlIO::Layer 'perlio') {
444e39b5 16 ok( binmode(STDERR, ":unix"), ' with unix discipline' );
17} else {
6b5da1a3 18 ok(1, ' skip unix discipline without PerlIO layers' );
444e39b5 19}
e940ddbb 20ok( binmode(STDERR, ":raw"), ' raw' );
21ok( binmode(STDERR, ":crlf"), ' and crlf' );
22
23# If this one fails, we're in trouble. So we just bail out.
24ok( binmode(STDOUT), 'STDOUT made binary' ) || exit(1);
6b5da1a3 25if (find PerlIO::Layer 'perlio') {
444e39b5 26 ok( binmode(STDOUT, ":unix"), ' with unix discipline' );
27} else {
6b5da1a3 28 ok(1, ' skip unix discipline without PerlIO layers' );
444e39b5 29}
30ok( binmode(STDOUT, ":raw"), ' raw' );
31ok( binmode(STDOUT, ":crlf"), ' and crlf' );
b5fe5ca2 32
33SKIP: {
34 skip "no EBADF", 1 if (!exists &Errno::EBADF);
35
36 no warnings 'io';
37 $! = 0;
38 binmode(B);
39 ok($! == &Errno::EBADF);
40}