[squeak-dev] The Trunk: KernelTests-dtl.175.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 28 02:49:16 UTC 2011


David T. Lewis uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-dtl.175.mcz

==================== Summary ====================

Name: KernelTests-dtl.175
Author: dtl
Time: 27 February 2011, 9:48:28.704 pm
UUID: 8b527a84-abff-42c1-96d6-845975beff75
Ancestors: KernelTests-ul.174

Add test to document Float>>printPaddedWith:To: bug reported on http://lists.gforge.inria.fr/pipermail/pharo-users/2011-February/001569.html.

=============== Diff against KernelTests-ul.174 ===============

Item was added:
+ ----- Method: FloatTest>>testPrintPaddedWithTo (in category 'printing') -----
+ testPrintPaddedWithTo
+ 	"This bug was reported in http://lists.gforge.inria.fr/pipermail/pharo-users/2011-February/001569.html.
+ 	The problem was caused by treating the format specifier as a number rather than
+ 	as a string, such the the number may be a Float subject to floating point rounding
+ 	errors. The solution to treat the format specifier as a string, and extract the integer
+ 	fields before and after the decimal point in the string."
+ 
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.2) = '01.00'].
+ 	self assert: [(1.0 printPaddedWith: $X to: 2.2) = 'X1.0X'].
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2) = '01.0'].
+ 	self assert: [(12345.6789 printPaddedWith: $0 to: 2) = '12345.6789'].
+ 	self assert: [(12345.6789 printPaddedWith: $0 to: 2.2) = '12345.6789'].
+ 	self assert: [(12.34 printPaddedWith: $0 to: 2.2) = '12.34'].
+ 	self assert: [(12345.6789 printPaddedWith: $0 to: 2.2) = '12345.6789'].
+ 	self assert: [(123.456 printPaddedWith: $X to: 4.4) = 'X123.456X'].
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.1) = '01.0'].
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.2) = '01.00'].
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.3) = '01.000']. "previously failed due to float usage"
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.4) = '01.0000']. "previously failed due to float usage"
+ 	self assert: [(1.0 printPaddedWith: $0 to: 2.5) = '01.00000']
+ 
+ !




More information about the Squeak-dev mailing list