remove additional line from write_file

pull/916/head
aguspiza 2019-07-01 23:24:19 +02:00 committed by Alexander Medvednikov
parent dc8c84a2a8
commit 1cd95091f2
2 changed files with 13 additions and 1 deletions

View File

@ -470,7 +470,7 @@ pub fn home_dir() string {
// write_file writes text data to a file in `path`.
pub fn write_file(path, text string) {
f := os.create(path)
f.writeln(text)
f.write(text)
f.close()
}

View File

@ -19,3 +19,15 @@ fn test_unsetenv() {
assert os.getenv('foo') == ''
}
fn test_write_and_read_string_to_file() {
filename := './test1.txt'
hello := 'hello world!'
os.write_file(filename, hello)
assert hello.len == os.file_size(filename)
read_hello := os.read_file(filename) or {
panic('error reading file $filename')
return
}
assert hello == read_hello
}