Mercurial > vim
view src/testdir/test_writefile.vim @ 12503:4d40b2644e92 v8.0.1130
patch 8.0.1130: the qf_jump() function is still too long
commit https://github.com/vim/vim/commit/9cb03716c963338f9a98d2ebc7aa3ac8b9c1eea6
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 20 22:43:02 2017 +0200
patch 8.0.1130: the qf_jump() function is still too long
Problem: The qf_jump() function is still too long.
Solution: Split of parts to separate functions. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 20 Sep 2017 22:45:04 +0200 |
parents | 16ccaedce025 |
children | ae2802b6bf7d |
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 func Test_writefile_fails_conversion() if !has('multi_byte') || !has('iconv') return endif set nobackup nowritebackup new let contents = ["line one", "line two"] call writefile(contents, 'Xfile') edit Xfile call setline(1, ["first line", "cannot convert \u010b", "third line"]) call assert_fails('write ++enc=cp932') call assert_equal(contents, readfile('Xfile')) call delete('Xfile') bwipe! set backup& writebackup& endfunc