[Issue 10026] New: Allow to assert that exception must be thrown

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 3 18:55:10 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10026

           Summary: Allow to assert that exception must be thrown
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: druntime
        AssignedTo: nobody at puremagic.com
        ReportedBy: stpasha at gmail.com


--- Comment #0 from Pasha S <stpasha at gmail.com> 2013-05-03 18:55:02 PDT ---
I'd like to suggest that existing syntax for assert() keyword was enhanced in
order to allow detection of exception thrown by the expression provided. It may
look like this:

    assert!(DivisionByZero)( powermod(2, 1000, 0) );
    assert!(InvalidArgument)( fastsqrt(-42) );

(or it may look otherwise, I'm not really an expert in language syntax).

The reason for such functionality to exist is that "assert" is used for
unit-testing of a class or module. Correct handling of errors is part of the
specification of any non-trivial class, and the "D way" to handle errors is by
throwing exceptions. Which current assert cannot test.

What do you think?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list