Fix UV_SIZEOF to UVSIZE; change the overflow tests
[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
767a6a26 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
33 Read 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]
599cee73 39 sub fred { fred() if $a++ < 200} fred()
40
767a6a26 41 Deep recursion on anonymous subroutine [Perl_sub_crush_depth]
599cee73 42 $a = sub { &$a if $a++ < 200} &$a
43
767a6a26 44
599cee73 45__END__
767a6a26 46# pp_hot.c [pp_print]
4438c4b7 47use warnings 'unopened' ;
599cee73 48$f = $a = "abc" ;
0453d815 49print $f $a;
4438c4b7 50no warnings 'unopened' ;
0453d815 51print $f $a;
599cee73 52EXPECT
53Filehandle main::abc never opened at - line 4.
54########
767a6a26 55# pp_hot.c [pp_print]
4438c4b7 56use warnings 'io' ;
599cee73 57print STDIN "anc";
af8c498a 58print <STDOUT>;
59print <STDERR>;
60open(FOO, ">&STDOUT") and print <FOO>;
61print getc(STDERR);
62print getc(FOO);
88c07c36 63####################################################################
37bd1396 64# The next test is known to fail on some systems (Linux/BSD+glibc, #
65# NeXT among others. glibc should be fixed in the next version, #
66# but it appears other platforms have little hope. We skip it for #
67# now (on the grounds that it is "just" a warning). #
88c07c36 68####################################################################
37bd1396 69#read(FOO,$_,1);
70no warnings 'io' ;
71print STDIN "anc";
599cee73 72EXPECT
73Filehandle main::STDIN opened only for input at - line 3.
af8c498a 74Filehandle main::STDOUT opened only for output at - line 4.
75Filehandle main::STDERR opened only for output at - line 5.
76Filehandle main::FOO opened only for output at - line 6.
77Filehandle main::STDERR opened only for output at - line 7.
78Filehandle main::FOO opened only for output at - line 8.
599cee73 79########
767a6a26 80# pp_hot.c [pp_print]
4438c4b7 81use warnings 'closed' ;
599cee73 82close STDIN ;
83print STDIN "anc";
4438c4b7 84no warnings 'closed' ;
0453d815 85print STDIN "anc";
599cee73 86EXPECT
87print on closed filehandle main::STDIN at - line 4.
88########
767a6a26 89# pp_hot.c [pp_rv2av]
4438c4b7 90use warnings 'uninitialized' ;
599cee73 91my $a = undef ;
0453d815 92my @b = @$a;
4438c4b7 93no warnings 'uninitialized' ;
0453d815 94my @c = @$a;
599cee73 95EXPECT
96Use of uninitialized value at - line 4.
97########
767a6a26 98# pp_hot.c [pp_rv2hv]
4438c4b7 99use warnings 'uninitialized' ;
599cee73 100my $a = undef ;
0453d815 101my %b = %$a;
4438c4b7 102no warnings 'uninitialized' ;
0453d815 103my %c = %$a;
599cee73 104EXPECT
105Use of uninitialized value at - line 4.
106########
767a6a26 107# pp_hot.c [pp_aassign]
4438c4b7 108use warnings 'unsafe' ;
599cee73 109my %X ; %X = (1,2,3) ;
4438c4b7 110no warnings 'unsafe' ;
0453d815 111my %Y ; %Y = (1,2,3) ;
599cee73 112EXPECT
113Odd number of elements in hash assignment at - line 3.
114########
767a6a26 115# pp_hot.c [pp_aassign]
4438c4b7 116use warnings 'unsafe' ;
599cee73 117my %X ; %X = [1 .. 3] ;
4438c4b7 118no warnings 'unsafe' ;
0453d815 119my %Y ; %Y = [1 .. 3] ;
599cee73 120EXPECT
121Reference found where even-sized list expected at - line 3.
122########
767a6a26 123# pp_hot.c [Perl_do_readline]
4438c4b7 124use warnings 'closed' ;
599cee73 125close STDIN ; $a = <STDIN> ;
4438c4b7 126no warnings 'closed' ;
0453d815 127$a = <STDIN> ;
599cee73 128EXPECT
af8c498a 129Read on closed filehandle main::STDIN at - line 3.
599cee73 130########
767a6a26 131# pp_hot.c [Perl_do_readline]
132use warnings 'io' ;
133my $file = "./xcv" ; unlink $file ;
134open (FH, ">./xcv") ;
135my $a = <FH> ;
136no warnings 'io' ;
137$a = <FH> ;
138unlink $file ;
139EXPECT
140Filehandle main::FH opened only for output at - line 5.
141########
142# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 143use warnings 'recursion' ;
599cee73 144sub fred
145{
146 fred() if $a++ < 200
147}
4a925ff6 148{
149 local $SIG{__WARN__} = sub {
150 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
151 };
152 fred();
153}
599cee73 154EXPECT
4a925ff6 155ok
599cee73 156########
767a6a26 157# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 158no warnings 'recursion' ;
0453d815 159sub fred
160{
161 fred() if $a++ < 200
162}
163{
164 local $SIG{__WARN__} = sub {
165 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
166 };
167 fred();
168}
169EXPECT
170
171########
767a6a26 172# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 173use warnings 'recursion' ;
599cee73 174$b = sub
175{
176 &$b if $a++ < 200
177} ;
178
179&$b ;
180EXPECT
181Deep recursion on anonymous subroutine at - line 5.
0453d815 182########
767a6a26 183# pp_hot.c [Perl_sub_crush_depth]
4438c4b7 184no warnings 'recursion' ;
0453d815 185$b = sub
186{
187 &$b if $a++ < 200
188} ;
189
190&$b ;
191EXPECT
192