This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change error wording for \o{}
[perl5.git] / t / lib / warnings / pp
1   pp.c  TODO
2
3   substr outside of string
4     $a = "ab" ; $b = substr($a, 4,5) ;
5
6   Attempt to use reference as lvalue in substr 
7     $a = "ab" ; $b = \$a ;  substr($b, 1,1) = $b
8
9   Use of uninitialized value in scalar dereference      [pp_rv2sv()]
10         my $a = undef ; my $b = $$a
11
12   Odd number of elements in hash list
13         my $a = { 1,2,3 } ;
14
15   Explicit blessing to '' (assuming package main)
16         bless \[], "";
17
18   Constant subroutine %s undefined
19         sub foo () { 1 }; undef &foo;
20
21   Constant subroutine (anonymous) undefined
22         $foo = sub () { 3 }; undef &$foo;
23
24   Invalid negative number (%s) in chr
25
26 __END__
27 # pp.c
28 use warnings 'substr' ;
29 $a = "ab" ; 
30 $b = substr($a, 4,5) ;
31 no warnings 'substr' ;
32 $a = "ab" ; 
33 $b = substr($a, 4,5)  ;
34 EXPECT
35 substr outside of string at - line 4.
36 ########
37 # pp.c
38 use warnings 'substr' ;
39 $a = "ab" ; 
40 $b = \$a ;  
41 substr($b, 1,1) = "ab" ;
42 $b = \$a;
43 substr($b, 1,1) = "\x{100}" ;
44 no warnings 'substr' ;
45 $b = \$a;
46 substr($b, 1,1) = "ab" ;
47 $b = \$a;
48 substr($b, 1,1) = "\x{100}" ;
49 EXPECT
50 Attempt to use reference as lvalue in substr at - line 5.
51 Attempt to use reference as lvalue in substr at - line 7.
52 ########
53 # pp.c
54 use warnings 'misc' ;
55 @a = qw( a b c );
56 splice(@a, 4, 0, 'e') ;
57 @a = qw( a b c );
58 splice(@a, 4, 1) ;
59 @a = qw( a b c );
60 splice(@a, 4) ;
61 no warnings 'misc' ;
62 @a = qw( a b c );
63 splice(@a, 4, 0, 'e') ;
64 @a = qw( a b c );
65 splice(@a, 4, 1) ;
66 @a = qw( a b c );
67 splice(@a, 4) ;
68 EXPECT
69 splice() offset past end of array at - line 4.
70 splice() offset past end of array at - line 6.
71 ########
72 # pp.c
73 use warnings 'uninitialized';
74 $x = undef; $y = $$x;
75 no warnings 'uninitialized' ;
76 $u = undef; $v = $$u;
77 EXPECT
78 Use of uninitialized value $x in scalar dereference at - line 3.
79 ########
80 # pp.c
81 use warnings 'misc' ;
82 my $a = { 1,2,3};
83 no warnings 'misc' ;
84 my $b = { 1,2,3};
85 EXPECT
86 Odd number of elements in anonymous hash at - line 3.
87 ########
88 # pp.c
89 use warnings 'misc' ;
90 bless \[], "" ;
91 no warnings 'misc' ;
92 bless \[], "" ;
93 EXPECT
94 Explicit blessing to '' (assuming package main) at - line 3.
95 ########
96 # pp.c
97 use warnings 'misc';
98 sub foo () { 1 }
99 undef &foo;
100 no warnings 'misc';
101 sub bar () { 2 }
102 undef &bar;
103 EXPECT
104 Constant subroutine foo undefined at - line 4.
105 ########
106 # pp.c
107 use utf8;
108 use open qw( :utf8 :std );
109 use warnings 'misc';
110 sub ฝᶱ () { 1 }
111 undef &ฝᶱ;
112 no warnings 'misc';
113 sub ƚ () { 2 }
114 undef &ƚ;
115 EXPECT
116 Constant subroutine ฝᶱ undefined at - line 6.
117 ########
118 # pp.c
119 use warnings 'misc';
120 $foo = sub () { 3 };
121 undef &$foo;
122 no warnings 'misc';
123 $bar = sub () { 4 };
124 undef &$bar;
125 EXPECT
126 Constant subroutine (anonymous) undefined at - line 4.
127 ########
128 # pp.c
129 use utf8 ;
130 $_ = "\x80  \xff" ;
131 reverse ;
132 EXPECT
133 ########
134 # NAME chr -1
135 use warnings 'utf8';
136 my $chr = chr(-1);
137 EXPECT
138 Invalid negative number (-1) in chr at - line 2.