Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.134.mcz==================== Summary ====================
Name: KernelTests-nice.134
Author: nice
Time: 13 February 2010, 4:18:41.12 am
UUID: 1c6d57c9-931e-cb48-b7e8-83a3926d68e5
Ancestors: KernelTests-nice.133
Add some tests for hash and = disagreement.
Also for problems of non transitivity of =
http://bugs.squeak.org/view.php?id=3360http://bugs.squeak.org/view.php?id=3374=============== Diff against KernelTests-nice.133 ===============
Item was added:
+ ----- Method: FloatTest>>testComparison (in category 'testing compare') -----
+ testComparison
+
+ "test equality when Float conversion loose bits"
+ | a b c |
+ a := 16r1FFFFFFFFFFFFF1.
+ b := 16r1FFFFFFFFFFFFF3.
+ c := a asFloat.
+ self assert: ((a = c) & (b = c)) ==> (a = b).
+
+ "Test equality when Float conversion exact"
+ self assert: 16r1FFFFFFFFFFFFF = 16r1FFFFFFFFFFFFF asFloat.
+ self assert: 16r1FFFFFFFFFFFFF = 16r1FFFFFFFFFFFFF asFloat asInteger.
+
+ "Test inequality when Float conversion loose bits"
+ self assert: (((1 bitShift: 54)+1)/(1 bitShift: 54)) > 1.
+ self assert: (((1 bitShift: 54)+1)/(1 bitShift: 54)) > 1.0.
+
+ self assert: (((1 bitShift: 54)-1)/(1 bitShift: 54)) < 1.
+ self assert: (((1 bitShift: 54)-1)/(1 bitShift: 54)) < 1.0.
+
+ "Test exact vs inexact arithmetic"
+ (1 to: 100) do: [:i |
+ i isPowerOfTwo
+ ifTrue: [self assert: (1/i) = (1/i) asFloat]
+ ifFalse: [self deny: (1/i) = (1/i) asFloat]].
+
+ "Test overflow (compare to infinity)"
+ a := (11 raisedTo: 400) / 2.
+ b := (13 raisedTo: 400) / 2.
+ c := a asFloat.
+ self assert: ((a = c) & (b = c)) ==> (a = b).
+
+ "every integer is smaller than infinity"
+ self assert: a < Float infinity.
+ self assert: a > Float infinity negated.
+
+ "Test underflow"
+ self deny: 1 / (11 raisedTo: 400) = 0.
+ self deny: 1 / (11 raisedTo: 400) = 0.0.
+
+ "Test hash code"
+ self assert:
+ ((Set new: 3) add: 3; add: 3.0; size) =
+ ((Set new: 4) add: 3; add: 3.0; size).!
Item was added:
+ ----- Method: FloatTest>>testSetOfFloat (in category 'testing') -----
+ testSetOfFloat
+ "Classical disagreement between hash and = did lead to a bug.
+ This is a non regression test from
http://bugs.squeak.org/view.php?id=3360"
+
+ | size3 size4 |
+ size3 := (Set new: 3) add: 3; add: 3.0; size.
+ size4 := (Set new: 4) add: 3; add: 3.0; size.
+ self assert: size3 = size4 description: 'The size of a Set should not depend on its capacity.'!