Integer constants (0x, 0[0-7], 0b) now overflow fatally,
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / util
1   util.c AOK
2  
3      Illegal octal digit ignored 
4         my $a = oct "029" ;
5
6      Illegal hexadecimal digit ignored 
7         my $a = hex "0xv9" ;
8
9      Illegal binary digit ignored
10       my $a = oct "0b9" ;
11
12      
13      Mandatory Warnings
14      ------------------
15      Integer overflow in binary number
16      Integer overflow in octal number
17      Integer overflow in hex number
18
19 __END__
20 # util.c
21 use warning 'octal' ;
22 my $a = oct "029" ;
23 no warning 'octal' ;
24 my $b = oct "029" ;
25 EXPECT
26 Illegal octal digit '9' ignored at - line 3.
27 ########
28 # util.c
29 use warning 'unsafe' ;
30 *a =  hex "0xv9" ;
31 no warning 'unsafe' ;
32 *a =  hex "0xv9" ;
33 EXPECT
34 Illegal hexadecimal digit 'v' ignored at - line 3.
35 ########
36 # util.c
37 use warning 'unsafe' ;
38 *a =  oct "0b9" ;
39 no warning 'unsafe' ;
40 *a =  oct "0b9" ;
41 EXPECT
42 Illegal binary digit '9' ignored at - line 3.
43 ########
44 # util.c
45 $^W = 1 ;
46 sub make_bin { "1" x $_[0] }
47 $n = make_bin(33);
48 {
49   use warning 'unsafe' ;
50   my $a = oct "0b$n" ;
51   no warning 'unsafe' ;
52   my $b = oct "0b$n" ;
53 }
54 my $c = oct "0b$n" ;
55 EXPECT
56 Binary number > 0b11111111111111111111111111111111 non-portable at - line 7.
57 Binary number > 0b11111111111111111111111111111111 non-portable at - line 11.
58 ########
59 # util.c
60 $^W = 1 ;
61 sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) }
62 $n = make_oct(33);
63 {
64   use warning 'unsafe' ;
65   my $a = oct "$n" ;
66   no warning 'unsafe' ;
67   my $b = oct "$n" ;
68 }
69 my $c = oct "$n" ;
70 EXPECT
71 Octal number > 037777777777 non-portable at - line 7.
72 Octal number > 037777777777 non-portable at - line 11.
73 ########
74 # util.c
75 $^W = 1 ;
76 sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) }
77 $n = make_hex(33);
78 {
79   use warning 'unsafe' ;
80   my $a = hex "$n" ;
81   no warning 'unsafe' ;
82   my $b = hex "$n" ;
83 }
84 my $c = hex "$n" ;
85 EXPECT
86 Hexadecimal number > 0xffffffff non-portable at - line 7.
87 Hexadecimal number > 0xffffffff non-portable at - line 11.
88