Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.93.mcz==================== Summary ====================
Name: KernelTests-nice.93
Author: nice
Time: 19 September 2009, 8:12:18 am
UUID: 2903cf1d-6255-474a-8740-c677ca3e5cbd
Ancestors: KernelTests-laza.92
Add some tests for #printShowingDecimalPlaces:
This is essentially
http://bugs.squeak.org/view.php?id=5640(and its duplicates)
=============== Diff against KernelTests-laza.92 ===============
Item was added:
+ ----- Method: NumberTest>>testPrintShowingDecimalPlaces2 (in category 'tests') -----
+ testPrintShowingDecimalPlaces2
+ "This tests problems related to Float>>rounded and Float>>roundTo::
+ - Float>>#rounded is inexact
+ - Float>>#roundTo: might overflow"
+
+ "5000000000000001.0 asTrueFraction = 5000000000000001.
+ 5000000000000001 highBit = 53.
+ This number is represented exactly asFloat, it should print exactly"
+ self assert: (5000000000000001.0 printShowingDecimalPlaces: 0) = '5000000000000001'.
+
+ "50000000000001.25 asTrueFraction = (200000000000005/4).
+ 200000000000005 highBit = 48, 4 isPowerOfTwo,
+ So this number is also represented exactly as Float, it should print exactly.
+ Beware: (50000000000001.25 / 0.01) rounded exhibit the same problem as above."
+ self assert: (50000000000001.25 printShowingDecimalPlaces: 2) = '50000000000001.25'.
+
+ "This number is close to maximum float value"
+ self shouldnt: [1.0e306 printShowingDecimalPlaces: 3] raise: Error.!
Item was added:
+ ----- Method: NumberTest>>testPrintShowingDecimalPlaces3 (in category 'tests') -----
+ testPrintShowingDecimalPlaces3
+ "This problem were reported at
http://bugs.squeak.org/view.php?id=7028+ unfortunate inversion of left / right padding"
+
+ self assert: (1.009 printShowingDecimalPlaces: 3) = '1.009'.
+ self assert: (35.900 printShowingDecimalPlaces: 3) = '35.900'.
+ self assert: (-0.097 printShowingDecimalPlaces: 3) = '-0.097'.!