Linker error regarding importing and unit tests. Is this a bug?
Gary Willoughby
dev at nomad.so
Sun Nov 3 03:48:40 PST 2013
On Friday, 1 November 2013 at 16:24:09 UTC, Gary Willoughby wrote:
> On Friday, 1 November 2013 at 15:32:54 UTC, Daniel Davidson
> wrote:
>> An alternative is to move the import statements in test1.d out
>> of the unittest block, which becomes a function, to file
>> scope. Then if you have multiple unittests in test1.d all are
>> covered and the symbols are available.
>>
>> ...
>> version(unittest) {
>> import methods;
>> }
>> unittest
>> {
>> import std.stdio;
>> writeln("test1 unit test");
>> S s;
>> assert(s.x.nothing());
>> }
>>
>> Thanks
>> Dan
>
> Ah right, if the unit tests are transformed into a function
> then is this a problem with the scoped import rules? It seems
> really odd, as the compiler seems to strip out the imports
> within the unit test block when that module is imported into
> another. This doesn't seem to affect the standard library only
> user modules.
Any one else got any input to this?
More information about the Digitalmars-d-learn
mailing list