This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
test.pl: Allow NAME to be used with --FILE--
[perl5.git] / t / uni / readline.t
CommitLineData
2a507800
BF
1#!./perl
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
9plan tests => 7;
10
11use utf8;
12use open qw( :utf8 :std );
13
14# [perl #19566]: sv_gets writes directly to its argument via
15# TARG. Test that we respect SvREADONLY.
16eval { for (\2) { $_ = <Fʜ> } };
17like($@, 'Modification of a read-only value attempted', '[perl #19566]');
18
19# [perl #21628]
20{
21 my $file = tempfile();
22 open Ạ,'+>',$file; $a = 3;
23 is($a .= <Ạ>, 3, '#21628 - $a .= <A> , A eof');
12578451 24 close Ạ; $a = 4;
2a507800
BF
25 is($a .= <Ạ>, 4, '#21628 - $a .= <A> , A closed');
26}
27
28use strict;
29
30open ᕝ, '.' and sysread ᕝ, $_, 1;
31my $err = $! + 0;
32close ᕝ;
33
34SKIP: {
35 skip "you can read directories as plain files", 2 unless( $err );
36
37 $!=0;
38 open ᕝ, '.' and $_=<ᕝ>;
39 ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' );
40 close ᕝ;
41
42 $!=0;
43 { local $/;
44 open ᕝ, '.' and $_=<ᕝ>;
45 ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' );
46 close ᕝ;
47 }
48}
49
50my $obj = bless [], "Ȼლᔆ";
51$obj .= <DATA>;
52like($obj, qr/Ȼლᔆ=ARRAY.*world/u, 'rcatline and refs');
53
54{
55 my $file = tempfile();
56 open my $out_fh, ">", $file;
57 print { $out_fh } "Data\n";
58 close $out_fh;
59
60 open hòฟ, "<", $file;
61 is( scalar(<hòฟ>), "Data\n", "readline() works correctly on UTF-8 filehandles" );
62 close hòฟ;
63}
64
65__DATA__
66world