This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlreapi: use parent in example, not base
[perl5.git] / t / io / binmode.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = qw(. ../lib);
6     require './test.pl';
7     eval 'use Errno';
8     die $@ if $@ and !is_miniperl();
9 }
10
11
12 plan(tests => 9);
13
14 ok( binmode(STDERR),            'STDERR made binary' );
15 SKIP: {
16     skip('skip unix discipline without PerlIO layers', 1)
17         unless find PerlIO::Layer 'perlio';
18     ok( binmode(STDERR, ":unix"),   '  with unix discipline' );
19 }
20 ok( binmode(STDERR, ":raw"),    '  raw' );
21 ok( binmode(STDERR, ":crlf"),   '  and crlf' );
22
23 # If this one fails, we're in trouble.  So we just bail out.
24 ok( binmode(STDOUT),            'STDOUT made binary' )      || exit(1);
25 SKIP: {
26     skip('skip unix discipline without PerlIO layers', 1)
27         unless find PerlIO::Layer 'perlio';
28     ok( binmode(STDOUT, ":unix"),   '  with unix discipline' );
29 }
30 ok( binmode(STDOUT, ":raw"),    '  raw' );
31 ok( binmode(STDOUT, ":crlf"),   '  and crlf' );
32
33 SKIP: {
34     skip "no EBADF", 1 unless exists &Errno::EBADF;
35
36     no warnings 'io', 'once';
37     $! = 0;
38     binmode(B);
39     cmp_ok($!, '==', Errno::EBADF());
40 }