[8.0.2] Duration>>- bug?

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

[8.0.2] Duration>>- bug?

Postby g.cotelli » Mon May 31, 2010 9:15 am

Hi,
I think I found a bug in Duration>>-

Original Code:
Code: Select all
- operand
   "Synopsis
      Answer the result of subtracting @operand from the receiver.
    Definition: <Duration>
      Answer a <Duration> whose value is the result of subtracting @operand from the receiver.
    Parameters
      @operand <Duration> unspecified
    Return Values
      <Duration> new
    Errors
      None
    Implementation Notes
      Do it the hard way to stay away from LargeIntegers as long as possible."

   | secs msecs |
   
   secs := self totalSeconds - operand totalSeconds.
   msecs := self microseconds -  operand microseconds.
   msecs < 0
      ifTrue: [
         secs := secs - 1.
         msecs = msecs + MicrosecondsPerSecond].
      
   ^ self class  totalSeconds: secs microseconds: msecs


I think that msecs = msecs + MicrosecondsPerSecond must be: msecs := msecs + MicrosecondsPerSecond .

Proposed Fix:
Code: Select all
- operand
   "Synopsis
      Answer the result of subtracting @operand from the receiver.
    Definition: <Duration>
      Answer a <Duration> whose value is the result of subtracting @operand from the receiver.
    Parameters
      @operand <Duration> unspecified
    Return Values
      <Duration> new
    Errors
      None
    Implementation Notes
      Do it the hard way to stay away from LargeIntegers as long as possible."

   | secs msecs |

   secs := self totalSeconds - operand totalSeconds.
   msecs := self microseconds - operand microseconds.
   msecs < 0
      ifTrue: [
         secs := secs - 1.
         msecs := msecs + MicrosecondsPerSecond].

   ^self class totalSeconds: secs microseconds: msecs


Regards,
Gabriel
g.cotelli
 
Posts: 13
Joined: Wed Feb 24, 2010 9:30 am

Re: [8.0.2] Duration>>- bug?

Postby koschate » Mon May 31, 2010 10:36 am

The same problem exists in Duration>>+ as well; there's an equal (=) being used instead of the assignment operator (:=):
Code: Select all
msecs = msecs - MicrosecondsPerSecond
koschate
[|]
 
Posts: 102
Joined: Thu Feb 01, 2007 7:24 am

Re: [8.0.2] Duration>>- bug?

Postby wembley » Tue Jun 01, 2010 7:50 am

Case 46660 opened and fixed (as suggested) in V8.0.3 first development build.
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest