On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote:
[...]

The docs say it should work:

https://dlang.org/spec/betterc.html#unittests

[...]

Thank you for the link, can confirm that:
```
int foo() {

   return 4;
}

unittest {

   assert(foo() != 4, "!= Assert triggered.");
   assert(foo() == 4, "== Assert triggered.");
}

extern(C) void main()
{
static foreach(u; __traits(getUnitTests, __traits(parent, main)))
        u();
}
```
run via:
```
dmd -betterC -unittest -i -run foo2
```
works as expected.


However, as a suggestion to create a consistent experience with 'Full D', should not the combination of '-main' and '-betterC' cause the generation
and attachment of the boilerplate code
```
extern(C) void main()
{
static foreach(u; __traits(getUnitTests, __traits(parent, main)))
        u();
}
```
to a source file containing just the original function and it's unittests?

  • Re: unittest und... ryuukk_ via Digitalmars-d-learn
    • Re: unittes... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: uni... ryuukk_ via Digitalmars-d-learn
        • Re:... DLearner via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... ryuukk_ via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
            • ... Mike Parker via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
            • ... Mike Parker via Digitalmars-d-learn
            • ... DLearner via Digitalmars-d-learn
            • ... Ernesto Castellotti via Digitalmars-d-learn
            • ... DLearner via Digitalmars-d-learn

Reply via email to