From e7a34b74f298eaabd7bdbe2f080bf9747ed6bfd9 Mon Sep 17 00:00:00 2001 From: andri lim Date: Tue, 3 Sep 2019 14:50:13 +0700 Subject: [PATCH] fixes output stream casting problem --- faststreams/output_stream.nim | 4 +++- tests/test_output_stream.nim | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/faststreams/output_stream.nim b/faststreams/output_stream.nim index 5fd8dae..e9f3c26 100644 --- a/faststreams/output_stream.nim +++ b/faststreams/output_stream.nim @@ -6,7 +6,9 @@ type buffer: string startOffset: int - OutputStream* = object + # somehow casting outputDevice to + # OutputStreamVar requires RootObj + OutputStream* = object of RootObj cursor*: WriteCursor pages: Deque[OutputPage] endPos: int diff --git a/tests/test_output_stream.nim b/tests/test_output_stream.nim index 90f17a2..4514743 100644 --- a/tests/test_output_stream.nim +++ b/tests/test_output_stream.nim @@ -58,7 +58,7 @@ suite "output stream": test "append zero length slice": output "" checkOutputsMatch() - + test "string output": for i in 0 .. 1: output $i @@ -150,3 +150,14 @@ suite "output stream": # The final outputs are the same check altOutput == memStream.getOutput + test "nim odd behavior": + # discovered in status-im/nim-snappy#2 + proc encode(s: OutputStreamVar) = + check true + + proc abc(s: OutputStreamVar) = + OutputStreamVar(s.outputDevice).encode + check true + + var os = new OutputStream + os.abc()