[Pharo-project] About testing that ensure works

Stéphane Ducasse stephane.ducasse at inria.fr
Sun Apr 24 13:26:09 CEST 2011


How can I ensure that really in case of error or not a piece of code is executed.
Now I'm totally confused by the semantics of ensure: 

So I wrote that:

testOnDo
	"self run: #testOnDo "
	
	self doOnDo: [ self error].
	self assert: x = 3.
	x := 77.
	self doOnDo: [x = 21].
	self assert: x = 3



ensure
	x := 3

doOnDo: aBlock 
	x := 5.
	[aBlock value.
	self ensure] on: Error do:  [:ex | self ensure].


More information about the Pharo-project mailing list