SYN SYN
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / pp_hot
CommitLineData
767a6a26 1 pp_hot.c
599cee73 2
22d4bb9c 3 print() on unopened filehandle abc [pp_print]
599cee73 4 $f = $a = "abc" ; print $f $a
5
767a6a26 6 Filehandle %s opened only for input [pp_print]
599cee73 7 print STDIN "abc" ;
8
767a6a26 9 Filehandle %s opened only for output [pp_print]
af8c498a 10 print <STDOUT> ;
599cee73 11
9a7dcd9c 12 print() on closed filehandle %s [pp_print]
599cee73 13 close STDIN ; print STDIN "abc" ;
14
767a6a26 15 uninitialized [pp_rv2av]
599cee73 16 my $a = undef ; my @b = @$a
17
767a6a26 18 uninitialized [pp_rv2hv]
599cee73 19 my $a = undef ; my %b = %$a
20
767a6a26 21 Odd number of elements in hash list [pp_aassign]
599cee73 22 %X = (1,2,3) ;
23
767a6a26 24 Reference found where even-sized list expected [pp_aassign]
599cee73 25 $X = [ 1 ..3 ];
26
767a6a26 27 Filehandle %s opened only for output [Perl_do_readline]
28 open (FH, ">./xcv") ;
29 my $a = <FH> ;
30
31 glob failed (can't start child: %s) [Perl_do_readline] <<TODO
32
9a7dcd9c 33 readline() on closed filehandle %s [Perl_do_readline]
599cee73 34 close STDIN ; $a = <STDIN>;
35
22d4bb9c 36 readline() on closed filehandle %s [Perl_do_readline]
37 readline(NONESUCH);
38
767a6a26 39 glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO
40
41 Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth]
6bc102ca 42 sub fred { fred() if $a++ < 200} fred()
599cee73 43
767a6a26 44 Deep recursion on anonymous subroutine [Perl_sub_crush_depth]
6bc102ca 45 $a = sub { &$a if $a++ < 200} &$a
599cee73 46
6bc102ca 47 Possible Y2K bug: about to append an integer to '19' [pp_concat]
48 $x = "19$yy\n";
767a6a26 49
599cee73 50__END__
767a6a26 51# pp_hot.c [pp_print]
4438c4b7 52use warnings 'unopened' ;
599cee73 53$f = $a = "abc" ;
0453d815 54print $f $a;
4438c4b7 55no warnings 'unopened' ;
0453d815 56print $f $a;
599cee73 57EXPECT
22d4bb9c 58print() on unopened filehandle abc at - line 4.
599cee73 59########
767a6a26 60# pp_hot.c [pp_print]
4438c4b7 61use warnings 'io' ;
599cee73 62print STDIN "anc";
af8c498a 63print <STDOUT>;
64print <STDERR>;
65open(FOO, ">&STDOUT") and print <FOO>;
66print getc(STDERR);
67print getc(FOO);
ea1135d6 68####################################################################
69# The next test is known to fail on some systems (Linux+old glibc, #
70# old *BSDs, and NeXT, among others. #
71# We skip it for now (on the grounds that it is "just" a warning). #
72####################################################################
37bd1396 73#read(FOO,$_,1);
74no warnings 'io' ;
75print STDIN "anc";
599cee73 76EXPECT
4b19af01 77Filehandle STDIN opened only for input at - line 3.
78Filehandle STDOUT opened only for output at - line 4.
79Filehandle STDERR opened only for output at - line 5.
80Filehandle FOO opened only for output at - line 6.
81Filehandle STDERR opened only for output at - line 7.
82Filehandle FOO opened only for output at - line 8.
599cee73 83########
767a6a26 84# pp_hot.c [pp_print]
4438c4b7 85use warnings 'closed' ;
599cee73 86close STDIN ;
87print STDIN "anc";
69282e91 88opendir STDIN, ".";
89print STDIN "anc";
90closedir STDIN;
4438c4b7 91no warnings 'closed' ;
0453d815 92print STDIN "anc";
69282e91 93opendir STDIN, ".";
94print STDIN "anc";
599cee73 95EXPECT
4b19af01 96print() on closed filehandle STDIN at - line 4.
97print() on closed filehandle STDIN at - line 6.
98 (Are you trying to call print() on dirhandle STDIN?)
599cee73 99########
767a6a26 100# pp_hot.c [pp_rv2av]
4438c4b7 101use warnings 'uninitialized' ;
599cee73 102my $a = undef ;
0453d815 103my @b = @$a;
4438c4b7 104no warnings 'uninitialized' ;
0453d815 105my @c = @$a;
599cee73 106EXPECT
b89fed5f 107Use of uninitialized value in array dereference at - line 4.
599cee73 108########
767a6a26 109# pp_hot.c [pp_rv2hv]
4438c4b7 110use warnings 'uninitialized' ;
599cee73 111my $a = undef ;
0453d815 112my %b = %$a;
4438c4b7 113no warnings 'uninitialized' ;
0453d815 114my %c = %$a;
599cee73 115EXPECT
b89fed5f 116Use of uninitialized value in hash dereference at - line 4.
599cee73 117########
767a6a26 118# pp_hot.c [pp_aassign]
e476b1b5 119use warnings 'misc' ;
599cee73 120my %X ; %X = (1,2,3) ;
e476b1b5 121no warnings 'misc' ;
0453d815 122my %Y ; %Y = (1,2,3) ;
599cee73 123EXPECT
124Odd number of elements in hash assignment at - line 3.
125########
767a6a26 126# pp_hot.c [pp_aassign]
e476b1b5 127use warnings 'misc' ;
599cee73 128my %X ; %X = [1 .. 3] ;
e476b1b5 129no warnings 'misc' ;
0453d815 130my %Y ; %Y = [1 .. 3] ;
599cee73 131EXPECT
132Reference found where even-sized list expected at - line 3.
133########
767a6a26 134# pp_hot.c [Perl_do_readline]
4438c4b7 135use warnings 'closed' ;
69282e91 136close STDIN ; $a = <STDIN> ;
137opendir STDIN, "." ; $a = <STDIN> ;
138closedir STDIN;
4438c4b7 139no warnings 'closed' ;
69282e91 140opendir STDIN, "." ; $a = <STDIN> ;
0453d815 141$a = <STDIN> ;
599cee73 142EXPECT
4b19af01 143readline() on closed filehandle STDIN at - line 3.
144readline() on closed filehandle STDIN at - line 4.
145 (Are you trying to call readline() on dirhandle STDIN?)
599cee73 146########
767a6a26 147# pp_hot.c [Perl_do_readline]
148use warnings 'io' ;
149my $file = "./xcv" ; unlink $file ;
150open (FH, ">./xcv") ;
151my $a = <FH> ;
152no warnings 'io' ;
153$a = <FH> ;
154unlink $file ;
155EXPECT
4b19af01 156Filehandle FH opened only for output at - line 5.
767a6a26 157########
158# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 159use warnings 'recursion' ;
599cee73 160sub fred
161{
162 fred() if $a++ < 200
163}
4a925ff6 164{
165 local $SIG{__WARN__} = sub {
166 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
167 };
168 fred();
169}
599cee73 170EXPECT
4a925ff6 171ok
599cee73 172########
767a6a26 173# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 174no warnings 'recursion' ;
0453d815 175sub fred
176{
177 fred() if $a++ < 200
178}
179{
180 local $SIG{__WARN__} = sub {
181 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
182 };
183 fred();
184}
185EXPECT
186
187########
767a6a26 188# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 189use warnings 'recursion' ;
599cee73 190$b = sub
191{
192 &$b if $a++ < 200
193} ;
194
195&$b ;
196EXPECT
197Deep recursion on anonymous subroutine at - line 5.
0453d815 198########
767a6a26 199# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 200no warnings 'recursion' ;
0453d815 201$b = sub
202{
203 &$b if $a++ < 200
204} ;
205
206&$b ;
207EXPECT
6bc102ca 208########
209# pp_hot.c [pp_concat]
e476b1b5 210use warnings 'y2k';
6bc102ca 211use Config;
212BEGIN {
213 unless ($Config{ccflags} =~ /Y2KWARN/) {
214 print "SKIPPED\n# perl not built with -DPERL_Y2KWARN";
215 exit 0;
216 }
217}
218my $x;
219my $yy = 78;
220$x = "19$yy\n";
221$x = "19" . $yy . "\n";
222$x = "319$yy\n";
223$x = "319" . $yy . "\n";
e476b1b5 224no warnings 'y2k';
6bc102ca 225$x = "19$yy\n";
226$x = "19" . $yy . "\n";
227EXPECT
228Possible Y2K bug: about to append an integer to '19' at - line 12.
229Possible Y2K bug: about to append an integer to '19' at - line 13.