2016-01-12 0:40 GMT+01:00 Vincent BLONDEAU < vincent.blond...@polytech-lille.net>:
> Hi, > > > > It is expected. > > When you evaluate a block with a return, the method containing the block > definition (here testBlock) will return. > > So the test will pass. > > > > BTW, you don’t need to put a return in a block. By default, the last > instruction will be returned. > > > [ ^ 1 ] => non local return [ 1 ] => local return The 2 blocks are very different from each other. One returns to the closure activation sender, while the other returns to the closure creating context sender. See the chapter 14.4 Returning from inside a Block from the free book Deep Into Pharo <http://deepintopharo.com/> So I would not say you don't need to put a return in a block. You want to put a return or not depending on the behavior you want. > Cheers, > > Vincent > > > > *From:* Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] *On > Behalf Of *abdelghani ALIDRA > *Sent:* mardi 12 janvier 2016 00:26 > *To:* Any Question About Pharo Is Welcome > *Subject:* [Pharo-users] Failling Tests are green if BlockCannotReturn > exception > > > > Hi, > > > > I observed this unexpected behavior in test classes. > > In a test class define a method : > > > > > > > > *testBlock |aBlock| aBlock := [ ^1 ]. aBlock value. self > assert: false.* > > > > Althought the assertion is false at the end of the test, the test is green. > > Actually, It does not matter what you put after *aBlock value*, the test > always succedes (I tried to put a self halt, it does not execute) > > I tried this both in Pharo 4 and 5 under Windows and MacOS. > > > > Any ideas? > > > > Cheers > > Abdelghani > > > > >