Oct. 29, 2009
6:37 a.m.
2009/10/27 Niko Schwarz <niko.schwarz@googlemail.com>
The example discussed above would read in code as follows:
EGExample subclass: #ForExampleStack â¦
shouldBeEmpty "Create the empty stack" | stack | stack := Stack new. stack should be isEmpty. stack size should = 0. ^ stack
shouldPushElement "Push one element" | stack | stack := self given: #shouldBeEmpty.
I'd suggest this to be: stack := self given: [self shouldBeEmpty]. This way it's easier to follow what happenning, and refactoring can be applied.
stack push: 42. stack should not be isEmpty. stack size should = 1. stack top should = 42. ^ stack
-- Dennis Schetinin