On 07/15/2010 05:32 PM, Michel Fortin wrote:

Le 2010-07-15 à 18:00, Walter Bright a écrit :

4. DESIRED: assert is NOT hacked, any failing assert ends the current unittest, 
the failure message is printed, execution continues with the next unittest, 
program ends with error code if at least one assert failed, everybody's happy.

Everybody's happy except the guys like me who want to run all the unit tests in 
one go.

I think this is the root of the misunderstanding. Either you consider each 
assert grouped in a unittest blocks to be a unit test in itself; or you 
consider each unittest block to be a test with multiple possible points of 
failure across the path of the test.

The former is best illustrated this way:

        unittest {
                assert(sqrt(16) == 4);
                assert(sqrt(4) == 2);
                assert(sqrt(1) == 1);
        }

There's one more problem with this, which should be discussed - an assert inside e.g. sqrt or any function that sqrt transitively calls _does_ stop the entire thing. So assert has different semantics depending on locus, which I hope we agree is not a desirable trait. Also, as you mentioned, if someone throws, we're again back to a different semantics.

I think there's a disadvantage there. FWIW changing the semantics of assert that way will translate into a disincentive to use it inside unittests ("Hmm, I better use enforce() here because assert() is just weird.")


Andrei
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to