Mercurial > vim
view src/testdir/test_writefile.vim @ 11519:4a1f7849fe86 v8.0.0642
patch 8.0.0642: writefile() continues after detecting an error
commit https://github.com/vim/vim/commit/8cf91286ca46a501d24e4b7d631b193256782c88
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 13 19:38:37 2017 +0200
patch 8.0.0642: writefile() continues after detecting an error
Problem: writefile() continues after detecting an error.
Solution: Bail out as soon as an error is detected. (suggestions by Nikolai
Pavlov, closes #1476)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 13 Jun 2017 19:45:03 +0200 |
parents | c577c6a2e88b |
children | 16ccaedce025 |
line wrap: on
line source
" Tests for the writefile() function. func Test_writefile() let f = tempname() call writefile(["over","written"], f, "b") call writefile(["hello","world"], f, "b") call writefile(["!", "good"], f, "a") call writefile(["morning"], f, "ab") call writefile(["", "vimmers"], f, "ab") let l = readfile(f) call assert_equal("hello", l[0]) call assert_equal("world!", l[1]) call assert_equal("good", l[2]) call assert_equal("morning", l[3]) call assert_equal("vimmers", l[4]) call delete(f) endfunc func Test_writefile_fails_gently() call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:') call assert_false(filereadable("Xfile")) call delete("Xfile") call assert_fails('call writefile(["test", [], [], [], "tset"], "Xfile")', 'E730:') call assert_false(filereadable("Xfile")) call delete("Xfile") call assert_fails('call writefile([], "Xfile", [])', 'E730:') call assert_false(filereadable("Xfile")) call delete("Xfile") call assert_fails('call writefile([], [])', 'E730:') endfunc