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