Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Assertions


NAME

Assertions - event handling for failed assertions

SYNOPSIS

TYPE Identifier = ARRAY 32 OF CHAR;
TYPE Event = POINTER TO EventRec;
TYPE EventRec =
   RECORD
      (Events.EventRec)
      object: RelatedEvents.Object;
      module: Identifier;
      proc: Identifier;
   END;
TYPE EventType = POINTER TO EventTypeRec;
TYPE EventTypeRec = RECORD (Events.EventTypeRec) END;


VAR failedAssertion: Events.EventType;

PROCEDURE Define(VAR type: Events.EventType; module: ARRAY OF CHAR); PROCEDURE Raise(object: RelatedEvents.Object; type: Events.EventType; proc: ARRAY OF CHAR; text: ARRAY OF CHAR);

DESCRIPTION

Assertions generates events for failed assertions. These events are intended for programming errors either in the library or the calling module.

Define creates an event type for the given module and should be called during initialization time. Initially, the priority is set to Priorities.assertions.

Raise raises failedAssertion with priority Priority.assertions. Further, an event of the given type is passed to RelatedEvents. Both events contain all paramters of Raise and the module identifier which has been passed to Define. By default, failedAssertion is ignored.

SEE ALSO

Events
error handling if object = NIL
RelatedEvents
error handling if object # NIL

BUGS

Assertions is now obsolete due to new standard procedure ASSERT of the Oberon programming language. Therefore it is recommended to replace constructions like
IF (* failure detected? *) THEN
   Assertions.Raise(...);
END;
by
ASSERT( ~(* failure detected? *) );
ASSERT calls in case of failures RTErrors.FailedAssertion which, in turn, raises an event of the type RTErrors.error[RTErrors.assertion] (see RTErrors).
Edited by: borchert, last change: 2003/07/10, revision: 1.3, converted to HTML: 2003/07/10

Oberon || Library || Module Index || Search Engine || Definition || Module