aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-04-08 13:24:43 +0800
committerGitHub <noreply@github.com>2025-04-08 13:24:43 +0800
commitc0f46daca5e6b3b5546013e2c3ed87f54fd24b9f (patch)
tree9fd7761719eb24df79f20febb824adf1185d69be /test
parent8af9f8ab5ecd59df52aed9019e8ecc9f8101ee7d (diff)
parent454abde1aa99fde0e50b65a973f0d2eaabd4dc1e (diff)
downloadrneovim-c0f46daca5e6b3b5546013e2c3ed87f54fd24b9f.tar.gz
rneovim-c0f46daca5e6b3b5546013e2c3ed87f54fd24b9f.tar.bz2
rneovim-c0f46daca5e6b3b5546013e2c3ed87f54fd24b9f.zip
Merge pull request #33381 from zeertzjq/vim-9.1.1283
vim-patch:9.1.{1253,1283,1287}
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/gen_opt_test.vim2
-rw-r--r--test/old/testdir/test_quickfix.vim181
2 files changed, 183 insertions, 0 deletions
diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim
index fb0af3de0a..01c7d88464 100644
--- a/test/old/testdir/gen_opt_test.vim
+++ b/test/old/testdir/gen_opt_test.vim
@@ -106,6 +106,7 @@ let test_values = {
\ []],
\
"\ number options
+ \ 'chistory': [[1, 2, 10, 50], [1000, -1]],
\ 'cmdheight': [[0, 1, 2, 10], [-1]],
\ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
\ 'columns': [[12, 80, 10000], [-1, 0, 10]],
@@ -116,6 +117,7 @@ let test_values = {
"\ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
"\ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
"\ 'imstyle': [[0, 1], [-1, 2, 999]],
+ \ 'lhistory': [[1, 2, 10, 50], [1000, -1]],
\ 'lines': [[2, 24, 1000], [-1, 0, 1]],
\ 'linespace': [[-1, 0, 2, 4, 999], ['']],
\ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
diff --git a/test/old/testdir/test_quickfix.vim b/test/old/testdir/test_quickfix.vim
index ca48812e7d..ced6c8d7bd 100644
--- a/test/old/testdir/test_quickfix.vim
+++ b/test/old/testdir/test_quickfix.vim
@@ -43,6 +43,8 @@ func s:setup_commands(cchar)
command! -count=1 -nargs=0 Xabove <mods><count>cabove
command! -count=1 -nargs=0 Xbefore <mods><count>cbefore
command! -count=1 -nargs=0 Xafter <mods><count>cafter
+ command! -nargs=1 Xsethist <mods>set chistory=<args>
+ command! -nargs=0 Xsethistdefault <mods>set chistory&
let g:Xgetlist = function('getqflist')
let g:Xsetlist = function('setqflist')
call setqflist([], 'f')
@@ -80,6 +82,9 @@ func s:setup_commands(cchar)
command! -count=1 -nargs=0 Xabove <mods><count>labove
command! -count=1 -nargs=0 Xbefore <mods><count>lbefore
command! -count=1 -nargs=0 Xafter <mods><count>lafter
+ command! -nargs=1 Xsethist <mods>set lhistory=<args>
+ command! -nargs=1 Xsetlocalhist <mods>setlocal lhistory=<args>
+ command! -nargs=0 Xsethistdefault <mods>set lhistory&
let g:Xgetlist = function('getloclist', [0])
let g:Xsetlist = function('setloclist', [0])
call setloclist(0, [], 'f')
@@ -6596,4 +6601,180 @@ func Test_hardlink_fname()
call Xtest_hardlink_fname('l')
endfunc
+" Test for checking if correct number of tests are deleted
+" and current list stays the same after setting Xhistory
+" to a smaller number. Do roughly the same for growing the stack.
+func Xtest_resize_list_stack(cchar)
+ call s:setup_commands(a:cchar)
+ Xsethist 100
+
+ for i in range(1, 100)
+ Xexpr string(i)
+ endfor
+ Xopen
+ call assert_equal(g:Xgetlist({'nr': '$'}).nr, 100)
+ call assert_equal("|| 100", getline(1))
+ Xsethist 8
+ call assert_equal("|| 100", getline(1))
+ Xolder 5
+ call assert_equal("|| 95", getline(1))
+ Xsethist 6
+ call assert_equal("|| 95", getline(1))
+ Xsethist 1
+ call assert_equal("|| 100", getline(1))
+
+ " grow array again
+ Xsethist 100
+ for i in range(1, 99)
+ Xexpr string(i)
+ endfor
+ call assert_equal("|| 99", getline(1))
+ Xolder 99
+ call assert_equal("|| 100", getline(1))
+
+ Xsethistdefault
+endfunc
+
+func Test_resize_list_stack()
+ call Xtest_resize_list_stack('c')
+ call Xtest_resize_list_stack('l')
+endfunc
+
+" Test to check if order of lists is from
+" oldest at the bottom to newest at the top
+func Xtest_Xhistory_check_order(cchar)
+
+ Xsethist 100
+
+ for i in range(1, 100)
+ Xexpr string(i)
+ endfor
+
+ Xopen
+ for i in range(100, 1, -1)
+ let l:ret = assert_equal("|| " .. i, getline(1))
+
+ if ret == 1 || i == 1
+ break
+ endif
+ Xolder
+ endfor
+
+ for i in range(1, 50)
+ Xexpr string(i)
+ endfor
+
+ for i in range(50, 1, -1)
+ let l:ret = assert_equal("|| " .. i, getline(1))
+
+ if ret == 1 || i == 50
+ break
+ endif
+ Xolder
+ endfor
+
+ for i in range(50, 1, -1)
+ let l:ret = assert_equal("|| " .. i, getline(1))
+
+ if ret == 1 || i == 50
+ break
+ endif
+ Xolder
+ endfor
+
+ Xsethistdefault
+endfunc
+
+func Test_set_history_to_check_order()
+ call Xtest_Xhistory_check_order('c')
+ call Xtest_Xhistory_check_order('l')
+endfunc
+
+" Check if 'lhistory' is the same between the location list window
+" and associated normal window
+func Test_win_and_loc_synced()
+ new
+ set lhistory=2
+ lexpr "Text"
+ lopen
+
+ " check if lhistory is synced when modified inside the
+ " location list window
+ setlocal lhistory=1
+ wincmd k
+ call assert_equal(&lhistory, 1)
+
+ " check if lhistory is synced when modified inside the
+ " normal window
+ setlocal lhistory=10
+ lopen
+ call assert_equal(&lhistory, 10)
+
+ wincmd k
+ lclose
+ wincmd q
+
+ set lhistory&
+endfunc
+
+" Test if setting the lhistory of one window doesn't affect the other
+func Test_two_win_are_independent_of_history()
+ setlocal lhistory=10
+ new
+ setlocal lhistory=20
+ wincmd w
+ call assert_equal(&lhistory, 10)
+ wincmd w
+ wincmd q
+
+ set lhistory&
+endfunc
+
+" Test if lhistory is copied over to a new window
+func Test_lhistory_copied_over()
+ setlocal lhistory=3
+ split
+ call assert_equal(&lhistory, 3)
+ wincmd q
+
+ set lhistory&
+endfunc
+
+" Test if error occurs when given invalid history number
+func Xtest_invalid_history_num(cchar)
+ call s:setup_commands(a:cchar)
+
+ call assert_fails('Xsethist -10000', "E1542:")
+ call assert_fails('Xsethist 10000', "E1543:")
+ Xsethistdefault
+endfunc
+
+func Test_invalid_history_num()
+ call Xtest_invalid_history_num('c')
+ call Xtest_invalid_history_num('l')
+endfunc
+
+" Test if chistory and lhistory don't affect each other
+func Test_chi_and_lhi_are_independent()
+ set chistory=100
+ set lhistory=100
+
+ set chistory=10
+ call assert_equal(&lhistory, 100)
+
+ set lhistory=1
+ call assert_equal(&chistory, 10)
+
+ set chistory&
+ set lhistory&
+endfunc
+
+func Test_quickfix_close_buffer_crash()
+ new
+ lexpr 'test' | lopen
+ wincmd k
+ lclose
+ wincmd q
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab