File: readline.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (69 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!./perl

BEGIN {
    chdir 't' if -d 't';
    require './test.pl';
    set_up_inc('../lib');
}

plan tests => 7;

use utf8;
use open qw( :utf8 :std );

# [perl #19566]: sv_gets writes directly to its argument via
# TARG. Test that we respect SvREADONLY.
use constant roref=>\2;
eval { for (roref) { $_ = <Fʜ> } };
like($@, qr/Modification of a read-only value attempted/, '[perl #19566]');

# [perl #21628]
{
  my $file = tempfile();
  open Ạ,'+>',$file; $a = 3;
  is($a .= <Ạ>, 3, '#21628 - $a .= <A> , A eof');
  close Ạ; $a = 4;
  is($a .= <Ạ>, 4, '#21628 - $a .= <A> , A closed');
}

use strict;
my $err;
{
  open ᕝ, '.' and binmode ᕝ and sysread ᕝ, $_, 1;
  $err = $! + 0;
  close ᕝ;
}

SKIP: {
  skip "you can read directories as plain files", 2 unless( $err );

  $!=0;
  open ᕝ, '.' and $_=<ᕝ>;
  ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' );
  close ᕝ;

  $!=0;
  { local $/;
    open ᕝ, '.' and $_=<ᕝ>;
    ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' );
    close ᕝ;
  }
}

my $obj = bless [], "Ȼლᔆ";
$obj .= <DATA>;
like($obj, qr/Ȼლᔆ=ARRAY.*world/u, 'rcatline and refs');

{
    my $file = tempfile();
    open my $out_fh, ">", $file;
    print { $out_fh } "Data\n";
    close $out_fh;

    open hòฟ, "<", $file;
    is( scalar(<hòฟ>), "Data\n", "readline() works correctly on UTF-8 filehandles" );
    close hòฟ;
}

__DATA__
world