Change t/pragma/warn oct()/hex() overflow tests to use %Config
[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 $n = make_bin(8 * $Config{longsize}    ) ;
49 $o = make_bin(8 * $Config{longsize} + 1) ;
50 {
51   use warning 'unsafe' ;
52   my $a = oct "0b$n" ;
53   my $b = oct "0b$o" ;
54   no warning 'unsafe' ;
55   $b = oct "0b$o" ;
56 }
57 my $b = oct "0b$o" ;
58 EXPECT
59 Integer overflow in binary number at - line 10.
60 Integer overflow in binary number at - line 14.
61 ########
62 # util.c
63 BEGIN { require Config ; import Config }
64 $^W =1 ;
65 sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) }
66 $n = make_oct(8 * $Config{longsize}    );
67 $o = make_oct(8 * $Config{longsize} + 1);
68 {
69   use warning 'unsafe' ;
70   my $a = oct "$n" ;
71   my $b = oct "$o" ;
72   no warning 'unsafe' ;
73   $b = oct "$o" ;
74 }
75 my $b = oct "$o" ;
76 EXPECT
77 Integer overflow in octal number at - line 10.
78 Integer overflow in octal number at - line 14.
79 ########
80 # util.c
81 BEGIN { require Config ; import Config }
82 $^W =1 ;
83 sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) }
84 $n = make_hex(8 * $Config{longsize}    ) ;
85 $o = make_hex(8 * $Config{longsize} + 1) ;
86 {
87   use warning 'unsafe' ;
88   my $a = hex "$n" ;
89   my $b = hex "$o" ;
90   no warning 'unsafe' ;
91   $b = hex "$o" ;
92 }
93 my $b = hex "$o" ;
94 EXPECT
95 Integer overflow in hexadecimal number at - line 10.
96 Integer overflow in hexadecimal number at - line 14.
97