Hi folks!
Today, at work, a friend ask me about a method in TestResource because he thought it was a bug. We look at it, and for us, it could be a bug. So, I ask to you.
See TestResource class side isAvailable
------------------------ isAvailable ^self current notNil and: [self current isAvailable] ------------------------
the first part (self current notNil) ALWAYS return true because of the implementation of self current:
------------------------ current
current isNil ifTrue: [current := self new].
^current -------------------------
The second part too. Because the implementation of self available (object side method):
------------------------- isAvailable "override to provide information on the readiness of the resource"
^true -------------------------
Ok, you can override and change this method in subclasses, however, the first part is ALWAYS true.
Is this correct ? or isAvailable should be:
isAvailable ^ self current isAvailable
Thanks!
Mariano
The second part too. Because the implementation of self available (object side method):
isAvailable "override to provide information on the readiness of the resource"
^true
This method is just a place holder, if your resource (e.g. database) may not be available then it will be overridden
Ok, you can override and change this method in subclasses, however, the first part is ALWAYS true.
Is this correct ? or isAvailable should be:
isAvailable ^ self current isAvailable
I cant think of any reason why not. Except that the setter #current: is defined, implying that someone might use that to set it to nil. Therefor I would propose removing the setting and doing it your way...
in squeaksource/Testing
Name: SUnit-kph.119 Author: kph Time: 30 April 2009, 10:21:58 am UUID: 31103250-f994-4e96-aabd-139e2a331799 Ancestors: SUnit-kph.118
#isAvailable tidied Removed setter #current:
Keith
squeak-dev@lists.squeakfoundation.org