mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-28 01:21:40 +00:00
use doAssert in tests (#16486)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -52,5 +52,5 @@ while true:
|
||||
poll()
|
||||
if clientCount == swarmSize: break
|
||||
|
||||
assert msgCount == swarmSize * messagesToSend
|
||||
doAssert msgCount == swarmSize * messagesToSend
|
||||
doAssert msgCount == 2000
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user