strange code in RBRefactoringTest
hi, Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp assoc := RBRefactoringManager classPool associationAt: #Instance ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance']. manager := assoc value. Thanks, Christophe
I'd say that it looks like a "bug ward". But I think the system should not contain right now classpools with string keys. They should all be symbols. (Smalltalk allClasses gather: [ :class | class classPool keys ]) select: [ :k | k isSymbol not ] should be an empty collection. So you probably can replace those three lines by: manager := Instance. ? Guille El mié., 27 de may. de 2015 a la(s) 9:46 a. m., Christophe Demarey < christophe.demarey@inria.fr> escribió:
hi,
Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp
assoc := RBRefactoringManager classPool associationAt: #Instance ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance']. manager := assoc value.
Thanks, Christophe
On 27 May 2015, at 09:46, Christophe Demarey <christophe.demarey@inria.fr> wrote:
hi,
Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp
assoc := RBRefactoringManager classPool associationAt: #Instance ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance']. manager := assoc value.
I guess someone wanted to reset the class var without adding a #reset method. There is #nuke, though: nuke Instance notNil ifTrue: [ Instance release ]. Instance := nil maybe the test does not want to call #release? The reflective API was improved in the meantime, you can just do RBRefactoringManagerclassVarNamed: âInstance' put: nil. Marcus
Le 27 mai 2015 à 09:55, Marcus Denker a écrit :
On 27 May 2015, at 09:46, Christophe Demarey <christophe.demarey@inria.fr> wrote:
hi,
Does anyone knows if there is a particular reason to write this kind of code (snippet from RBRefactoringTest>>setUp
assoc := RBRefactoringManager classPool associationAt: #Instance ifAbsent: [RBRefactoringManager classPool associationAt: 'Instance']. manager := assoc value.
I guess someone wanted to reset the class var without adding a #reset method.
There is #nuke, though:
nuke Instance notNil ifTrue: [ Instance release ]. Instance := nil
maybe the test does not want to call #release?
The reflective API was improved in the meantime, you can just do
RBRefactoringManagerclassVarNamed: âInstance' put: nil.
Marcus
ok, thanks
participants (4)
-
Christophe Demarey -
Christophe Demarey -
Guillermo Polito -
Marcus Denker