Initial import from FreeBSD RELENG_4:
[games.git] / contrib / perl5 / t / pragma / warn-1global
1 Check existing $^W functionality
2
3 __END__
4
5 # warnable code, warnings disabled
6 $a =+ 3 ;
7 EXPECT
8
9 ########
10 -w
11 # warnable code, warnings enabled via command line switch
12 $a =+ 3 ;
13 EXPECT
14 Reversed += operator at - line 3.
15 Name "main::a" used only once: possible typo at - line 3.
16 ########
17 #! perl -w
18 # warnable code, warnings enabled via #! line
19 $a =+ 3 ;
20 EXPECT
21 Reversed += operator at - line 3.
22 Name "main::a" used only once: possible typo at - line 3.
23 ########
24
25 # warnable code, warnings enabled via compile time $^W
26 BEGIN { $^W = 1 }
27 $a =+ 3 ;
28 EXPECT
29 Reversed += operator at - line 4.
30 Name "main::a" used only once: possible typo at - line 4.
31 ########
32
33 # compile-time warnable code, warnings enabled via runtime $^W
34 # so no warning printed.
35 $^W = 1 ;
36 $a =+ 3 ;
37 EXPECT
38
39 ########
40
41 # warnable code, warnings enabled via runtime $^W
42 $^W = 1 ;
43 my $b ; chop $b ;
44 EXPECT
45 Use of uninitialized value at - line 4.
46 ########
47
48 # warnings enabled at compile time, disabled at run time
49 BEGIN { $^W = 1 }
50 $^W = 0 ;
51 my $b ; chop $b ;
52 EXPECT
53
54 ########
55
56 # warnings disabled at compile time, enabled at run time
57 BEGIN { $^W = 0 }
58 $^W = 1 ;
59 my $b ; chop $b ;
60 EXPECT
61 Use of uninitialized value at - line 5.
62 ########
63 -w
64 --FILE-- abcd
65 my $b ; chop $b ;
66 1 ;
67 --FILE-- 
68 require "./abcd";
69 EXPECT
70 Use of uninitialized value at ./abcd line 1.
71 ########
72
73 --FILE-- abcd
74 my $b ; chop $b ;
75 1 ;
76 --FILE-- 
77 #! perl -w
78 require "./abcd";
79 EXPECT
80 Use of uninitialized value at ./abcd line 1.
81 ########
82
83 --FILE-- abcd
84 my $b ; chop $b ;
85 1 ;
86 --FILE-- 
87 $^W =1 ;
88 require "./abcd";
89 EXPECT
90 Use of uninitialized value at ./abcd line 1.
91 ########
92
93 --FILE-- abcd
94 $^W = 0;
95 my $b ; chop $b ;
96 1 ;
97 --FILE-- 
98 $^W =1 ;
99 require "./abcd";
100 EXPECT
101
102 ########
103
104 --FILE-- abcd
105 $^W = 1;
106 1 ;
107 --FILE-- 
108 $^W =0 ;
109 require "./abcd";
110 my $b ; chop $b ;
111 EXPECT
112 Use of uninitialized value at - line 3.
113 ########
114
115 $^W = 1;
116 eval "my $b ; chop $b ;" ;
117 EXPECT
118 Use of uninitialized value at - line 3.
119 Use of uninitialized value at - line 3.
120 ########
121
122 eval "$^W = 1;" ;
123 my $b ; chop $b ;
124 EXPECT
125
126 ########
127
128 eval {$^W = 1;} ;
129 my $b ; chop $b ;
130 EXPECT
131 Use of uninitialized value at - line 3.
132 ########
133
134 {
135     local ($^W) = 1;
136 }
137 my $b ; chop $b ;
138 EXPECT
139
140 ########
141
142 my $a ; chop $a ;
143 {
144     local ($^W) = 1;
145     my $b ; chop $b ;
146 }
147 my $c ; chop $c ;
148 EXPECT
149 Use of uninitialized value at - line 5.
150 ########
151 -w
152 -e undef
153 EXPECT
154 Use of uninitialized value at - line 2.
155 ########
156 BEGIN { $^W = 1 }
157 for (@{[0]}) { "$_" }           # check warning isn't duplicated
158 EXPECT
159 Useless use of string in void context at - line 2.