This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Patch to JPL example program
[perl5.git] / t / pragma / warn / sv
CommitLineData
599cee73
PM
1 sv.c AOK
2
3 warn(warn_uninit);
4
5 warn(warn_uninit);
6
7 warn(warn_uninit);
8
9 warn(warn_uninit);
10
11 not_a_number(sv);
12
13 not_a_number(sv);
14
15 warn(warn_uninit);
16
17 not_a_number(sv);
18
19 warn(warn_uninit);
20
21 not_a_number(sv);
22
23 not_a_number(sv);
24
25 warn(warn_uninit);
26
27 warn(warn_uninit);
28
29 Subroutine %s redefined
30
31 Invalid conversion in %s:
32
33 Undefined value assigned to typeglob
34
35
36__END__
37# sv.c
38use integer ;
39use warning 'uninitialized' ;
40$x = 1 + $a[0] ; # a
41EXPECT
42Use of uninitialized value at - line 4.
43########
44# sv.c (sv_2iv)
45package fred ;
46sub TIESCALAR { my $x ; bless \$x}
47sub FETCH { return undef }
48sub STORE { return 1 }
49package main ;
50tie $A, 'fred' ;
51use integer ;
52use warning 'uninitialized' ;
53$A *= 2 ;
54EXPECT
55Use of uninitialized value at - line 10.
56########
57# sv.c
58use integer ;
59use warning 'uninitialized' ;
60my $x *= 2 ; #b
61EXPECT
62Use of uninitialized value at - line 4.
63########
64# sv.c (sv_2uv)
65package fred ;
66sub TIESCALAR { my $x ; bless \$x}
67sub FETCH { return undef }
68sub STORE { return 1 }
69package main ;
70tie $A, 'fred' ;
71use warning 'uninitialized' ;
72$B = 0 ;
73$B |= $A ;
74EXPECT
75Use of uninitialized value at - line 10.
76########
77# sv.c
78use warning 'uninitialized' ;
79my $Y = 1 ;
80my $x = 1 | $a[$Y]
81EXPECT
82Use of uninitialized value at - line 4.
83########
84# sv.c
85use warning 'uninitialized' ;
86my $x *= 1 ; # d
87EXPECT
88Use of uninitialized value at - line 3.
89########
90# sv.c
91use warning 'uninitialized' ;
92$x = 1 + $a[0] ; # e
93EXPECT
94Use of uninitialized value at - line 3.
95########
96# sv.c (sv_2nv)
97package fred ;
98sub TIESCALAR { my $x ; bless \$x}
99sub FETCH { return undef }
100sub STORE { return 1 }
101package main ;
102tie $A, 'fred' ;
103use warning 'uninitialized' ;
104$A *= 2 ;
105EXPECT
106Use of uninitialized value at - line 9.
107########
108# sv.c
109use warning 'uninitialized' ;
110$x = $y + 1 ; # f
111EXPECT
112Use of uninitialized value at - line 3.
113########
114# sv.c
115use warning 'uninitialized' ;
116$x = chop undef ; # g
117EXPECT
b0c98cec 118Modification of a read-only value attempted at - line 3.
599cee73
PM
119########
120# sv.c
121use warning 'uninitialized' ;
122$x = chop $y ; # h
123EXPECT
124Use of uninitialized value at - line 3.
125########
126# sv.c (sv_2pv)
127package fred ;
128sub TIESCALAR { my $x ; bless \$x}
129sub FETCH { return undef }
130sub STORE { return 1 }
131package main ;
132tie $A, 'fred' ;
133use warning 'uninitialized' ;
134$B = "" ;
135$B .= $A ;
136EXPECT
137Use of uninitialized value at - line 10.
138########
139# sv.c
140use warning 'numeric' ;
141sub TIESCALAR{bless[]} ;
142sub FETCH {"def"} ;
143tie $a,"main" ;
144my $b = 1 + $a
145EXPECT
146Argument "def" isn't numeric in add at - line 6.
147########
148# sv.c
149use warning 'numeric' ;
150my $x = 1 + "def" ;
151EXPECT
152Argument "def" isn't numeric in add at - line 3.
153########
154# sv.c
155use warning 'numeric' ;
156my $a = "def" ;
157my $x = 1 + $a ;
158EXPECT
159Argument "def" isn't numeric in add at - line 4.
160########
161# sv.c
162use warning 'numeric' ; use integer ;
163my $a = "def" ;
164my $x = 1 + $a ;
165EXPECT
166Argument "def" isn't numeric in i_add at - line 4.
167########
168# sv.c
169use warning 'numeric' ;
170my $x = 1 & "def" ;
171EXPECT
172Argument "def" isn't numeric in bit_and at - line 3.
173########
174# sv.c
175use warning 'redefine' ;
176sub fred {}
177sub joe {}
178*fred = \&joe ;
179EXPECT
180Subroutine fred redefined at - line 5.
181########
182# sv.c
183use warning 'printf' ;
3eeba6fb 184open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73
PM
185printf F "%q\n" ;
186my $a = sprintf "%q" ;
187printf F "%" ;
188$a = sprintf "%" ;
189printf F "%\x02" ;
190$a = sprintf "%\x02" ;
191EXPECT
192Invalid conversion in sprintf: "%q" at - line 5.
193Invalid conversion in sprintf: end of string at - line 7.
194Invalid conversion in sprintf: "%\002" at - line 9.
195Invalid conversion in printf: "%q" at - line 4.
196Invalid conversion in printf: end of string at - line 6.
197Invalid conversion in printf: "%\002" at - line 8.
198########
199# sv.c
200use warning 'unsafe' ;
201*a = undef ;
202EXPECT
203Undefined value assigned to typeglob at - line 3.