[Newbies] Creating a SUnit Test for A Morphic Object

Jason Burke burkej71 at gmail.com
Tue Jun 3 18:35:05 UTC 2008


Hello All,

I'm new to the list here, and I have a question on creating SUnit tests for
Morphs. In my latest bi-annual "Squeak Peek", something clicked that hadn't
in the past 3 years of periodically checking into Squeak: It started to make
sense (I usually give up in frustration after a week or so, but the, "Squeak
by Example" book has really helped this time. Kudos to the writers).

So, I started digging around in the Morphic classes, and I stumbled across,
what appeared to be, a bug in LedDigitMorph. I played around with it until I
felt satisfied that it was indeed a bug, and then submitted a report to
bugs.squeak.org. The powers that be agreed that this looked like a bug, and
asked me to do a little more footwork on it (I had submitted my fix with the
report). However, I'm not quite sure how to accomplish what was requested.

Here's the bug (mantis ID: 0007067), and a test case:

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.

The morph will not show the number 2 until you click on it.

I solved this bug in my image by changing the digit: message to this:

digit: anInteger

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

The response I got back asked me to create a SUnit test for this issue (One
that fails before the patch and passes afterwards).

Unfortunately, I'm not sure how to do this (though I'd be happy to continue
to work on it). Can someone give me some guidance on how to go about
creating SUnit test cases for this Morphic object?

Thanks,

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080603/efd05673/attachment.htm


More information about the Beginners mailing list