diff --git a/src/core/sync/barrier.d b/src/core/sync/barrier.d index a9497bea73..d7366f6eca 100644 --- a/src/core/sync/barrier.d +++ b/src/core/sync/barrier.d @@ -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 ); } diff --git a/src/core/sync/condition.d b/src/core/sync/condition.d index 6768f7845b..9fafb1a016 100644 --- a/src/core/sync/condition.d +++ b/src/core/sync/condition.d @@ -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() @@ -631,11 +630,7 @@ version (unittest) assert( !alertedTwo ); } - - unittest - { - testNotify(); - testNotifyAll(); - testWaitTimeout(); - } + testNotify(); + testNotifyAll(); + testWaitTimeout(); } diff --git a/src/core/sync/semaphore.d b/src/core/sync/semaphore.d index a7e52fa9d8..a74fd69a2b 100644 --- a/src/core/sync/semaphore.d +++ b/src/core/sync/semaphore.d @@ -359,8 +359,7 @@ protected: // Unit Tests //////////////////////////////////////////////////////////////////////////////// - -version (unittest) +unittest { import core.thread, core.atomic; @@ -447,10 +446,6 @@ version (unittest) assert(alertedOne && !alertedTwo); } - - unittest - { - testWait(); - testWaitTimeout(); - } + testWait(); + testWaitTimeout(); } diff --git a/src/core/sys/posix/sys/select.d b/src/core/sys/posix/sys/select.d index eeb79f3f27..cd4b9fce64 100644 --- a/src/core/sys/posix/sys/select.d +++ b/src/core/sys/posix/sys/select.d @@ -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; @@ -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; diff --git a/src/etc/linux/memoryerror.d b/src/etc/linux/memoryerror.d index 38080d0fd4..3faae9eeb9 100644 --- a/src/etc/linux/memoryerror.d +++ b/src/etc/linux/memoryerror.d @@ -80,13 +80,10 @@ class NullPointerError : InvalidPointerError } } -version (unittest) +unittest { int* getNull() { return null; } -} -unittest -{ assert(registerMemoryErrorHandler()); bool b;