fixes broken test

This commit is contained in:
jangko 2021-01-07 12:12:55 +07:00
commit 91d119fdb0
No known key found for this signature in database
GPG key ID: 31702AE10541E6B9
3 changed files with 12 additions and 4 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
nimcache/ nimcache/
*.exe

View file

@ -789,7 +789,7 @@ proc readInto*(s: InputStream, target: var openarray[byte]): bool =
s.readIntoEx(target) == target.len s.readIntoEx(target) == target.len
template readIntoEx*(sp: AsyncInputStream, dst: var openarray[byte]): int = template readIntoEx*(sp: AsyncInputStream, dst: var openarray[byte]): int =
let s = sp let s = InputStream(sp)
# BEWARE! `openArrayToPair` here is needed to avoid # BEWARE! `openArrayToPair` here is needed to avoid
# double evaluation of the `dst` expression: # double evaluation of the `dst` expression:
let (dstAddr, dstLen) = openArrayToPair(dst) let (dstAddr, dstLen) = openArrayToPair(dst)
@ -806,7 +806,7 @@ template readInto*(sp: AsyncInputStream, dst: var openarray[byte]): bool =
## the expression will complete immediately. ## the expression will complete immediately.
## Otherwise, it will await more bytes to become available. ## Otherwise, it will await more bytes to become available.
let s = sp let s = InputStream(sp)
# BEWARE! `openArrayToPair` here is needed to avoid # BEWARE! `openArrayToPair` here is needed to avoid
# double evaluation of the `dst` expression: # double evaluation of the `dst` expression:
let (dstAddr, dstLen) = openArrayToPair(dst) let (dstAddr, dstLen) = openArrayToPair(dst)

View file

@ -38,6 +38,15 @@ template timeit(timerVar: var Nanos, code: untyped) =
code code
timerVar = int(getTicks() - t0) div 1000000 timerVar = int(getTicks() - t0) div 1000000
proc getOutput(sp: AsyncInputStream, T: type string): Future[string] {.async.} =
# this proc is a quick hack to let the test pass
# do not use it in production code
let size = sp.totalUnconsumedBytes()
if size > 0:
var data = newSeq[byte](size)
discard sp.readinto(data)
result = cast[string](data)
procSuite "pipelines": procSuite "pipelines":
let loremIpsum = """ let loremIpsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
@ -117,4 +126,3 @@ procSuite "pipelines":
let fsAsyncres = await f let fsAsyncres = await f
check fsAsyncRes == toUpperAscii(inputText) check fsAsyncRes == toUpperAscii(inputText)