aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-31 09:39:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-07-31 10:49:57 +0800
commit30f85fcb7f86857d70601569847e6bd0019fa54c (patch)
treee28aaa8e9449b38e5cc25386575e8a05b9084a84
parent619cb143f93fbf75adde9710415a74d36c8eb63d (diff)
downloadrneovim-30f85fcb7f86857d70601569847e6bd0019fa54c.tar.gz
rneovim-30f85fcb7f86857d70601569847e6bd0019fa54c.tar.bz2
rneovim-30f85fcb7f86857d70601569847e6bd0019fa54c.zip
vim-patch:9.1.0419: eval.c not sufficiently tested
Problem: eval.c not sufficiently tested Solution: Add a few more additional tests for eval.c, (Yegappan Lakshmanan) closes: vim/vim#14799 https://github.com/vim/vim/commit/4776e64e72de2976ff90b17d236e50e2b02c5540 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--test/old/testdir/test_autoload.vim1
-rw-r--r--test/old/testdir/test_fold.vim29
-rw-r--r--test/old/testdir/test_spellrare.vim18
-rw-r--r--test/old/testdir/test_substitute.vim14
-rw-r--r--test/old/testdir/test_vimscript.vim11
5 files changed, 58 insertions, 15 deletions
diff --git a/test/old/testdir/test_autoload.vim b/test/old/testdir/test_autoload.vim
index e89fe3943b..156387a2d2 100644
--- a/test/old/testdir/test_autoload.vim
+++ b/test/old/testdir/test_autoload.vim
@@ -21,5 +21,4 @@ func Test_source_autoload()
call assert_equal(1, g:loaded_sourced_vim)
endfunc
-
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_fold.vim b/test/old/testdir/test_fold.vim
index 7b4e56508d..36f72f5e01 100644
--- a/test/old/testdir/test_fold.vim
+++ b/test/old/testdir/test_fold.vim
@@ -1497,6 +1497,35 @@ func Test_foldtext_in_modeline()
delfunc ModelineFoldText
endfunc
+" Test for setting 'foldexpr' from the modeline and executing the expression
+" in a sandbox
+func Test_foldexpr_in_modeline()
+ func ModelineFoldExpr()
+ call feedkeys('aFoo', 'xt')
+ return strlen(matchstr(getline(v:lnum),'^\s*'))
+ endfunc
+ let lines =<< trim END
+ aaa
+ bbb
+ ccc
+ ccc
+ bbb
+ aaa
+ " vim: foldenable foldmethod=expr foldexpr=ModelineFoldExpr()
+ END
+ call writefile(lines, 'Xmodelinefoldexpr', 'D')
+
+ set modeline modelineexpr
+ split Xmodelinefoldexpr
+
+ call assert_equal(2, foldlevel(3))
+ call assert_equal(lines, getbufline('', 1, '$'))
+
+ bw!
+ set modeline& modelineexpr&
+ delfunc ModelineFoldExpr
+endfunc
+
" Make sure a fold containing a nested fold is split correctly when using
" foldmethod=indent
func Test_fold_split()
diff --git a/test/old/testdir/test_spellrare.vim b/test/old/testdir/test_spellrare.vim
index bbb13c27c2..ceb35cbd17 100644
--- a/test/old/testdir/test_spellrare.vim
+++ b/test/old/testdir/test_spellrare.vim
@@ -11,15 +11,15 @@ func Test_spellrareword()
" Create a small word list to test that spellbadword('...')
" can return ['...', 'rare'].
let lines =<< trim END
- foo
- foobar/?
- foobara/?
-END
- call writefile(lines, 'Xwords', 'D')
-
- mkspell! Xwords.spl Xwords
- set spelllang=Xwords.spl
- call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
+ foo
+ foobar/?
+ foobara/?
+ END
+ call writefile(lines, 'Xwords', 'D')
+
+ mkspell! Xwords.spl Xwords
+ set spelllang=Xwords.spl
+ call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
new
call setline(1, ['foo', '', 'foo bar foo bar foobara foo foo foo foobar', '', 'End'])
diff --git a/test/old/testdir/test_substitute.vim b/test/old/testdir/test_substitute.vim
index f69a3c525b..f0a25b2804 100644
--- a/test/old/testdir/test_substitute.vim
+++ b/test/old/testdir/test_substitute.vim
@@ -1507,4 +1507,18 @@ func Test_substitute_expr_recursive()
exe bufnr .. "bw!"
endfunc
+" Test for changing 'cpo' in a substitute expression
+func Test_substitute_expr_cpo()
+ func XSubExpr()
+ set cpo=
+ return 'x'
+ endfunc
+
+ let save_cpo = &cpo
+ call assert_equal('xxx', substitute('abc', '.', '\=XSubExpr()', 'g'))
+ call assert_equal(save_cpo, &cpo)
+
+ delfunc XSubExpr
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim
index 108321e8ad..7f29c7f651 100644
--- a/test/old/testdir/test_vimscript.vim
+++ b/test/old/testdir/test_vimscript.vim
@@ -7450,12 +7450,13 @@ func Test_for_over_string()
endfor
call assert_equal('', res)
- " Test for ignoring loop var assignment
- let c = 0
- for _ in 'abc'
- let c += 1
+ " Test for using "_" as the loop variable
+ let i = 0
+ let s = 'abc'
+ for _ in s
+ call assert_equal(s[i], _)
+ let i += 1
endfor
- call assert_equal(3, c)
endfunc
" Test for deeply nested :source command {{{1