Chris Muller uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-cmm.206.mcz ==================== Summary ==================== Name: CollectionsTests-cmm.206 Author: cmm Time: 31 August 2013, 4:34:41.685 pm UUID: 18d460d5-be23-418b-a3f0-b340b0c3e948 Ancestors: CollectionsTests-nice.205 testAsMutator test with a selector that already ends with a colon. =============== Diff against CollectionsTests-nice.205 =============== Item was changed: ----- Method: SymbolTest>>testAsMutator (in category 'tests') ----- testAsMutator + self + assert: #x asMutator = #x: ; + assert: #x: asMutator = #x: ; + assert: #x asMutator isSymbol! - - self assert: #x asMutator = #x:. - self assert: #x asMutator isSymbol! |
On 31 August 2013 22:34, <[hidden email]> wrote:
> Chris Muller uploaded a new version of CollectionsTests to project The Trunk: > http://source.squeak.org/trunk/CollectionsTests-cmm.206.mcz > > ==================== Summary ==================== > > Name: CollectionsTests-cmm.206 > Author: cmm > Time: 31 August 2013, 4:34:41.685 pm > UUID: 18d460d5-be23-418b-a3f0-b340b0c3e948 > Ancestors: CollectionsTests-nice.205 > > testAsMutator test with a selector that already ends with a colon. > > =============== Diff against CollectionsTests-nice.205 =============== > > Item was changed: > ----- Method: SymbolTest>>testAsMutator (in category 'tests') ----- > testAsMutator > + self > + assert: #x asMutator = #x: ; > + assert: #x: asMutator = #x: ; > + assert: #x asMutator isSymbol! > - > - self assert: #x asMutator = #x:. > - self assert: #x asMutator isSymbol! I've been ripping out #assert: calls in the tests and replacing them with #assert:equals: mainly because #assert:equals: produces a much nicer error message: looking at the failing test on CI will tell you how the assert failed, not just that it failed. frank |
Ok, I'll try to remember to do that next time.
On Sat, Aug 31, 2013 at 5:50 PM, Frank Shearar <[hidden email]> wrote: > On 31 August 2013 22:34, <[hidden email]> wrote: >> Chris Muller uploaded a new version of CollectionsTests to project The Trunk: >> http://source.squeak.org/trunk/CollectionsTests-cmm.206.mcz >> >> ==================== Summary ==================== >> >> Name: CollectionsTests-cmm.206 >> Author: cmm >> Time: 31 August 2013, 4:34:41.685 pm >> UUID: 18d460d5-be23-418b-a3f0-b340b0c3e948 >> Ancestors: CollectionsTests-nice.205 >> >> testAsMutator test with a selector that already ends with a colon. >> >> =============== Diff against CollectionsTests-nice.205 =============== >> >> Item was changed: >> ----- Method: SymbolTest>>testAsMutator (in category 'tests') ----- >> testAsMutator >> + self >> + assert: #x asMutator = #x: ; >> + assert: #x: asMutator = #x: ; >> + assert: #x asMutator isSymbol! >> - >> - self assert: #x asMutator = #x:. >> - self assert: #x asMutator isSymbol! > > I've been ripping out #assert: calls in the tests and replacing them > with #assert:equals: mainly because #assert:equals: produces a much > nicer error message: looking at the failing test on CI will tell you > how the assert failed, not just that it failed. > > frank > |
In reply to this post by commits-2
On Sat, 31 Aug 2013, [hidden email] wrote:
> Chris Muller uploaded a new version of CollectionsTests to project The Trunk: > http://source.squeak.org/trunk/CollectionsTests-cmm.206.mcz > > ==================== Summary ==================== > > Name: CollectionsTests-cmm.206 > Author: cmm > Time: 31 August 2013, 4:34:41.685 pm > UUID: 18d460d5-be23-418b-a3f0-b340b0c3e948 > Ancestors: CollectionsTests-nice.205 > > testAsMutator test with a selector that already ends with a colon. The previous "contract" was that the user was responsible for sending the #asMutator message to the right receiver. Let's say that "contract" is wrong. How would you fix #asMutator? Would you raise an error if the receiver is not an accessor? E.g.: self numArgs caseOf: { [ 0 ] -> [ ^(self copyWith: $:) asSymbol ] } [ 1 ] -> [ self isKeyword ifTrue: [ ^self ] ]. otherwise: [ ]. self error: 'Receiver is not an accessor.' Or just try to add a colon to the end if it's not there? E.g.: (self size > 0 and: [ (self at: self size) == $: ]) ifTrue: [ ^self ]. ^(self copyWith: $:) asSymbol Levente > > =============== Diff against CollectionsTests-nice.205 =============== > > Item was changed: > ----- Method: SymbolTest>>testAsMutator (in category 'tests') ----- > testAsMutator > + self > + assert: #x asMutator = #x: ; > + assert: #x: asMutator = #x: ; > + assert: #x asMutator isSymbol! > - > - self assert: #x asMutator = #x:. > - self assert: #x asMutator isSymbol! > > > |
The latter. Just as with other "as" methods, if it is already in the
desired state, answer it "as"-is. :) I have not yet committed it but here is the new implementation of #asMutator: asMutator "Return a setter message from a getter message. For example, #name asMutator returns #name:" ^ self last = $: ifTrue: [ self ] ifFalse: [ (self copyWith: $:) asSymbol ] The comment indicates the purpose is for converting a getter to a setter, and since a method selector cannot be empty, sending asMutator to an empty Symbol should raise an error. On Wed, Sep 4, 2013 at 10:02 AM, Levente Uzonyi <[hidden email]> wrote: > On Sat, 31 Aug 2013, [hidden email] wrote: > >> Chris Muller uploaded a new version of CollectionsTests to project The >> Trunk: >> http://source.squeak.org/trunk/CollectionsTests-cmm.206.mcz >> >> ==================== Summary ==================== >> >> Name: CollectionsTests-cmm.206 >> Author: cmm >> Time: 31 August 2013, 4:34:41.685 pm >> UUID: 18d460d5-be23-418b-a3f0-b340b0c3e948 >> Ancestors: CollectionsTests-nice.205 >> >> testAsMutator test with a selector that already ends with a colon. > > > The previous "contract" was that the user was responsible for sending the > #asMutator message to the right receiver. Let's say that "contract" is > wrong. How would you fix #asMutator? > > Would you raise an error if the receiver is not an accessor? E.g.: > > self numArgs > caseOf: { > [ 0 ] -> [ ^(self copyWith: $:) asSymbol ] } > [ 1 ] -> [ self isKeyword ifTrue: [ ^self ] ]. > otherwise: [ ]. > self error: 'Receiver is not an accessor.' > > Or just try to add a colon to the end if it's not there? E.g.: > > (self size > 0 and: [ (self at: self size) == $: ]) ifTrue: [ ^self > ]. > ^(self copyWith: $:) asSymbol > > > Levente > > >> >> =============== Diff against CollectionsTests-nice.205 =============== >> >> Item was changed: >> ----- Method: SymbolTest>>testAsMutator (in category 'tests') ----- >> testAsMutator >> + self >> + assert: #x asMutator = #x: ; >> + assert: #x: asMutator = #x: ; >> + assert: #x asMutator isSymbol! >> - >> - self assert: #x asMutator = #x:. >> - self assert: #x asMutator isSymbol! >> >> >> > |
Free forum by Nabble | Edit this page |