This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[shell changes from patch from perl5.003_19 to perl5.003_20]
[perl5.git] / t / pragma / warn-1global
CommitLineData
8ebc5c01
PP
1Check existing $^W functionality
2
3__END__
4
5# warnable code, warnings disabled
6$a =+ 3 ;
7EXPECT
8
9########
10-w
11# warnable code, warnings enabled via command line switch
12$a =+ 3 ;
13EXPECT
14Reversed += operator at - line 3.
15########
16#! perl -w
17# warnable code, warnings enabled via #! line
18$a =+ 3 ;
19EXPECT
20Reversed += operator at - line 3.
21########
22
23# warnable code, warnings enabled via compile time $^W
24BEGIN { $^W = 1 }
25$a =+ 3 ;
26EXPECT
27Reversed += operator at - line 4.
28########
29
30# compile-time warnable code, warnings enabled via runtime $^W
31# so no warning printed.
32$^W = 1 ;
33$a =+ 3 ;
34EXPECT
35
36########
37
38# warnable code, warnings enabled via runtime $^W
39$^W = 1 ;
40my $b ; chop $b ;
41EXPECT
42Use of uninitialized value at - line 4.
43########
44
45# warnings enabled at compile time, disabled at run time
46BEGIN { $^W = 1 }
47$^W = 0 ;
48my $b ; chop $b ;
49EXPECT
50
51########
52
53# warnings disabled at compile time, enabled at run time
54BEGIN { $^W = 0 }
55$^W = 1 ;
56my $b ; chop $b ;
57EXPECT
58Use of uninitialized value at - line 5.
59########
60-w
61--FILE-- abcd
62my $b ; chop $b ;
631 ;
64--FILE--
65require "./abcd";
66EXPECT
67Use of uninitialized value at ./abcd line 1.
68########
69
70--FILE-- abcd
71my $b ; chop $b ;
721 ;
73--FILE--
74#! perl -w
75require "./abcd";
76EXPECT
77Use of uninitialized value at ./abcd line 1.
78########
79
80--FILE-- abcd
81my $b ; chop $b ;
821 ;
83--FILE--
84$^W =1 ;
85require "./abcd";
86EXPECT
87Use of uninitialized value at ./abcd line 1.
88########
89
90--FILE-- abcd
91$^W = 0;
92my $b ; chop $b ;
931 ;
94--FILE--
95$^W =1 ;
96require "./abcd";
97EXPECT
98
99########
100
101--FILE-- abcd
102$^W = 1;
1031 ;
104--FILE--
105$^W =0 ;
106require "./abcd";
107my $b ; chop $b ;
108EXPECT
109Use of uninitialized value at - line 3.
110########
111
112$^W = 1;
113eval "my $b ; chop $b ;" ;
114EXPECT
115Use of uninitialized value at - line 3.
116Use of uninitialized value at - line 3.
117########
118
119eval "$^W = 1;" ;
120my $b ; chop $b ;
121EXPECT
122
123########
124
125eval {$^W = 1;} ;
126my $b ; chop $b ;
127EXPECT
128Use of uninitialized value at - line 3.
129########
130
131{
132 local ($^W) = 1;
133}
134my $b ; chop $b ;
135EXPECT
136
137########
138
139my $a ; chop $a ;
140{
141 local ($^W) = 1;
142 my $b ; chop $b ;
143}
144my $c ; chop $c ;
145EXPECT
146Use of uninitialized value at - line 5.