Alexander Lazarević uploaded a new version of SystemChangeNotification-Tests to project The Trunk: http://source.squeak.org/trunk/SystemChangeNotification-Tests-laza.16.mcz
==================== Summary ====================
Name: SystemChangeNotification-Tests-laza.16 Author: laza Time: 3 November 2011, 8:09:52.984 am UUID: 8edbb2d9-dbf3-6d44-8e0d-941702d8f7cc Ancestors: SystemChangeNotification-Tests-laza.15
SystemOrganizer>>addCategory:before: does not trigger any notifications
=============== Diff against SystemChangeNotification-Tests-bp.11 ===============
Item was added: + TestCase subclass: #SystemChangeFileTest + instanceVariableNames: 'tempChangesFile' + classVariableNames: '' + poolDictionaries: '' + category: 'SystemChangeNotification-Tests'!
Item was added: + ----- Method: SystemChangeFileTest>>change:verify: (in category 'testing') ----- + change: changeBlock verify: verifyBlock + self prepare: [] change: changeBlock verify: verifyBlock!
Item was added: + ----- Method: SystemChangeFileTest>>createClass: (in category 'private') ----- + createClass: name + ^Object + subclass: name + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: self genericClassCategory!
Item was added: + ----- Method: SystemChangeFileTest>>directory (in category 'accessing') ----- + directory + "Where we want to place the temporary changes file" + ^FileDirectory default!
Item was added: + ----- Method: SystemChangeFileTest>>genericClassCategory (in category 'private') ----- + genericClassCategory + ^(self prefixClassCategory, self randomString capitalized) asSymbol!
Item was added: + ----- Method: SystemChangeFileTest>>genericClassName (in category 'private') ----- + genericClassName + ^(self prefixClassName, self randomString capitalized) asSymbol!
Item was added: + ----- Method: SystemChangeFileTest>>genericInstVarName (in category 'private') ----- + genericInstVarName + ^(self prefixInstVarName, self randomString capitalized) asSymbol!
Item was added: + ----- Method: SystemChangeFileTest>>genericProtocol (in category 'private') ----- + genericProtocol + ^(self prefixProtocol, self randomString) asSymbol!
Item was added: + ----- Method: SystemChangeFileTest>>genericSelector (in category 'private') ----- + genericSelector + ^(self prefixSelector, self randomString capitalized) asSymbol!
Item was added: + ----- Method: SystemChangeFileTest>>prefixClassCategory (in category 'private') ----- + prefixClassCategory + ^self prefixGeneral, 'Category-'!
Item was added: + ----- Method: SystemChangeFileTest>>prefixClassName (in category 'private') ----- + prefixClassName + ^self prefixGeneral, 'Class'!
Item was added: + ----- Method: SystemChangeFileTest>>prefixGeneral (in category 'private') ----- + prefixGeneral + ^self class name select: [:each | each isUppercase]!
Item was added: + ----- Method: SystemChangeFileTest>>prefixInstVarName (in category 'private') ----- + prefixInstVarName + ^self prefixGeneral asLowercase, 'InstVar'!
Item was added: + ----- Method: SystemChangeFileTest>>prefixProtocol (in category 'private') ----- + prefixProtocol + ^self prefixGeneral asLowercase, ' protocol '!
Item was added: + ----- Method: SystemChangeFileTest>>prefixSelector (in category 'private') ----- + prefixSelector + ^self prefixGeneral asLowercase, 'Selector'!
Item was added: + ----- Method: SystemChangeFileTest>>prepare:change:verify: (in category 'testing') ----- + prepare: prepareBlock change: changeBlock verify: verifyBlock + "All tests follow this pattern. Beware that prepareBlock (and verifyBlock) will be evalutated twice." + + "Setup the testcourt" + prepareBlock value. + + "Embrace the changeBlock so that any changes to our testcourt + gets recorded in our temporary changes file" + self useTemporaryChangesFile. + changeBlock value. + "Check if the changes we made worked as expected. We need to do + this before we switch back to the standard changes file" + "We raise an Error if this fails, because then the testcase is broken" + [verifyBlock value] + on: TestFailure + do: [self error: 'The verifyBlock needs to validate the changes made in the changeBlock']. + self useStandardChangesFile. + + "Remove the testcourt completely" + self removeTestcourt. + + "Setup the testcourt once again" + prepareBlock value. + + "Replay the changes from the temporary changes file" + self replayChanges. + + "See if we got the same changes as we did before using the changeBlock" + verifyBlock value. + !
Item was added: + ----- Method: SystemChangeFileTest>>randomString (in category 'private') ----- + randomString + ^Character alphabet shuffled!
Item was added: + ----- Method: SystemChangeFileTest>>removeTestcourt (in category 'private') ----- + removeTestcourt + SystemOrganization categories do: [:each | + (each beginsWith: self prefixClassCategory) ifTrue: [ + SystemOrganization removeSystemCategory: each. + ]. + ]. + + !
Item was added: + ----- Method: SystemChangeFileTest>>replayChanges (in category 'private') ----- + replayChanges + | file | + file := FileStream fileNamed: (self directory fullNameFor: self tempChangesName). + Transcript show: file contents; cr. + file fileIn. + !
Item was added: + ----- Method: SystemChangeFileTest>>tearDown (in category 'running') ----- + tearDown + self useStandardChangesFile. + tempChangesFile := tempChangesFile ifNotNil: [tempChangesFile close]. + (self directory fileExists: self tempChangesName) + ifTrue: [self directory deleteFileNamed: self tempChangesName]. + self removeTestcourt. + !
Item was added: + ----- Method: SystemChangeFileTest>>tempChangesName (in category 'accessing') ----- + tempChangesName + ^'temp.changes'!
Item was added: + ----- Method: SystemChangeFileTest>>testCategoryAdded (in category 'testing') ----- + testCategoryAdded + | aClassCategory | + aClassCategory := self genericClassCategory. + self + change: [ + SystemOrganization addCategory: aClassCategory. + ] + verify: [ + self assert: (SystemOrganization categories includes: aClassCategory). + ] + !
Item was added: + ----- Method: SystemChangeFileTest>>testCategoryAddedBefore (in category 'testing') ----- + testCategoryAddedBefore + | aClassCategory | + aClassCategory := self genericClassCategory. + self + change: [ + SystemOrganization addCategory: aClassCategory before: nil. + ] + verify: [ + self assert: (SystemOrganization categories includes: aClassCategory). + ] + !
Item was added: + ----- Method: SystemChangeFileTest>>testCategoryModified (in category 'as yet unclassified') ----- + testCategoryModified!
Item was added: + ----- Method: SystemChangeFileTest>>testCategoryRemoved (in category 'testing') ----- + testCategoryRemoved + | aClassCategory | + aClassCategory := self genericClassCategory. + self + prepare: [ + SystemOrganization addCategory: aClassCategory. + ] + change: [ + SystemOrganization removeCategory: aClassCategory. + ] + verify: [ + self deny: (SystemOrganization categories includes: aClassCategory). + ] + !
Item was added: + ----- Method: SystemChangeFileTest>>testCategoryRenamed (in category 'testing') ----- + testCategoryRenamed + | aNewClassCategory anOldClassCategory | + anOldClassCategory := self genericClassCategory. + aNewClassCategory := self genericClassCategory. + self + prepare: [ + SystemOrganization addCategory: anOldClassCategory. + ] + change: [ + SystemOrganization renameCategory: anOldClassCategory toBe: aNewClassCategory + ] + verify: [ + self assert: (SystemOrganization categories includes: aNewClassCategory). + self deny: (SystemOrganization categories includes: anOldClassCategory). + ] + !
Item was added: + ----- Method: SystemChangeFileTest>>testClassAdded (in category 'testing') ----- + testClassAdded + | aClassName | + aClassName := self genericClassName. + self + change: [ + self createClass: aClassName. + ] + verify: [ + self assert: (Smalltalk keys includes: aClassName). + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testClassCommented (in category 'testing') ----- + testClassCommented + | aClass aClassName aComment | + aClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aComment := self randomString. + aClass classComment: aComment. + ] + verify: [ + self assert: aClass organization classComment string = aComment. + ].!
Item was added: + ----- Method: SystemChangeFileTest>>testClassModified (in category 'testing') ----- + testClassModified + | aClass aClassName aInstVarName | + aClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aInstVarName := self genericInstVarName. + aClass addInstVarName: aInstVarName. + ] + verify: [ + self assert: (aClass instVarNames includes: aInstVarName). + ].!
Item was added: + ----- Method: SystemChangeFileTest>>testClassRecategorized (in category 'as yet unclassified') ----- + testClassRecategorized!
Item was added: + ----- Method: SystemChangeFileTest>>testClassRemoved (in category 'testing') ----- + testClassRemoved + | aClass aClassName | + aClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aClass removeFromSystem. + ] + verify: [ + self deny: (Smalltalk keys includes: aClassName). + ]. + !
Item was added: + ----- Method: SystemChangeFileTest>>testClassRenamed (in category 'testing') ----- + testClassRenamed + | aClass aNewClassName anOldClassName | + anOldClassName := self genericClassName. + aNewClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: anOldClassName. + ] + change: [ + aClass rename: aNewClassName. + ] + verify: [ + self assert: (Smalltalk keys includes: aNewClassName). + self deny: (Smalltalk keys includes: anOldClassName). + ].!
Item was added: + ----- Method: SystemChangeFileTest>>testClassReorganized (in category 'as yet unclassified') ----- + testClassReorganized!
Item was added: + ----- Method: SystemChangeFileTest>>testExpressionDoIt (in category 'testing') ----- + testExpressionDoIt + | aClassName | + aClassName := self genericClassName.. + self + prepare: [ + self createClass: aClassName. + ] + change: [ + Compiler evaluate: '(Smalltalk at: ', aClassName storeString, ') removeFromSystem'. + ] + verify: [ + self deny: (Smalltalk keys includes: aClassName). + ].!
Item was added: + ----- Method: SystemChangeFileTest>>testMethodAdded (in category 'testing') ----- + testMethodAdded + | aClassName aClass aSelector | + aClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aSelector := self genericSelector. + aClass compile: aSelector. + ] + verify: [ + self assert: (aClass methodDict keys includes: aSelector). + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testMethodModified (in category 'testing') ----- + testMethodModified + | aClassName aClass aSelector aMethodSource | + aClassName := self genericClassName. + aSelector := self genericSelector. + self + prepare: [ + aClass := self createClass: aClassName. + aClass compile: aSelector, ' ', self randomString storeString. + ] + change: [ + aMethodSource := aSelector, ' ', self randomString storeString. + aClass compile: aMethodSource. + ] + verify: [ + self assert: (aClass sourceCodeAt: aSelector) string = aMethodSource. + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testMethodRecategorized (in category 'testing') ----- + testMethodRecategorized + | aClassName aClass aNewProtocol aSelector anOldProtocol | + aClassName := self genericClassName. + aSelector := self genericSelector. + anOldProtocol := self genericProtocol. + self + prepare: [ + aClass := self createClass: aClassName. + aClass compile: aSelector classified: anOldProtocol. + ] + change: [ + aNewProtocol := self genericProtocol. + aClass organization classify: aSelector under: aNewProtocol. + ] + verify: [ + self assert: (aClass organization categoryOfElement: aSelector) = aNewProtocol + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testMethodRemoved (in category 'testing') ----- + testMethodRemoved + | aClassName aClass aSelector | + aClassName := self genericClassName. + aSelector := self genericSelector. + self + prepare: [ + aClass := self createClass: aClassName. + aClass compile: aSelector. + ] + change: [ + aClass removeSelector: aSelector. + ] + verify: [ + self deny: (aClass methodDict keys includes: aSelector). + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testProtocolAdded (in category 'testing') ----- + testProtocolAdded + | aClassName aClass aProtocol | + aClassName := self genericClassName. + aProtocol := self genericProtocol. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aClass organization addCategory: aProtocol. + ] + verify: [ + self assert: (aClass organization categories includes: aProtocol) + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testProtocolDefault (in category 'testing') ----- + testProtocolDefault + | aClassName aClass aSelector | + aClassName := self genericClassName. + self + prepare: [ + aClass := self createClass: aClassName. + ] + change: [ + aSelector := self genericSelector. + aClass compile: aSelector. + ] + verify: [ + self assert: (aClass organization categoryOfElement: aSelector) = aClass organization class default. + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testProtocolModified (in category 'as yet unclassified') ----- + testProtocolModified!
Item was added: + ----- Method: SystemChangeFileTest>>testProtocolRemoved (in category 'testing') ----- + testProtocolRemoved + | aClassName aClass aProtocol | + aClassName := self genericClassName. + aProtocol := self genericProtocol. + self + prepare: [ + aClass := self createClass: aClassName. + aClass organization addCategory: aProtocol. + ] + change: [ + aClass organization removeCategory: aProtocol. + ] + verify: [ + self deny: (aClass organization categories includes: aProtocol) + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>testProtocolRenamed (in category 'testing') ----- + testProtocolRenamed + | aClassName aClass anOldProtocol aNewProtocol | + aClassName := self genericClassName. + anOldProtocol := self genericProtocol. + self + prepare: [ + aClass := self createClass: aClassName. + aClass organization addCategory: anOldProtocol. + ] + change: [ + aNewProtocol := self genericProtocol. + aClass organization renameCategory: anOldProtocol toBe: aNewProtocol. + ] + verify: [ + self deny: (aClass organization categories includes: anOldProtocol). + self assert: (aClass organization categories includes: aNewProtocol). + ] + + !
Item was added: + ----- Method: SystemChangeFileTest>>useStandardChangesFile (in category 'private') ----- + useStandardChangesFile + Smalltalk + closeSourceFiles; + openSourceFiles!
Item was added: + ----- Method: SystemChangeFileTest>>useTemporaryChangesFile (in category 'private') ----- + useTemporaryChangesFile + Smalltalk closeSourceFiles. + tempChangesFile := self directory forceNewFileNamed: self tempChangesName. + SourceFiles at: 2 put: tempChangesFile!
squeak-dev@lists.squeakfoundation.org