[Issue 8765] New: assert should print the source code for the condition when no message argument present

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 5 20:11:47 PDT 2012


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

           Summary: assert should print the source code for the condition
                    when no message argument present
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: val at markovic.io


--- Comment #0 from Val Markovic <val at markovic.io> 2012-10-05 19:59:52 PDT ---
I'd love to see the following:

assert(5 == 4);

print out the actual source code of the condition on failure, that is
"core.exception.AssertError at foo.d(123): 5 == 4". This should happen when there
is no user-defined message (and maybe _in addition to_ the provided message).
Currently I just get "unittest failure" instead of the condition source, which
is useless.

This would make it far, far easier to track down which assert failed without
having to actually go look at the line number in the file. Also, this is what
most unit-testing libraries for other languages do already, like for example
GoogleTest for C++ etc.

Since assert() is not a function but an expression in the language, this should
not be impossible to implement, should it? GoogleTest does it with macros, but
(thank God) we don't have those in D.

-- 
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