Re: Ah, simple solution to unittests inside templates

2016-09-22 Thread Nick Treleaven via Digitalmars-d
On Sunday, 18 September 2016 at 12:16:54 UTC, Andrei Alexandrescu wrote: I don't see that as much of a hurdle seeing as any template written has a few "obvious" types it'll work with. To encapsulate that if needed: struct Awesome(A, B, C) { private enum ut = is(A == int) && is(B == int)

Re: Ah, simple solution to unittests inside templates

2016-09-19 Thread H. S. Teoh via Digitalmars-d
On Mon, Sep 19, 2016 at 09:02:05AM -0700, H. S. Teoh via Digitalmars-d wrote: > On Sat, Sep 17, 2016 at 01:22:52PM -0400, Andrei Alexandrescu via > Digitalmars-d wrote: > > Recall the discussion a few days ago about unittests inside templates > > being instantiated with the template. Often that's

Re: Ah, simple solution to unittests inside templates

2016-09-19 Thread H. S. Teoh via Digitalmars-d
On Sat, Sep 17, 2016 at 01:22:52PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: > Recall the discussion a few days ago about unittests inside templates > being instantiated with the template. Often that's desirable, but > sometimes not - for example when you want to generate nice ddoc >

Re: Ah, simple solution to unittests inside templates

2016-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/18/16 8:14 AM, Andrei Alexandrescu wrote: On 9/18/16 6:00 AM, Jonathan M Davis via Digitalmars-d wrote: Yes. That's DIP 82: http://wiki.dlang.org/DIP82 I need to go over it again and then introduce it into the new DIP process. But I really think that that's where we should go to fix this

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Sunday, September 18, 2016 20:11:56 Andrei Alexandrescu via Digitalmars-d wrote: > Understood. I don't want anyone to get furious later on account of my > sugarcoating things, so let me say this: I'm likely to oppose such a > proposal. Walter and I have similar design sensibilities so he's

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrei Alexandrescu via Digitalmars-d
On 09/18/2016 04:29 PM, Jonathan M Davis via Digitalmars-d wrote: On Sunday, September 18, 2016 08:14:47 Andrei Alexandrescu via Digitalmars-d wrote: On 9/18/16 6:00 AM, Jonathan M Davis via Digitalmars-d wrote: Yes. That's DIP 82: http://wiki.dlang.org/DIP82 I need to go over it again and

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Monday, September 19, 2016 01:55:58 Timon Gehr via Digitalmars-d wrote: > On 18.09.2016 22:10, Jonathan M Davis via Digitalmars-d wrote: > > In > > this case, a non-static unittest block would be compiled into each > > template > > intsantiation, whereas a static one would be compiled once per

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Timon Gehr via Digitalmars-d
On 18.09.2016 22:52, Jonathan M Davis via Digitalmars-d wrote: On Sunday, September 18, 2016 13:10:36 Jonathan M Davis via Digitalmars-d wrote: On Sunday, September 18, 2016 08:02:47 Andrei Alexandrescu via Digitalmars-d wrote: On 9/17/16 5:23 PM, Andrej Mitrovic wrote: I think at some point

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Timon Gehr via Digitalmars-d
On 18.09.2016 22:10, Jonathan M Davis via Digitalmars-d wrote: On Sunday, September 18, 2016 08:02:47 Andrei Alexandrescu via Digitalmars-d wrote: > On 9/17/16 5:23 PM, Andrej Mitrovic wrote: > > I think at some point someone suggested we could implement explicit > > support for such unittests

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Sunday, September 18, 2016 13:10:36 Jonathan M Davis via Digitalmars-d wrote: > On Sunday, September 18, 2016 08:02:47 Andrei Alexandrescu via Digitalmars-d > wrote: > > On 9/17/16 5:23 PM, Andrej Mitrovic wrote: > > > I think at some point someone suggested we could implement explicit > > > >

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Sunday, September 18, 2016 08:14:47 Andrei Alexandrescu via Digitalmars-d wrote: > On 9/18/16 6:00 AM, Jonathan M Davis via Digitalmars-d wrote: > > Yes. That's DIP 82: > > > > http://wiki.dlang.org/DIP82 > > > > I need to go over it again and then introduce it into the new DIP process. > >

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Sunday, September 18, 2016 08:02:47 Andrei Alexandrescu via Digitalmars-d wrote: > On 9/17/16 5:23 PM, Andrej Mitrovic wrote: > > I think at some point someone suggested we could implement explicit > > support for such unittests via `static unittest`: > That suggests the unittest shall be

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrej Mitrovic via Digitalmars-d
On Sunday, 18 September 2016 at 12:02:47 UTC, Andrei Alexandrescu wrote: That suggests the unittest shall be evaluated during compilation. -- Andrei Nah, static is already quite overloaded and needs context to understand what it does. For example module constructors. Anyway compiler

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrei Alexandrescu via Digitalmars-d
On 09/18/2016 09:01 AM, John Colvin wrote: What would be really good would be to have a way to make ddoc associate a unittest with a particular symbol, regardless of location. Though there are many ways in which we could be better, I really think we're good. See e.g.

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread John Colvin via Digitalmars-d
On Sunday, 18 September 2016 at 12:02:47 UTC, Andrei Alexandrescu wrote: On 9/17/16 5:23 PM, Andrej Mitrovic wrote: I think at some point someone suggested we could implement explicit support for such unittests via `static unittest`: That suggests the unittest shall be evaluated during

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrei Alexandrescu via Digitalmars-d
On 9/18/16 6:23 AM, Nick Treleaven wrote: Besides the other comments, we still have to instantiate Awesome!int somewhere for the tests to run, which could be forgotten or improperly done, failing silently. (Also int is arbitrary, unhelpful for the uninitiated). I don't see that as much of a

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrei Alexandrescu via Digitalmars-d
On 9/18/16 6:00 AM, Jonathan M Davis via Digitalmars-d wrote: Yes. That's DIP 82: http://wiki.dlang.org/DIP82 I need to go over it again and then introduce it into the new DIP process. But I really think that that's where we should go to fix this problem. Just a thought: things that we can't

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Andrei Alexandrescu via Digitalmars-d
On 9/17/16 5:23 PM, Andrej Mitrovic wrote: I think at some point someone suggested we could implement explicit support for such unittests via `static unittest`: That suggests the unittest shall be evaluated during compilation. -- Andrei

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread ZombineDev via Digitalmars-d
On Sunday, 18 September 2016 at 11:10:22 UTC, ZombineDev wrote: On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei Alexandrescu wrote: [...] This solution is used extensively by ndslice [1] and I agree that it's quite flexible. [1]:

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread ZombineDev via Digitalmars-d
On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei Alexandrescu wrote: Recall the discussion a few days ago about unittests inside templates being instantiated with the template. Often that's desirable, but sometimes not - for example when you want to generate nice ddoc unittests and avoid

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Nick Treleaven via Digitalmars-d
On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei Alexandrescu wrote: /// static if (is(T == int)) unittest { Awesome awesome; awesome.awesome; } } The unittest documentation is nicely generated. The unittest code itself is only generated for one

Re: Ah, simple solution to unittests inside templates

2016-09-18 Thread Jonathan M Davis via Digitalmars-d
On Saturday, September 17, 2016 21:23:58 Andrej Mitrovic via Digitalmars-d wrote: > On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei > > Alexandrescu wrote: > > The unittest documentation is nicely generated. The unittest > > code itself is only generated for one instantiation. > > I had a

Re: Ah, simple solution to unittests inside templates

2016-09-17 Thread Andrej Mitrovic via Digitalmars-d
On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei Alexandrescu wrote: The unittest documentation is nicely generated. The unittest code itself is only generated for one instantiation. I had a similar thought, but I didn't really like verbosity of the static if. I think at some point

Ah, simple solution to unittests inside templates

2016-09-17 Thread Andrei Alexandrescu via Digitalmars-d
Recall the discussion a few days ago about unittests inside templates being instantiated with the template. Often that's desirable, but sometimes not - for example when you want to generate nice ddoc unittests and avoid bloating. For those cases, here's a simple solution that I don't think has