mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fixes #5349
This commit is contained in:
@@ -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"
|
||||
|
||||
main()
|
||||
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
|
||||
|
||||
removeFile(fn)
|
||||
|
||||
Reference in New Issue
Block a user