This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #94390] Optimised numeric sort should warn for nan
[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 __END__
25 # pp.c
26 use warnings 'substr' ;
27 $a = "ab" ; 
28 $b = substr($a, 4,5) ;
29 no warnings 'substr' ;
30 $a = "ab" ; 
31 $b = substr($a, 4,5)  ;
32 EXPECT
33 substr outside of string at - line 4.
34 ########
35 # pp.c
36 use warnings 'substr' ;
37 $a = "ab" ; 
38 $b = \$a ;  
39 substr($b, 1,1) = "ab" ;
40 no warnings 'substr' ;
41 substr($b, 1,1) = "ab" ;
42 EXPECT
43 Attempt to use reference as lvalue in substr at - line 5.
44 ########
45 # pp.c
46 use warnings 'misc' ;
47 @a = qw( a b c );
48 splice(@a, 4, 0, 'e') ;
49 @a = qw( a b c );
50 splice(@a, 4, 1) ;
51 @a = qw( a b c );
52 splice(@a, 4) ;
53 no warnings 'misc' ;
54 @a = qw( a b c );
55 splice(@a, 4, 0, 'e') ;
56 @a = qw( a b c );
57 splice(@a, 4, 1) ;
58 @a = qw( a b c );
59 splice(@a, 4) ;
60 EXPECT
61 splice() offset past end of array at - line 4.
62 splice() offset past end of array at - line 6.
63 ########
64 # pp.c
65 use warnings 'uninitialized';
66 $x = undef; $y = $$x;
67 no warnings 'uninitialized' ;
68 $u = undef; $v = $$u;
69 EXPECT
70 Use of uninitialized value $x in scalar dereference at - line 3.
71 ########
72 # pp.c
73 use warnings 'misc' ;
74 my $a = { 1,2,3};
75 no warnings 'misc' ;
76 my $b = { 1,2,3};
77 EXPECT
78 Odd number of elements in anonymous hash at - line 3.
79 ########
80 # pp.c
81 use warnings 'misc' ;
82 bless \[], "" ;
83 no warnings 'misc' ;
84 bless \[], "" ;
85 EXPECT
86 Explicit blessing to '' (assuming package main) at - line 3.
87 ########
88 # pp.c
89 use warnings 'misc';
90 sub foo () { 1 }
91 undef &foo;
92 no warnings 'misc';
93 sub bar () { 2 }
94 undef &bar;
95 EXPECT
96 Constant subroutine foo undefined at - line 4.
97 ########
98 # pp.c
99 use utf8;
100 use open qw( :utf8 :std );
101 use warnings 'misc';
102 sub ฝᶱ () { 1 }
103 undef &ฝᶱ;
104 no warnings 'misc';
105 sub ƚ () { 2 }
106 undef &ƚ;
107 EXPECT
108 Constant subroutine ฝᶱ undefined at - line 6.
109 ########
110 # pp.c
111 use warnings 'misc';
112 $foo = sub () { 3 };
113 undef &$foo;
114 no warnings 'misc';
115 $bar = sub () { 4 };
116 undef &$bar;
117 EXPECT
118 Constant subroutine (anonymous) undefined at - line 4.
119 ########
120 # pp.c
121 use utf8 ;
122 $_ = "\x80  \xff" ;
123 reverse ;
124 EXPECT