1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: fix file read end-of-file detection (#10070)

This commit is contained in:
Leigh McCulloch
2021-05-12 23:48:55 -07:00
committed by GitHub
parent ebe58dcafa
commit 49deeac71e
3 changed files with 110 additions and 63 deletions

View File

@@ -160,8 +160,13 @@ fn test_write_and_read_bytes() {
// check that trying to read data from EOF doesn't error and returns 0
mut a := []byte{len: 5}
nread := file_read.read_bytes_into(5, mut a) or {
eprintln(err)
int(-1)
n := if err is none {
int(0)
} else {
eprintln(err)
int(-1)
}
n
}
assert nread == 0
file_read.close()