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