www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9721] New: Code coverage for templates

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9721

           Summary: Code coverage for templates
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simendsjo gmail.com


--- Comment #0 from simendsjo <simendsjo gmail.com> 2013-03-14 09:30:28 PDT ---
Ref.: http://forum.dlang.org/thread/wwjaeexnyaeqnqsqydte forum.dlang.org

Is there a way to get code coverage functionality for templates to see what
parts of templates are instantiated?

t.d:
    module t;
    template t(T) {
        static if(is(T == int))
            alias int t;
        else static if(is(T == short))
            alias short t;
    }
    unittest {
        t!int a = 10;
        assert(a == 10);
    }
    void main() {}

$ dmd -unittest -cov -run t

t.lst:
       |    module t;
       |    template t(T) {
       |        static if(is(T == int))
       |            alias int t;
       |        else static if(is(T == short))
       |            alias short t;
       |    }
       |    unittest {
      1|        t!int a = 10;
      1|        assert(a == 10);
       |    }
       |    void main() {}
t.d is 100% covered

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 14 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9721


thelastmammoth gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thelastmammoth gmail.com


--- Comment #1 from thelastmammoth gmail.com 2013-03-18 14:29:52 PDT ---
see also:
http://forum.dlang.org/thread/lznwctdwgrolhmqawave forum.dlang.org

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