Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Paul Backus
snarwin at gmail.com
Mon Jan 11 23:42:15 UTC 2021
On Monday, 11 January 2021 at 22:28:04 UTC, jmh530 wrote:
> On Monday, 11 January 2021 at 21:33:36 UTC, Paul Backus wrote:
>> On Monday, 11 January 2021 at 21:17:20 UTC, jmh530 wrote:
>>> Of course, the typical response would be, "well why not use
>>> alias s = static array". I would ask what about an @nogc
>>> unittest where the author is trying to limit calls to
>>> functions that aren't really central to what is being tested.
>>
>> I've used std.array.staticArray for @nogc unit tests. It works
>> fine, and the fact that it has a descriptive name makes it a
>> lot more readable than something like `[1, 2, 3]s`.
>
> I know it can be used. My main point was "where the author is
> trying to limit calls to functions that aren't really central
> to what is being tested".
Yes, and my point is, staticArray is a well-tested
standard-library function with an extremely simple
implementation, so the odds of it introducing spurious faults
into a unit test are essentially zero. So even though I always
try to limit calls to unrelated functions in my unit tests, I
consider staticArray safe to use.
More information about the Digitalmars-d-announce
mailing list