POSIX [[:character class:]] support for standard, locale,
[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
9
10 print on closed filehandle %s
11 close STDIN ; print STDIN "abc" ;
12
13 uninitialized
14 my $a = undef ; my @b = @$a
15
16 uninitialized
17 my $a = undef ; my %b = %$a
18
19 Odd number of elements in hash list
20 %X = (1,2,3) ;
21
22 Reference found where even-sized list expected
23 $X = [ 1 ..3 ];
24
25 Read on closed filehandle <%s>
26 close STDIN ; $a = <STDIN>;
27
28 Deep recursion on subroutine \"%s\"
29 sub fred { fred() if $a++ < 200} fred()
30
31 Deep recursion on anonymous subroutine
32 $a = sub { &$a if $a++ < 200} &$a
33
34__END__
35# pp_hot.c
36use warning 'unopened' ;
37$f = $a = "abc" ;
38print $f $a
39EXPECT
40Filehandle main::abc never opened at - line 4.
41########
42# pp_hot.c
43use warning 'io' ;
44print STDIN "anc";
45EXPECT
46Filehandle main::STDIN opened only for input at - line 3.
47########
48# pp_hot.c
49use warning 'closed' ;
50close STDIN ;
51print STDIN "anc";
52EXPECT
53print on closed filehandle main::STDIN at - line 4.
54########
55# pp_hot.c
56use warning 'uninitialized' ;
57my $a = undef ;
58my @b = @$a
59EXPECT
60Use of uninitialized value at - line 4.
61########
62# pp_hot.c
63use warning 'uninitialized' ;
64my $a = undef ;
65my %b = %$a
66EXPECT
67Use of uninitialized value at - line 4.
68########
69# pp_hot.c
70use warning 'unsafe' ;
71my %X ; %X = (1,2,3) ;
72EXPECT
73Odd number of elements in hash assignment at - line 3.
74########
75# pp_hot.c
76use warning 'unsafe' ;
77my %X ; %X = [1 .. 3] ;
78EXPECT
79Reference found where even-sized list expected at - line 3.
80########
81# pp_hot.c
82use warning 'closed' ;
83close STDIN ; $a = <STDIN> ;
84EXPECT
85Read on closed filehandle <STDIN> at - line 3.
86########
87# pp_hot.c
88use warning 'recursion' ;
89sub fred
90{
91 fred() if $a++ < 200
92}
4a925ff6 93{
94 local $SIG{__WARN__} = sub {
95 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
96 };
97 fred();
98}
599cee73 99EXPECT
4a925ff6 100ok
599cee73 101########
102# pp_hot.c
103use warning 'recursion' ;
104$b = sub
105{
106 &$b if $a++ < 200
107} ;
108
109&$b ;
110EXPECT
111Deep recursion on anonymous subroutine at - line 5.