'From Squeak3.3alpha of 15 February 2002 [latest update: #4817] on 1 April 2002 at 12:20:15 pm'! "Change Set: MthFinder-tk Date: 1 April 2002 Author: Ted Kaehler Add the selectors #asWords and #threeDigitName to the list that the MethodFinder uses. -125 asWords 'negative one hundred twenty-five' It used to say 'a negative three', so I removed the 'a ' from the front. Had to fix the SUnit test case for TestRunner in Integer also."! !Collection class methodsFor: 'examples' stamp: 'tk 4/1/2002 11:32'! exampleFor: aSelector "Provide a MethodCall with a valid example of aSelector, ready to run. If 'all', provide all tests we know about for SUnit tests. When 'all', each will be a Verifier, with an expected answer. Returns a list of MethodCalls, Verifiers, or VerifierOfPropertys." | doAll list kind joe mc kindIfTestingState sel | doAll _ (aSelector class == String) and: [aSelector = 'all']. list _ OrderedCollection new. kind _ doAll ifFalse: [MethodCall] ifTrue: [Verifier]. kindIfTestingState _ doAll ifFalse: [MethodCall] ifTrue: [VerifierOfProperty]. joe _ Array with: 5 with: 6 with: 0 with: -3. (sel _ #collect:) == aSelector | doAll ifTrue: [ list add: (mc _ kind receiver: joe copy selector: sel argument: [:element | element odd]). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: {true. false. false. true}]]. (sel _ #select:) == aSelector | doAll ifTrue: [ list add: (mc _ kind receiver: joe copy selector: sel argument: [:element | element < 4]). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: #(0 -3)]]. (sel _ #detect:) == aSelector | doAll ifTrue: [ list add: (mc _ kind receiver: (joe copy) selector: sel argument: [:element | element asWords beginsWith: 's']). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: 6]]. (sel _ #asSortedArray) == aSelector | doAll ifTrue: [ list add: (mc _ kind receiver: (joe copy) selector: sel). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: #(-3 0 5 6)]]. (sel _ #sum) == aSelector | doAll ifTrue: [ list add: (mc _ kind receiver: joe copy selector: sel). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: 8]]. (sel _ #asSortedCollection:) == aSelector | doAll ifTrue: [ list add: (mc _ kindIfTestingState receiver: (joe copy) selector: sel argument: [:aa :bb | aa asWords < bb asWords]). "mc get methodInterface" doAll ifTrue: [mc desiredAnswer: #none. mc theTest: ((Verifier receiver: #answer selector: #asArray) desiredAnswer: #(5 -3 6 0))]]. ^ list! ! !Integer methodsFor: 'printing' stamp: 'tk 4/1/2002 11:30'! asWords "SmallInteger maxVal asWords" | mils minus three num answer milCount | self = 0 ifTrue: [^'zero']. mils _ #('' ' thousand' ' million' ' billion' ' trillion' ' quadrillion' ' quintillion' ' sextillion' ' septillion' ' octillion' ' nonillion' ' decillion' ' undecillion' ' duodecillion' ' tredecillion' ' quattuordecillion' ' quindecillion' ' sexdecillion' ' septendecillion' ' octodecillion' ' novemdecillion' ' vigintillion'). num _ self. minus _ ''. self < 0 ifTrue: [ minus _ 'negative '. num _ num negated. ]. answer _ String new. milCount _ 1. [num > 0] whileTrue: [ three _ (num \\ 1000) threeDigitName. num _ num // 1000. three isEmpty ifFalse: [ answer isEmpty ifFalse: [ answer _ ', ',answer ]. answer _ three,(mils at: milCount),answer. ]. milCount _ milCount + 1. ]. ^minus,answer! ! !MethodFinder methodsFor: 'initialize' stamp: 'tk 4/1/2002 11:33'! initialize3 "additional selectors to consider" #(asWords threeDigitName ) do: [:sel | Approved add: sel].! ! "Postscript: If you have been using the MethodFinder, reinitialize it." (MethodFinder classPool at: #Approved) ifNotNil: [MethodFinder new initialize]. !