unittest behaviour

DLearner bmqazwsx123 at gmail.com
Tue Dec 17 19:16:55 UTC 2024


On Sunday, 15 December 2024 at 20:30:21 UTC, monkyyy wrote:
> On Sunday, 15 December 2024 at 08:45:22 UTC, DLearner wrote:
>>
>> I appreciate this behaviour matches the docs (so not a bug), 
>> but is it desirable?
>
> yes, the alternative would be that unittests attempt to undo 
> themselves, and that would make bugs horrible horrible bugs or 
> executable clear global scope and stack effectively restarting 
> the program, this could be incredibly slow if you have big 
> arrays in global scope and then hundards of small unrelated 
> unittests(which btw you do, the std has plenty and I think the 
> run time also injects some)

What is wrong with changing the specification of unittest so that 
it recompiles/reexecutes the associated source on every unittest 
{} block?

That way, there would be no alteration in behaviour if the source 
was 'pure', but you would have flexibility if you wanted to test 
source that was (intentionally) 'stateful'.




More information about the Digitalmars-d-learn mailing list