aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_autocmd.vim49
-rw-r--r--src/nvim/testdir/test_edit.vim19
-rw-r--r--src/nvim/testdir/test_substitute.vim11
-rw-r--r--src/nvim/testdir/test_writefile.vim25
4 files changed, 78 insertions, 26 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 1c1da0572b..8182c6973b 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -72,7 +72,31 @@ if has('timers')
au! CursorHoldI
set updatetime&
endfunc
-endif
+
+ func Test_OptionSet_modeline()
+ throw 'skipped: Nvim does not support test_override()'
+ call test_override('starting', 1)
+ au! OptionSet
+ augroup set_tabstop
+ au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
+ augroup END
+ call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline')
+ set modeline
+ let v:errmsg = ''
+ call assert_fails('split XoptionsetModeline', 'E12:')
+ call assert_equal(7, &ts)
+ call assert_equal('', v:errmsg)
+
+ augroup set_tabstop
+ au!
+ augroup END
+ bwipe!
+ set ts&
+ call delete('XoptionsetModeline')
+ call test_override('starting', 0)
+ endfunc
+
+endif "has('timers')
func Test_bufunload()
augroup test_bufunload_group
@@ -677,29 +701,6 @@ func Test_OptionSet_diffmode_close()
"delfunc! AutoCommandOptionSet
endfunc
-func Test_OptionSet_modeline()
- throw 'skipped: Nvim does not support test_override()'
- call test_override('starting', 1)
- au! OptionSet
- augroup set_tabstop
- au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
- augroup END
- call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline')
- set modeline
- let v:errmsg = ''
- call assert_fails('split XoptionsetModeline', 'E12:')
- call assert_equal(7, &ts)
- call assert_equal('', v:errmsg)
-
- augroup set_tabstop
- au!
- augroup END
- bwipe!
- set ts&
- call delete('XoptionsetModeline')
- call test_override('starting', 0)
-endfunc
-
" Test for Bufleave autocommand that deletes the buffer we are about to edit.
func Test_BufleaveWithDelete()
new | edit Xfile1
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index de0f3ddb06..7f3994300f 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -1385,9 +1385,26 @@ func Test_edit_complete_very_long_name()
return
endtry
- " Try to get the Vim window position before setting 'columns'.
+ " Try to get the Vim window position before setting 'columns', so that we can
+ " move the window back to where it was.
let winposx = getwinposx()
let winposy = getwinposy()
+
+ if winposx >= 0 && winposy >= 0 && !has('gui_running')
+ " We did get the window position, but xterm may report the wrong numbers.
+ " Move the window to the reported position and compute any offset.
+ exe 'winpos ' . winposx . ' ' . winposy
+ sleep 100m
+ let x = getwinposx()
+ if x >= 0
+ let winposx += winposx - x
+ endif
+ let y = getwinposy()
+ if y >= 0
+ let winposy += winposy - y
+ endif
+ endif
+
let save_columns = &columns
" Need at least about 1100 columns to reproduce the problem.
set columns=2000
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index e074a85530..8b306192f0 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -639,6 +639,17 @@ func Test_nocatch_sub_failure_handling()
call assert_equal(1, error_caught)
call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+ " Same, but using "n" flag so that "sandbox" gets set
+ call setline(1, ['1 aaa', '2 aaa', '3 aaa'])
+ let error_caught = 0
+ try
+ %s/aaa/\=Foo()/gn
+ catch
+ let error_caught = 1
+ endtry
+ call assert_equal(1, error_caught)
+ call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+
bwipe!
endfunc
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim
index 1cd5fb306a..b4585a72ef 100644
--- a/src/nvim/testdir/test_writefile.vim
+++ b/src/nvim/testdir/test_writefile.vim
@@ -36,13 +36,15 @@ func Test_writefile_fails_conversion()
if !has('multi_byte') || !has('iconv')
return
endif
+ " Without a backup file the write won't happen if there is a conversion
+ " error.
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_fails('write ++enc=cp932', 'E513:')
call assert_equal(contents, readfile('Xfile'))
call delete('Xfile')
@@ -50,6 +52,27 @@ func Test_writefile_fails_conversion()
set backup& writebackup&
endfunc
+func Test_writefile_fails_conversion2()
+ if !has('iconv') || has('sun')
+ return
+ endif
+ " With a backup file the write happens even if there is a conversion error,
+ " but then the backup file must remain
+ set nobackup writebackup
+ let contents = ["line one", "line two"]
+ call writefile(contents, 'Xfile_conversion_err')
+ edit Xfile_conversion_err
+ call setline(1, ["first line", "cannot convert \u010b", "third line"])
+ set fileencoding=latin1
+ let output = execute('write')
+ call assert_match('CONVERSION ERROR', output)
+ call assert_equal(contents, readfile('Xfile_conversion_err~'))
+
+ call delete('Xfile_conversion_err')
+ call delete('Xfile_conversion_err~')
+ bwipe!
+endfunc
+
func SetFlag(timer)
let g:flag = 1
endfunc