assert() -> doAssert()
Also fixed a test and added the other to the Nimble task.
This commit is contained in:
parent
7903f1680f
commit
acd5a6063c
6 changed files with 18 additions and 13 deletions
|
|
@ -101,7 +101,7 @@ proc eob*(s: ByteStream): bool {.inline.} =
|
|||
s.head != s.bufferEnd
|
||||
|
||||
proc peek*(s: ByteStream): byte {.inline.} =
|
||||
assert s.head != s.bufferEnd
|
||||
doAssert s.head != s.bufferEnd
|
||||
return s.head[]
|
||||
|
||||
when debugHelpers:
|
||||
|
|
@ -121,7 +121,7 @@ proc read*(s: var ByteStream): byte =
|
|||
|
||||
proc checkReadAhead(s: ByteStreamVar, n: int): ptr byte =
|
||||
result = s.head
|
||||
assert distance(s.head, s.bufferEnd) >= n
|
||||
doAssert distance(s.head, s.bufferEnd) >= n
|
||||
s.head = s.head.shift(n)
|
||||
|
||||
template readBytes*(s: ByteStreamVar, n: int): auto =
|
||||
|
|
@ -133,9 +133,9 @@ proc next*(s: var ByteStream): Option[byte] =
|
|||
|
||||
proc bufferPos(s: ByteStream, pos: int): ptr byte =
|
||||
let shiftFromEnd = pos - s.bufferEndPos
|
||||
assert shiftFromEnd < 0
|
||||
doAssert shiftFromEnd < 0
|
||||
result = s.bufferEnd.shift shiftFromEnd
|
||||
assert result >= s.bufferStart
|
||||
doAssert result >= s.bufferStart
|
||||
|
||||
proc pos*(s: ByteStream): int {.inline.} =
|
||||
s.bufferEndPos - distance(s.head, s.bufferEnd)
|
||||
|
|
@ -148,7 +148,7 @@ proc `[]`*(s: ByteStream, pos: int): byte {.inline.} =
|
|||
|
||||
proc rewind*(s: var ByteStream, delta: int) =
|
||||
s.head = s.head.shift(-delta)
|
||||
assert s.head >= s.bufferStart
|
||||
doAssert s.head >= s.bufferStart
|
||||
|
||||
proc rewindTo*(s: var ByteStream, pos: int) {.inline.} =
|
||||
s.head = s.bufferPos(pos)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ proc getOutput*(s: OutputStreamVar, T: type string): string =
|
|||
else:
|
||||
result = newStringOfCap(s.pos)
|
||||
for page in s.pages:
|
||||
assert page.delayedWrites == 0
|
||||
doAssert page.delayedWrites == 0
|
||||
result.add page.buffer.toOpenArray(page.startOffset.int,
|
||||
page.buffer.len - 1)
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ proc flushDelayedPages*(s: OutputStreamVar) =
|
|||
# Send to output
|
||||
|
||||
proc delayFixedSizeWrite*(s: OutputStreamVar, size: int): DelayedWriteCursor =
|
||||
assert size < pageSize
|
||||
doAssert size < pageSize
|
||||
|
||||
let remainingBytesInPage = distance(s.head, s.bufferEnd)
|
||||
if size > remainingBytesInPage:
|
||||
|
|
@ -132,7 +132,7 @@ proc delayVarSizeWrite*(s: OutputStreamVar, maxSize: int): DelayedWriteCursor =
|
|||
|
||||
proc decRef(x: var int16): int16 =
|
||||
result = x - 1
|
||||
assert result >= 0
|
||||
doAssert result >= 0
|
||||
x = result
|
||||
|
||||
proc endWrite*(cursor: DelayedWriteCursor, data: openarray[byte]) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue