change#3612 is buggy when quotemeta argument matches target
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / pp_hot
CommitLineData
599cee73 1 pp_hot.c AOK
2
3 Filehandle %s never opened
4 $f = $a = "abc" ; print $f $a
5
6 Filehandle %s opened only for input
7 print STDIN "abc" ;
8
af8c498a 9 Filehandle %s opened only for output
10 print <STDOUT> ;
599cee73 11
12 print on closed filehandle %s
13 close STDIN ; print STDIN "abc" ;
14
15 uninitialized
16 my $a = undef ; my @b = @$a
17
18 uninitialized
19 my $a = undef ; my %b = %$a
20
21 Odd number of elements in hash list
22 %X = (1,2,3) ;
23
24 Reference found where even-sized list expected
25 $X = [ 1 ..3 ];
26
af8c498a 27 Read on closed filehandle %s
599cee73 28 close STDIN ; $a = <STDIN>;
29
30 Deep recursion on subroutine \"%s\"
31 sub fred { fred() if $a++ < 200} fred()
32
33 Deep recursion on anonymous subroutine
34 $a = sub { &$a if $a++ < 200} &$a
35
36__END__
37# pp_hot.c
4438c4b7 38use warnings 'unopened' ;
599cee73 39$f = $a = "abc" ;
0453d815 40print $f $a;
4438c4b7 41no warnings 'unopened' ;
0453d815 42print $f $a;
599cee73 43EXPECT
44Filehandle main::abc never opened at - line 4.
45########
46# pp_hot.c
4438c4b7 47use warnings 'io' ;
599cee73 48print STDIN "anc";
af8c498a 49print <STDOUT>;
50print <STDERR>;
51open(FOO, ">&STDOUT") and print <FOO>;
52print getc(STDERR);
53print getc(FOO);
88c07c36 54####################################################################
37bd1396 55# The next test is known to fail on some systems (Linux/BSD+glibc, #
56# NeXT among others. glibc should be fixed in the next version, #
57# but it appears other platforms have little hope. We skip it for #
58# now (on the grounds that it is "just" a warning). #
88c07c36 59####################################################################
37bd1396 60#read(FOO,$_,1);
61no warnings 'io' ;
62print STDIN "anc";
599cee73 63EXPECT
64Filehandle main::STDIN opened only for input at - line 3.
af8c498a 65Filehandle main::STDOUT opened only for output at - line 4.
66Filehandle main::STDERR opened only for output at - line 5.
67Filehandle main::FOO opened only for output at - line 6.
68Filehandle main::STDERR opened only for output at - line 7.
69Filehandle main::FOO opened only for output at - line 8.
599cee73 70########
71# pp_hot.c
4438c4b7 72use warnings 'closed' ;
599cee73 73close STDIN ;
74print STDIN "anc";
4438c4b7 75no warnings 'closed' ;
0453d815 76print STDIN "anc";
599cee73 77EXPECT
78print on closed filehandle main::STDIN at - line 4.
79########
80# pp_hot.c
4438c4b7 81use warnings 'uninitialized' ;
599cee73 82my $a = undef ;
0453d815 83my @b = @$a;
4438c4b7 84no warnings 'uninitialized' ;
0453d815 85my @c = @$a;
599cee73 86EXPECT
87Use of uninitialized value at - line 4.
88########
89# pp_hot.c
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########
98# pp_hot.c
4438c4b7 99use warnings 'unsafe' ;
599cee73 100my %X ; %X = (1,2,3) ;
4438c4b7 101no warnings 'unsafe' ;
0453d815 102my %Y ; %Y = (1,2,3) ;
599cee73 103EXPECT
104Odd number of elements in hash assignment at - line 3.
105########
106# pp_hot.c
4438c4b7 107use warnings 'unsafe' ;
599cee73 108my %X ; %X = [1 .. 3] ;
4438c4b7 109no warnings 'unsafe' ;
0453d815 110my %Y ; %Y = [1 .. 3] ;
599cee73 111EXPECT
112Reference found where even-sized list expected at - line 3.
113########
114# pp_hot.c
4438c4b7 115use warnings 'closed' ;
599cee73 116close STDIN ; $a = <STDIN> ;
4438c4b7 117no warnings 'closed' ;
0453d815 118$a = <STDIN> ;
599cee73 119EXPECT
af8c498a 120Read on closed filehandle main::STDIN at - line 3.
599cee73 121########
122# pp_hot.c
4438c4b7 123use warnings 'recursion' ;
599cee73 124sub fred
125{
126 fred() if $a++ < 200
127}
4a925ff6 128{
129 local $SIG{__WARN__} = sub {
130 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
131 };
132 fred();
133}
599cee73 134EXPECT
4a925ff6 135ok
599cee73 136########
137# pp_hot.c
4438c4b7 138no warnings 'recursion' ;
0453d815 139sub fred
140{
141 fred() if $a++ < 200
142}
143{
144 local $SIG{__WARN__} = sub {
145 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
146 };
147 fred();
148}
149EXPECT
150
151########
152# pp_hot.c
4438c4b7 153use warnings 'recursion' ;
599cee73 154$b = sub
155{
156 &$b if $a++ < 200
157} ;
158
159&$b ;
160EXPECT
161Deep recursion on anonymous subroutine at - line 5.
0453d815 162########
163# pp_hot.c
4438c4b7 164no warnings 'recursion' ;
0453d815 165$b = sub
166{
167 &$b if $a++ < 200
168} ;
169
170&$b ;
171EXPECT
172