Expand the documentation; Clean up debugging code; Enable all tests

This commit is contained in:
Zahary Karadjov 2020-05-05 19:20:25 +03:00
commit 18f9488bee
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
11 changed files with 205 additions and 120 deletions

View file

@ -13,7 +13,7 @@ proc bytes(s: string): seq[byte] =
proc str(bytes: openarray[byte]): string =
result = newStringOfCap(bytes.len)
for b in bytes:
for b in items(bytes):
result.add b.char
proc countLines(s: InputStream): Natural =
@ -31,13 +31,15 @@ procSuite "input stream":
test "input is not readable with read":
check not input.readable
expect Defect:
echo "This read should not complete: ", input.read
when not defined(danger):
expect Defect:
echo "This read should not complete: ", input.read
test "input is not readable with read(n)":
check not input.readable(10)
expect Defect:
echo "This read should not complete: ", input.read(10)
when not defined(danger):
expect Defect:
echo "This read should not complete: ", input.read(10)
test "next returns none":
check input.next.isNone

View file

@ -26,7 +26,6 @@ proc upcaseAllCharacters(i: InputStream, o: OutputStream) {.fsMultiSync.} =
while i.readable:
o.write toUpperAscii(i.read.char)
echo "closing upcase"
close o
proc printTimes(t: TestTimes) =
@ -51,7 +50,6 @@ procSuite "pipelines":
"""
#[
test "upper-case/base64 pipeline benchmark":
var
times: TestTimes
@ -61,9 +59,8 @@ procSuite "pipelines":
let inputText = loremIpsum.repeat(5000)
when debugHelpers:
echo "Input len: ", inputText.len
echo "Base 64 len: ", base64.encode(inputText).len
timeIt times.stdFunctionCalls:
stdRes = base64.decode(base64.encode(toUpperAscii(inputText)))
timeIt times.fsPipeline:
fsRes = executePipeline(unsafeMemoryInput(inputText),
@ -79,21 +76,14 @@ procSuite "pipelines":
base64decode,
getOutput string)
timeIt times.stdFunctionCalls:
stdRes = base64.decode(base64.encode(toUpperAscii(inputText)))
check fsAsyncRes == stdRes
check fsRes == stdRes
printTimes times
]#
asyncTest "upper-case/base64 async pipeline":
let pipe = asyncPipe()
let inputText = repeat(loremIpsum, 8)
when debugHelpers:
echo "Input len: ", inputText.len
let inputText = repeat(loremIpsum, 100)
proc pipeFeeder(s: AsyncOutputStream) {.gcsafe, async.} =
randomize 1234
@ -112,7 +102,6 @@ procSuite "pipelines":
let sleep = rand(50) - 45
if sleep > 0:
echo "written ", pos
await sleepAsync(sleep.milliseconds)
close s

View file

@ -0,0 +1,4 @@
--linedir:off
--linetrace:off
--stacktrace:off