Skip to content

Commit

Permalink
Merge pull request #6681 from BBasile/pub-symbol-unittest
Browse files Browse the repository at this point in the history
Fix issue 11959 - Set private symbols declared in version(unittest) blocks
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Aug 26, 2018
2 parents f4c6d5c + db81957 commit dc40232
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions std/conv.d
Expand Up @@ -5125,7 +5125,7 @@ version(unittest) private class __conv_EmplaceTestClass
version(unittest)
{
//Ambiguity
struct __std_conv_S
private struct __std_conv_S
{
int i;
this(__std_conv_SS ss) {assert(0);}
Expand All @@ -5135,7 +5135,7 @@ version(unittest)
return s;
}
}
struct __std_conv_SS
private struct __std_conv_SS
{
int j;
__std_conv_S s;
Expand Down
1 change: 1 addition & 0 deletions std/datetime/date.d
Expand Up @@ -10418,6 +10418,7 @@ if (isSomeString!T)

version(unittest)
{
private:
// All of these helper arrays are sorted in ascending order.
auto testYearsBC = [-1999, -1200, -600, -4, -1, 0];
auto testYearsAD = [1, 4, 1000, 1999, 2000, 2012];
Expand Down
5 changes: 3 additions & 2 deletions std/datetime/systime.d
Expand Up @@ -10417,7 +10417,7 @@ afterMon: stripAndCheckLen(value[3 .. value.length], "1200:00A".length);
assertThrown!DateTimeException(parseRFC822DateTime(badStr));
}

version(unittest) void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__)
version(unittest) private void testParse822(alias cr)(string str, SysTime expected, size_t line = __LINE__)
{
import std.format : format;
auto value = cr(str);
Expand All @@ -10426,7 +10426,7 @@ version(unittest) void testParse822(alias cr)(string str, SysTime expected, size
throw new AssertError(format("wrong result. expected [%s], actual[%s]", expected, result), __FILE__, line);
}

version(unittest) void testBadParse822(alias cr)(string str, size_t line = __LINE__)
version(unittest) private void testBadParse822(alias cr)(string str, size_t line = __LINE__)
{
try
parseRFC822DateTime(cr(str));
Expand Down Expand Up @@ -11365,6 +11365,7 @@ if (isIntegral!T && isSigned!T) // The constraints on R were already covered by

version(unittest)
{
private:
// Variables to help in testing.
Duration currLocalDiffFromUTC;
immutable (TimeZone)[] testTZs;
Expand Down
Expand Up @@ -662,7 +662,7 @@ public:

version(unittest)
{
static void testrw(void[] b) @nogc nothrow
private static void testrw(void[] b) @nogc nothrow
{
ubyte* buf = cast(ubyte*) b.ptr;
buf[0] = 100;
Expand All @@ -671,7 +671,7 @@ version(unittest)
assert(buf[b.length - 1] == 101);
}

static size_t getPageSize() @nogc nothrow
private static size_t getPageSize() @nogc nothrow
{
size_t pageSize;
version(Posix)
Expand Down
12 changes: 6 additions & 6 deletions std/format.d
Expand Up @@ -4582,7 +4582,7 @@ private T getNth(string kind, alias Condition, T, A...)(uint index, A args)
/* ======================== Unit Tests ====================================== */

version(unittest)
void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __FILE__)
private void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __FILE__)
{
import core.exception : AssertError;
import std.array : appender;
Expand All @@ -4596,7 +4596,7 @@ void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __F
}

version(unittest)
void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, string fn = __FILE__) @safe
private void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, string fn = __FILE__) @safe
{
import core.exception : AssertError;
import std.array : appender;
Expand All @@ -4609,7 +4609,7 @@ void formatTest(T)(string fmt, T val, string expected, size_t ln = __LINE__, str
}

version(unittest)
void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__)
private void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__)
{
import core.exception : AssertError;
import std.array : appender;
Expand All @@ -4627,7 +4627,7 @@ void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = _
}

