digitalmars.D.bugs - [Issue 10026] New: Allow to assert that exception must be thrown
- d-bugmail puremagic.com (27/27) May 03 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10026
- d-bugmail puremagic.com (11/11) May 03 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10026
- d-bugmail puremagic.com (12/12) May 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10026
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 puremagic.com ReportedBy: stpasha gmail.com 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: -------
May 03 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10026 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc See: http://dlang.org/phobos/std_exception.html -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 03 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10026 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich gmail.com Resolution| |WONTFIX 03:54:18 PDT --- Use assertThrown and assertNotThrown from std.exception. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 04 2013