sunitExitWith:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

sunitExitWith:

Steve Alan Waring
Hi,

In the package "SUnitPreload", Exception>>sunitExitWith: is implemented to
send #exit:

In the SUnitPreload packages I have been using in D4, it is implemented to
send: #return:.

I have a vague memory of Blair changing this method to use #return: when
SUnit3 was released, but I can not find the message. In any case, it causes
problems for tests involving resumable exceptions.

Thanks,
Steve Waring


Reply | Threaded
Open this post in threaded view
|

Re: sunitExitWith:

Blair McGlashan
"Steve Waring" <[hidden email]> wrote in message
news:[hidden email]...

> Hi,
>
> In the package "SUnitPreload", Exception>>sunitExitWith: is implemented to
> send #exit:
>
> In the SUnitPreload packages I have been using in D4, it is implemented to
> send: #return:.
>
> I have a vague memory of Blair changing this method to use #return: when
> SUnit3 was released, but I can not find the message. In any case, it
causes
> problems for tests involving resumable exceptions.

Sorry, don't recall that one Steve. We did patch #sunitSignalWith: (which
was erroneously using #signalWith: in place of #signal:), but looking back
through our SCCS there doesn't seem to be any relevant history.

Actually it is not entirely clear cut whether #return: or #exit: should be
used, but certainly #return: looks more correct as you suggest. For those
that don't know, #return: always returns its argument value from the handler
without resuming the try-block, whereas #exit: will either #resume: or
#return: depending on whether the exception it is sent to is resumable.
Obviously notifications and warnings are resumable, but so are some Errors
such as MessageNotUnderstood, therefore the use of #exit: to terminate the
try-block in SUnit will not work for MNU errors (for example).

Perhaps Joseph could comment?

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: sunitExitWith:

Blair McGlashan
"Blair McGlashan" <[hidden email]> wrote in message
news:[hidden email]...
> "Steve Waring" <[hidden email]> wrote in message
> news:[hidden email]...
> > Hi,
> >
> > In the package "SUnitPreload", Exception>>sunitExitWith: is implemented
to
> > send #exit:
> >
> > In the SUnitPreload packages I have been using in D4, it is implemented
to
> > send: #return:.
> >...

I've attached Joseph's comments below. I must apologize to him because he
sent me them some days ago and they have been languishing in my inbox ever
since.

My summary:
- The intended behaviour he outlines for Debug is certainly not the way it
works in the Dolphin port of SUnit at present (and I'm not sure I would want
it like that myself as I prefer to see the error immediately and then
'restart' the frame if necessary, though this does require that the tests be
restartable without running tearDown/setUp again)
- #halt handling seems OK already.
- Still not entirely sure about the resumable exceptions: Yes they should be
resumably, but should they be resumed? I don't think SUnit should be
resuming Errors (as opposed to Warnings or Notifications) if the application
(or tests) did not explicitly do that. I have therefore changed it to
#return: as per Steve's suggestion.

We should be able to standardize the behaviour of #sunitExitWith: across all
ports, since this is one area in which the ANSI standard is particularly
complete and precise, and (as reasoned above) I suspect it should be
implemented in terms of the ANSI #return: message.

Regards

Blair

------------------------------

From: "Joseph Pelrine" <[hidden email]>
To: <[hidden email]>
Subject: sunitExitWith:
Date: 20 March 2002 14:46

HI Blair

Sorry, but I'm on the road, and can't easily post to the newsgroup. Please
feel free to prune, censor, and post my comments as you see fit.

AFAIK, Beck never exactly stated the expected behavior upon hitting a test
failure or error. It was also unclear to us when we started the
CampSmalltalk SUnit project. For this reason, there are still a few ugly
differences in behaviour between dialects - especially wrt what happens
when you hit "Debug".

I don't have time to try out the various options, but I feel that the goal
should be that
- "Debug" puts you in the debugger IN the test method at the beginning.
- putting "self halt" in a test method should bring up the debugger even
during test time.
- resumable exceptions should be resumable.

Use whichever exception handling variants that allow you to do that.

Cheers
--
Joseph Pelrine
MetaProg GmbH
Email: [hidden email]
Web:   http://www.metaprog.com

"Inheritance was invented at 2 AM between January 5th and 6th, 1967" -
Krysten Nygaard