cvsuser     02/12/27 17:37:54

  Modified:    .        core.ops
               t/op     number.t
  Log:
  The core parrot op neg() allows zero to become negative. That shouldn't
  happen. I've attached a patch to this email that corrects the problem by
  testing if neg() was passed a value of zero. I've also attached a patch that
  adds a new test to make sure that zero cannot become negative.
  
  Courtesy of Michael Joyce <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.241     +10 -2     parrot/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/core.ops,v
  retrieving revision 1.240
  retrieving revision 1.241
  diff -u -w -r1.240 -r1.241
  --- core.ops  27 Dec 2002 09:33:11 -0000      1.240
  +++ core.ops  28 Dec 2002 01:37:52 -0000      1.241
  @@ -1703,21 +1703,29 @@
   =cut
   
   inline op neg(inout INT) {
  +  if($1) {
     $1 = -($1);
  +  }
     goto NEXT();
   }
   
   inline op neg(inout NUM) {
  +  if($1 == 0.0)
  +    goto NEXT();
     $1 = -($1);
     goto NEXT();
   }
   
   inline op neg(out INT, in INT) {
  +  if($2) {
     $1 = -($2);
  +  }
     goto NEXT();
   }
   
   inline op neg(out NUM, in NUM) {
  +  if($2 == 0.0)
  +    goto NEXT();
     $1 = -($2);
     goto NEXT();
   }
  
  
  
  1.28      +11 -1     parrot/t/op/number.t
  
  Index: number.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/op/number.t,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -r1.27 -r1.28
  --- number.t  14 Dec 2002 01:17:04 -0000      1.27
  +++ number.t  28 Dec 2002 01:37:54 -0000      1.28
  @@ -1,6 +1,6 @@
   #! perl -w
   
  -use Parrot::Test tests => 36;
  +use Parrot::Test tests => 37;
   use Test::More;
   
   output_is(<<CODE, <<OUTPUT, "set_n_nc");
  @@ -885,6 +885,16 @@
       end
   CODE
   -3.000000
  +OUTPUT
  +
  +output_is(<<CODE, <<OUTPUT, "neg 0.0");
  +    set N1, 0
  +    neg N1
  +    print N1
  +    print "\\n"
  +    end
  +CODE
  +0.000000
   OUTPUT
   
   output_is(<<CODE, <<OUTPUT, "mul_n_n");
  
  
  


Reply via email to