Mantis - Squeak
Viewing Issue Advanced Details
7067 Morphic minor always 05-25-08 03:14 06-04-08 04:16
jburke71  
 
normal  
new 3.10  
open  
none    
none  
0007067: [BUG] [FIX] LedDigitMorph does not change digit state automatically.
In the new Squeak3.10-7159-basic.image, LedDigitMorph does not change its state after receiving a digit: message. You have to click on the morph before it changes. The test case is:

myDigit := LedDigitMorph new openInWorld.
myDigit digit: 2.

Could be that it was designed this way, but I thought it was annoying.
To fix this, change digit: method in LedDigitMorph

From:

digit: anInteger

    digit _ anInteger \\ 10 "make sure it stays between 0 and 9"

To:

digit: anInteger

    digit _ anInteger \\ 10. "make sure it stays between 0 and 9"
    self changed.

Notes
(0012164)
wiz   
05-25-08 19:25   
Hi jburke,

Your analysis looks right.

It would be good if you could provide the patch in the form of a fix.
(do a fileout of the corrected method and post it here).

It would also be good if you could create an sunit test. One that fails before the patch and passes afterwards.

That will help prevent the future undoing of the fix.

Cheer,

Yours in service and curiosity, --Jerome Peace

P.s. you might want to add a guard clause to insure that change happened.

If new and old digits are the same do nothing.

If led has no owner (or is invisible) no change to the display is needed.

(0012249)
jburke71   
06-03-08 18:39   
I'll see what I can do to clean this up properly and submit a patch. I'm fairly new to Squeak, so it might take me a bit. Though I'm happy to work on it (seems like a good beginners project).

Thanks for the feedback.

Jason
(0012251)
wiz   
06-04-08 04:16   
Hi Jason,

Thanks for taking up the challenge.

For the test itself you want to test that the screen gets updated.

So put an led on the screen (or two for comparison).
Get a form from the display at the led.
Update the led.
Make the world update or wait till the world updates.
Get another form from the same location.
Compare the two forms.
The unupdated form would match the updated one would not.
Or you could display a reference led with the before or after value and check the forms against that.

For setup and teardown look at the MorphicUITests. I like to put morphs I am displaying into the cases array and then have the teardown delete them.

So I subclass tests of this type under the MorphicUITests because then the setup teardown stuff is present and I don't have to duplicate it.

Look at the other tests in that class for examples.

Yours in curiosity and service, --Jerome Peace