[Issue 10990] New: Passing in a module as a mixin to __traits(getUnitTests) behaves differently than passing in the module directly.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 7 19:49:10 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10990
Summary: Passing in a module as a mixin to
__traits(getUnitTests) behaves differently than
passing in the module directly.
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: opantm2+dbugs at gmail.com
--- Comment #0 from Kapps <opantm2+dbugs at gmail.com> 2013-09-07 19:49:06 PDT ---
I don't know if this is specific to __traits(getUnitTests), though I doubt it
is. When passing in a module directly, such as through __traits(getUnitTests,
ptest2), a compiler error is raised saying that a module/aggregate is expected
instead of an import. Passing the module in as a mixin, through
__traits(getUnitTests, mixin("ptest2")) however works as expected. I tried with
__traits(allMembers) and __traits(derivedMembers) which both seem to work fine,
but I don't know of any other traits I could test with modules.
Sample code passing in as module:
import std.stdio;
import ptest2;
void main() {
writeln(__traits(getUnitTests, ptest2).length);
}
Results in the following errors:
ptest.d(6): Error: argument ptest2 to __traits(getUnitTests) must be a module
or aggregate, not a import
ptest.d(6): Error: no property 'length' for type 'bool'
Passing in as mixin results in no errors and works as expected:
import std.stdio;
import ptest2;
void main() {
writeln(__traits(getUnitTests, mixin("ptest2")).length);
}
Code for ptest2.d:
module ptest2;
import std.stdio;
unittest {
writeln("First unittest.");
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list