diff options
Diffstat (limited to 'tests/vm/tfile_rw.nim')
-rw-r--r-- | tests/vm/tfile_rw.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/vm/tfile_rw.nim b/tests/vm/tfile_rw.nim new file mode 100644 index 000000000..439886e49 --- /dev/null +++ b/tests/vm/tfile_rw.nim @@ -0,0 +1,22 @@ +# test file read write in vm + +import os, strutils + +const filename = splitFile(currentSourcePath).dir / "tfile_rw.txt" + +const mytext = "line1\nline2\nline3" +static: + writeFile(filename, mytext) +const myfile_str = staticRead(filename) +const myfile_str2 = readFile(filename) +const myfile_str_seq = readLines(filename, 3) + +static: + doAssert myfile_str == mytext + doAssert myfile_str2 == mytext + doAssert myfile_str_seq[0] == "line1" + doAssert myfile_str_seq[1] == "line2" + doAssert myfile_str_seq.join("\n") == mytext + + +removeFile(filename) |