use doAssert in tests (#16486)

This commit is contained in:
flywind
2020-12-28 07:13:21 -06:00
committed by GitHub
parent f9a15dbae9
commit 6d442a40a6
78 changed files with 1056 additions and 1056 deletions

View File

@@ -5,9 +5,9 @@ proc doubleSleep(hardSleep: int) {.async.} =
sleep(hardSleep)
template assertTime(target, timeTook: float): untyped {.dirty.} =
assert(timeTook*1000 > target - 1000, "Took too short, should've taken " &
doAssert(timeTook*1000 > target - 1000, "Took too short, should've taken " &
$target & "ms, but took " & $(timeTook*1000) & "ms")
assert(timeTook*1000 < target + 1000, "Took too long, should've taken " &
doAssert(timeTook*1000 < target + 1000, "Took too long, should've taken " &
$target & "ms, but took " & $(timeTook*1000) & "ms")
var

View File

@@ -7,7 +7,7 @@ discard """
'''
"""
assert compileOption("threads"), "this test will not do anything useful without --threads:on"
doAssert compileOption("threads"), "this test will not do anything useful without --threads:on"
import asyncdispatch

View File

@@ -4,7 +4,7 @@ discard """
file: "asyncmacro.nim"
"""
assert compileOption("threads"), "this test will not do anything useful without --threads:on"
doAssert compileOption("threads"), "this test will not do anything useful without --threads:on"
import asyncdispatch

View File

@@ -52,5 +52,5 @@ while true:
poll()
if clientCount == swarmSize: break
assert msgCount == swarmSize * messagesToSend
doAssert msgCount == swarmSize * messagesToSend
doAssert msgCount == 2000

View File

@@ -21,12 +21,12 @@ proc runServer() {.async.} =
var lastN = 0
while true:
let frame = await client.recv(FrameSize)
assert frame.len == FrameSize
doAssert frame.len == FrameSize
let n = frame[0..<6].parseInt()
echo "RCVD #", n, ": ", frame[0..80], "..."
if n != lastN + 1:
echo &"******** ERROR: Server received #{n}, but last was #{lastN}!"
assert n == lastN + 1
doAssert n == lastN + 1
lastN = n
await sleepAsync 100

View File

@@ -84,7 +84,7 @@ while true:
if recvCount == swarmSize * messagesToSend:
break
assert msgCount == swarmSize * messagesToSend
assert sendports == recvports
doAssert msgCount == swarmSize * messagesToSend
doAssert sendports == recvports
echo msgCount

View File

@@ -69,5 +69,5 @@ when defined(ssl):
elif defined(linux) and int.sizeof == 8:
# currently: msgCount == 10
flakyAssert cond()
assert msgCount > 0
else: assert cond(), $msgCount
doAssert msgCount > 0
else: doAssert cond(), $msgCount