version(unittest)
void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) @safe
private void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) @safe
{
import core.exception : AssertError;
import std.array : appender;
Expand Down Expand Up @@ -5109,7 +5109,7 @@ here:
}

version(unittest)
void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = __FILE__, size_t ln = __LINE__)
private void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = __FILE__, size_t ln = __LINE__)
{
import core.exception : AssertError;
import std.array : appender;
Expand Down Expand Up @@ -5151,7 +5151,7 @@ void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = _
}

version(unittest)
void formatReflectTest(T)(ref T val, string fmt, string[] formatted, string fn = __FILE__, size_t ln = __LINE__)
private void formatReflectTest(T)(ref T val, string fmt, string[] formatted, string fn = __FILE__, size_t ln = __LINE__)
{
import core.exception : AssertError;
import std.array : appender;
Expand Down
2 changes: 1 addition & 1 deletion std/internal/math/biguintcore.d
Expand Up @@ -1340,7 +1340,7 @@ int highestPowerBelowUlongMax(uint x) pure nothrow @safe
version(unittest)
{

int slowHighestPowerBelowUintMax(uint x) pure nothrow @safe
private int slowHighestPowerBelowUintMax(uint x) pure nothrow @safe
{
int pwr = 1;
for (ulong q = x;x*q < cast(ulong) uint.max; )
Expand Down
2 changes: 1 addition & 1 deletion std/parallelism.d
Expand Up @@ -4123,7 +4123,7 @@ private struct RoundRobinBuffer(C1, C2)
version(unittest)
{
// This was the only way I could get nested maps to work.
__gshared TaskPool poolInstance;
private __gshared TaskPool poolInstance;
}

// These test basic functionality but don't stress test for threading bugs.
Expand Down
1 change: 1 addition & 0 deletions std/path.d
Expand Up @@ -4154,6 +4154,7 @@ string expandTilde(string inputPath) @safe nothrow

version(unittest)
{
private:
/* Define a mock RandomAccessRange to use for unittesting.
*/

Expand Down
1 change: 1 addition & 0 deletions std/process.d
Expand Up @@ -3078,6 +3078,7 @@ if (is(typeof(allocator(size_t.init)[0] = char.init)))

version(Windows) version(unittest)
{
private:
import core.stdc.stddef;
import core.stdc.wchar_ : wcslen;
import core.sys.windows.shellapi : CommandLineToArgvW;
Expand Down
2 changes: 1 addition & 1 deletion std/stdio.d
Expand Up @@ -5451,7 +5451,7 @@ version(linux)
}
}

version(unittest) string testFilename(string file = __FILE__, size_t line = __LINE__) @safe
version(unittest) private string testFilename(string file = __FILE__, size_t line = __LINE__) @safe
{
import std.conv : text;
import std.file : deleteme;
Expand Down
3 changes: 2 additions & 1 deletion std/traits.d
Expand Up @@ -2438,6 +2438,7 @@ if (is(T == function))

version(unittest)
{
private:
// Some function types to test.
int sc(scope int, ref int, out int, lazy int, int);
extern(System) int novar();
Expand Down Expand Up @@ -7873,7 +7874,7 @@ if (sth.length == 1)
static assert(TL == AliasSeq!("i", "xi", "yi"));
}

version(unittest) void freeFunc(string);
version(unittest) private void freeFunc(string);

@safe unittest
{
Expand Down
3 changes: 2 additions & 1 deletion std/utf.d
Expand Up @@ -3368,6 +3368,7 @@ if (isSomeChar!C)
// Ranges of code units for testing.
version(unittest)
{
private:
struct InputCU(C)
{
import std.conv : to;
Expand Down Expand Up @@ -4122,7 +4123,7 @@ pure @safe nothrow @nogc unittest
}

version(unittest)
int impureVariable;
private int impureVariable;

@system unittest
{
Expand Down

0 comments on commit dc40232

Please sign in to comment.