Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.368.mcz
==================== Summary ====================
Name: Tools-btc.368
Author: btc
Time: 13 July 2011, 12:09:33.417 am
UUID: 04b62880-e5a2-3445-8440-482d7c7586fb
Ancestors: Tools-btc.367
Single stepping through a debugger might observe the state of an OrderedCollection instance after creation by basicNew but before initiialisation. Thus 'object size' throws a DNU error for arithmetic on a nil value that needs to be handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger might observe the state of an OrderedCollection
+ instance after creation by basicNew but before initiialisation. Thus 'object size'
+ throws a DNU error for arithmetic on a nil value that needs to be handled here."
+
+ ^ [ object size ] on: Error do: [ 0 ]
+ !
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-btc.49.mcz
==================== Summary ====================
Name: ToolsTests-btc.49
Author: btc
Time: 12 July 2011, 12:22:10.5 am
UUID: e31f9b65-d96b-8846-a317-25ba0bc319c4
Ancestors: ToolsTests-fbs.48
Single stepping through a debugger can observe an inconsistent state after object creation but before initiialisation. Thus 'object size' may throw an axception for trying to do arithmetic on nil. Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception. This tests that fix.
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: ( (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete notNil ) raise: Error.!
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-btc.49.mcz
==================== Summary ====================
Name: ToolsTests-btc.49
Author: btc
Time: 12 July 2011, 12:22:10.5 am
UUID: e31f9b65-d96b-8846-a317-25ba0bc319c4
Ancestors: ToolsTests-fbs.48
Single stepping through a debugger can observe an inconsistent state after object creation but before initiialisation. Thus 'object size' may throw an axception for trying to do arithmetic on nil. Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception. This tests that fix.
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: ( (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete notNil ) raise: Error.!
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-btc.49.mcz
==================== Summary ====================
Name: ToolsTests-btc.49
Author: btc
Time: 12 July 2011, 12:22:10.5 am
UUID: e31f9b65-d96b-8846-a317-25ba0bc319c4
Ancestors: ToolsTests-fbs.48
Single stepping through a debugger can observe an inconsistent state after object creation but before initiialisation. Thus 'object size' may throw an axception for trying to do arithmetic on nil. Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception. This tests that fix.
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: ( (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete notNil ) raise: Error.!
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-ul.50.mcz
==================== Summary ====================
Name: ToolsTests-ul.50
Author: ul
Time: 16 July 2011, 11:07:01.313 am
UUID: b3b70a70-701a-494b-b43a-4d72e02c8bcc
Ancestors: ToolsTests-btc.49
#shouldnt:raise:'s first argument should be a block in OrderedCollectionInspectorTest >> #testUninitialized
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: [ (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete ] raise: Error.!
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-ul.50.mcz
==================== Summary ====================
Name: ToolsTests-ul.50
Author: ul
Time: 16 July 2011, 11:07:01.313 am
UUID: b3b70a70-701a-494b-b43a-4d72e02c8bcc
Ancestors: ToolsTests-btc.49
#shouldnt:raise:'s first argument should be a block in OrderedCollectionInspectorTest >> #testUninitialized
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: [ (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete ] raise: Error.!
Levente Uzonyi uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-ul.50.mcz
==================== Summary ====================
Name: ToolsTests-ul.50
Author: ul
Time: 16 July 2011, 11:07:01.313 am
UUID: b3b70a70-701a-494b-b43a-4d72e02c8bcc
Ancestors: ToolsTests-btc.49
#shouldnt:raise:'s first argument should be a block in OrderedCollectionInspectorTest >> #testUninitialized
=============== Diff against ToolsTests-fbs.48 ===============
Item was added:
+ TestCase subclass: #OrderedCollectionInspectorTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Inspector'!
Item was added:
+ ----- Method: OrderedCollectionInspectorTest>>testUninitialized (in category 'as yet unclassified') -----
+ testUninitialized
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+ "Modified OrderedCollectionInspector>>fieldList to call 'self objectSize' to handle this exception."
+ "Original error reproduction: [ self halt. OrderedCollectionInspector openOn: (OrderedCollection new: 5) ] "
+
+ self shouldnt: [ (OrderedCollectionInspector openOn: OrderedCollection basicNew) delete ] raise: Error.!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.605.mcz
==================== Summary ====================
Name: Kernel-nice.605
Author: nice
Time: 15 July 2011, 11:21:58.548 pm
UUID: 59831937-c6b3-4a5a-9f2a-a14f898e6fd7
Ancestors: Kernel-ul.604
Fix: a negative fraction asFloat should answer negativeZero when it underflows
=============== Diff against Kernel-ul.604 ===============
Item was changed:
----- Method: Fraction>>asFloat (in category 'converting') -----
asFloat
"Answer a Float that closely approximates the value of the receiver.
This implementation will answer the closest floating point number to
the receiver.
It uses the IEEE 754 round to nearest even mode
(can happen in case denominator is a power of two)"
| a b q r exponent floatExponent n ha hb hq q1 |
a := numerator abs.
b := denominator abs.
ha := a highBit.
hb := b highBit.
"If both numerator and denominator are represented exactly in floating point number,
then fastest thing to do is to use hardwired float division"
(ha < 54 and: [hb < 54]) ifTrue: [^numerator asFloat / denominator asFloat].
"Try and obtain a mantissa with 54 bits.
First guess is rough, we might get one more bit or one less"
exponent := ha - hb - 54.
exponent > 0
ifTrue: [b := b bitShift: exponent]
ifFalse: [a := a bitShift: exponent negated].
q := a quo: b.
r := a - (q * b).
hq := q highBit.
"check for gradual underflow, in which case we should use less bits"
floatExponent := exponent + hq - 1.
n := floatExponent > -1023
ifTrue: [54]
ifFalse: [54 + floatExponent + 1022].
hq > n
ifTrue: [exponent := exponent + hq - n.
r := (q bitAnd: (1 bitShift: hq - n) - 1) * b + r.
q := q bitShift: n - hq].
hq < n
ifTrue: [exponent := exponent + hq - n.
q1 := (r bitShift: n - hq) quo: b.
q := (q bitShift: n - hq) bitAnd: q1.
r := (r bitShift: n - hq) - (q1 * b)].
"check if we should round upward.
The case of exact half (q bitAnd: 1) isZero not & (r isZero)
will be handled by Integer>>asFloat"
((q bitAnd: 1) isZero or: [r isZero])
ifFalse: [q := q + 1].
^ (self positive
ifTrue: [q asFloat]
+ ifFalse: [q = 0
+ ifTrue: [Float negativeZero]
+ ifFalse: [q asFloat negated]])
- ifFalse: [q asFloat negated])
timesTwoPower: exponent!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.605.mcz
==================== Summary ====================
Name: Kernel-nice.605
Author: nice
Time: 15 July 2011, 11:21:58.548 pm
UUID: 59831937-c6b3-4a5a-9f2a-a14f898e6fd7
Ancestors: Kernel-ul.604
Fix: a negative fraction asFloat should answer negativeZero when it underflows
=============== Diff against Kernel-ul.604 ===============
Item was changed:
----- Method: Fraction>>asFloat (in category 'converting') -----
asFloat
"Answer a Float that closely approximates the value of the receiver.
This implementation will answer the closest floating point number to
the receiver.
It uses the IEEE 754 round to nearest even mode
(can happen in case denominator is a power of two)"
| a b q r exponent floatExponent n ha hb hq q1 |
a := numerator abs.
b := denominator abs.
ha := a highBit.
hb := b highBit.
"If both numerator and denominator are represented exactly in floating point number,
then fastest thing to do is to use hardwired float division"
(ha < 54 and: [hb < 54]) ifTrue: [^numerator asFloat / denominator asFloat].
"Try and obtain a mantissa with 54 bits.
First guess is rough, we might get one more bit or one less"
exponent := ha - hb - 54.
exponent > 0
ifTrue: [b := b bitShift: exponent]
ifFalse: [a := a bitShift: exponent negated].
q := a quo: b.
r := a - (q * b).
hq := q highBit.
"check for gradual underflow, in which case we should use less bits"
floatExponent := exponent + hq - 1.
n := floatExponent > -1023
ifTrue: [54]
ifFalse: [54 + floatExponent + 1022].
hq > n
ifTrue: [exponent := exponent + hq - n.
r := (q bitAnd: (1 bitShift: hq - n) - 1) * b + r.
q := q bitShift: n - hq].
hq < n
ifTrue: [exponent := exponent + hq - n.
q1 := (r bitShift: n - hq) quo: b.
q := (q bitShift: n - hq) bitAnd: q1.
r := (r bitShift: n - hq) - (q1 * b)].
"check if we should round upward.
The case of exact half (q bitAnd: 1) isZero not & (r isZero)
will be handled by Integer>>asFloat"
((q bitAnd: 1) isZero or: [r isZero])
ifFalse: [q := q + 1].
^ (self positive
ifTrue: [q asFloat]
+ ifFalse: [q = 0
+ ifTrue: [Float negativeZero]
+ ifFalse: [q asFloat negated]])
- ifFalse: [q asFloat negated])
timesTwoPower: exponent!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.605.mcz
==================== Summary ====================
Name: Kernel-nice.605
Author: nice
Time: 15 July 2011, 11:21:58.548 pm
UUID: 59831937-c6b3-4a5a-9f2a-a14f898e6fd7
Ancestors: Kernel-ul.604
Fix: a negative fraction asFloat should answer negativeZero when it underflows
=============== Diff against Kernel-ul.604 ===============
Item was changed:
----- Method: Fraction>>asFloat (in category 'converting') -----
asFloat
"Answer a Float that closely approximates the value of the receiver.
This implementation will answer the closest floating point number to
the receiver.
It uses the IEEE 754 round to nearest even mode
(can happen in case denominator is a power of two)"
| a b q r exponent floatExponent n ha hb hq q1 |
a := numerator abs.
b := denominator abs.
ha := a highBit.
hb := b highBit.
"If both numerator and denominator are represented exactly in floating point number,
then fastest thing to do is to use hardwired float division"
(ha < 54 and: [hb < 54]) ifTrue: [^numerator asFloat / denominator asFloat].
"Try and obtain a mantissa with 54 bits.
First guess is rough, we might get one more bit or one less"
exponent := ha - hb - 54.
exponent > 0
ifTrue: [b := b bitShift: exponent]
ifFalse: [a := a bitShift: exponent negated].
q := a quo: b.
r := a - (q * b).
hq := q highBit.
"check for gradual underflow, in which case we should use less bits"
floatExponent := exponent + hq - 1.
n := floatExponent > -1023
ifTrue: [54]
ifFalse: [54 + floatExponent + 1022].
hq > n
ifTrue: [exponent := exponent + hq - n.
r := (q bitAnd: (1 bitShift: hq - n) - 1) * b + r.
q := q bitShift: n - hq].
hq < n
ifTrue: [exponent := exponent + hq - n.
q1 := (r bitShift: n - hq) quo: b.
q := (q bitShift: n - hq) bitAnd: q1.
r := (r bitShift: n - hq) - (q1 * b)].
"check if we should round upward.
The case of exact half (q bitAnd: 1) isZero not & (r isZero)
will be handled by Integer>>asFloat"
((q bitAnd: 1) isZero or: [r isZero])
ifFalse: [q := q + 1].
^ (self positive
ifTrue: [q asFloat]
+ ifFalse: [q = 0
+ ifTrue: [Float negativeZero]
+ ifFalse: [q asFloat negated]])
- ifFalse: [q asFloat negated])
timesTwoPower: exponent!