Fix the bin/oct/hex constant overflow tests for
[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 hex 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 $a = 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 BEGIN { require Config ; import Config }
46 $^W =1 ;
47 sub make_bin { "1" x $_[0] }
48 my $s = $Config{longsize};
49 eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
50 $n = make_bin(8 * $s    ) ;
51 $o = make_bin(8 * $s + 1) ;
52 {
53   use warning 'unsafe' ;
54   my $a = oct "0b$n" ;
55   my $b = oct "0b$o" ;
56   no warning 'unsafe' ;
57   $b = oct "0b$o" ;
58 }
59 my $b = oct "0b$o" ;
60 EXPECT
61 Integer overflow in binary number at - line 12.
62 Integer overflow in binary number at - line 16.
63 ########
64 # util.c
65 BEGIN { require Config ; import Config }
66 $^W =1 ;
67 sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) }
68 my $s = $Config{longsize};
69 eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
70 $n = make_oct(8 * $s    );
71 $o = make_oct(8 * $s + 1);
72 {
73   use warning 'unsafe' ;
74   my $a = oct "$n" ;
75   my $b = oct "$o" ;
76   no warning 'unsafe' ;
77   $b = oct "$o" ;
78 }
79 my $b = oct "$o" ;
80 EXPECT
81 Integer overflow in octal number at - line 12.
82 Integer overflow in octal number at - line 16.
83 ########
84 # util.c
85 BEGIN { require Config ; import Config }
86 $^W =1 ;
87 sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) }
88 my $s = $Config{longsize};
89 eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
90 $n = make_hex(8 * $s    ) ;
91 $o = make_hex(8 * $s + 1) ;
92 {
93   use warning 'unsafe' ;
94   my $a = hex "$n" ;
95   my $b = hex "$o" ;
96   no warning 'unsafe' ;
97   $b = hex "$o" ;
98 }
99 my $b = hex "$o" ;
100 EXPECT
101 Integer overflow in hexadecimal number at - line 12.
102 Integer overflow in hexadecimal number at - line 16.
103