Thread overview
setuptime
May 10
monkyyy
May 10

Unittests can have side effects, most yall will say this is a bug to use but every once in a while Im tempted.

It would mean requiring a user to pass a flag tho and you now are dependent on unit tests passing all the time. Unit tests could be duplicated under another keyword or colored.

File myconfig;
int getconfigdetail(){
  assert(myconfig.isopen);
  return 3;
}
void main(){
  int detail=getconfigdetail();
}

setuptime{//unittest{
  myconfig=File(myconfig);
}
unittest{
  assert(1==0);
}

In the above code the myconfig file would be properly opened at "unittest time" without passing the -unittest flag and then getting a failing program from the bad unit test. Eliminating the trade offs, and unclear use of the feature.

May 11

On Saturday, 10 May 2025 at 17:22:09 UTC, monkyyy wrote:

>

Unittests can have side effects, most yall will say this is a bug to use but every once in a while Im tempted.

It would mean requiring a user to pass a flag tho and you now are dependent on unit tests passing all the time. Unit tests could be duplicated under another keyword or colored.

[...]

In the above code the myconfig file would be properly opened at "unittest time" without passing the -unittest flag and then getting a failing program from the bad unit test. Eliminating the trade offs, and unclear use of the feature.

We have this already; it's called static this.

May 22
On 5/11/2025 2:38 AM, Paul Backus wrote:
> We have this already; it's called `static this`.

Yes, that should do it.