missing file in change#5170
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / 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   uninitialized in pp_rv2gv()
10         my *b = *{ undef()}
11
12   uninitialized in pp_rv2sv()
13         my $a = undef ; my $b = $$a
14
15   Odd number of elements in hash list
16         my $a = { 1,2,3 } ;
17
18   Invalid type in unpack: '%c
19         my $A = pack ("A,A", 1,2) ;
20         my @A = unpack ("A,A", "22") ;
21
22   Attempt to pack pointer to temporary value
23         pack("p", "abc") ;
24
25   Explicit blessing to '' (assuming package main)
26         bless \[], "";
27
28   Constant subroutine %s undefined                      <<<TODO
29   Constant subroutine (anonymous) undefined             <<<TODO
30
31   Mandatory Warnings
32   ------------------
33   Malformed UTF-8 character (not tested: difficult to produce with
34                              perl now)
35
36 __END__
37 # pp.c
38 use warnings 'substr' ;
39 $a = "ab" ; 
40 $b = substr($a, 4,5) ;
41 no warnings 'substr' ;
42 $a = "ab" ; 
43 $b = substr($a, 4,5)  ;
44 EXPECT
45 substr outside of string at - line 4.
46 ########
47 # pp.c
48 use warnings 'substr' ;
49 $a = "ab" ; 
50 $b = \$a ;  
51 substr($b, 1,1) = "ab" ;
52 no warnings 'substr' ;
53 substr($b, 1,1) = "ab" ;
54 EXPECT
55 Attempt to use reference as lvalue in substr at - line 5.
56 ########
57 # pp.c
58 use warnings 'uninitialized' ;
59 # TODO
60 EXPECT
61
62 ########
63 # pp.c
64 use warnings 'misc' ;
65 my $a = { 1,2,3};
66 no warnings 'misc' ;
67 my $b = { 1,2,3};
68 EXPECT
69 Odd number of elements in hash assignment at - line 3.
70 ########
71 # pp.c
72 use warnings 'pack' ;
73 use warnings 'unpack' ;
74 my @a = unpack ("A,A", "22") ;
75 my $a = pack ("A,A", 1,2) ;
76 no warnings 'pack' ;
77 no warnings 'unpack' ;
78 my @b = unpack ("A,A", "22") ;
79 my $b = pack ("A,A", 1,2) ;
80 EXPECT
81 Invalid type in unpack: ',' at - line 4.
82 Invalid type in pack: ',' at - line 5.
83 ########
84 # pp.c
85 use warnings 'uninitialized' ;
86 my $a = undef ; 
87 my $b = $$a;
88 no warnings 'uninitialized' ;
89 my $c = $$a;
90 EXPECT
91 Use of uninitialized value in scalar dereference at - line 4.
92 ########
93 # pp.c
94 use warnings 'pack' ;
95 sub foo { my $a = "a"; return $a . $a++ . $a++ }
96 my $a = pack("p", &foo) ;
97 no warnings 'pack' ;
98 my $b = pack("p", &foo) ;
99 EXPECT
100 Attempt to pack pointer to temporary value at - line 4.
101 ########
102 # pp.c
103 use warnings 'misc' ;
104 bless \[], "" ;
105 no warnings 'misc' ;
106 bless \[], "" ;
107 EXPECT
108 Explicit blessing to '' (assuming package main) at - line 3.
109 ########
110 # pp.c
111 use utf8 ;
112 $_ = "\x80  \xff" ;
113 reverse ;
114 EXPECT
115 ########
116 # pp.c
117 BEGIN {
118     if (ord("\t") == 5) {
119         print "SKIPPED\n# Character codes differ on ebcdic machines.";
120         exit 0;
121     }
122 }
123 use warnings 'utf8'  ;
124 use utf8 ;
125 $_ = "\x80  \xff" ;
126 reverse ;
127 no warnings 'utf8'  ;
128 $_ = "\x80  \xff" ;
129 reverse ;
130 EXPECT
131 \x80 will produce malformed UTF-8 character; use \x{80} for that at - line 10.
132 \xff will produce malformed UTF-8 character; use \x{ff} for that at - line 10.