From: Father Chrysostomos Date: Tue, 26 Oct 2010 04:29:24 +0000 (-0700) Subject: -$zero should not modify $zero X-Git-Tag: accepted/trunk/20130322.191538~7147 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=886a446526bf7a98f554b67775a504fa1d5d08e9;p=platform%2Fupstream%2Fperl.git -$zero should not modify $zero With change a5b92898, negation started modifying numeric arguments, causing problems for modules like Data::Float. --- diff --git a/pp.c b/pp.c index 6811ba0..c99d697 100644 --- a/pp.c +++ b/pp.c @@ -2457,7 +2457,7 @@ PP(pp_negate) SV * const sv = TOPs; const int flags = SvFLAGS(sv); - if( looks_like_number( sv ) ){ + if( !SvNIOK( sv ) && looks_like_number( sv ) ){ SvIV_please( sv ); } diff --git a/t/op/numconvert.t b/t/op/numconvert.t index ce78809..d353861 100644 --- a/t/op/numconvert.t +++ b/t/op/numconvert.t @@ -260,7 +260,7 @@ for my $num_chain (1..$max_chain) { } # Tests that use test.pl start here. -BEGIN { $::additional_tests = 3 } +BEGIN { $::additional_tests = 4 } curr_test($test); @@ -268,3 +268,6 @@ ok(-0.0 eq "0", 'negative zero stringifies as 0'); ok(!-0.0, "neg zero is boolean false"); my $nz = -0.0; "$nz"; ok(!$nz, 'previously stringified -0.0 is boolean false'); +$nz = -0.0; +is sprintf("%+.f", - -$nz), sprintf("%+.f", - -$nz), + "negation does not coerce negative zeroes";