Move the locale/strict/warnings helper files back
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / 1global
CommitLineData
8ebc5c01 1Check existing $^W functionality
2
599cee73 3
8ebc5c01 4__END__
5
6# warnable code, warnings disabled
7$a =+ 3 ;
8EXPECT
9
10########
11-w
12# warnable code, warnings enabled via command line switch
13$a =+ 3 ;
14EXPECT
15Reversed += operator at - line 3.
1c17f625 16Name "main::a" used only once: possible typo at - line 3.
8ebc5c01 17########
18#! perl -w
19# warnable code, warnings enabled via #! line
20$a =+ 3 ;
21EXPECT
22Reversed += operator at - line 3.
1c17f625 23Name "main::a" used only once: possible typo at - line 3.
8ebc5c01 24########
25
26# warnable code, warnings enabled via compile time $^W
27BEGIN { $^W = 1 }
28$a =+ 3 ;
29EXPECT
30Reversed += operator at - line 4.
1c17f625 31Name "main::a" used only once: possible typo at - line 4.
8ebc5c01 32########
33
34# compile-time warnable code, warnings enabled via runtime $^W
35# so no warning printed.
36$^W = 1 ;
37$a =+ 3 ;
38EXPECT
39
40########
41
42# warnable code, warnings enabled via runtime $^W
43$^W = 1 ;
44my $b ; chop $b ;
45EXPECT
b89fed5f 46Use of uninitialized value in scalar chop at - line 4.
8ebc5c01 47########
48
49# warnings enabled at compile time, disabled at run time
50BEGIN { $^W = 1 }
51$^W = 0 ;
52my $b ; chop $b ;
53EXPECT
54
55########
56
57# warnings disabled at compile time, enabled at run time
58BEGIN { $^W = 0 }
59$^W = 1 ;
60my $b ; chop $b ;
61EXPECT
b89fed5f 62Use of uninitialized value in scalar chop at - line 5.
8ebc5c01 63########
64-w
65--FILE-- abcd
66my $b ; chop $b ;
671 ;
68--FILE--
69require "./abcd";
70EXPECT
b89fed5f 71Use of uninitialized value in scalar chop at ./abcd line 1.
8ebc5c01 72########
73
74--FILE-- abcd
75my $b ; chop $b ;
761 ;
77--FILE--
78#! perl -w
79require "./abcd";
80EXPECT
b89fed5f 81Use of uninitialized value in scalar chop at ./abcd line 1.
8ebc5c01 82########
83
84--FILE-- abcd
85my $b ; chop $b ;
861 ;
87--FILE--
88$^W =1 ;
89require "./abcd";
90EXPECT
b89fed5f 91Use of uninitialized value in scalar chop at ./abcd line 1.
8ebc5c01 92########
93
94--FILE-- abcd
95$^W = 0;
96my $b ; chop $b ;
971 ;
98--FILE--
99$^W =1 ;
100require "./abcd";
101EXPECT
102
103########
104
105--FILE-- abcd
106$^W = 1;
1071 ;
108--FILE--
109$^W =0 ;
110require "./abcd";
111my $b ; chop $b ;
112EXPECT
b89fed5f 113Use of uninitialized value in scalar chop at - line 3.
8ebc5c01 114########
115
116$^W = 1;
599cee73 117eval 'my $b ; chop $b ;' ;
118print $@ ;
8ebc5c01 119EXPECT
b89fed5f 120Use of uninitialized value in scalar chop at (eval 1) line 1.
8ebc5c01 121########
122
599cee73 123eval '$^W = 1;' ;
124print $@ ;
8ebc5c01 125my $b ; chop $b ;
126EXPECT
b89fed5f 127Use of uninitialized value in scalar chop at - line 4.
8ebc5c01 128########
129
130eval {$^W = 1;} ;
599cee73 131print $@ ;
8ebc5c01 132my $b ; chop $b ;
133EXPECT
b89fed5f 134Use of uninitialized value in scalar chop at - line 4.
8ebc5c01 135########
136
137{
138 local ($^W) = 1;
139}
140my $b ; chop $b ;
141EXPECT
142
143########
144
145my $a ; chop $a ;
146{
147 local ($^W) = 1;
148 my $b ; chop $b ;
149}
150my $c ; chop $c ;
151EXPECT
b89fed5f 152Use of uninitialized value in scalar chop at - line 5.
4b74e3fb 153########
154-w
155-e undef
156EXPECT
b89fed5f 157Use of uninitialized value in -e at - line 2.
599cee73 158########
159
160$^W = 1 + 2 ;
161EXPECT
162
163########
164
165$^W = $a ;
166EXPECT
167
168########
169
170sub fred {}
171$^W = fred() ;
172EXPECT
173
174########
175
176sub fred { my $b ; chop $b ;}
177{ local $^W = 0 ;
178 fred() ;
179}
180EXPECT
181
182########
183
184sub fred { my $b ; chop $b ;}
185{ local $^W = 1 ;
186 fred() ;
187}
188EXPECT
b89fed5f 189Use of uninitialized value in scalar chop at - line 2.