From d3e1bb0cdb85dab5227c8501b9b3265e839fa516 Mon Sep 17 00:00:00 2001 From: Alexandru Militaru Date: Mon, 6 Jan 2020 00:57:15 +0200 Subject: [PATCH] Some version (unittest) blocks removed --- std/process.d | 15 +++++++----- std/typecons.d | 8 +++---- std/uni.d | 63 +++++++++++++++++++++----------------------------- 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/std/process.d b/std/process.d index d371d788b1e..3bffae45aea 100644 --- a/std/process.d +++ b/std/process.d @@ -1163,8 +1163,9 @@ version (Posix) @system unittest version (Posix) { import std.path : buildPath; - import std.file : remove, write, setAttributes; + import std.file : remove, write, setAttributes, tempDir; import core.sys.posix.sys.stat : S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH; + import std.conv : to; string deleteme = buildPath(tempDir(), "deleteme.std.process.unittest.pid") ~ to!string(thisProcessID); write(deleteme, ""); scope(exit) remove(deleteme); @@ -1177,6 +1178,7 @@ version (Posix) @system unittest @system unittest // Specifying a working directory. { import std.path; + import std.file; TestScript prog = "echo foo>bar"; auto directory = uniqueTempPath(); @@ -1191,6 +1193,7 @@ version (Posix) @system unittest @system unittest // Specifying a bad working directory. { import std.exception : assertThrown; + import std.file; TestScript prog = "echo"; auto directory = uniqueTempPath(); @@ -1230,6 +1233,7 @@ version (Posix) @system unittest @system unittest // Reopening the standard streams (issue 13258) { import std.string; + import std.file; void fun() { spawnShell("echo foo").wait(); @@ -1360,6 +1364,7 @@ version (Windows) @system unittest { import std.string; + import std.conv : text; TestScript prog = "echo %0 %*"; auto outputFn = uniqueTempPath(); scope(exit) if (exists(outputFn)) remove(outputFn); @@ -2771,6 +2776,7 @@ private struct TestScript version (Posix) { import core.sys.posix.sys.stat : chmod; + import std.conv : octal; chmod(path.tempCString(), octal!777); } } @@ -3104,6 +3110,7 @@ private: { import std.algorithm.iteration : map; import std.array : array; + import std.conv : to; auto lpCommandLine = (to!(WCHAR[])(line) ~ '\0').ptr; int numArgs; auto args = CommandLineToArgvW(lpCommandLine, &numArgs); @@ -3115,6 +3122,7 @@ private: @system unittest { + import std.conv : text; string[] testStrings = [ `Hello`, `Hello, world`, @@ -3778,11 +3786,6 @@ version (Posix) { import core.sys.posix.stdlib; } -version (unittest) -{ - import std.conv, std.file, std.random; -} - private void toAStringz(in string[] a, const(char)**az) { diff --git a/std/typecons.d b/std/typecons.d index ad14cf8bb0b..49f566bd747 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -5971,16 +5971,14 @@ private template TypeMod(T) enum TypeMod = cast(TypeModifier)(mod1 | mod2); } -version (unittest) +@system unittest { - private template UnittestFuncInfo(alias f) + template UnittestFuncInfo(alias f) { enum name = __traits(identifier, f); alias type = FunctionTypeOf!f; } -} -@system unittest -{ + class A { int draw() { return 1; } diff --git a/std/uni.d b/std/uni.d index ad2a2b7aa11..9f6da50976e 100644 --- a/std/uni.d +++ b/std/uni.d @@ -715,33 +715,6 @@ debug(std_uni) import std.stdio; // writefln, writeln private: -version (unittest) -{ -private: - struct TestAliasedString - { - string get() @safe @nogc pure nothrow { return _s; } - alias get this; - @disable this(this); - string _s; - } - - bool testAliasedString(alias func, Args...)(string s, Args args) - { - import std.algorithm.comparison : equal; - auto a = func(TestAliasedString(s), args); - auto b = func(s, args); - static if (is(typeof(equal(a, b)))) - { - // For ranges, compare contents instead of object identity. - return equal(a, b); - } - else - { - return a == b; - } - } -} void copyBackwards(T,U)(T[] src, U[] dest) { @@ -3509,14 +3482,10 @@ pure @safe unittest// Uint24 tests }} } -version (unittest) -{ - private alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); -} - pure @safe unittest// core set primitives test { import std.conv : text; + alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); foreach (CodeList; AllSets) { CodeList a; @@ -3638,6 +3607,7 @@ pure @safe unittest pure @safe unittest { // full set operations import std.conv : text; + alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); foreach (CodeList; AllSets) { CodeList a, b, c, d; @@ -9255,8 +9225,32 @@ if (isConvertibleToString!Range) @safe unittest { + static struct TestAliasedString + { + string get() @safe @nogc pure nothrow { return _s; } + alias get this; + @disable this(this); + string _s; + } + + static bool testAliasedString(alias func, Args...)(string s, Args args) + { + import std.algorithm.comparison : equal; + auto a = func(TestAliasedString(s), args); + auto b = func(s, args); + static if (is(typeof(equal(a, b)))) + { + // For ranges, compare contents instead of object identity. + return equal(a, b); + } + else + { + return a == b; + } + } assert(testAliasedString!asLowerCase("hEllo")); assert(testAliasedString!asUpperCase("hEllo")); + assert(testAliasedString!asCapitalized("hEllo")); } @safe unittest @@ -9442,11 +9436,6 @@ if (isConvertibleToString!Range) return asCapitalized!(StringTypeOf!Range)(str); } -@safe unittest -{ - assert(testAliasedString!asCapitalized("hEllo")); -} - @safe pure nothrow @nogc unittest { auto r = "hEllo".asCapitalized();