Skip to content
Closed
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
48 changes: 35 additions & 13 deletions std/parallelism.d
Original file line number Diff line number Diff line change
Expand Up @@ -4291,20 +4291,43 @@ unittest
assertThrown!Exception(poolInstance.asyncBuf(ThrowingRange.init));
}

bool isNaN(float f)
{
static import std.math;
return std.math.isNaN(f);
}

bool isNaN(double f)
{
static import std.math;
return std.math.isNaN(f);
}

bool isNaN(real f)
{
static import std.math;
return std.math.isNaN(f);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burner shouldn't these be one import?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so to, but isNaN was passed as a function to a function of parallelism. But this code has not been run at least since isNaN became a template. This is just code trying to get the tests into a compileable state.


//version = parallelismStressTest;

// These are more like stress tests than real unit tests. They print out
// tons of stuff and should not be run every time make unittest is run.
version(parallelismStressTest)
unittest
{
unittest
testFunction(1);
testFunction2(1);
}

void testFunction(size_t runs)
{
import std.stdio : stderr, writeln;
size_t attempt;
for (; attempt < 10; attempt++)
for (; attempt < runs; attempt++)
foreach (poolSize; [0, 4])
{

poolInstance = new TaskPool(poolSize);
auto poolInstance = new TaskPool(poolSize);

uint[] numbers = new uint[1_000];

Expand Down Expand Up @@ -4373,19 +4396,19 @@ version(parallelismStressTest)
poolInstance.stop();
}

assert(attempt == 10);
writeln("Press enter to go to next round of unittests.");
readln();
assert(attempt == runs);
}

// These unittests are intended more for actual testing and not so much
// as examples.
unittest
// These unittests are intended more for actual testing and not so much
// as examples.
void testFunction2(size_t runs)
{
foreach (attempt; 0..10)
import std.stdio : stderr;

foreach (attempt; 0..runs)
foreach (poolSize; [0, 4])
{
poolInstance = new TaskPool(poolSize);
auto poolInstance = new TaskPool(poolSize);

// Test indexing.
stderr.writeln("Creator Raw Index: ", poolInstance.threadIndex);
Expand Down Expand Up @@ -4540,7 +4563,6 @@ version(parallelismStressTest)
poolInstance.stop();
}
}
}

version(unittest)
{
Expand Down