[squeak-dev] The Inbox: KernelTests-jar.430.mcz
Jaromir Matas
mail at jaromir.net
Tue Jun 7 18:22:10 UTC 2022
Hi Eliot,
> Why not something like
| p errorUnhandled errorCaught unwindBlock |
unwindBlock := [[1/0] on: UnhandledError do: [errorUnhandled := true]].
p := [ [ [Semaphore new wait] ensure: unwindBlock ]
on: ZeroDivide
do: [errorCaught := true] ] fork.
Processor yield.
self assert: p isBlocked.
errorUnhandled := errorCaught := false.
p terminate.
self deny: errorUnhandled.
self assert: errorCaught.
self assert: p isTerminated!
yes, that's way more explicit, thanks!
> And I see no point to the unwindBlock temporary. Why not just put the code inline?
no reason, just for readability (plus I'm not sure how to nicely indent the inner nested on:do: ;) )
Thanks for checking this.
Best,
Jaromir
--
JaromÃr Matas
mail at jaromir.net
________________________________
From: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> on behalf of Eliot Miranda <eliot.miranda at gmail.com>
Sent: Tuesday, June 7, 2022 7:45:40 PM
To: The general-purpose Squeak developers list <squeak-dev at lists.squeakfoundation.org>
Subject: Re: [squeak-dev] The Inbox: KernelTests-jar.430.mcz
Hi Jaromir,
On Sun, Jun 5, 2022 at 2:11 PM <commits at source.squeak.org<mailto:commits at source.squeak.org>> wrote:
A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-jar.430.mcz
==================== Summary ====================
Name: KernelTests-jar.430
Author: jar
Time: 5 June 2022, 11:11:12.187824 pm
UUID: 209031e0-7bc5-984a-94dd-b3c3a24216c3
Ancestors: KernelTests-jar.429
Oops, fix comment in previous test KernelTests-jar.429... Sorry for the noise.
=============== Diff against KernelTests-jar.429 ===============
Item was changed:
----- Method: ProcessTest>>testTerminateHandlingUnwindError (in category 'tests') -----
testTerminateHandlingUnwindError
"Test an error inside an unwind block is handled correctly."
"Workspace example:
[ [[Processor activeProcess terminate] ensure: [1/0]] on: ZeroDivide do: [] ] fork
ZeroDivide error should get caught by the handler without opening the Debugger.
To model this example as a test case we have to keep in mind that an error signal
in one thread cannot be caught in a different thread: if process 'p' signals an error
it won't be searching for a handler in the thread that sent 'p terminate' message.
So we can't do something like:
+ p := [ [ [Semaphore new wait] ensure: [1/0] ] on: ZeroDivide do: [] ] fork.
- p := [ [ [Semaphore new wait] ensure: unwindBlock ] on: ZeroDivide do: [] ] fork.
Processor yield.
self shouldnt: [p terminate] raise: Error
Instead, in order to catch the situation the ZeroDivide error is not caught within 'p',
we try to catch the UnhandledError raised in 'p' indicating the ZeroDivide has been
missed. "
| p error unwindBlock |
unwindBlock := [[1/0] on: UnhandledError do: [error := true]].
p := [ [ [Semaphore new wait] ensure: unwindBlock ] on: ZeroDivide do: [] ] fork.
Processor yield.
self assert: p isBlocked.
error := false.
p terminate.
self deny: error.
self assert: p isTerminated!
Why not something like
| p errorUnhandled errorCaught unwindBlock |
unwindBlock := [[1/0] on: UnhandledError do: [errorUnhandled := true]].
p := [ [ [Semaphore new wait] ensure: unwindBlock ]
on: ZeroDivide
do: [errorCaught := true] ] fork.
Processor yield.
self assert: p isBlocked.
errorUnhandled := errorCaught := false.
p terminate.
self deny: errorUnhandled.
self assert: errorCaught.
self assert: p isTerminated!
? And I see no point to the unwindBlock temporary. Why not just put the code inline?
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220607/95de5d99/attachment-0001.html>
More information about the Squeak-dev
mailing list
|