Re: How to unit-test behavior under "version"?

2022-03-30 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 30 March 2022 at 04:15:24 UTC, Paul Backus wrote: Probably the easiest way is to split it into two functions ```d void f() { version (foo) fVersionFoo(); else fDefault(); } void fVersionFoo() { /* ... */ } void fDefault() { /* ... */ } ``` Then yo

Re: How to unit-test behavior under "version"?

2022-03-29 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 29 March 2022 at 19:55:52 UTC, Andrey Zherikov wrote: I have a function below (just an example). What's the recommended way to unit-test it for all `version` cases? ```d void f() { import std.stdio: writeln; version(foo) writeln("foo"); else writeln("

Re: How to unit-test behavior under "version"?

2022-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/22 8:57 PM, Andrey Zherikov wrote: On Tuesday, 29 March 2022 at 20:20:46 UTC, Steven Schveighoffer wrote: So keep in mind that versions are *module-wide*, and usually *compilation-wide*. Which means that you won't be testing multiple version configurations in the same build. ... In t

Re: How to unit-test behavior under "version"?

2022-03-29 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 29 March 2022 at 20:20:46 UTC, Steven Schveighoffer wrote: So keep in mind that versions are *module-wide*, and usually *compilation-wide*. Which means that you won't be testing multiple version configurations in the same build. ... In the case where version is going to *affect th

Re: How to unit-test behavior under "version"?

2022-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/22 3:55 PM, Andrey Zherikov wrote: I have a function below (just an example). What's the recommended way to unit-test it for all `version` cases? ```d void f() { import std.stdio: writeln;     version(foo)     writeln("foo");     else     writeln("no foo"); } ``` So k

How to unit-test behavior under "version"?

2022-03-29 Thread Andrey Zherikov via Digitalmars-d-learn
I have a function below (just an example). What's the recommended way to unit-test it for all `version` cases? ```d void f() { import std.stdio: writeln; version(foo) writeln("foo"); else writeln("no foo"); } ```