Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
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
49 changes: 22 additions & 27 deletions src/core/sync/barrier.d
Original file line number Diff line number Diff line change
Expand Up @@ -112,40 +112,35 @@ private:
// Unit Tests
////////////////////////////////////////////////////////////////////////////////


version (unittest)
unittest
{
private import core.thread;
import core.thread;

int numThreads = 10;
auto barrier = new Barrier( numThreads );
auto synInfo = new Object;
int numReady = 0;
int numPassed = 0;

unittest
void threadFn()
{
int numThreads = 10;
auto barrier = new Barrier( numThreads );
auto synInfo = new Object;
int numReady = 0;
int numPassed = 0;

void threadFn()
synchronized( synInfo )
{
synchronized( synInfo )
{
++numReady;
}
barrier.wait();
synchronized( synInfo )
{
++numPassed;
}
++numReady;
}

auto group = new ThreadGroup;

for ( int i = 0; i < numThreads; ++i )
barrier.wait();
synchronized( synInfo )
{
group.create( &threadFn );
++numPassed;
}
group.joinAll();
assert( numReady == numThreads && numPassed == numThreads );
}

auto group = new ThreadGroup;

for ( int i = 0; i < numThreads; ++i )
{
group.create( &threadFn );
}
group.joinAll();
assert( numReady == numThreads && numPassed == numThreads );
}
19 changes: 7 additions & 12 deletions src/core/sync/condition.d
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,11 @@ private:
// Unit Tests
////////////////////////////////////////////////////////////////////////////////


version (unittest)
unittest
{
private import core.thread;
private import core.sync.mutex;
private import core.sync.semaphore;
import core.thread;
import core.sync.mutex;
import core.sync.semaphore;


void testNotify()
Expand Down Expand Up @@ -631,11 +630,7 @@ version (unittest)
assert( !alertedTwo );
}


unittest
{
testNotify();
testNotifyAll();
testWaitTimeout();
}
testNotify();
testNotifyAll();
testWaitTimeout();
}
11 changes: 3 additions & 8 deletions src/core/sync/semaphore.d
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ protected:
// Unit Tests
////////////////////////////////////////////////////////////////////////////////


version (unittest)
unittest
{
import core.thread, core.atomic;

Expand Down Expand Up @@ -447,10 +446,6 @@ version (unittest)
assert(alertedOne && !alertedTwo);
}


unittest
{
testWait();
testWaitTimeout();
}
testWait();
testWaitTimeout();
}
3 changes: 2 additions & 1 deletion src/core/sys/posix/sys/select.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public import core.sys.posix.sys.types; // for time_t
public import core.sys.posix.signal; // for sigset_t

//debug=select; // uncomment to turn on debugging printf's
version (unittest) import core.stdc.stdio: printf;

version (OSX)
version = Darwin;
Expand Down Expand Up @@ -560,6 +559,8 @@ else

pure unittest
{
import core.stdc.stdio: printf;

debug(select) printf("core.sys.posix.sys.select unittest\n");

fd_set fd;
Expand Down
5 changes: 1 addition & 4 deletions src/etc/linux/memoryerror.d
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ class NullPointerError : InvalidPointerError
}
}

version (unittest)
unittest
{
int* getNull() { return null; }
}

unittest
{
assert(registerMemoryErrorHandler());

bool b;
Expand Down