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