Eliot Miranda uploaded a new version of SUnit to project The Trunk:
http://source.squeak.org/trunk/SUnit-eem.91.mcz ==================== Summary ==================== Name: SUnit-eem.91 Author: eem Time: 5 February 2013, 9:45:22.157 pm UUID: 563010a6-5bbc-4312-ae7c-b09410b24fad Ancestors: SUnit-cmm.90 Robust testCase printing. i.e. TestCase new asString should not raise an error. =============== Diff against SUnit-cmm.90 =============== Item was changed: ----- Method: TestCase>>printOn: (in category 'printing') ----- printOn: aStream + testSelector + ifNil: [super printOn: aStream] + ifNotNil: + [aStream + nextPutAll: self class printString; + nextPutAll: '>>#'; + nextPutAll: testSelector] ! - aStream - nextPutAll: self class printString; - nextPutAll: '>>#'; - nextPutAll: testSelector - ! |
Wouldn't it be better to use #print:?
E.g.: aStream print: self class; nextPutAll: '>>'; print: testSelector Levente On Wed, 6 Feb 2013, [hidden email] wrote: > Eliot Miranda uploaded a new version of SUnit to project The Trunk: > http://source.squeak.org/trunk/SUnit-eem.91.mcz > > ==================== Summary ==================== > > Name: SUnit-eem.91 > Author: eem > Time: 5 February 2013, 9:45:22.157 pm > UUID: 563010a6-5bbc-4312-ae7c-b09410b24fad > Ancestors: SUnit-cmm.90 > > Robust testCase printing. i.e. TestCase new asString should > not raise an error. > > =============== Diff against SUnit-cmm.90 =============== > > Item was changed: > ----- Method: TestCase>>printOn: (in category 'printing') ----- > printOn: aStream > > + testSelector > + ifNil: [super printOn: aStream] > + ifNotNil: > + [aStream > + nextPutAll: self class printString; > + nextPutAll: '>>#'; > + nextPutAll: testSelector] ! > - aStream > - nextPutAll: self class printString; > - nextPutAll: '>>#'; > - nextPutAll: testSelector > - ! > > > |
Kent Beck makes a case for using #print: in his Reversing Method
pattern on page 33 of the original "Smalltalk Best Practice Patterns", but the basis for that is to avoid having messages going to different receivers on every line. If Eliot had used self class printOn: aStream. aStream nextPutAll: '>>#'. testSelector printOn: aStream then Kents argument would apply. However, since Eliot has a nice cascaded flow of messages all going to the same receiver, the Reversing Method isn't necessary. Having said that, I normally prefer not to send #printString to any object inside a printOn: method -- since that object should just be able to print itself on the stream. So I think print: would be nicer: aStream print: self class; print: '>>#'; print: testSelector BUT, having said THAT, the caveat with #print: comes with Strings and Characters -- that they print the syntax punctuation; strings surrounded by single-quotes and Characters prefixed with '$' rather than simply printing the contents like nextPutAll:. - Chris |
On Wed, 6 Feb 2013, Chris Muller wrote:
> Kent Beck makes a case for using #print: in his Reversing Method > pattern on page 33 of the original "Smalltalk Best Practice Patterns", > but the basis for that is to avoid having messages going to different > receivers on every line. > > If Eliot had used > > self class printOn: aStream. > aStream nextPutAll: '>>#'. > testSelector printOn: aStream > > then Kents argument would apply. However, since Eliot has a nice > cascaded flow of messages all going to the same receiver, the > Reversing Method isn't necessary. > > Having said that, I normally prefer not to send #printString to any > object inside a printOn: method -- since that object should just be > able to print itself on the stream. So I think print: would be nicer: > > aStream > print: self class; > print: '>>#'; > print: testSelector > > BUT, having said THAT, the caveat with #print: comes with Strings and > Characters -- that they print the syntax punctuation; strings > surrounded by single-quotes and Characters prefixed with '$' rather > than simply printing the contents like nextPutAll:. Um, yeah. That's why I used #nextPutAll: and '>>'. The last #print: will print the #, if testSelector is a symbol. And there's no need for quotes around >>. Levente > > - Chris > > |
Free forum by Nabble | Edit this page |