Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 10, 2014 Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Hi, Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||) At first I tough I could do: version(unittest, debug) {} but this doesn't work. Then I tried to define a new version: version(DebugOrUnittest) { version = debug; version = unittest; } But this also doesn't work. |
June 10, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juanjo Alvarez | Juanjo Alvarez:
> Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||)
>
> At first I tough I could do:
>
> version(unittest, debug) {}
You can define a enum boolean value in the version unittest block, and another inside the debug {} else {}. And then you can use "if (b1 || b2) { ... }".
Bye,
bearophile
|
June 10, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 10/06/14 16:06, bearophile wrote: > You can define a enum boolean value in the version unittest block, and > another inside the debug {} else {}. And then you can use "if (b1 || b2) > { ... }". "static if" is probably what's needed. -- /Jacob Carlborg |
June 10, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juanjo Alvarez | Juanjo Alvarez:
> Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||)
Regarding your latest ER, Walter is usually not fond of such ideas. I have seen many similar ideas being shot down.
Bye,
bearophile
|
June 11, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juanjo Alvarez | debug version = DebugOrUnittest; else version(unittest)version = DebugOrUnittest; version(DebugOrUnittest) { static assert(false,"DebugOrUnittest"); } |
June 11, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 10 June 2014 at 14:06:58 UTC, bearophile wrote:
> Juanjo Alvarez:
>
>> Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||)
>>
>> At first I tough I could do:
>>
>> version(unittest, debug) {}
>
> You can define a enum boolean value in the version unittest block, and another inside the debug {} else {}. And then you can use "if (b1 || b2) { ... }".
>
> Bye,
> bearophile
Not pretty, but works.
Thanks!
|
June 12, 2014 Re: Version() for unittest OR debug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Wednesday, 11 June 2014 at 06:50:08 UTC, Kagamin wrote:
> debug version = DebugOrUnittest;
> else version(unittest)version = DebugOrUnittest;
>
> version(DebugOrUnittest) { static assert(false,"DebugOrUnittest"); }
I like this option more. I didn't knew you could assign to "version".
Thanks,
Juanjo
|
Copyright © 1999-2021 by the D Language Foundation