Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 12, 2014 at 09:30:44PM -0700, H. S. Teoh via Digitalmars-d-learn wrote: > On Sat, Jul 12, 2014 at 09:20:06PM -0700, Ali Çehreli via Digitalmars-d-learn > wrote: [...] > > The twist here is that the OP's function returned 'this' by > > reference. Changing that not only not have any ef

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 12, 2014 at 09:20:06PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 07/12/2014 08:37 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > ref makes it possible for the caller to modify the pointer returned by > > the callee. For example: > > > > class D { int x; } > >

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread Ali Çehreli via Digitalmars-d-learn
On 07/12/2014 08:37 PM, H. S. Teoh via Digitalmars-d-learn wrote: > ref makes it possible for the caller to modify the pointer returned by > the callee. For example: > >class D { int x; } >class C { >D d; >this(D _d) { d = _d; } >ref D getPtr() { return

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread dysmondad via Digitalmars-d-learn
... https://github.com/rikkimax/skeleton/blob/master/source/skeleton/syntax/download_mkdir.d#L175 Of course there will be better ones, just something I was doing last night however. Thanks for the link and the information. That's looks like what I need so I'm going to rip off your code exampl

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 13, 2014 at 02:39:00AM +, dysmondad via Digitalmars-d-learn wrote: > On Saturday, 12 July 2014 at 05:23:29 UTC, Ali Çehreli wrote: > >On 07/11/2014 10:08 PM, dysmondad wrote: > > > >> class Velocity > >> { > > > >[...] > > > >> ref Velocity opOpAssign(string op) ( in float mul

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 13, 2014 at 02:35:11AM +, dysmondad via Digitalmars-d-learn wrote: [...] > So, what is the generally accepted way include unit testing? TDD is > all the rage these days and I though I would try my hand at it as well > as D. Just include unittest blocks in your program and compile

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread Rikki Cattermole via Digitalmars-d-learn
On 13/07/2014 2:35 p.m., dysmondad wrote: . try: unittest { Velocity v = new Velocity( 2.0f, 5.0f ); v *= 5.0f; // <- line 110 printf( "v = %s\n", to!string(v) ); } instead. Basically version is like static if, it doesn't indicate its a function. Instead it changes what

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread dysmondad via Digitalmars-d-learn
. try: unittest { Velocity v = new Velocity( 2.0f, 5.0f ); v *= 5.0f; // <- line 110 printf( "v = %s\n", to!string(v) ); } instead. Basically version is like static if, it doesn't indicate its a function. Instead it changes what code gets compiled. Where as a unittest

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-12 Thread dysmondad via Digitalmars-d-learn
On Saturday, 12 July 2014 at 05:23:29 UTC, Ali Çehreli wrote: On 07/11/2014 10:08 PM, dysmondad wrote: > class Velocity > { [...] > ref Velocity opOpAssign(string op) ( in float multiplier ) Unrelated to your question, you want to return just Velocity there. Unlike C++, classes are refe

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2014 10:08 PM, dysmondad wrote: > class Velocity > { [...] > ref Velocity opOpAssign(string op) ( in float multiplier ) Unrelated to your question, you want to return just Velocity there. Unlike C++, classes are reference types in D. So, Velocity itself is essentially a Velocit

Re: I don't get it. version(unittest) can't seem to use local variable

2014-07-11 Thread Rikki Cattermole via Digitalmars-d-learn
On 12/07/2014 5:08 p.m., dysmondad wrote: I'm new to D. I've been using C since it was a baby and C++ back when it was only a pre-compiler for c. So, I may just be stuck thinking in C land. The issue is I am attempting to use the version(unittest) feature. However the compiler pukes up the error

I don't get it. version(unittest) can't seem to use local variable

2014-07-11 Thread dysmondad via Digitalmars-d-learn
I'm new to D. I've been using C since it was a baby and C++ back when it was only a pre-compiler for c. So, I may just be stuck thinking in C land. The issue is I am attempting to use the version(unittest) feature. However the compiler pukes up the error below. I'm sure it's something easy en