Frank Shearar uploaded a new version of Tests to project The Trunk:
http://source.squeak.org/trunk/Tests-fbs.227.mcz ==================== Summary ==================== Name: Tests-fbs.227 Author: fbs Time: 29 June 2013, 10:23:04.332 pm UUID: 72ba076d-3256-9247-84d5-083b821bf818 Ancestors: Tests-fbs.226 MethodReferenceTest belongs with the other System-Support tests. =============== Diff against Tests-fbs.226 =============== Item was added: + ClassTestCase subclass: #MethodReferenceTest + instanceVariableNames: 'env' + classVariableNames: '' + poolDictionaries: '' + category: 'Tests-System-Support'! Item was added: + ----- Method: MethodReferenceTest>>createClass: (in category 'private') ----- + createClass: aSymbol + | builder | + builder := ClassBuilder new. + ^ builder + name: aSymbol + inEnvironment: env + subclassOf: Object + type: #normal + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'Test'.! Item was added: + ----- Method: MethodReferenceTest>>setUp (in category 'running') ----- + setUp + | g p | + env := Environment named: 'test'. + g := self createClass: #Griffle. + p := self createClass: #Plonk. + g compile: 'foo ^ 1'. + g organization classify: #foo under: #accessing. + g class compile: 'classFoo ^ 1'. + g compile: 'bar ^ 1'. + p compile: 'foo ^ 2'. + self createClass: #Unused.! Item was added: + ----- Method: MethodReferenceTest>>testActualClassIsScopedToEnvironment (in category 'tests') ----- + testActualClassIsScopedToEnvironment + | mref | + mref := MethodReference class: (env at: #Griffle) selector: #foo environment: env. + self assert: (env at: #Griffle) equals: mref actualClass.! Item was added: + ----- Method: MethodReferenceTest>>testCanReferToMethodInSpecificEnvironment (in category 'tests') ----- + testCanReferToMethodInSpecificEnvironment + | mref | + mref := MethodReference class: self class selector: #testReferencedEnvironmentDefaultsToSmalltalkGlobals environment: env. + self assert: env equals: mref environment.! Item was added: + ----- Method: MethodReferenceTest>>testCategory (in category 'tests') ----- + testCategory + | mref | + mref := MethodReference class: (env at: #Griffle) selector: #foo environment: env. + self assert: #accessing equals: mref category.! Item was added: + ----- Method: MethodReferenceTest>>testEquals (in category 'Running') ----- + testEquals + | aMethodReference anotherMethodReference | + aMethodReference := MethodReference new. + anotherMethodReference := MethodReference new. + "Two fresh instances should be equals between them" + self assert: MethodReference new equals: MethodReference new. + self assert: MethodReference new hash equals: MethodReference new hash. + + "Two instances representing the same method (same class and + same selector) should be equals" + self assert: (MethodReference class: String selector: #foo) equals: (MethodReference class: String selector: #foo). + self assert: (MethodReference class: String selector: #foo) hash equals: (MethodReference class: String selector: #foo) hash.! Item was added: + ----- Method: MethodReferenceTest>>testNotEquals (in category 'Running') ----- + testNotEquals + self + deny: (MethodReference class: String selector: #foo) = (MethodReference class: String class selector: #foo) + description: 'Different classes, same selector -> no more equals'. + self + deny: (MethodReference class: String selector: #foo) = (MethodReference class: String selector: #bar) + description: 'Same class, different selectors -> no more equals'.! Item was added: + ----- Method: MethodReferenceTest>>testReferencedEnvironmentDefaultsToSmalltalkGlobals (in category 'tests') ----- + testReferencedEnvironmentDefaultsToSmalltalkGlobals + | mref | + mref := MethodReference class: self class selector: #testReferencedEnvironmentDefaultsToSmalltalkGlobals. + self assert: Smalltalk globals equals: mref environment.! |
Free forum by Nabble | Edit this page |