Commit | Line | Data |
8ebc5c01 |
1 | Check strict vars functionality |
2 | |
3 | __END__ |
4 | |
5 | # no strict, should build & run ok. |
6 | Fred ; |
7 | my $fred ; |
8 | $b = "fred" ; |
9 | $a = $$b ; |
10 | EXPECT |
11 | |
12 | ######## |
13 | |
14 | use strict qw(subs refs) ; |
15 | $fred ; |
16 | EXPECT |
17 | |
18 | ######## |
19 | |
20 | use strict ; |
21 | no strict 'vars' ; |
22 | $fred ; |
23 | EXPECT |
24 | |
25 | ######## |
26 | |
27 | # strict vars - no error |
28 | use strict 'vars' ; |
29 | use vars qw( $freddy) ; |
30 | local $abc::joe ; |
31 | my $fred ; |
32 | my $b = \$fred ; |
33 | $Fred::ABC = 1 ; |
34 | $freddy = 2 ; |
35 | EXPECT |
36 | |
37 | ######## |
38 | |
39 | # strict vars - error |
40 | use strict ; |
41 | $fred ; |
42 | EXPECT |
2c4aebbd |
43 | Global symbol "$fred" requires explicit package name at - line 4. |
8ebc5c01 |
44 | Execution of - aborted due to compilation errors. |
45 | ######## |
46 | |
47 | # strict vars - error |
48 | use strict 'vars' ; |
49 | $fred ; |
50 | EXPECT |
2c4aebbd |
51 | Global symbol "$fred" requires explicit package name at - line 4. |
8ebc5c01 |
52 | Execution of - aborted due to compilation errors. |
53 | ######## |
54 | |
55 | # strict vars - error |
56 | use strict 'vars' ; |
57 | local $fred ; |
58 | EXPECT |
2c4aebbd |
59 | Global symbol "$fred" requires explicit package name at - line 4. |
8ebc5c01 |
60 | Execution of - aborted due to compilation errors. |
61 | ######## |
62 | |
63 | # Check compile time scope of strict vars pragma |
64 | use strict 'vars' ; |
65 | { |
66 | no strict ; |
67 | $joe = 1 ; |
68 | } |
69 | $joe = 1 ; |
70 | EXPECT |
71 | Variable "$joe" is not imported at - line 8. |
2c4aebbd |
72 | Global symbol "$joe" requires explicit package name at - line 8. |
8ebc5c01 |
73 | Execution of - aborted due to compilation errors. |
74 | ######## |
75 | |
76 | # Check compile time scope of strict vars pragma |
77 | no strict; |
78 | { |
79 | use strict 'vars' ; |
80 | $joe = 1 ; |
81 | } |
82 | $joe = 1 ; |
83 | EXPECT |
2c4aebbd |
84 | Global symbol "$joe" requires explicit package name at - line 6. |
8ebc5c01 |
85 | Execution of - aborted due to compilation errors. |
86 | ######## |
87 | |
88 | --FILE-- abc |
89 | $joe = 1 ; |
90 | 1; |
91 | --FILE-- |
92 | use strict 'vars' ; |
93 | require "./abc"; |
94 | EXPECT |
95 | |
96 | ######## |
97 | |
98 | --FILE-- abc |
99 | use strict 'vars' ; |
100 | 1; |
101 | --FILE-- |
102 | require "./abc"; |
103 | $joe = 1 ; |
104 | EXPECT |
105 | |
106 | ######## |
107 | |
108 | --FILE-- abc |
109 | use strict 'vars' ; |
110 | $joe = 1 ; |
111 | 1; |
112 | --FILE-- |
113 | $joe = 1 ; |
114 | require "./abc"; |
115 | EXPECT |
116 | Variable "$joe" is not imported at ./abc line 2. |
2c4aebbd |
117 | Global symbol "$joe" requires explicit package name at ./abc line 2. |
7a2e2cd6 |
118 | Compilation failed in require at - line 2. |
8ebc5c01 |
119 | ######## |
120 | |
121 | --FILE-- abc.pm |
122 | use strict 'vars' ; |
123 | $joe = 1 ; |
124 | 1; |
125 | --FILE-- |
126 | $joe = 1 ; |
127 | use abc; |
128 | EXPECT |
129 | Variable "$joe" is not imported at abc.pm line 2. |
2c4aebbd |
130 | Global symbol "$joe" requires explicit package name at abc.pm line 2. |
7a2e2cd6 |
131 | Compilation failed in require at - line 2. |
8ebc5c01 |
132 | BEGIN failed--compilation aborted at - line 2. |
133 | ######## |
134 | |
135 | # Check scope of pragma with eval |
136 | no strict ; |
137 | eval { |
138 | $joe = 1 ; |
139 | }; |
140 | print STDERR $@; |
141 | $joe = 1 ; |
142 | EXPECT |
143 | |
144 | ######## |
145 | |
146 | # Check scope of pragma with eval |
147 | no strict ; |
148 | eval { |
149 | use strict 'vars' ; |
150 | $joe = 1 ; |
151 | }; |
152 | print STDERR $@; |
153 | $joe = 1 ; |
154 | EXPECT |
2c4aebbd |
155 | Global symbol "$joe" requires explicit package name at - line 6. |
8ebc5c01 |
156 | Execution of - aborted due to compilation errors. |
157 | ######## |
158 | |
159 | # Check scope of pragma with eval |
160 | use strict 'vars' ; |
161 | eval { |
162 | $joe = 1 ; |
163 | }; |
164 | print STDERR $@; |
165 | $joe = 1 ; |
166 | EXPECT |
2c4aebbd |
167 | Global symbol "$joe" requires explicit package name at - line 5. |
8ebc5c01 |
168 | Execution of - aborted due to compilation errors. |
169 | ######## |
170 | |
171 | # Check scope of pragma with eval |
172 | use strict 'vars' ; |
173 | eval { |
174 | no strict ; |
175 | $joe = 1 ; |
176 | }; |
177 | print STDERR $@; |
178 | $joe = 1 ; |
179 | EXPECT |
180 | Variable "$joe" is not imported at - line 9. |
2c4aebbd |
181 | Global symbol "$joe" requires explicit package name at - line 9. |
8ebc5c01 |
182 | Execution of - aborted due to compilation errors. |
183 | ######## |
184 | |
185 | # Check scope of pragma with eval |
186 | no strict ; |
187 | eval ' |
188 | $joe = 1 ; |
189 | '; print STDERR $@ ; |
190 | $joe = 1 ; |
191 | EXPECT |
192 | |
193 | ######## |
194 | |
195 | # Check scope of pragma with eval |
196 | no strict ; |
197 | eval q[ |
198 | use strict 'vars' ; |
199 | $joe = 1 ; |
200 | ]; print STDERR $@; |
201 | EXPECT |
2c4aebbd |
202 | Global symbol "$joe" requires explicit package name at (eval 1) line 3. |
8ebc5c01 |
203 | ######## |
204 | |
205 | # Check scope of pragma with eval |
206 | use strict 'vars' ; |
207 | eval ' |
208 | $joe = 1 ; |
209 | '; print STDERR $@ ; |
210 | EXPECT |
2c4aebbd |
211 | Global symbol "$joe" requires explicit package name at (eval 1) line 2. |
8ebc5c01 |
212 | ######## |
213 | |
214 | # Check scope of pragma with eval |
215 | use strict 'vars' ; |
216 | eval ' |
217 | no strict ; |
218 | $joe = 1 ; |
219 | '; print STDERR $@; |
220 | $joe = 1 ; |
221 | EXPECT |
2c4aebbd |
222 | Global symbol "$joe" requires explicit package name at - line 8. |
8ebc5c01 |
223 | Execution of - aborted due to compilation errors. |