Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.364.mcz==================== Summary ====================
Name: KernelTests-nice.364
Author: nice
Time: 13 May 2019, 5:47:01.649569 pm
UUID: 48139b72-ab12-d140-af26-7bce15bae277
Ancestors: KernelTests-nice.363
Integer sqrt is now correctly rounded - this is a new feature.
That's the case by construction for SmallInteger which rely on Float sqrt
but less obvious for LargePositiveInteger, so let's test it
=============== Diff against KernelTests-nice.363 ===============
Item was added:
+ ----- Method: LargeNegativeIntegerTest>>testSqrt (in category 'tests - mathematical functions') -----
+ testSqrt
+ self should: [(SmallInteger minVal - 1) sqrt] raise: DomainError!
Item was added:
+ ----- Method: LargePositiveIntegerTest>>assertSqrtCorrectlyRoundedForExponent: (in category 'asserting') -----
+ assertSqrtCorrectlyRoundedForExponent: exp
+ "Requires exp > Float precision, so that f ulp/2 is integer"
+ {1.5. 1.25 squared. 2.0 predecessor} do: [:sf |
+ | f xe xp xm |
+
+ f := sf timesTwoPower: exp.
+
+ "make two integers around the pivot"
+ xe := f asInteger + (f ulp asInteger / 2).
+ xm := xe squared - 1.
+ xp := xe squared + 1.
+ self assert: xe squared sqrt equals: xe.
+ self assert: xe squared sqrt isInteger.
+
+ "check rounding when result is near f squared"
+ self assert: xm sqrt equals: f.
+ self assert: xm sqrt isFloat.
+ self assert: xp sqrt equals: f successor.
+ self assert: xp sqrt isFloat.
+
+ "same in the other direction"
+ xe := f asInteger - (f ulp asInteger / 2).
+ xm := xe squared - 1.
+ xp := xe squared + 1.
+ self assert: xe squared sqrt equals: xe.
+ self assert: xe squared sqrt isInteger.
+
+ "check rounding when result is near f squared"
+ self assert: xm sqrt equals: f predecessor.
+ self assert: xm sqrt isFloat.
+ self assert: xp sqrt equals: f.
+ self assert: xp sqrt isFloat].!
Item was added:
+ ----- Method: LargePositiveIntegerTest>>testSqrt (in category 'tests - mathematical functions') -----
+ testSqrt
+ self assert: (SmallInteger maxVal + 1) sqrt equals: (SmallInteger maxVal + 1) asFloat sqrt.!
Item was added:
+ ----- Method: LargePositiveIntegerTest>>testSqrtCorrectlyRounded (in category 'tests - mathematical functions') -----
+ testSqrtCorrectlyRounded
+ self assertSqrtCorrectlyRoundedForExponent: Float precision * 2 - 1.
+ self assertSqrtCorrectlyRoundedForExponent: Float precision * 2 + 1.
+ self assertSqrtCorrectlyRoundedForExponent: Float precision * 2 + 3.
+ self assertSqrtCorrectlyRoundedForExponent: Float precision * 3 // 2.
+ self assertSqrtCorrectlyRoundedForExponent: Float emax* 2 // 3. "such that asFloat would overflow"
+ self assertSqrtCorrectlyRoundedForExponent: Float emax.!