Unittest Absurdity

jfondren julian.fondren at gmail.com
Fri Aug 5 02:27:53 UTC 2022


On Friday, 5 August 2022 at 02:20:31 UTC, Steven Schveighoffer 
wrote:
> On 8/4/22 9:51 PM, Paul Backus wrote:
> Another option: use -vcg-ast, and have the compiler tell you 
> what it's actually calling. It's not ignoring that line, it's 
> just not doing what you think it's doing.

The output's not that useful...

```d
import object;
struct S
{
	int n;
	void opOpAssign(string op)(S rhs) if (op == "/=")
	{
		n++;
	}
	void opOpAssign(string op)(S rhs) if (op == "/")
	{
	}
}
unittest
{
	S a = S(1);
	S b = S(2);
	a.opOpAssign(b);
	b.opOpAssign(a);
	assert(a.n == 2);
	assert(b.n == 3);
}
...
```

With this tiny example code it's clear by the end when there's 
only this one template instantiation:

```d
opOpAssign!"/"
{
	pure nothrow @nogc @safe void opOpAssign(S rhs)
	{
	}

}
```


More information about the Digitalmars-d-learn mailing list