Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-30 Thread Jacob Carlborg via Digitalmars-d
On 2016-05-29 22:03, Atila Neves wrote: Yep, that's definitely crazier than I what I posted. Nifty! Should add that the code for replacing functions is from flectioned [1]. [1] http://dsource.org/projects/flectioned -- /Jacob Carlborg

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-29 Thread Seb via Digitalmars-d
On Sunday, 29 May 2016 at 22:20:05 UTC, Era Scarecrow wrote: On Thursday, 26 May 2016 at 09:40:26 UTC, Atila Neves wrote: On Wednesday, 25 May 2016 at 21:52:37 UTC, Alex Parrill wrote: Have you looked at std.typecons.AutoImplement at all? I'd never seen it before, thanks! I recall adding

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-29 Thread Era Scarecrow via Digitalmars-d
On Thursday, 26 May 2016 at 09:40:26 UTC, Atila Neves wrote: On Wednesday, 25 May 2016 at 21:52:37 UTC, Alex Parrill wrote: Have you looked at std.typecons.AutoImplement at all? I'd never seen it before, thanks! I recall adding on a wishlist somewhere that every week or something that a

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-29 Thread Atila Neves via Digitalmars-d
On Friday, 27 May 2016 at 18:49:12 UTC, Jacob Carlborg wrote: On 2016-05-27 15:12, Atila Neves wrote: [...] Hmm, here's the code inline: module red; [...] Yep, that's definitely crazier than I what I posted. Nifty! Atila

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-27 Thread Jacob Carlborg via Digitalmars-d
On 2016-05-27 15:12, Atila Neves wrote: I get an SSL warning for that link. Hmm, here's the code inline: module red; import std.stdio; import core.sys.posix.sys.mman : mprotect, PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC; import core.stdc.errno : errno; import core.stdc.string :

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-27 Thread Atila Neves via Digitalmars-d
On Thursday, 26 May 2016 at 20:03:50 UTC, Jacob Carlborg wrote: On 2016-05-25 23:38, Atila Neves wrote: [...] Interesting, yes. Crazy, not enough :). Here's an example of replacing functions and replacing methods on individual objects [1]. [...] I get an SSL warning for that link.

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Jacob Carlborg via Digitalmars-d
On 2016-05-25 23:38, Atila Neves wrote: Interesting? Crazy? Worth adding to unit-threaded? Phobos (after much cleaning up)? Interesting, yes. Crazy, not enough :). Here's an example of replacing functions and replacing methods on individual objects [1]. I'm trying to do something like you

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Robert burner Schadek via Digitalmars-d
On Thursday, 26 May 2016 at 09:42:59 UTC, Atila Neves wrote: Internal, and not really a mock. I used a range as an example - anything with an accompanying interface would be supported. I see, I thought as much What's wrong with dmocks revived (I've never used it)? I'm not afraid of classes,

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Atila Neves via Digitalmars-d
On Wednesday, 25 May 2016 at 22:07:07 UTC, Robert burner Schadek wrote: +1 having a look at AutoImplement For testing ranges, I usually use https://github.com/dlang/phobos/blob/master/std/internal/test/dummyrange.d even though its internal ;-) Internal, and not really a mock. I used a range

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Atila Neves via Digitalmars-d
On Thursday, 26 May 2016 at 08:08:01 UTC, Gary Willoughby wrote: On Wednesday, 25 May 2016 at 21:38:23 UTC, Atila Neves wrote: There was talk in the forum of making it easier to come up instantiations of say, an input range for testing purposes. That got me thinking of how mocking frameworks

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Atila Neves via Digitalmars-d
On Wednesday, 25 May 2016 at 21:52:37 UTC, Alex Parrill wrote: On Wednesday, 25 May 2016 at 21:38:23 UTC, Atila Neves wrote: [...] Have you looked at std.typecons.AutoImplement at all? http://dlang.org/phobos/std_typecons.html#.AutoImplement I'd never seen it before, thanks! Doesn't do the

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-26 Thread Gary Willoughby via Digitalmars-d
On Wednesday, 25 May 2016 at 21:38:23 UTC, Atila Neves wrote: There was talk in the forum of making it easier to come up instantiations of say, an input range for testing purposes. That got me thinking of how mocking frameworks make it easy to pass in dependencies without having to write a

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-25 Thread Robert burner Schadek via Digitalmars-d
+1 having a look at AutoImplement For testing ranges, I usually use https://github.com/dlang/phobos/blob/master/std/internal/test/dummyrange.d even though its internal ;-) anyway, more and better testing always good. p.s. I think at some point we have to build some (the perfect) mocking

Re: A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-25 Thread Alex Parrill via Digitalmars-d
On Wednesday, 25 May 2016 at 21:38:23 UTC, Atila Neves wrote: There was talk in the forum of making it easier to come up instantiations of say, an input range for testing purposes. That got me thinking of how mocking frameworks make it easy to pass in dependencies without having to write a

A technique to mock "static interfaces" (e.g. isInputRange)

2016-05-25 Thread Atila Neves via Digitalmars-d
There was talk in the forum of making it easier to come up instantiations of say, an input range for testing purposes. That got me thinking of how mocking frameworks make it easy to pass in dependencies without having to write a whole new "test double" type oneself. How would one do that for