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

os: refactor err == IError(os.Eof{}) to err is os.Eof

This commit is contained in:
Delyan Angelov 2022-11-16 00:53:37 +02:00
parent ddc1a1fc08
commit 9bb1867be0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 4 additions and 4 deletions

View File

@ -144,7 +144,7 @@ fn test_read_eof_last_read_partial_buffer_fill() {
assert false assert false
} else { } else {
// Expected an error when received end-of-file. // Expected an error when received end-of-file.
assert err == IError(os.Eof{}) assert err is os.Eof
} }
f.close() f.close()
} }
@ -176,7 +176,7 @@ fn test_read_eof_last_read_full_buffer_fill() {
assert false assert false
} else { } else {
// Expect an error at EOF. // Expect an error at EOF.
assert err == IError(os.Eof{}) assert err is os.Eof
} }
f.close() f.close()
} }

View File

@ -89,7 +89,7 @@ fn slurp_file_in_builder(fp &C.FILE) !strings.Builder {
mut sb := strings.new_builder(os.buf_size) mut sb := strings.new_builder(os.buf_size)
for { for {
mut read_bytes := fread(&buf[0], 1, os.buf_size, fp) or { mut read_bytes := fread(&buf[0], 1, os.buf_size, fp) or {
if err == IError(Eof{}) { if err is Eof {
break break
} }
unsafe { sb.free() } unsafe { sb.free() }

View File

@ -194,7 +194,7 @@ fn test_write_and_read_bytes() {
// check that trying to read data from EOF doesn't error and returns 0 // check that trying to read data from EOF doesn't error and returns 0
mut a := []u8{len: 5} mut a := []u8{len: 5}
nread := file_read.read_bytes_into(5, mut a) or { nread := file_read.read_bytes_into(5, mut a) or {
n := if err == IError(os.Eof{}) { n := if err is os.Eof {
int(0) int(0)
} else { } else {
eprintln(err) eprintln(err)