www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10990] New: Passing in a module as a mixin to __traits(getUnitTests) behaves differently than passing in the module directly.

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: opantm2+dbugs gmail.com



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: -------
Sep 07 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10990


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



20:14:01 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2534

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10990




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/49dd6b6cd0c10f2ef21d6d3da02dacd4d535de9e
Fixes Issue 10990 - getUnitTest trait does not work with module import.

https://github.com/D-Programming-Language/dmd/commit/e5bd2934c5b08fb197221bab82b3fac18bd99cf2


Issue 10990 - getUnitTest trait does not work with a module import.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 12 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10990


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 12 2013