This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta
[perl5.git] / dist / IO / t / io_utf8argv.t
CommitLineData
986a805c
FC
1#!./perl
2
3BEGIN {
e6aa2bc1 4 unless ( PerlIO::Layer->find('perlio') ) {
986a805c
FC
5 print "1..0 # Skip: not perlio\n";
6 exit 0;
7 }
9cfa7410 8 require($ENV{PERL_CORE} ? "../../t/test.pl" : "./t/test.pl");
986a805c
FC
9}
10
11use utf8;
12
e50b6166
KW
13skip_all("EBCDIC platform; testing not core")
14 if $::IS_EBCDIC && ! $ENV{PERL_CORE};
986a805c 15
7a992ccc 16plan(tests => 4);
986a805c 17
e50b6166
KW
18my $bytes =
19 "\xce\x9c\xe1\xbd\xb7\xce\xb1\x20\xcf\x80\xe1\xbd\xb1\xcf\x80\xce".
20 "\xb9\xce\xb1\x2c\x20\xce\xbc\xe1\xbd\xb0\x20\xcf\x80\xce\xbf\xce".
21 "\xb9\xe1\xbd\xb0\x20\xcf\x80\xe1\xbd\xb1\xcf\x80\xce\xb9\xce\xb1".
22 "\xcd\xbe\x0a";
23
24if ($::IS_EBCDIC) {
9cfa7410 25 require($ENV{PERL_CORE} ? "../../t/charset_tools.pl" : "./t/charset_tools.pl");
e50b6166
KW
26 $bytes = byte_utf8a_to_utf8n($bytes)
27}
28
ae92a15b 29open my $fh, ">:raw", 'io_utf8argv';
e50b6166 30print $fh $bytes;
986a805c
FC
31close $fh or die "close: $!";
32
33
986a805c
FC
34use IO::Handle;
35
61e73f5d
NC
36SKIP: {
37 skip("PERL_UNICODE set", 2)
38 if exists $ENV{PERL_UNICODE};
39
40 @ARGV = ('io_utf8argv') x 2;
41 is *ARGV->getline, $bytes,
42 'getline (no open pragma) when magically opening ARGV';
7a992ccc 43
61e73f5d
NC
44 is join('',*ARGV->getlines), $bytes,
45 'getlines (no open pragma) when magically opening ARGV';
46}
7a992ccc
NC
47
48use open ":std", ":utf8";
49
50@ARGV = ('io_utf8argv') x 2;
986a805c
FC
51is *ARGV->getline, "Μία πάπια, μὰ ποιὰ πάπια;\n",
52 'getline respects open pragma when magically opening ARGV';
53
54is join('',*ARGV->getlines), "Μία πάπια, μὰ ποιὰ πάπια;\n",
55 'getlines respects open pragma when magically opening ARGV';
56
57END {
58 1 while unlink "io_utf8argv";
6edfdc07 59}