Levente Uzonyi uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-ul.309.mcz==================== Summary ====================
Name: KernelTests-ul.309
Author: ul
Time: 2 April 2016, 9:23:24.449569 pm
UUID: c82a8276-ad4f-4219-9205-826357bcf0b7
Ancestors: KernelTests-cmm.308
Extracted #testDecimalDigitLength from SmallIntegerTest >> #testPrintString, and added a few extra cases to it.
=============== Diff against KernelTests-cmm.308 ===============
Item was added:
+ ----- Method: SmallIntegerTest>>testDecimalDigitLength (in category 'testing - printing') -----
+ testDecimalDigitLength
+
+ | x length random |
+ "Test edge cases"
+ x := 1.
+ length := 1.
+ [ x <= SmallInteger maxVal ] whileTrue: [
+ self
+ assert: length equals: x decimalDigitLength;
+ assert: (length - 1 max: 1) equals: (x - 1) decimalDigitLength.
+ x := x * 10.
+ length := length + 1 ].
+ "A few values by hand"
+ #(
+ 0 1
+ 4 1
+ 12 2
+ 123 3
+ 1234 4
+ 56789 5
+ 657483 6
+ 6571483 7
+ 65174383 8
+ 625744831 9
+ 1000001111 10
+ ), {
+ SmallInteger maxVal. Smalltalk wordSize = 8 ifTrue: [ 19 ] ifFalse: [ 10 ]
+ } groupsDo: [ :input :expectedOutput |
+ self assert: expectedOutput equals: input decimalDigitLength ].
+ "Pseudorandom tests."
+ random := Random seed: 36rSqueak.
+ 10000 timesRepeat: [
+ x := SmallInteger maxVal atRandom: random.
+ self assert: x asString size equals: x decimalDigitLength ]!
Item was changed:
----- Method: SmallIntegerTest>>testPrintString (in category 'testing - printing') -----
testPrintString
+
self assert: 1 printString = '1'.
self assert: -1 printString = '-1'.
self assert: SmallInteger minVal printString = (Smalltalk wordSize = 8 ifTrue: [ '-1152921504606846976'] ifFalse: ['-1073741824']).
self assert: SmallInteger maxVal printString = (Smalltalk wordSize = 8 ifTrue: [ '1152921504606846975'] ifFalse: ['1073741823']).
self assert: 12345 printString = '12345'.
+ self assert: -54321 printString = '-54321'!
- self assert: -54321 printString = '-54321'.
-
- self assert: 0 decimalDigitLength = 1.
- self assert: 4 decimalDigitLength = 1.
- self assert: 12 decimalDigitLength = 2.
- self assert: 123 decimalDigitLength = 3.
- self assert: 1234 decimalDigitLength = 4.
- self assert: 56789 decimalDigitLength = 5.
- self assert: 657483 decimalDigitLength = 6.
- self assert: 6571483 decimalDigitLength = 7.
- self assert: 65174383 decimalDigitLength = 8.
- self assert: 625744831 decimalDigitLength = 9.
- self assert: 1000001111 decimalDigitLength = 10.
- self assert: SmallInteger maxVal decimalDigitLength = (Smalltalk wordSize = 8 ifTrue: [19] ifFalse: [10]).!