diff --git a/chronos/asyncloop.nim b/chronos/asyncloop.nim index 515a446a..5ba56a77 100644 --- a/chronos/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -362,13 +362,13 @@ when defined(windows) or defined(nimdoc): ## Creates a new Dispatcher instance. new result result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1) - when compiles(initHashSet): + when declared(initHashSet): # After 0.20.0 Nim's stdlib version result.handles = initHashSet[AsyncFD]() else: # Pre 0.20.0 Nim's stdlib version result.handles = initSet[AsyncFD]() - when compiles(initHeapQueue): + when declared(initHeapQueue): # After 0.20.0 Nim's stdlib version result.timers = initHeapQueue[TimerCallback]() else: @@ -510,7 +510,12 @@ elif unixPlatform: ## Create new dispatcher. new result result.selector = newSelector[SelectorData]() - result.timers.newHeapQueue() + when declared(initHeapQueue): + # After 0.20.0 Nim's stdlib version + result.timers = initHeapQueue() + else: + # Before 0.20.0 Nim's stdlib version + result.timers.newHeapQueue() result.callbacks = initDeque[AsyncCallback](64) result.keys = newSeq[ReadyKey](64) result.trackers = initTable[string, TrackerBase]() diff --git a/tests/testaddress.nim b/tests/testaddress.nim index 7855a21d..56c9f827 100644 --- a/tests/testaddress.nim +++ b/tests/testaddress.nim @@ -8,6 +8,8 @@ import strutils, unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "TransportAddress test suite": test "initTAddress(string)": check $initTAddress("0.0.0.0:1") == "0.0.0.0:1" diff --git a/tests/testasyncstream.nim b/tests/testasyncstream.nim index 7b52df5d..a5c7a04e 100644 --- a/tests/testasyncstream.nim +++ b/tests/testasyncstream.nim @@ -8,6 +8,8 @@ import strutils, unittest, os import ../chronos, ../chronos/streams/tlsstream +when defined(nimHasUsed): {.used.} + const SelfSignedRsaKey = """ -----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDSXcKMR6zIIHSy diff --git a/tests/testbugs.nim b/tests/testbugs.nim index 3a78f8b9..6154d3b5 100644 --- a/tests/testbugs.nim +++ b/tests/testbugs.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Asynchronous issues test suite": const HELLO_PORT = 45679 const TEST_MSG = "testmsg" diff --git a/tests/testdatagram.nim b/tests/testdatagram.nim index b2dfec09..3cde640b 100644 --- a/tests/testdatagram.nim +++ b/tests/testdatagram.nim @@ -8,6 +8,8 @@ import strutils, net, unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Datagram Transport test suite": const TestsCount = 2000 diff --git a/tests/testfut.nim b/tests/testfut.nim index ad0fa3e1..d0725b24 100644 --- a/tests/testfut.nim +++ b/tests/testfut.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Future[T] behavior test suite": proc testFuture1(): Future[int] {.async.} = await sleepAsync(0.milliseconds) diff --git a/tests/testmacro.nim b/tests/testmacro.nim index ac509832..19e8e498 100644 --- a/tests/testmacro.nim +++ b/tests/testmacro.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + proc asyncRetValue(n: int): Future[int] {.async.} = await sleepAsync(n.milliseconds) result = n * 10 diff --git a/tests/testnet.nim b/tests/testnet.nim index 5d001611..76139ac5 100644 --- a/tests/testnet.nim +++ b/tests/testnet.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Network utilities test suite": const MaskVectors = [ diff --git a/tests/testserver.nim b/tests/testserver.nim index d1cadd28..890208d1 100644 --- a/tests/testserver.nim +++ b/tests/testserver.nim @@ -8,6 +8,8 @@ import strutils, unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Server's test suite": type CustomServer = ref object of StreamServer diff --git a/tests/testsignal.nim b/tests/testsignal.nim index 0b7d64d2..b8605568 100644 --- a/tests/testsignal.nim +++ b/tests/testsignal.nim @@ -8,6 +8,8 @@ import unittest, strutils import ../chronos +when defined(nimHasUsed): {.used.} + when not defined(windows): import posix diff --git a/tests/testsoon.nim b/tests/testsoon.nim index b8a79e7e..dfa712b3 100644 --- a/tests/testsoon.nim +++ b/tests/testsoon.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "callSoon() tests suite": const CallSoonTests = 10 var soonTest1 = 0'u diff --git a/tests/teststream.nim b/tests/teststream.nim index 2ce9a0e8..6c1bbc3c 100644 --- a/tests/teststream.nim +++ b/tests/teststream.nim @@ -8,6 +8,8 @@ import strutils, unittest, os import ../chronos +when defined(nimHasUsed): {.used.} + when defined(windows): import winlean else: diff --git a/tests/testsync.nim b/tests/testsync.nim index 02b94332..56c6a77b 100644 --- a/tests/testsync.nim +++ b/tests/testsync.nim @@ -8,6 +8,8 @@ import unittest import ../chronos +when defined(nimHasUsed): {.used.} + suite "Asynchronous sync primitives test suite": var testLockResult = "" var testEventResult = "" diff --git a/tests/testtime.nim b/tests/testtime.nim index 00401d9b..56649e3e 100644 --- a/tests/testtime.nim +++ b/tests/testtime.nim @@ -8,6 +8,8 @@ import os, unittest import ../chronos, ../chronos/timer +when defined(nimHasUsed): {.used.} + suite "Asynchronous timers test suite": const TimersCount = 10