Fix UV_SIZEOF to UVSIZE; change the overflow tests
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / pp_hot
1   pp_hot.c      
2
3   Filehandle %s never opened                    [pp_print]
4     $f = $a = "abc" ; print $f $a
5
6   Filehandle %s opened only for input           [pp_print]
7     print STDIN "abc" ;
8
9   Filehandle %s opened only for output          [pp_print]
10     print <STDOUT> ;
11
12   print on closed filehandle %s                 [pp_print]
13     close STDIN ; print STDIN "abc" ;
14
15   uninitialized                                 [pp_rv2av]
16         my $a = undef ; my @b = @$a
17
18   uninitialized                                 [pp_rv2hv]
19         my $a = undef ; my %b = %$a
20
21   Odd number of elements in hash list           [pp_aassign]
22         %X = (1,2,3) ;
23
24   Reference found where even-sized list expected [pp_aassign]
25         $X = [ 1 ..3 ];
26
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]
34     close STDIN ; $a = <STDIN>;
35
36   glob failed (child exited with status %d%s)   [Perl_do_readline] <<TODO
37
38   Deep recursion on subroutine \"%s\"           [Perl_sub_crush_depth]
39      sub fred { fred() if $a++ < 200} fred()
40
41   Deep recursion on anonymous subroutine        [Perl_sub_crush_depth]
42      $a = sub { &$a if $a++ < 200} &$a
43
44
45 __END__
46 # pp_hot.c [pp_print]
47 use warnings 'unopened' ;
48 $f = $a = "abc" ; 
49 print $f $a;
50 no warnings 'unopened' ;
51 print $f $a;
52 EXPECT
53 Filehandle main::abc never opened at - line 4.
54 ########
55 # pp_hot.c [pp_print]
56 use warnings 'io' ;
57 print STDIN "anc";
58 print <STDOUT>;
59 print <STDERR>;
60 open(FOO, ">&STDOUT") and print <FOO>;
61 print getc(STDERR);
62 print getc(FOO);
63 ####################################################################
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).                #
68 ####################################################################
69 #read(FOO,$_,1);
70 no warnings 'io' ;
71 print STDIN "anc";
72 EXPECT
73 Filehandle main::STDIN opened only for input at - line 3.
74 Filehandle main::STDOUT opened only for output at - line 4.
75 Filehandle main::STDERR opened only for output at - line 5.
76 Filehandle main::FOO opened only for output at - line 6.
77 Filehandle main::STDERR opened only for output at - line 7.
78 Filehandle main::FOO opened only for output at - line 8.
79 ########
80 # pp_hot.c [pp_print]
81 use warnings 'closed' ;
82 close STDIN ;
83 print STDIN "anc";
84 no warnings 'closed' ;
85 print STDIN "anc";
86 EXPECT
87 print on closed filehandle main::STDIN at - line 4.
88 ########
89 # pp_hot.c [pp_rv2av]
90 use warnings 'uninitialized' ;
91 my $a = undef ;
92 my @b = @$a;
93 no warnings 'uninitialized' ;
94 my @c = @$a;
95 EXPECT
96 Use of uninitialized value at - line 4.
97 ########
98 # pp_hot.c [pp_rv2hv]
99 use warnings 'uninitialized' ;
100 my $a = undef ;
101 my %b = %$a;
102 no warnings 'uninitialized' ;
103 my %c = %$a;
104 EXPECT
105 Use of uninitialized value at - line 4.
106 ########
107 # pp_hot.c [pp_aassign]
108 use warnings 'unsafe' ;
109 my %X ; %X = (1,2,3) ;
110 no warnings 'unsafe' ;
111 my %Y ; %Y = (1,2,3) ;
112 EXPECT
113 Odd number of elements in hash assignment at - line 3.
114 ########
115 # pp_hot.c [pp_aassign]
116 use warnings 'unsafe' ;
117 my %X ; %X = [1 .. 3] ;
118 no warnings 'unsafe' ;
119 my %Y ; %Y = [1 .. 3] ;
120 EXPECT
121 Reference found where even-sized list expected at - line 3.
122 ########
123 # pp_hot.c [Perl_do_readline]
124 use warnings 'closed' ;
125 close STDIN ; $a = <STDIN> ;
126 no warnings 'closed' ;
127 $a = <STDIN> ;
128 EXPECT
129 Read on closed filehandle main::STDIN at - line 3.
130 ########
131 # pp_hot.c [Perl_do_readline]
132 use warnings 'io' ;
133 my $file = "./xcv" ; unlink $file ;
134 open (FH, ">./xcv") ;
135 my $a = <FH> ;
136 no warnings 'io' ;
137 $a = <FH> ;
138 unlink $file ;
139 EXPECT
140 Filehandle main::FH opened only for output at - line 5.
141 ########
142 # pp_hot.c [Perl_sub_crush_depth]
143 use warnings 'recursion' ;
144 sub fred 
145
146     fred() if $a++ < 200
147
148 {
149   local $SIG{__WARN__} = sub {
150     die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
151   };
152   fred();
153 }
154 EXPECT
155 ok
156 ########
157 # pp_hot.c [Perl_sub_crush_depth]
158 no warnings 'recursion' ;
159 sub 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 }
169 EXPECT
170
171 ########
172 # pp_hot.c [Perl_sub_crush_depth]
173 use warnings 'recursion' ;
174 $b = sub 
175
176     &$b if $a++ < 200
177 }  ;
178
179 &$b ;
180 EXPECT
181 Deep recursion on anonymous subroutine at - line 5.
182 ########
183 # pp_hot.c [Perl_sub_crush_depth]
184 no warnings 'recursion' ;
185 $b = sub 
186
187     &$b if $a++ < 200
188 }  ;
189
190 &$b ;
191 EXPECT
192