Andreas Raab uploaded a new version of TraitsTests to project The Trunk:
http://source.squeak.org/trunk/TraitsTests-ar.5.mcz ==================== Summary ==================== Name: TraitsTests-ar.5 Author: ar Time: 2 February 2010, 8:32:10.854 pm UUID: 2837d2ee-bcc0-4f41-9a71-274f2f6b6143 Ancestors: TraitsTests-ul.4 Improve Traits tests: - Remove a duplicate test - Extend the superclass change test so that it covers the problems encountered with ClassBuilder usage - Add an extra reshape test to avoid side-effects due to superclass involvement in previos test =============== Diff against TraitsTests-ul.4 =============== Item was changed: ----- Method: PureBehaviorTest>>testChangeSuperclass (in category 'testing-applying trait composition') ----- testChangeSuperclass "self run: #testChangeSuperclass" "Test that when the superclass of a class is changed the non-local methods of the class sending super are recompiled to correctly store the new superclass." | aC2 newSuperclass | aC2 := self c2 new. "C1 is current superclass of C2" self assert: aC2 m51. self assert: self c2 superclass == self c1. self deny: (self c2 localSelectors includes: #m51). + self deny: (self c2 >> #m52) == (self t5 >> #m52). "no sharing!!" + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo). + + "change superclass of C2 from C1 to X" newSuperclass := self createClassNamed: #X superclass: Object uses: {}. newSuperclass subclass: self c2 name uses: self c2 traitComposition instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: self c2 category. self assert: self c2 superclass == newSuperclass. newSuperclass compile: 'foo ^17'. self assert: aC2 m51 = 17. self deny: (self c2 localSelectors includes: #m51). self c2 compile: 'm51 ^19'. self assert: aC2 m51 = 19. self deny: (self c2 >> #m52) == (self t5 >> #m52). "no sharing!!" + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo m51). + "change superclass of C2 back to C1" + self c1 + subclass: self c2 name + uses: self c2 traitComposition + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self c2 category. + + self assert: (aC2 m51 = 19). + self assert: self c2 superclass == self c1. + self assert: (self c2 localSelectors includes: #m51). + self deny: (self c2 >> #m52) == (self t5 >> #m52). "no sharing!!" + + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo m51). + ! - ! Item was added: + ----- Method: PureBehaviorTest>>testReshapeClass (in category 'testing-applying trait composition') ----- + testReshapeClass + "self run: #testReshapeClass" + + "Ensure that reshaping a class has no impact on its traits" + + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo). + + self c2 addInstVarName: 'foobar'. + + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo). + + self c2 removeInstVarName: 'foobar'. + + self assert: self c2 traitCompositionString = 'T5 - {#m11}'. + self assert: self c2 selectors sort = #(bar foo m12 m13 m21 m22 m51 m52 m53). + self assert: self c2 localSelectors sort = #(bar foo). + ! Item was removed: - ----- Method: TraitsTestCase>>testChangeSuperclass (in category 'testing-applying trait composition') ----- - testChangeSuperclass - "self run: #testChangeSuperclass" - - "Test that when the superclass of a class is changed the non-local methods - of the class sending super are recompiled to correctly store the new superclass." - - | aC2 newSuperclass | - aC2 := self c2 new. - - "C1 is current superclass of C2" - self assert: aC2 m51. - self assert: self c2 superclass == self c1. - self deny: (self c2 localSelectors includes: #m51). - - "change superclass of C2 from C1 to X" - newSuperclass := self createClassNamed: #TraitsTestX superclass: Object uses: {}. - newSuperclass - subclass: self c2 name - uses: self c2 traitComposition - instanceVariableNames: '' - classVariableNames: '' - poolDictionaries: '' - category: self c2 category. - - self assert: self c2 superclass == newSuperclass. - - newSuperclass compile: 'foo ^17'. - self assert: aC2 m51 = 17. - self deny: (self c2 localSelectors includes: #m51). - - self c2 compile: 'm51 ^19'. - self assert: aC2 m51 = 19. - - "no sharing!!" - self deny: (self c2 >> #m52) == (self t5 >> #m52).! |
Free forum by Nabble | Edit this page |