Andreas Raab uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-ar.240.mcz ==================== Summary ==================== Name: Traits-ar.240 Author: ar Time: 21 October 2009, 9:40:11 am UUID: c257e896-367f-aa4b-a63c-d50b8a863c5d Ancestors: Traits-nice.239 Tests for broken traits behavior. =============== Diff against Traits-nice.239 =============== Item was added: + ----- Method: TraitTest>>testTraitMethodSelector (in category 'testing') ----- + testTraitMethodSelector + "Tests that the #selector of a trait method isn't screwed up when aliasing traits" + | baseTrait classA methodA classB methodB traitMethod | + [baseTrait := Trait named: #TraitTestBaseTrait uses:{} category: self class category. + baseTrait compileSilently: 'traitMethod' classified: 'tests'. + traitMethod := baseTrait compiledMethodAt: #traitMethod. + self assert: traitMethod selector == #traitMethod. + + classA := Object subclass: #TraitTestMethodClassA + uses: {baseTrait @ {#methodA -> #traitMethod}} + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self class category. + methodA := classA compiledMethodAt: #methodA. + + self assert: traitMethod selector == #traitMethod. + self assert: methodA selector == #methodA. + + classB := Object subclass: #TraitTestMethodClassB + uses: {baseTrait @ {#methodB -> #traitMethod}} + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self class category. + methodB := classB compiledMethodAt: #methodB. + + + self assert: traitMethod selector == #traitMethod. + self assert: methodA selector == #methodA. + self assert: methodB selector == #methodB. + + ] ensure:[ + classA ifNotNil:[classA removeFromSystem: false]. + classB ifNotNil:[classB removeFromSystem: false]. + baseTrait ifNotNil:[baseTrait removeFromSystem: false]. + ].! Item was added: + ----- Method: TraitTest>>testTraitMethodClass (in category 'testing') ----- + testTraitMethodClass + "Tests that the #methodClass of a trait method isn't screwed up" + | baseTrait classA methodA classB methodB traitMethod | + [baseTrait := Trait named: #TraitTestBaseTrait uses:{} category: self class category. + baseTrait compileSilently: 'traitMethod' classified: 'tests'. + traitMethod := baseTrait compiledMethodAt: #traitMethod. + self assert: traitMethod methodClass == baseTrait. + + classA := Object subclass: #TraitTestMethodClassA + uses: baseTrait + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self class category. + methodA := classA compiledMethodAt: #traitMethod. + + self assert: traitMethod methodClass == baseTrait. + self assert: methodA methodClass == classA. + + classB := Object subclass: #TraitTestMethodClassB + uses: baseTrait + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self class category. + methodB := classB compiledMethodAt: #traitMethod. + + + self assert: traitMethod methodClass == baseTrait. + self assert: methodA methodClass == classA. + self assert: methodB methodClass == classB. + + ] ensure:[ + classA ifNotNil:[classA removeFromSystem: false]. + classB ifNotNil:[classB removeFromSystem: false]. + baseTrait ifNotNil:[baseTrait removeFromSystem: false]. + ].! |
Free forum by Nabble | Edit this page |