Chris Muller uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-cmm.348.mcz ==================== Summary ==================== Name: KernelTests-cmm.348 Author: cmm Time: 29 August 2018, 5:54:41.347658 pm UUID: 684f3fdd-c6e7-4fbd-a467-5836ba630909 Ancestors: KernelTests-eem.347 Added test which exposes a bug in detection of duplicate inst-var names in class hierarchies. =============== Diff against KernelTests-eem.347 =============== Item was changed: ClassTestCase subclass: #ClassBuilderTest + instanceVariableNames: 'baseClass subClass baseClass2 subSubClass' - instanceVariableNames: 'baseClass subClass' classVariableNames: '' poolDictionaries: '' category: 'KernelTests-Classes'! Item was changed: ----- Method: ClassBuilderTest>>cleanup (in category 'utilities') ----- cleanup + subSubClass ifNotNil:[subSubClass removeFromSystem]. subClass ifNotNil:[subClass removeFromSystem]. baseClass ifNotNil:[baseClass removeFromSystem]. + baseClass2 ifNotNil: [baseClass2 removeFromSystem]. (Smalltalk organization listAtCategoryNamed: self categoryNameForTemporaryClasses) isEmpty ifTrue: [Smalltalk organization removeCategory: self categoryNameForTemporaryClasses]! Item was added: + ----- Method: ClassBuilderTest>>subSubClassName (in category 'utilities') ----- + subSubClassName + ^#DummyClassBuilderFormatTestSubSubClass! Item was changed: ----- Method: ClassBuilderTest>>testDuplicateInstanceVariableError (in category 'testing - reshape') ----- testDuplicateInstanceVariableError + | didRaise | + "Define 'var' in a superclass." + baseClass := Object + subclass: self baseClassName - baseClass := Object subclass: self baseClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' category: self categoryNameForTemporaryClasses. + "Ensure trying to define a subclass with same var errors." + didRaise := false. + [baseClass subclass: self subClassName - - self should:[ - subClass := baseClass subclass: self subClassName instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses ] + on: DuplicateVariableError do: + [ : err | + didRaise := true. + self assert: err superclass == baseClass. + self assert: err variable = 'var' ]. + self assert: didRaise. + "Prepare for next test: Remove 'var' from superclass." + baseClass := Object + subclass: self baseClassName - category: self categoryNameForTemporaryClasses - ] raise: DuplicateVariableError. - - [subClass := baseClass subclass: self subClassName - instanceVariableNames: 'var' - classVariableNames: '' - poolDictionaries: '' - category: self categoryNameForTemporaryClasses - ] on: DuplicateVariableError do:[:ex| - self assert: ex superclass == baseClass. - self assert: ex variable = 'var'. - ex resume. - ]. - - baseClass := Object subclass: self baseClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: self categoryNameForTemporaryClasses. + "Define a subclass without 'var'..." + subClass := baseClass + subclass: self subClassName + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self categoryNameForTemporaryClasses. + "... but with a subclass of THAT, with 'var' defined." + subSubClass := subClass subclass: self subSubClassName + instanceVariableNames: 'var' + classVariableNames: '' + poolDictionaries: '' + category: self categoryNameForTemporaryClasses. + "... as well as a different base class with 'var' already defined..." + baseClass2 := Object + subclass: (self baseClassName,'2') asSymbol + instanceVariableNames: 'var' + classVariableNames: '' + poolDictionaries: '' + category: self categoryNameForTemporaryClasses. + "...and now try to move the middle subClass, whose subclass (a.k.a., subSubClass) defines 'var', to the new baseClass which also defines 'var'." + didRaise := false. + [baseClass2 subclass: self subClassName + instanceVariableNames: '' - - self should:[ - baseClass := Object subclass: self baseClassName - instanceVariableNames: 'var' classVariableNames: '' poolDictionaries: '' + category: self categoryNameForTemporaryClasses ] + on: DuplicateVariableError do: + [ : err | + didRaise := true. + self assert: err superclass == baseClass2. + self assert: err variable = 'var' ]. + self assert: didRaise! - category: self categoryNameForTemporaryClasses. - ] raise: DuplicateVariableError. - - [baseClass := Object subclass: self baseClassName - instanceVariableNames: 'var' - classVariableNames: '' - poolDictionaries: '' - category: self categoryNameForTemporaryClasses. - ] on: DuplicateVariableError do:[:ex| - self assert: ex superclass == baseClass. - self assert: ex variable = 'var'. - ex resume. - ].! |
Free forum by Nabble | Edit this page |