SmallNic: A simple result
Stephane Ducasse
ducasse at iam.unibe.ch
Sat Feb 15 17:53:44 UTC 2003
Hi all
We were coding a bit with hannes during the smallNic organized at
Berne. I showed to hannes
that tests can be used as documentation. I wnated to shared that with
the other documenters.
Here are two tests:
testColorOfButtonIsGivenByWindow
"(self selector: #testColorOfButtonIsGivenByWindow) run"
"this test shows that if a button is embedded into a window using
addMorph:frame:
it gets the color of the window"
| window button |
window := SystemWindow labelled: 'Test Window'.
window setWindowColor: Color orange.
button := PluggableButtonMorph
on: nil
getState: nil
action: #doItAction.
button label: 'Do It'.
button color: Color blue.
self assert: button color = Color blue.
window
addMorph: button
frame: (0.0 @ 0 extent: 0.25 @ 0.1).
window openInWorld.
self deny: button color = Color blue.
window delete
testColorOfButtonIsNotGivenByWindow
"(self selector: #testColorOfButtonIsNotGivenByWindow) run"
"this test shows that if a button is embedded into another
morph, it does not get the color of the window"
| window button rectangle |
rectangle := RectangleMorph new.
window := SystemWindow labelled: 'Test Window'.
window setWindowColor: Color orange.
button := PluggableButtonMorph
on: nil
getState: nil
action: #doItAction.
button label: 'Do It'.
button color: Color blue.
self assert: button color = Color blue.
rectangle addMorph: button.
window
addMorph: rectangle
frame: (0.0 @ 0 extent: 0.25 @ 0.1).
window openInWorld.
self assert: button color = Color blue.
window delete
Stef
Prof. Dr. Stéphane DUCASSE (ducasse at iam.unibe.ch)
http://www.iam.unibe.ch/~ducasse/
"if you knew today was your last day on earth, what would you do
different? ... especially if, by doing something different, today
might not be your last day on earth" Calvin&Hobbes
More information about the Squeak-dev
mailing list
|