Cover handler for a statement or a block of statements.
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jun 8 12:09:17 PDT 2011
On 2011-06-08 12:06, vincent wrote:
> Cover handler for a statement or a block of statements.
>
> I would like to suggest a method for defining code statement
> covering. Some examp1es of a cover are as follows :-
> - try ... finally - this is defined in dotnet as a using
> - try ... (catch)+
> - cursor save and display others ... restore saved cursor
>
> a possible syntax -
>
> cover hourglass(Application &app)
> {
> Cursor save = app.cursor;
> app.cursor = HOURGLASS_CURSOR;
> ~ code ~
> app.cursor = save;
> }
>
> usage could be something like -
>
> void function(Application &app)
> {
> hourglass(app)
> {
> ... // code to be run by cover
> }
> }
That would typically be done with either a struct with a destructor or with a
scope statement.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list