diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-10 12:23:21 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-10 12:23:21 +0000 |
commit | 651978e76e838ccd7ba8590fab59df5320c0a952 (patch) | |
tree | ab116c89df024ebb3e4ab31807569d039b54b1d5 /t/pragma/warn/util | |
parent | 9287a323f956849348c19a4d945e5121df84e5d3 (diff) | |
download | perl-651978e76e838ccd7ba8590fab59df5320c0a952.tar.gz |
Change t/pragma/warn oct()/hex() overflow tests to use %Config
to adapt to the underlying platform (the binary, 0b1..., test
was broken in 64-bit platforms). Also change "hex" in the
warning messages to "hexadecimal" to match "binary" and "octal".
p4raw-id: //depot/cfgperl@3662
Diffstat (limited to 't/pragma/warn/util')
-rw-r--r-- | t/pragma/warn/util | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/t/pragma/warn/util b/t/pragma/warn/util index bd29f7b254..ea3aed5cca 100644 --- a/t/pragma/warn/util +++ b/t/pragma/warn/util @@ -31,7 +31,7 @@ use warning 'unsafe' ; no warning 'unsafe' ; *a = hex "0xv9" ; EXPECT -Illegal hex digit 'v' ignored at - line 3. +Illegal hexadecimal digit 'v' ignored at - line 3. ######## # util.c use warning 'unsafe' ; @@ -42,41 +42,56 @@ EXPECT Illegal binary digit '9' ignored at - line 3. ######## # util.c +BEGIN { require Config ; import Config } $^W =1 ; +sub make_bin { "1" x $_[0] } +$n = make_bin(8 * $Config{longsize} ) ; +$o = make_bin(8 * $Config{longsize} + 1) ; { use warning 'unsafe' ; - my $a = oct "0b111111111111111111111111111111111" ; + my $a = oct "0b$n" ; + my $b = oct "0b$o" ; no warning 'unsafe' ; - $a = oct "0b111111111111111111111111111111111" ; + $b = oct "0b$o" ; } -my $a = oct "0b111111111111111111111111111111111" ; +my $b = oct "0b$o" ; EXPECT -Integer overflow in binary number at - line 5. -Integer overflow in binary number at - line 9. +Integer overflow in binary number at - line 10. +Integer overflow in binary number at - line 14. ######## # util.c +BEGIN { require Config ; import Config } $^W =1 ; +sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) } +$n = make_oct(8 * $Config{longsize} ); +$o = make_oct(8 * $Config{longsize} + 1); { use warning 'unsafe' ; - my $a = oct "777777777777777777777777777777777777" ; + my $a = oct "$n" ; + my $b = oct "$o" ; no warning 'unsafe' ; - $a = oct "777777777777777777777777777777777777" ; + $b = oct "$o" ; } -my $a = oct "777777777777777777777777777777777777" ; +my $b = oct "$o" ; EXPECT -Integer overflow in octal number at - line 5. -Integer overflow in octal number at - line 9. +Integer overflow in octal number at - line 10. +Integer overflow in octal number at - line 14. ######## # util.c +BEGIN { require Config ; import Config } $^W =1 ; +sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) } +$n = make_hex(8 * $Config{longsize} ) ; +$o = make_hex(8 * $Config{longsize} + 1) ; { use warning 'unsafe' ; - my $a = hex "ffffffffffffffffffffffffffffffff" ; + my $a = hex "$n" ; + my $b = hex "$o" ; no warning 'unsafe' ; - $a = hex "ffffffffffffffffffffffffffffffff" ; + $b = hex "$o" ; } -my $a = hex "ffffffffffffffffffffffffffffffff" ; +my $b = hex "$o" ; EXPECT -Integer overflow in hex number at - line 5. -Integer overflow in hex number at - line 9. +Integer overflow in hexadecimal number at - line 10. +Integer overflow in hexadecimal number at - line 14. |