Mantis - Squeak
Viewing Issue Advanced Details
6666 Collections minor always 09-09-07 13:30 09-10-07 00:25
JTS  
 
normal  
new 3.10  
open  
none    
none  
0006666: Bugs in String>>#withoutTrailingDigits
StringTest>>#testWithoutTrailingDigits

       self assert: ' 1abc23' withoutTrailingDigits2 = ' 1abc'.
    self assert: '123 ' withoutTrailingDigits2 = ''.
    self assert: 'abc ' withoutTrailingDigits2 = 'abc'.
    self assert: '' withoutTrailingDigits = ''

This test will fail:

        self assert: ' 1abc23' withoutTrailingDigits2 = ' 1abc'.

It returns an empty string instead.
This will past the tests:

withoutTrailingDigits2

    "Answer the portion of the receiver that precedes any trailing series of digits and blanks. If the receiver consists entirely of digits and blanks, return an empty string"

    | firstDigit |
    firstDigit := (self findLast: [:each | each isDigit not and: [(each = Character space) not]]).
    ^ firstDigit > 0
        ifTrue:
            [self copyFrom: 1 to: firstDigit]
        ifFalse:
            ['']

Notes
(0011103)
wiz   
09-10-07 00:25   
Cool,

Please submit code and tests as uploads.

That will help testing and speed harvesting.

Yours in curiosity and service, --Jerome Peace