Re: Unittest Absurdity

2022-08-05 Thread frame via Digitalmars-d-learn
On Friday, 5 August 2022 at 21:24:13 UTC, Steven Schveighoffer wrote: That's not what I was talking about here. I'm talking about `-vcg-ast` not telling you how it's calling the function. Thanks for clarification. I had that in mind but wasn't sure. I first thought it just get optimized

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/5/22 3:53 PM, frame wrote: On Friday, 5 August 2022 at 15:24:16 UTC, Steven Schveighoffer wrote: oof, I expected this to include the template parameters! I believe it normally does? This is a bug that should be filed. -Steve Sorry, I don't get what you takling about? The docs says:

Re: Unittest Absurdity

2022-08-05 Thread frame via Digitalmars-d-learn
On Friday, 5 August 2022 at 15:24:16 UTC, Steven Schveighoffer wrote: oof, I expected this to include the template parameters! I believe it normally does? This is a bug that should be filed. -Steve Sorry, I don't get what you takling about? The docs says: The expression: `a op= b` is

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/5/22 11:24 AM, Steven Schveighoffer wrote: On 8/4/22 10:27 PM, jfondren wrote:  a.opOpAssign(b);  b.opOpAssign(a); oof, I expected this to include the template parameters! I believe it normally does? It does not! I'm genuinely shocked. ```d void foo(string s, T)(T t) {} void

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/22 10:27 PM, jfondren wrote: 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);   

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
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

Re: Unittest Absurdity

2022-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/22 9:51 PM, Paul Backus wrote: On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: I found the issue:  opOpAssign isn't getting called at all.  I have no idea why, though. Given that the example works, the problem must be in some other part of your code that you

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:53:42 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } Nevermind. I have

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:51:21 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes

Re: Unittest Absurdity

2022-08-04 Thread Paul Backus via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: I found the issue: opOpAssign isn't getting called at all. I have no idea why, though. Given that the example works, the problem must be in some other part of your code that you haven't posted. If you can post a more

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs)

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } unittest { auto a = S(1),

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } unittest { auto a = S(1), b = S(2); a /= b; b /= a; assert(a.n == 2);

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:25:50 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:23:40 UTC, Ruby The Roobster wrote: [SNIP] Any function other than an operator overload seems to work fine. Also, this isn't mentioned in the spec. Additional Information: Fails for both DMD

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:23:40 UTC, Ruby The Roobster wrote: [SNIP] Any function other than an operator overload seems to work fine. Also, this isn't mentioned in the spec. Additional Information: Fails for both DMD and LDC on Windows x86_64 for dmd v2.100.1

Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
How do I get unittests to actually execute operator overloads? E.g.: ```d struct Struct { void opOpAssign(string op)(Struct rhs) //Assume that the operator `/=` is implemented here { //... } } unittest { Struct a = Struct(1); Struct b = Struct(2); a /= b;