mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: add os.open_stdin/0 and os.File.get_line/0
This commit is contained in:
@@ -43,6 +43,23 @@ fn test_open_file() {
|
||||
os.rm(filename)
|
||||
}
|
||||
|
||||
fn test_file_get_line() {
|
||||
filename := './fgetline.txt'
|
||||
os.write_file(filename, 'line 1\nline 2')
|
||||
mut f := os.open_file(filename, 'r', 0) or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
line1 := f.get_line() or { '' }
|
||||
line2 := f.get_line() or { '' }
|
||||
f.close()
|
||||
//
|
||||
//eprintln('line1: $line1')
|
||||
//eprintln('line2: $line2')
|
||||
assert line1 == 'line 1\n'
|
||||
assert line2 == 'line 2'
|
||||
}
|
||||
|
||||
fn test_create_file() {
|
||||
filename := './test1.txt'
|
||||
hello := 'hello world!'
|
||||
|
||||
Reference in New Issue
Block a user