Version française
Home     About     Download     Resources     Contact us    
Browse thread
Exceptions inside assertions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <Gerd.Stolpmann@d...>
Subject: Exceptions inside assertions
Hi, 

I have a problem with exceptions which are raised within the expression of an
assertion, e.g.

assert (raise Not_found)

The current behaviour is that the exception "falls through the assertion" which
may not be appropriate for some cases. For example, consider

assert (Queue.peek queue == current_element)

>From my point of view, the assertion expresses that "queue" has at least one
element and that this element is identical to "current_element". But if the
assertion is violated because the queue is empty, I only get a Queue.Empty
exception, and I do not see the reason for it. Perhaps I even catch
Queue.Empty, and the program continues, which is very hard to find out.

I suggest to introduce a new Assert_failure_by_exception exception to better
report this situation.

Gerd
--
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   Gerd.Stolpmann@darmstadt.netsurf.de (privat)
Germany                     
----------------------------------------------------------------------------