summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-02-08 14:33:05 +0100
committerAraq <rumpf_a@web.de>2017-02-08 14:33:05 +0100
commit794d36cf31d8f7debc2ede1f7792fdbcc0a1ef5e (patch)
tree1c033f66544115028736e8ae22d7a6b0a0a3ed98 /tests/stdlib
parentb3dcef6616d0e1db1738d0ddaff06475f25fe8f3 (diff)
downloadNim-794d36cf31d8f7debc2ede1f7792fdbcc0a1ef5e.tar.gz
fixes #5349
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tio.nim40
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/stdlib/tio.nim b/tests/stdlib/tio.nim
index ebf2d70f3..93284c1f7 100644
--- a/tests/stdlib/tio.nim
+++ b/tests/stdlib/tio.nim
@@ -1,7 +1,39 @@
+discard """
+  output: '''9
+b = false
+123456789
+Second readLine raised an exception
+123456789
+'''
+"""
+# bug #5349
+import os
+
 # test the file-IO
 
-proc main() =
-  for line in lines("thello.nim"):
-    writeLine(stdout, line)
+const fn = "file9char.txt"
+
+writeFile(fn, "123456789")
+
+var f = open(fn)
+echo getFileSize(f)
+
+var line = newString(10)
+try:
+  let b = readLine(f, line)
+  echo "b = ", b
+except:
+  echo "First readLine raised an exception"
+
+echo line
+
+try:
+  line = readLine(f)
+  let b = readLine(f, line)
+  echo "b = ", b
+except:
+  echo "Second readLine raised an exception"
+
+echo line
 
-main()
+removeFile(fn)