Thread overview
unit testing version statements
Aug 22, 2014
Kagamin
Aug 22, 2014
Jonathan M Davis
Aug 22, 2014
Dicebot
August 22, 2014
How do I unit test version statements without fixing version in place forever.

----------------
bool fun() {
    version(Version1) return true;
    else version(Version2) return true;
    else return false;
}

version = Version1;
unittest {
    assert(fun());
}

version = Version2;
unittest {
    assert(fun());
}

unittest {
    assert(!fun());
}

version = None; // is there anyway to save and reset the version
----------------
August 22, 2014
Compile and run the tests with different version options.
August 22, 2014
On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote:
> Compile and run the tests with different version options.

that is not an option
August 22, 2014
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote:
> On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote:
>> Compile and run the tests with different version options.
>
> that is not an option

Well, that's normally how it would be done. But if you need to test them all with the same build, it's probably easier if the unit tests are in separate modules, since then you can just set the version for the module without having to worry about resetting it.

- Jonathan M Davis
August 22, 2014
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote:
> On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote:
>> Compile and run the tests with different version options.
>
> that is not an option

This is how version feature is intentionally designed to work