[squeak-dev] Squeak's AssertionFailure vs. SUnit's TestFailure

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Nov 11 21:29:13 UTC 2019

> I understand that Halt is just a way to invite users to debug programming Error, but an Error works equally well.

Related question: Why was Halt designed to behave exactly like an Error? I understand Halt as a note for a programmer to investigate something, but imho it does not indicate that something went wrong, so I would not expect it to abort the process (neglecting the fact that there is usually a debugger).

Imagine something like a ProductionToolSet (similar to the approach in https://wiki.squeak.org/squeak/6633), I would assume it should ignore Halts and should just resume. So wouldn't it be better if Halt raised an UnhandledHalt, which could be ignored by certain ToolSets? (I would even propose this behavior for the CommandLineToolSet.)

Please see the attached changeset.


Concerning AssertionFailures, I think outside of tests, this code

1 to: aCollection size do: [:index |

    aCollection remove: (aCollection at: index)].

self assert: [aCollection isEmpty].

should be broadly equivalent to

1 to: aCollection size do: [:index |

    aCollection remove: (aCollection at: index)].

aCollection isEmpty ifFalse: [

    self error: 'Internal error occurred! Collection is not empty'

    "Unless there is a programmer debugging, execution won't be continued"].

So I would agree with Marcel's proposal to derive AssertionFailure from Error.
Just a few days ago, I realized that an AssertionFaillure raised in a drawing method would damage the image, even if we catch "Error, Warning, Halt".
So it seems the right approach to me to refine the definition of exception classes instead of enumerating them at multiple different places.



Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Gesendet: Montag, 11. November 2019 21:24 Uhr
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Squeak's AssertionFailure vs. SUnit's TestFailure

Hi Marcel,
Halt is a breakpoint explicitly set in the source code.
In some way, Assertion could be viewed as conditional halt explicitly set in the source code...
However, I don't like this POV. IMO AssertionFailure should not be subclass of Halt.
Assertion failures are failure to fullfil some pre/post condition, and as such programming Error.
I understand that Halt is just a way to invite users to debug programming Error, but an Error works equally well.
Why using Halt?

Le lun. 11 nov. 2019 à 16:03, Marcel Taeumel <marcel.taeumel at hpi.de<mailto:marcel.taeumel at hpi.de>> a écrit :
Hi, there.

The Kernel package provides "AssertionFailure" through "self assert: ...".
The SUnit package provides "TestFailure" through "self assert: ..." in test cases.

AssertionFailure is a subclass of Halt.
TestFailure is a subclass of Exception.

Now, the test runner catches all errors (red) and all test failures (yellow). However, the rest runner stops working if an AssertionFailure is raised. The Decompiler can do that, for example. In that case, the user cannot easily get an overview of all non-passing tests.

Here are my questions:

- Should AssertionFailure be an Error instead of a Halt?
- Should SUnit treat "real" AssertionFailures also as errors (red)?

Find attached two changesets with two different strategies.

See TestResult >> #runCase: to see which exceptions are caught during test execution.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191111/37cd8199/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Halt is not an Error.1.cs
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191111/37cd8199/attachment-0001.ksh>

More information about the Squeak-dev mailing list