This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5db: add tests for v command
[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{
1ed4b776 32 open ᕝ, '.' and binmode ᕝ and sysread ᕝ, $_, 1;
ee970fec
MH
33 $err = $! + 0;
34 close ᕝ;
35}
2a507800
BF
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