[squeakdev] The Trunk: KernelTestsnice.422.mcz
Marcel Taeumel
marcel.taeumel at hpi.de
Thu May 5 14:07:40 UTC 2022
Hi Nicolas 
You forgot to commit #isFinite on Integer? Many ComplexTest tests are failing:
https://github.com/squeaksmalltalk/squeakapp/runs/6302546226?check_suite_focus=true
Best,
Marcel
Am 27.04.2022 17:18:13 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTestsnice.422.mcz
==================== Summary ====================
Name: KernelTestsnice.422
Author: nice
Time: 26 April 2022, 1:03:31.73252 pm
UUID: e963a1d7702a904d8b408dbf96032f0d
Ancestors: KernelTestsnice.421
Complex tests associated with that suggestion: complex arithmetic should detect case of overflow in intermediate computations and fallback to securedely scaled operations if it's the case.
=============== Diff against KernelTestsnice.421 ===============
Item was changed:
 Method: ComplexTest>>testDivision1 (in category 'tests') 
testDivision1
"self run: #testDivision1"
"self debug: #testDivision1"
 c1 c2 quotient 
c1 := 2.0e252 + 3.0e70 i.
c2 := c1.
quotient := c1 / c2.
 self deny: (quotient  1) isZero.
+ "This used to fail when / was not protected against floating point overflow in intermediate computations
+ but it should now work correctly if divideSecureBy: is correctly used as fallback case"
+ self assert: (quotient  1) isZero
 "This test fails due to the wonders of floating point arithmetic.
 Please have a look at Complex>>divideSecureBy: and #divideFastAndSecureBy:
 how this can be avoided."
!
Item was added:
+  Method: ComplexTest>>testMultiplyDoesNotOverflow (in category 'tests') 
+ testMultiplyDoesNotOverflow
+
+  c1 c2 product smallProduct scale 
+ c1 := (1 + 1 i) sqrt * Float fmax sqrt.
+ product := c1 squared.
+ self assert: product real isFinite.
+ self assert: product imaginary isFinite.
+ self assert: (product real  Float fmax) / Float fmax ulp
+ self assert: (product imaginary  Float fmax) / Float fmax ulp
+
+ "a more tricky case"
+ c1 := 1.0 + 0.25 i.
+ c2 := 1.125+ 0.5 i.
+ smallProduct := c1 * c2.
+ "check that we will not overflow in precondition"
+ self assert: smallProduct real abs
+ self assert: smallProduct imaginary abs
+ "now retry with a large scale"
+ scale := Float fmax.
+ product := c1 * scale * c2.
+ self assert: product real isFinite.
+ self assert: product imaginary isFinite.
+ self assert: (scale * smallProduct real  product real) / (scale * smallProduct real) ulp
+ self assert: (scale * smallProduct imaginary  product imaginary) / (scale * smallProduct imaginary) ulp
Item was added:
+  Method: ComplexTest>>testReciprocalDoesNotOverflow (in category 'tests') 
+ testReciprocalDoesNotOverflow
+ "Note: intermediate overflow might cause the answer to be zero in careless implementation"
+
+  c scale cScaled cScaledInv expected 
+ c := (1 + 1i).
+ scale := Float fmax.
+ cScaled := c * scale.
+ cScaledInv := cScaled reciprocal.
+ expected := c reciprocal real / scale + (c reciprocal imaginary / scale) i.
+ self assert: (expected real cScaledInv real) abs / expected real ulp
+ self assert: (expected imaginary  cScaledInv imaginary) abs / expected imaginary ulp
 next part 
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeakdev/attachments/20220505/73b2216e/attachment.html>
More information about the Squeakdev
mailing list
