Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -3115,6 +3122,7 @@ private:

@system unittest
{
import std.conv : text;
string[] testStrings = [
`Hello`,
`Hello, world`,
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 3 additions & 5 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
63 changes: 26 additions & 37 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down