aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-16 11:07:48 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-16 15:04:41 +0800
commit0167649ce4071e60d985b65f3f9408ffb21cb58c (patch)
tree0a6e9e3e31fc47d02de3561a7c063417ea3b45d2 /test
parentb75634e55ee4cdfee7917b29f39e3ca1307cb059 (diff)
downloadrneovim-0167649ce4071e60d985b65f3f9408ffb21cb58c.tar.gz
rneovim-0167649ce4071e60d985b65f3f9408ffb21cb58c.tar.bz2
rneovim-0167649ce4071e60d985b65f3f9408ffb21cb58c.zip
vim-patch:9.0.0379: cleaning up after writefile() is a hassle
Problem: Cleaning up after writefile() is a hassle. Solution: Add the 'D' flag to defer deleting the written file. Very useful in tests. https://github.com/vim/vim/commit/806a273f3c84ecd475913d901890bb1929be9a0a Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_quickfix.vim22
-rw-r--r--test/old/testdir/test_writefile.vim37
2 files changed, 27 insertions, 32 deletions
diff --git a/test/old/testdir/test_quickfix.vim b/test/old/testdir/test_quickfix.vim
index 838c4b1c15..f720b6e42d 100644
--- a/test/old/testdir/test_quickfix.vim
+++ b/test/old/testdir/test_quickfix.vim
@@ -6250,28 +6250,6 @@ func Test_very_long_error_line()
call setqflist([], 'f')
endfunc
-" The test depends on deferred delete and string interpolation, which haven't
-" been ported, so override it with a rewrite that doesn't use these features.
-func! Test_very_long_error_line()
- let msg = repeat('abcdefghijklmn', 146)
- let emsg = 'Xlonglines.c:1:' . msg
- call writefile([msg, emsg], 'Xerror')
- cfile Xerror
- call delete('Xerror')
- cwindow
- call assert_equal('|| ' .. msg, getline(1))
- call assert_equal('Xlonglines.c|1| ' .. msg, getline(2))
- cclose
-
- let l = execute('clist!')->split("\n")
- call assert_equal([' 1: ' .. msg, ' 2 Xlonglines.c:1: ' .. msg], l)
-
- let l = execute('cc')->split("\n")
- call assert_equal(['(2 of 2): ' .. msg], l)
-
- call setqflist([], 'f')
-endfunc
-
" In the quickfix window, spaces at the beginning of an informational line
" should not be removed but should be removed from an error line.
func Test_info_line_with_space()
diff --git a/test/old/testdir/test_writefile.vim b/test/old/testdir/test_writefile.vim
index 6019cee193..5e6428ded8 100644
--- a/test/old/testdir/test_writefile.vim
+++ b/test/old/testdir/test_writefile.vim
@@ -924,19 +924,36 @@ endfunc
" Test for ':write ++bin' and ':write ++nobin'
func Test_write_binary_file()
" create a file without an eol/eof character
- call writefile(0z616161, 'Xfile1', 'b')
- new Xfile1
- write ++bin Xfile2
- write ++nobin Xfile3
- call assert_equal(0z616161, readblob('Xfile2'))
+ call writefile(0z616161, 'Xwbfile1', 'b')
+ new Xwbfile1
+ write ++bin Xwbfile2
+ write ++nobin Xwbfile3
+ call assert_equal(0z616161, readblob('Xwbfile2'))
if has('win32')
- call assert_equal(0z6161610D.0A, readblob('Xfile3'))
+ call assert_equal(0z6161610D.0A, readblob('Xwbfile3'))
else
- call assert_equal(0z6161610A, readblob('Xfile3'))
+ call assert_equal(0z6161610A, readblob('Xwbfile3'))
endif
- call delete('Xfile1')
- call delete('Xfile2')
- call delete('Xfile3')
+ call delete('Xwbfile1')
+ call delete('Xwbfile2')
+ call delete('Xwbfile3')
+endfunc
+
+func DoWriteDefer()
+ call writefile(['some text'], 'XdeferDelete', 'D')
+ call assert_equal(['some text'], readfile('XdeferDelete'))
+endfunc
+
+" def DefWriteDefer()
+" writefile(['some text'], 'XdefdeferDelete', 'D')
+" assert_equal(['some text'], readfile('XdefdeferDelete'))
+" enddef
+
+func Test_write_with_deferred_delete()
+ call DoWriteDefer()
+ call assert_equal('', glob('XdeferDelete'))
+ " call DefWriteDefer()
+ " call assert_equal('', glob('XdefdeferDelete'))
endfunc
" Check that buffer is written before triggering QuitPre