Levente Uzonyi uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-ul.342.mcz ==================== Summary ==================== Name: KernelTests-ul.342 Author: ul Time: 13 June 2018, 1:49:28.364651 am UUID: 978ad05c-106d-40f0-a4ce-e0af383bcd3f Ancestors: KernelTests-ul.341 Run ClassVarScopeTest in its own environment so that the different tests won't interfere with each other. They were randomly failing because of an issue unrelated to class variable scopes. =============== Diff against KernelTests-ul.341 =============== Item was changed: TestCase subclass: #ClassVarScopeTest + instanceVariableNames: 'parent child grandchild foo environment' - instanceVariableNames: 'parent child grandchild foo' classVariableNames: '' poolDictionaries: '' category: 'KernelTests-Classes'! !ClassVarScopeTest commentStamp: 'nice 7/28/2013 16:05' prior: 0! Test that a class variable defined in a superclass takes precedence over a global variable of same name. In #setUp: Three classes are defined: parent, child and grandchild. A class variable is defined in child. A global with the same name is defined in Smalltalk globals. Methods are defined in all classes getting and setting this class or global variable. Test whether methods referencing the variable with that name access the correct variable.! Item was added: + ----- Method: ClassVarScopeTest>>createClass:superClass:classVariableNames: (in category 'private') ----- + createClass: aSymbol superClass: superClass classVariableNames: aString + + ^ClassBuilder new + name: aSymbol + inEnvironment: environment + subclassOf: superClass + type: #normal + instanceVariableNames: '' + classVariableNames: aString + poolDictionaries: '' + category: 'Test'! Item was changed: + ----- Method: ClassVarScopeTest>>setUp (in category 'running') ----- - ----- Method: ClassVarScopeTest>>setUp (in category 'command') ----- setUp + environment := Environment withName: 'test'. + environment importSelf. + parent := self createClass: #ClassVarScopeParent superClass: nil classVariableNames: ''. + child := self createClass: #ClassVarScopeChild superClass: parent classVariableNames: 'ClassVarScopeFoo'. + grandchild := self createClass: #ClassVarScopeGrandchild superClass: child classVariableNames: ''. + foo := environment at: #ClassVarScopeFoo put: Object basicNew. + - parent := Object - subclass: #ClassVarScopeParent - instanceVariableNames: '' - classVariableNames: '' - poolDictionaries: '' - category: 'Dummy-Tests-Class'. - child := parent - subclass: #ClassVarScopeChild - instanceVariableNames: '' - classVariableNames: 'ClassVarScopeFoo' - poolDictionaries: '' - category: 'Dummy-Tests-Class'. - grandchild := child - subclass: #ClassVarScopeGrandchild - instanceVariableNames: '' - classVariableNames: '' - poolDictionaries: '' - category: 'Dummy-Tests-Class'. - foo := Smalltalk globals at: #ClassVarScopeFoo put: Object basicNew. - parent compileSilently: self sourceOfParentGetFoo. parent compileSilently: self sourceOfParentSetFoo. parent class compileSilently: self sourceOfParentGetFoo. parent class compileSilently: self sourceOfParentSetFoo. child compileSilently: self sourceOfChildGetFoo. child compileSilently: self sourceOfChildSetFoo. child class compileSilently: self sourceOfChildGetFoo. child class compileSilently: self sourceOfChildSetFoo. grandchild compileSilently: self sourceOfGrandchildGetFoo. grandchild compileSilently: self sourceOfGrandchildSetFoo. grandchild class compileSilently: self sourceOfGrandchildGetFoo. grandchild class compileSilently: self sourceOfGrandchildSetFoo! Item was changed: + ----- Method: ClassVarScopeTest>>tearDown (in category 'running') ----- - ----- Method: ClassVarScopeTest>>tearDown (in category 'command') ----- tearDown | classes | classes := { grandchild. child. parent }. grandchild := child := parent := nil. classes do: [ :each | each removeFromChanges; removeFromSystemUnlogged ]. + environment removeKey: #ClassVarScopeFoo ifAbsent: []! - Smalltalk globals removeKey: #ClassVarScopeFoo! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedClassMethodInChild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedClassMethodInChild (in category 'test') ----- testDefinedClassMethodInChild self assert: child childGetFoo == nil. child childSetFoo: #bar. self assert: child childGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedClassMethodInGrandchild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedClassMethodInGrandchild (in category 'test') ----- testDefinedClassMethodInGrandchild self assert: grandchild grandchildGetFoo == nil. grandchild grandchildSetFoo: #bar. self assert: grandchild grandchildGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedClassMethodInParent (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedClassMethodInParent (in category 'test') ----- testDefinedClassMethodInParent self assert: parent parentGetFoo == foo. parent parentSetFoo: #bar. self assert: parent parentGetFoo = #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInChild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInChild (in category 'test') ----- testDefinedInstanceMethodInChild self assert: child basicNew childGetFoo == nil. child basicNew childSetFoo: #bar. self assert: child basicNew childGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInGrandchild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInGrandchild (in category 'test') ----- testDefinedInstanceMethodInGrandchild self assert: grandchild basicNew grandchildGetFoo == nil. grandchild basicNew grandchildSetFoo: #bar. self assert: grandchild basicNew grandchildGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInParent (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testDefinedInstanceMethodInParent (in category 'test') ----- testDefinedInstanceMethodInParent self assert: parent basicNew parentGetFoo == foo. parent basicNew parentSetFoo: #bar. self assert: parent basicNew parentGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testInheritedClassMethodInChild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testInheritedClassMethodInChild (in category 'test') ----- testInheritedClassMethodInChild self assert: child parentGetFoo == foo. child parentSetFoo: #bar. self assert: child parentGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testInheritedClassMethodInGrandchild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testInheritedClassMethodInGrandchild (in category 'test') ----- testInheritedClassMethodInGrandchild self assert: grandchild childGetFoo == nil. grandchild childSetFoo: #bar. self assert: grandchild childGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testInheritedInstanceMethodInChild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testInheritedInstanceMethodInChild (in category 'test') ----- testInheritedInstanceMethodInChild self assert: child basicNew parentGetFoo == foo. child basicNew parentSetFoo: #bar. self assert: child basicNew parentGetFoo == #bar! Item was changed: + ----- Method: ClassVarScopeTest>>testInheritedInstanceMethodInGrandchild (in category 'tests') ----- - ----- Method: ClassVarScopeTest>>testInheritedInstanceMethodInGrandchild (in category 'test') ----- testInheritedInstanceMethodInGrandchild self assert: grandchild basicNew childGetFoo == nil. grandchild basicNew childSetFoo: #bar. self assert: grandchild basicNew childGetFoo == #bar! |
Free forum by Nabble | Edit this page |