Sean Kelly wrote:

I think the current behavior is a good first step, but should probably be 
modified a bit further.  For example:

    void fnA()
    {
        assert( false, "fnA 1" );
        assert( false, "fnA 2 ");
    }

    unittest
    {
        assert( false, "unittest 1" );
        assert( false, "unittest 2" );
        fnA();
    }

    unittest
    {
        assert( false, "unittest 3" );
    }

    void main()
    {
}

Running this will print:

    test.d(9): unittest 1
    test.d(10): unittest 2
    [email protected](3): fnA 1

So if an assert error occurs inside some code being tested, the app will still 
exit.

No, if an assert occurs lexically outside of a unittest block, the regular assert failure code will be called.

  I tried modifying the unit testing code to eat the exception and continue, 
but then it simply prints:

    test.d(9): unittest 1
    test.d(10): unittest 2

So the best we can currently do is move on to test another module--there's no 
way to execute the remaining unit tests within the module.  Could we perhaps 
have an array of unittests within the ModuleInfo struct instead of just a 
single function pointer?  Or is the rationale really that if implementation 
code throws, the app should assume it's in an invalid state and exit?

It's simpler than that. The idea is if an assert fails within a unittest block, the unittests should continue. If an assert fails outside, then the app should stop.

_______________________________________________
dmd-internals mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-internals

Reply via email to