Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/std/package.d b/std/package.d
- index 8298837c4..a4d44adc9 100644
- --- a/std/package.d
- +++ b/std/package.d
- @@ -28,7 +28,65 @@ module std;
- assert(10.iota.map!(partial!(pow, 2)).sum == 1023);
- }
- +///Warning: EXTREMELY hacky code below.
- +unittest
- +{
- + import std.file;
- + import std.path;
- + import std.array;
- + import std.algorithm;
- +
- + string[] importedPackages = import("package.d").splitLines
- + .retro.until("//++=MARK=++//").array
- + .map!"a.stripLeft[0 .. $-1]".array;
- + string[][] modules;
- + foreach (i; dirEntries(".", SpanMode.breadth))
- + {
- + string[] pathSections = pathSplitter(i.name)
- + .retro.until("std", No.openRight).array.retro.array;
- + if (i.attributes.attrIsFile && pathSections.canFind("std")
- + && !pathSections.canFind("experimental")
- + && !pathSections.canFind("internal")
- + && !pathSections.canFind("windows")
- + && pathSections != ["std", "package.d"])
- + {
- + pathSections[$-1] = pathSections[$-1][0 .. $-2];//strip ".d"
- + modules ~= pathSections;
- + }
- + }
- +
- + string[][] packageModules = modules.filter!`a[$-1] == "package"`.array;
- + string[] uniqueModules;
- +
- + foreach (i; modules)
- + {
- + bool included = false;
- +
- + foreach (j; packageModules) {
- + if (i.canFind(j[0 .. $-1]))
- + {
- + if (!uniqueModules.canFind(j[0 .. $-1].join(".")))
- + uniqueModules ~= j[0 .. $-1].join(".");
- + included = true;
- + }
- + }
- + if (!included)
- + uniqueModules ~= i.join(".");
- + }
- +
- + bool notAllImported = false;
- + foreach (i; uniqueModules)
- + {
- + if (!importedPackages.canFind(i)) {
- + stderr.writeln(i, " is not imported in std.package.");
- + notAllImported = true;
- + }
- + }
- + assert(!notAllImported, "Not all modules are imported in std.package (see above messages).");
- +}
- +
- public import
- +//++=MARK=++//
- std.algorithm,
- std.array,
- std.ascii,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement