From 9e24b6e2f422a9f67d0605cdea60de0c597868f3 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Thu, 29 Jul 1999 14:02:50 +0000 Subject: Repent and make overly large integerish constants non-fatal. They are now promoted to NVs, accompanied by an overflow warning that is by default on. p4raw-id: //depot/cfgperl@3832 --- t/pragma/warn/6default | 38 +++++++++++++++++++++++++-------- t/pragma/warn/util | 57 ++------------------------------------------------ 2 files changed, 31 insertions(+), 64 deletions(-) (limited to 't/pragma') diff --git a/t/pragma/warn/6default b/t/pragma/warn/6default index be45c77777..5be41124ca 100644 --- a/t/pragma/warn/6default +++ b/t/pragma/warn/6default @@ -9,25 +9,45 @@ Integer overflow in octal number at - line 3. ######## # no warning should be displayed no warning ; -my $a = oct "7777777777777777777777777777777777779" ; +my $a = oct "7777777777777777777777777777777777778" ; EXPECT -Integer overflow in octal number at - line 3. ######## # all warning should be displayed use warning ; -my $a = oct "77777777797"; +my $a = oct "7777777777777777777777777777777777778" ; EXPECT -Illegal octal digit '9' ignored at - line 3. +Integer overflow in octal number at - line 3. +Illegal octal digit '8' ignored at - line 3. +Octal number > 037777777777 non-portable at - line 3. ######## # check scope use warning ; -my $a = oct "77777777797"; +my $a = oct "7777777777777777777777777777777777778" ; { no warning ; - my $b = oct "77777777797"; + my $a = oct "7777777777777777777777777777777777778" ; } -my $c = oct "7777777777777777777777777777777777779" ; +my $c = oct "7777777777777777777777777777777777778" ; EXPECT -Illegal octal digit '9' ignored at - line 3. -Octal number > 037777777777 non-portable at - line 8. +Integer overflow in octal number at - line 3. +Illegal octal digit '8' ignored at - line 3. +Octal number > 037777777777 non-portable at - line 3. Integer overflow in octal number at - line 8. +Illegal octal digit '8' ignored at - line 8. +Octal number > 037777777777 non-portable at - line 8. +######## +# all warning should be displayed +use warning ; +my $a = oct "0xfffffffffffffffffg" ; +EXPECT +Integer overflow in hexadecimal number at - line 3. +Illegal hexadecimal digit 'g' ignored at - line 3. +Hexadecimal number > 0xffffffff non-portable at - line 3. +######## +# all warning should be displayed +use warning ; +my $a = oct "0b111111111111111111111111111111111111111111111111111111111111111112"; +EXPECT +Integer overflow in binary number at - line 3. +Illegal binary digit '2' ignored at - line 3. +Binary number > 0b11111111111111111111111111111111 non-portable at - line 3. diff --git a/t/pragma/warn/util b/t/pragma/warn/util index 87d43e8ffc..605b42a771 100644 --- a/t/pragma/warn/util +++ b/t/pragma/warn/util @@ -3,25 +3,18 @@ Illegal octal digit ignored my $a = oct "029" ; - Illegal hexadecimal digit ignored + Illegal hex digit ignored my $a = hex "0xv9" ; Illegal binary digit ignored my $a = oct "0b9" ; - - Mandatory Warnings - ------------------ - Integer overflow in binary number - Integer overflow in octal number - Integer overflow in hex number - __END__ # util.c use warning 'octal' ; my $a = oct "029" ; no warning 'octal' ; -my $b = oct "029" ; +my $a = oct "029" ; EXPECT Illegal octal digit '9' ignored at - line 3. ######## @@ -40,49 +33,3 @@ no warning 'unsafe' ; *a = oct "0b9" ; EXPECT Illegal binary digit '9' ignored at - line 3. -######## -# util.c -$^W = 1 ; -sub make_bin { "1" x $_[0] } -$n = make_bin(33); -{ - use warning 'unsafe' ; - my $a = oct "0b$n" ; - no warning 'unsafe' ; - my $b = oct "0b$n" ; -} -my $c = oct "0b$n" ; -EXPECT -Binary number > 0b11111111111111111111111111111111 non-portable at - line 7. -Binary number > 0b11111111111111111111111111111111 non-portable at - line 11. -######## -# util.c -$^W = 1 ; -sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) } -$n = make_oct(33); -{ - use warning 'unsafe' ; - my $a = oct "$n" ; - no warning 'unsafe' ; - my $b = oct "$n" ; -} -my $c = oct "$n" ; -EXPECT -Octal number > 037777777777 non-portable at - line 7. -Octal number > 037777777777 non-portable at - line 11. -######## -# util.c -$^W = 1 ; -sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) } -$n = make_hex(33); -{ - use warning 'unsafe' ; - my $a = hex "$n" ; - no warning 'unsafe' ; - my $b = hex "$n" ; -} -my $c = hex "$n" ; -EXPECT -Hexadecimal number > 0xffffffff non-portable at - line 7. -Hexadecimal number > 0xffffffff non-portable at - line 11. - -- cgit v1.2.1