I hate class destructors with a burning passion
Tim
tim.dlang at t-online.de
Thu Jun 10 17:32:58 UTC 2021
On Thursday, 10 June 2021 at 12:07:34 UTC, Kagamin wrote:
>
> I'd say, lower assert failures in contracts to a different
> function, say, _d_contractFailed(), which can do a different
> thing, say, throw ContractError, and child contract can catch
> only this specific ContractError instead of any Error.
This could also enable a different use case: Testing functions
with random inputs, but ignoring failures for invalid inputs.
void randomTest(alias F)()
{
while(true)
{
Parameters!F args;
generateRandomArgs!(args);
try
{
F(args);
}
catch(ContractError)
{
// Ignore
}
catch(Exception)
{
// Ignore
}
}
}
This could find bugs, where an assert or bounds check fails in
the function.
More information about the Digitalmars-d
mailing list