summary refs log tree commit diff stats
path: root/tests/stdlib/tio.nim
blob: 28e1881e8e71a4b9d3c45258329807fa10749083 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
discard """
  output: '''9
b = false
123456789
Second readLine raised an exception
123456789
'''
"""
# bug #5349
import os

# test the file-IO

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
f.close()

removeFile(fn)