summaryrefslogtreecommitdiff
path: root/t/pragma/warn-1global
blob: 33252731b0e666b72769649d535dac7704e1ad66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Check existing $^W functionality

__END__

# warnable code, warnings disabled
$a =+ 3 ;
EXPECT

########
-w
# warnable code, warnings enabled via command line switch
$a =+ 3 ;
EXPECT
Reversed += operator at - line 3.
########
#! perl -w
# warnable code, warnings enabled via #! line
$a =+ 3 ;
EXPECT
Reversed += operator at - line 3.
########

# warnable code, warnings enabled via compile time $^W
BEGIN { $^W = 1 }
$a =+ 3 ;
EXPECT
Reversed += operator at - line 4.
########

# compile-time warnable code, warnings enabled via runtime $^W
# so no warning printed.
$^W = 1 ;
$a =+ 3 ;
EXPECT

########

# warnable code, warnings enabled via runtime $^W
$^W = 1 ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value at - line 4.
########

# warnings enabled at compile time, disabled at run time
BEGIN { $^W = 1 }
$^W = 0 ;
my $b ; chop $b ;
EXPECT

########

# warnings disabled at compile time, enabled at run time
BEGIN { $^W = 0 }
$^W = 1 ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value at - line 5.
########
-w
--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE-- 
require "./abcd";
EXPECT
Use of uninitialized value at ./abcd line 1.
########

--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE-- 
#! perl -w
require "./abcd";
EXPECT
Use of uninitialized value at ./abcd line 1.
########

--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE-- 
$^W =1 ;
require "./abcd";
EXPECT
Use of uninitialized value at ./abcd line 1.
########

--FILE-- abcd
$^W = 0;
my $b ; chop $b ;
1 ;
--FILE-- 
$^W =1 ;
require "./abcd";
EXPECT

########

--FILE-- abcd
$^W = 1;
1 ;
--FILE-- 
$^W =0 ;
require "./abcd";
my $b ; chop $b ;
EXPECT
Use of uninitialized value at - line 3.
########

$^W = 1;
eval "my $b ; chop $b ;" ;
EXPECT
Use of uninitialized value at - line 3.
Use of uninitialized value at - line 3.
########

eval "$^W = 1;" ;
my $b ; chop $b ;
EXPECT

########

eval {$^W = 1;} ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value at - line 3.
########

{
    local ($^W) = 1;
}
my $b ; chop $b ;
EXPECT

########

my $a ; chop $a ;
{
    local ($^W) = 1;
    my $b ; chop $b ;
}
my $c ; chop $c ;
EXPECT
Use of uninitialized value at - line 5.