This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
As well as PERL5LIB, remove PERLLIB and PERL5OPT from the environment.
[perl5.git] / t / io / perlio_open.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     if ($ENV{PERL_CORE_MINITEST}) {
7         print "1..0 # Skip: no Fcntl under miniperl\n";
8         exit 0;
9     }
10     unless (find PerlIO::Layer 'perlio') {
11         print "1..0 # Skip: not perlio\n";
12         exit 0;
13     }
14     use Config;
15     unless (" $Config{extensions} " =~ / Fcntl /) {
16         print "1..0 # Skip: no Fcntl (how did you get this far?)\n";
17         exit 0;
18     }
19     require './test.pl';
20 }
21
22 use strict;
23 use warnings;
24
25 plan tests => 6;
26
27 use Fcntl qw(:seek);
28
29 {
30     ok((open my $fh, "+>", undef), "open my \$fh, '+>', undef");
31     print $fh "the right write stuff";
32     ok(seek($fh, 0, SEEK_SET), "seek to zero");
33     my $data = <$fh>;
34     is($data, "the right write stuff", "found the right stuff");
35 }
36
37 {
38     ok((open my $fh, "+<", undef), "open my \$fh, '+<', undef");
39     print $fh "the right read stuff";
40     ok(seek($fh, 0, SEEK_SET), "seek to zero");
41     my $data = <$fh>;
42     is($data, "the right read stuff", "found the right stuff");
43 }
44
45
46
47