This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: any takers for this Storable bug?
[perl5.git] / t / op / readline.t
CommitLineData
79628082
SM
1#!./perl
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
bc44a8a2 9plan tests => 11;
79628082
SM
10
11eval { for (\2) { $_ = <FH> } };
12like($@, 'Modification of a read-only value attempted', '[perl #19566]');
13
ba92458f
AE
14{
15 open A,"+>a"; $a = 3;
16 is($a .= <A>, 3, '#21628 - $a .= <A> , A eof');
17 close A; $a = 4;
18 is($a .= <A>, 4, '#21628 - $a .= <A> , A closed');
19 unlink "a";
20}
10bcdfd6
NC
21
22# 82 is chosen to exceed the length for sv_grow in do_readline (80)
23foreach my $k ('k', 'k'x82) {
24 my $result
25 = runperl (switches => '-l', stdin => '', stderr => 1,
26 prog => "%a = qw($k v); \$_ = <> foreach keys %a; print qw(end)",
27 );
28 is ($result, "end", '[perl #21614] for length ' . length $k);
29}
bc44a8a2
NC
30
31
32foreach my $k ('perl', 'perl'x21) {
33 my $result
34 = runperl (switches => '-l', stdin => ' rules', stderr => 1,
35 prog => "%a = qw($k v); foreach (keys %a) {\$_ .= <>; print}",
36 );
37 is ($result, "$k rules", 'rcatline to shared sv for length ' . length $k);
38}
39
40foreach my $l (1, 82) {
41 my $k = $l;
42 $k = 'k' x $k;
43 my $copy = $k;
44 $k = <DATA>;
45 is ($k, "moo\n", 'catline to COW sv for length ' . length $copy);
46}
47
48
49foreach my $l (1, 21) {
50 my $k = $l;
51 $k = 'perl' x $k;
52 my $perl = $k;
53 $k .= <DATA>;
54 is ($k, "$perl rules\n", 'rcatline to COW sv for length ' . length $perl);
55}
56__DATA__
57moo
58moo
59 rules
60 rules