www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22596] New: The "publictests" target runs unittests at the

https://issues.dlang.org/show_bug.cgi?id=22596

          Issue ID: 22596
           Summary: The "publictests" target runs unittests at the
                    top-level namespace so they don't have access to
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider:

import std.stdio;

template canon(string v) {
    unittest {
        writeln(v);
    }
}

void main() {
    alias x = canon!"abc";
}

The unittest works properly because it has access to `v` being nested inside
the `canon` template. However, putting this unittest inside phobos and running
this will fail:

make publictests

It seems this is because that target uses a unittest extractor that does not
handle nested unittests properly.

--
Dec 13 2021