xref: /openbsd/gnu/usr.bin/perl/t/io/binmode.t (revision 73471bf0)
1#!./perl -w
2
3BEGIN {
4    chdir 't' if -d 't';
5    require './test.pl';
6    set_up_inc(qw(. ../lib));
7    eval 'use Errno';
8    die $@ if $@ and !is_miniperl();
9}
10
11
12plan(tests => 9);
13
14ok( binmode(STDERR),            'STDERR made binary' );
15SKIP: {
16    skip('skip unix discipline without PerlIO layers', 1)
17	unless find PerlIO::Layer 'perlio';
18    ok( binmode(STDERR, ":unix"),   '  with unix discipline' );
19}
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);
25SKIP: {
26    skip('skip unix discipline without PerlIO layers', 1)
27	unless find PerlIO::Layer 'perlio';
28    ok( binmode(STDOUT, ":unix"),   '  with unix discipline' );
29}
30ok( binmode(STDOUT, ":raw"),    '  raw' );
31ok( binmode(STDOUT, ":crlf"),   '  and crlf' );
32
33SKIP: {
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}
41