1#!./perl 2 3BEGIN { 4 chdir 't' if -d 't'; 5 require './test.pl'; 6 set_up_inc('../lib'); 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. 16use constant roref=>\2; 17eval { for (roref) { $_ = <Fʜ> } }; 18like($@, qr/Modification of a read-only value attempted/, '[perl #19566]'); 19 20# [perl #21628] 21{ 22 my $file = tempfile(); 23 open Ạ,'+>',$file; $a = 3; 24 is($a .= <Ạ>, 3, '#21628 - $a .= <A> , A eof'); 25 close Ạ; $a = 4; 26 is($a .= <Ạ>, 4, '#21628 - $a .= <A> , A closed'); 27} 28 29use strict; 30my $err; 31{ 32 open ᕝ, '.' and binmode ᕝ and sysread ᕝ, $_, 1; 33 $err = $! + 0; 34 close ᕝ; 35} 36 37SKIP: { 38 skip "you can read directories as plain files", 2 unless( $err ); 39 40 $!=0; 41 open ᕝ, '.' and $_=<ᕝ>; 42 ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' ); 43 close ᕝ; 44 45 $!=0; 46 { local $/; 47 open ᕝ, '.' and $_=<ᕝ>; 48 ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' ); 49 close ᕝ; 50 } 51} 52 53my $obj = bless [], "Ȼლᔆ"; 54$obj .= <DATA>; 55like($obj, qr/Ȼლᔆ=ARRAY.*world/u, 'rcatline and refs'); 56 57{ 58 my $file = tempfile(); 59 open my $out_fh, ">", $file; 60 print { $out_fh } "Data\n"; 61 close $out_fh; 62 63 open hòฟ, "<", $file; 64 is( scalar(<hòฟ>), "Data\n", "readline() works correctly on UTF-8 filehandles" ); 65 close hòฟ; 66} 67 68__DATA__ 69world 70