From 90333b24c3582cb017d823583d4896c8bbb8edb8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Feb 2023 19:35:31 +0800 Subject: vim-patch:9.0.1277: cursor may move with autocmd in Visual mode (#22116) Problem: Cursor may move with autocmd in Visual mode. Solution: Restore "VIsual_active" before calling check_cursor(). (closes vim/vim#11939) https://github.com/vim/vim/commit/49f0524fb575bb1cf4881e472afab7d37c579440 --- src/nvim/testdir/test_functions.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 500c30c76b..4ed1187a19 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1511,7 +1511,7 @@ endfunc func Test_setbufvar_options() " This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the - " window layout. + " window layout and cursor position. call assert_equal(1, winnr('$')) split dummy_preview resize 2 @@ -1525,11 +1525,20 @@ func Test_setbufvar_options() execute 'belowright vertical split #' . dummy_buf call assert_equal(wh, winheight(0)) let dum1_id = win_getid() + call setline(1, 'foo') + normal! V$ + call assert_equal(4, col('.')) + call setbufvar('dummy_preview', '&buftype', 'nofile') + call assert_equal(4, col('.')) wincmd h let wh = winheight(0) + call setline(1, 'foo') + normal! V$ + call assert_equal(4, col('.')) let dummy_buf = bufnr('dummy_buf2', v:true) eval 'nofile'->setbufvar(dummy_buf, '&buftype') + call assert_equal(4, col('.')) execute 'belowright vertical split #' . dummy_buf call assert_equal(wh, winheight(0)) -- cgit From 4b9bb3a1841489a18bbeb124fc11cbf359553ef5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 4 Feb 2023 16:05:45 +0100 Subject: vim-patch:9.0.1278: go.work.sum files are not recognized (#22121) Problem: go.work.sum files are not recognized. Solution: Recognize go.work.sum files as the gosum filetype. (Amaan Qureshi, closes vim/vim#11940) https://github.com/vim/vim/commit/4ad8ae8465e30df38dba31910f130891b16d38a0 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 7b5ec22dd4..7cf32bd3a5 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -235,7 +235,7 @@ let s:filename_checks = { \ 'gnuplot': ['file.gpi', '.gnuplot'], \ 'go': ['file.go'], \ 'gomod': ['go.mod'], - \ 'gosum': ['go.sum'], + \ 'gosum': ['go.sum', 'go.work.sum'], \ 'gowork': ['go.work'], \ 'gp': ['file.gp', '.gprc'], \ 'gpg': ['/.gnupg/options', '/.gnupg/gpg.conf', '/usr/any/gnupg/options.skel', 'any/.gnupg/gpg.conf', 'any/.gnupg/options', 'any/usr/any/gnupg/options.skel'], -- cgit From 5c4b503d3cb4a48d083bcf50d4932927e6eb749d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 5 Feb 2023 09:37:12 +0800 Subject: vim-patch:9.0.1279: display shows lines scrolled down erroneously (#22126) Problem: Display shows lines scrolled down erroneously. (Yishai Lerner) Solution: Do not change "wl_lnum" at index zero. (closes vim/vim#11938) https://github.com/vim/vim/commit/61fdbfa1e3c842252b701aec12f45839ca41ece5 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_move.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_move.vim b/src/nvim/testdir/test_move.vim index 8c40369dbd..40d75d887e 100644 --- a/src/nvim/testdir/test_move.vim +++ b/src/nvim/testdir/test_move.vim @@ -1,5 +1,8 @@ " Test the ":move" command. +source check.vim +source screendump.vim + func Test_move() enew! call append(0, ['line 1', 'line 2', 'line 3']) @@ -43,4 +46,25 @@ func Test_move() %bwipeout! endfunc +func Test_move_undo() + CheckRunVimInTerminal + + let lines =<< trim END + call setline(1, ['First', 'Second', 'Third', 'Fourth']) + END + call writefile(lines, 'Xtest_move_undo.vim', 'D') + let buf = RunVimInTerminal('-S Xtest_move_undo.vim', #{rows: 10, cols: 60, statusoff: 2}) + + call term_sendkeys(buf, "gg:move +1\") + call VerifyScreenDump(buf, 'Test_move_undo_1', {}) + + " here the display would show the last few lines scrolled down + call term_sendkeys(buf, "u") + call term_sendkeys(buf, ":\") + call VerifyScreenDump(buf, 'Test_move_undo_2', {}) + + call StopVimInTerminal(buf) +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 23e34fe534d201a1323ab040cb2201d21fe865cc Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 5 Feb 2023 17:59:18 +0100 Subject: vim-patch:9.0.1281: Cadence files are not recognized (#22130) Problem: Cadence files are not recognized. Solution: Recognize Cadence files. (Janez Podhostnik, closes vim/vim#11951) https://github.com/vim/vim/commit/cb626a4692df7154be02b47d6089ec679e95cb44 Co-authored-by: Janez Podhostnik --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 7cf32bd3a5..3af200799a 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -522,6 +522,7 @@ let s:filename_checks = { \ 'sinda': ['file.sin', 'file.s85'], \ 'sisu': ['file.sst', 'file.ssm', 'file.ssi', 'file.-sst', 'file._sst', 'file.sst.meta', 'file.-sst.meta', 'file._sst.meta'], \ 'skill': ['file.il', 'file.ils', 'file.cdf'], + \ 'cdc': ['file.cdc'], \ 'slang': ['file.sl'], \ 'slice': ['file.ice'], \ 'slpconf': ['/etc/slp.conf', 'any/etc/slp.conf'], -- cgit From 1675f0e270579036c454c38f28e650b60a3fba1a Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 6 Feb 2023 04:01:17 -0500 Subject: vim-patch:9.0.1282: Ron files are not recognized (#22132) Problem: Ron files are not recognized. Solution: Recognize Ron files. (Amaan Qureshi, closes vim/vim#11948) https://github.com/vim/vim/commit/c8ef30bc2eaec956549510cd4b2efc96b7aee563 --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 3af200799a..bdd12d44cb 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -489,6 +489,7 @@ let s:filename_checks = { \ 'rnoweb': ['file.rnw', 'file.snw'], \ 'robot': ['file.robot', 'file.resource'], \ 'robots': ['robots.txt'], + \ 'ron': ['file.ron'], \ 'routeros': ['file.rsc'], \ 'rpcgen': ['file.x'], \ 'rpl': ['file.rpl'], -- cgit From 1391385ba9f83d32f3b6fc54587f03a1d34960d9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Feb 2023 07:54:33 +0800 Subject: vim-patch:9.0.1290: CTRL-N and -P on cmdline don't trigger CmdlineChanged (#22151) Problem: CTRL-N and -P on cmdline don't trigger CmdlineChanged. Solution: Jump to cmdline_changed instead of cmdline_not_changed. (closes vim/vim#11956) https://github.com/vim/vim/commit/af9e28a5b8f888b79459393ddb26fffe613c3f3c Cherry-pick Test_Cmdline() change from patch 9.0.1039. --- src/nvim/testdir/test_autocmd.vim | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 83af0f6be0..a1a3ba3198 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1897,6 +1897,50 @@ func Test_Cmdline() call assert_equal(':', g:entered) au! CmdlineChanged + let g:log = [] + cnoremap call setcmdline('ls') + autocmd CmdlineChanged : let g:log += [getcmdline()] + call feedkeys(":\", 'xt') + call assert_equal(['ls'], g:log) + unlet g:log + au! CmdlineChanged + cunmap + + let g:log = [] + autocmd CmdlineChanged : let g:log += [getcmdline()] + call feedkeys(":sign \\\\\\\", 'xt') + call assert_equal([ + \ 's', + \ 'si', + \ 'sig', + \ 'sign', + \ 'sign ', + \ 'sign define', + \ 'sign jump', + \ 'sign list', + \ 'sign jump', + \ 'sign define', + \ 'sign ', + \ ], g:log) + let g:log = [] + set wildmenu wildoptions+=pum + call feedkeys(":sign \\\\\\", 'xt') + call assert_equal([ + \ 's', + \ 'si', + \ 'sig', + \ 'sign', + \ 'sign ', + \ 'sign unplace', + \ 'sign jump', + \ 'sign define', + \ 'sign undefine', + \ 'sign unplace', + \ ], g:log) + set wildmenu& wildoptions& + unlet g:log + au! CmdlineChanged + au! CmdlineEnter : let g:entered = expand('') au! CmdlineLeave : let g:left = expand('') let g:entered = 0 -- cgit From 8fbe75b3dda7ab3b9e6df0d5406539bde4c80887 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 7 Feb 2023 10:29:37 +0100 Subject: vim-patch:9.0.1288: FunC files are not recognized (#22153) Problem: FunC files are not recognized. Solution: Recognize FunC files. (Amaan Qureshi, closes vim/vim#11949) https://github.com/vim/vim/commit/91deac45392fe93094b9c31403b1ae771dc71938 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index bdd12d44cb..901d1c79de 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -211,6 +211,7 @@ let s:filename_checks = { \ 'fsh': ['file.fsh'], \ 'fsharp': ['file.fs', 'file.fsi', 'file.fsx'], \ 'fstab': ['fstab', 'mtab'], + \ 'func': ['file.fc'], \ 'fusion': ['file.fusion'], \ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file'], \ 'gdb': ['.gdbinit', 'gdbinit', 'file.gdb', '.config/gdbearlyinit', '.gdbearlyinit'], -- cgit From 1ca4a8b1ddf5256ad53cf486d0b2125434168270 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 8 Feb 2023 09:47:55 +0100 Subject: vim-patch:9.0.1291: Move language files are not recognized (#22162) Problem: Move language files are not recognized. Solution: Recognize Move language files. (Amaan Qureshi, closes vim/vim#11947) https://github.com/vim/vim/commit/6642982beaf4f1f5164f0315a1b3e3c275156089 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 901d1c79de..0264e203d9 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -381,6 +381,7 @@ let s:filename_checks = { \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'], \ 'moo': ['file.moo'], \ 'moonscript': ['file.moon'], + \ 'move': ['file.move'], \ 'mp': ['file.mp', 'file.mpxl', 'file.mpiv', 'file.mpvi'], \ 'mplayerconf': ['mplayer.conf', '/.mplayer/config', 'any/.mplayer/config'], \ 'mrxvtrc': ['mrxvtrc', '.mrxvtrc'], -- cgit From 3074ae69710f401d928356e7c3182edb0b0b2669 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:21:05 +0100 Subject: ci(oldtest): make a copy of scripts of ci/common in testdir (#22170) Having separate copies makes it easier to not accidentally break something when modifying the scripts. --- src/nvim/testdir/runnvim.sh | 5 ++- src/nvim/testdir/suite.sh | 36 ++++++++++++++++++++ src/nvim/testdir/test.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 src/nvim/testdir/suite.sh create mode 100644 src/nvim/testdir/test.sh (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/runnvim.sh b/src/nvim/testdir/runnvim.sh index 3a0a94b6bf..f316c7376e 100755 --- a/src/nvim/testdir/runnvim.sh +++ b/src/nvim/testdir/runnvim.sh @@ -22,13 +22,12 @@ main() {( i=$(( i+1 )) done - export CI_DIR="$root/ci" BUILD_DIR="$(dirname "$nvim_prg")/.." export BUILD_DIR export FAILED=0 - . "$CI_DIR/common/suite.sh" - . "$CI_DIR/common/test.sh" + . $(dirname $0)/suite.sh + . $(dirname $0)/test.sh # Redirect XDG_CONFIG_HOME so users local config doesn't interfere export XDG_CONFIG_HOME="$root" diff --git a/src/nvim/testdir/suite.sh b/src/nvim/testdir/suite.sh new file mode 100644 index 0000000000..3059773ca1 --- /dev/null +++ b/src/nvim/testdir/suite.sh @@ -0,0 +1,36 @@ +# Test success marker. If END_MARKER file exists, we know that all tests +# finished. If FAIL_SUMMARY_FILE exists we know that some tests failed, this +# file will contain information about failed tests. Build is considered +# successful if tests ended without any of them failing. +END_MARKER="$BUILD_DIR/.tests_finished" +FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors" + +fail() { + local test_name="$1" + local message="$2" + + : "${message:=Test $test_name failed}" + + local full_msg="$test_name :: $message" + echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" + echo "Failed: $full_msg" + export FAILED=1 +} + +ended_successfully() { + if test -f "${FAIL_SUMMARY_FILE}" ; then + echo 'Test failed, complete summary:' + cat "${FAIL_SUMMARY_FILE}" + + if [[ "$GITHUB_ACTIONS" == "true" ]]; then + rm -f "$FAIL_SUMMARY_FILE" + fi + + return 1 + fi + if ! test -f "${END_MARKER}" ; then + echo 'ended_successfully called before end marker was touched' + return 1 + fi + return 0 +} diff --git a/src/nvim/testdir/test.sh b/src/nvim/testdir/test.sh new file mode 100644 index 0000000000..eab1736c32 --- /dev/null +++ b/src/nvim/testdir/test.sh @@ -0,0 +1,82 @@ +. $(dirname $0)/suite.sh + +print_core() { + local app="$1" + local core="$2" + if test "$app" = quiet ; then + echo "Found core $core" + return 0 + fi + echo "======= Core file $core =======" + if test "${CI_OS_NAME}" = osx ; then + lldb -Q -o "bt all" -f "${app}" -c "${core}" + else + gdb -n -batch -ex 'thread apply all bt full' "${app}" -c "${core}" + fi +} + +check_core_dumps() { + local del= + if test "$1" = "--delete" ; then + del=1 + shift + fi + local app="${1:-${BUILD_DIR}/bin/nvim}" + local cores + if test "${CI_OS_NAME}" = osx ; then + cores="$(find /cores/ -type f -print)" + local _sudo='sudo' + else + cores="$(find ./ -type f \( -name 'core.*' -o -name core -o -name nvim.core \) -print)" + local _sudo= + fi + + if test -z "${cores}" ; then + return + fi + local core + for core in $cores; do + if test "$del" = "1" ; then + print_core "$app" "$core" >&2 + "$_sudo" rm "$core" + else + print_core "$app" "$core" + fi + done + if test "$app" != quiet ; then + fail 'cores' 'Core dumps found' + fi +} + +check_logs() { + # Iterate through each log to remove an useless warning. + # shellcheck disable=SC2044 + for log in $(find "${1}" -type f -name "${2}"); do + sed -i "${log}" \ + -e '/Warning: noted but unhandled ioctl/d' \ + -e '/could cause spurious value errors to appear/d' \ + -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d' + done + + # Now do it again, but only consider files with size > 0. + local err="" + # shellcheck disable=SC2044 + for log in $(find "${1}" -type f -name "${2}" -size +0); do + cat "${log}" + err=1 + rm "${log}" + done + if test -n "${err}" ; then + fail 'logs' 'Runtime errors detected.' + fi +} + +valgrind_check() { + check_logs "${1}" "valgrind-*" +} + +check_sanitizer() { + if test -n "${CLANG_SANITIZER}"; then + check_logs "${1}" "*san.*" | cat + fi +} -- cgit From 2294210660056df2f8abb277776cfd68f3fb1156 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:32:17 +0100 Subject: ci: remove fail summary (#22174) The tests already have a summary at the end, there's no need for an additional fail summary wrapper. --- src/nvim/testdir/runnvim.sh | 1 - src/nvim/testdir/suite.sh | 26 -------------------------- src/nvim/testdir/test.sh | 11 ++++++++++- 3 files changed, 10 insertions(+), 28 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/runnvim.sh b/src/nvim/testdir/runnvim.sh index f316c7376e..4d8ea0527d 100755 --- a/src/nvim/testdir/runnvim.sh +++ b/src/nvim/testdir/runnvim.sh @@ -26,7 +26,6 @@ main() {( export BUILD_DIR export FAILED=0 - . $(dirname $0)/suite.sh . $(dirname $0)/test.sh # Redirect XDG_CONFIG_HOME so users local config doesn't interfere diff --git a/src/nvim/testdir/suite.sh b/src/nvim/testdir/suite.sh index 3059773ca1..bf5a16fd89 100644 --- a/src/nvim/testdir/suite.sh +++ b/src/nvim/testdir/suite.sh @@ -1,10 +1,3 @@ -# Test success marker. If END_MARKER file exists, we know that all tests -# finished. If FAIL_SUMMARY_FILE exists we know that some tests failed, this -# file will contain information about failed tests. Build is considered -# successful if tests ended without any of them failing. -END_MARKER="$BUILD_DIR/.tests_finished" -FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors" - fail() { local test_name="$1" local message="$2" @@ -12,25 +5,6 @@ fail() { : "${message:=Test $test_name failed}" local full_msg="$test_name :: $message" - echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" export FAILED=1 } - -ended_successfully() { - if test -f "${FAIL_SUMMARY_FILE}" ; then - echo 'Test failed, complete summary:' - cat "${FAIL_SUMMARY_FILE}" - - if [[ "$GITHUB_ACTIONS" == "true" ]]; then - rm -f "$FAIL_SUMMARY_FILE" - fi - - return 1 - fi - if ! test -f "${END_MARKER}" ; then - echo 'ended_successfully called before end marker was touched' - return 1 - fi - return 0 -} diff --git a/src/nvim/testdir/test.sh b/src/nvim/testdir/test.sh index eab1736c32..affdc308d1 100644 --- a/src/nvim/testdir/test.sh +++ b/src/nvim/testdir/test.sh @@ -1,4 +1,13 @@ -. $(dirname $0)/suite.sh +fail() { + local test_name="$1" + local message="$2" + + : "${message:=Test $test_name failed}" + + local full_msg="$test_name :: $message" + echo "Failed: $full_msg" + export FAILED=1 +} print_core() { local app="$1" -- cgit From c9b0fe1f41ebaa6815a69ac614a5b2d1bab6f720 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 08:20:31 +0800 Subject: vim-patch:9.0.1297: wrong value for $LC_CTYPE makes the environ test fail (#22210) Problem: Wrong value for $LC_CTYPE makes the environ test fail. Solution: Unset $LC_CTYPE when running tests. (closes vim/vim#11963) https://github.com/vim/vim/commit/962d91643520ec3748fcf5af3263d89ccfcdda92 Co-authored-by: WuerfelDev --- src/nvim/testdir/test_environ.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_environ.vim b/src/nvim/testdir/test_environ.vim index d8344817f5..b5dbdce104 100644 --- a/src/nvim/testdir/test_environ.vim +++ b/src/nvim/testdir/test_environ.vim @@ -73,7 +73,7 @@ func Test_mac_locale() " If $LANG is not set then the system locale will be used. " Run Vim after unsetting all the locale environmental vars, and capture the " output of :lang. - let lang_results = system("unset LANG; unset LC_MESSAGES; " .. + let lang_results = system("unset LANG; unset LC_MESSAGES; unset LC_CTYPE; " .. \ shellescape(v:progpath) .. \ " --clean -esX -c 'redir @a' -c 'lang' -c 'put a' -c 'print' -c 'qa!' ") -- cgit From 9437800d280385c018a99aa0fbe9043e4d7715aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 18:44:06 +0800 Subject: vim-patch:9.0.1298: inserting register on the cmdline does not trigger incsearch Problem: Inserting a register on the command line does not trigger incsearch or update hlsearch. Solution: Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate and handle it correctly. (Ken Takata, closes vim/vim#11960) https://github.com/vim/vim/commit/c4b7dec38292fe1cfad7aa5f244031fc6f7c7a09 Co-authored-by: K.Takata --- src/nvim/testdir/test_hlsearch.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_hlsearch.vim b/src/nvim/testdir/test_hlsearch.vim index cf2791113a..043d378a39 100644 --- a/src/nvim/testdir/test_hlsearch.vim +++ b/src/nvim/testdir/test_hlsearch.vim @@ -1,5 +1,8 @@ " Test for v:hlsearch +source check.vim +source screendump.vim + func Test_hlsearch() new call setline(1, repeat(['aaa'], 10)) @@ -63,3 +66,23 @@ func Test_hlsearch_eol_highlight() set nohlsearch bwipe! endfunc + +func Test_hlsearch_Ctrl_R() + CheckRunVimInTerminal + + let lines =<< trim END + set incsearch hlsearch + let @" = "text" + put + END + call writefile(lines, 'XhlsearchCtrlR', 'D') + let buf = RunVimInTerminal('-S XhlsearchCtrlR', #{rows: 6, cols: 60}) + + call term_sendkeys(buf, "/\\\"") + call VerifyScreenDump(buf, 'Test_hlsearch_ctrlr_1', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From f1fcdcc2c43839b037517d1dd7b1a4570eb970a8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 19:01:43 +0800 Subject: vim-patch:9.0.1299: change for triggering incsearch not sufficiently tested Problem: Change for triggering incsearch not sufficiently tested. Solution: Add a test case. Simplify the code. (closes vim/vim#11971) https://github.com/vim/vim/commit/412e0e4ed903682f352d8ea58ded480930cc664f --- src/nvim/testdir/test_autocmd.vim | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index a1a3ba3198..30d30c8b29 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1897,17 +1897,15 @@ func Test_Cmdline() call assert_equal(':', g:entered) au! CmdlineChanged + autocmd CmdlineChanged : let g:log += [getcmdline()] + let g:log = [] cnoremap call setcmdline('ls') - autocmd CmdlineChanged : let g:log += [getcmdline()] call feedkeys(":\", 'xt') call assert_equal(['ls'], g:log) - unlet g:log - au! CmdlineChanged cunmap let g:log = [] - autocmd CmdlineChanged : let g:log += [getcmdline()] call feedkeys(":sign \\\\\\\", 'xt') call assert_equal([ \ 's', @@ -1938,6 +1936,22 @@ func Test_Cmdline() \ 'sign unplace', \ ], g:log) set wildmenu& wildoptions& + + let g:log = [] + let @r = 'abc' + call feedkeys(":0\r1\\r2\\r3\", 'xt') + call assert_equal([ + \ '0', + \ '0a', + \ '0ab', + \ '0abc', + \ '0abc1', + \ '0abc1abc', + \ '0abc1abc2', + \ '0abc1abc2abc', + \ '0abc1abc2abc3', + \ ], g:log) + unlet g:log au! CmdlineChanged -- cgit From 374955bcc571dff05f068ec18d0f578d1f334c5f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 20:00:31 +0800 Subject: vim-patch:9.0.1300: 'statusline' only supports one "%=" item (#22218) Problem: 'statusline' only supports one "%=" item. Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan Lakshmanan, closes vim/vim#11970, closes vim/vim#11965) https://github.com/vim/vim/commit/3ec78f973fdaec2cea8e036ed38037b2fe40670b Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_statusline.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim index 990c852ccd..1e06ad1c67 100644 --- a/src/nvim/testdir/test_statusline.vim +++ b/src/nvim/testdir/test_statusline.vim @@ -231,6 +231,10 @@ func Test_statusline() " %=: Separation point between left and right aligned items. set statusline=foo%=bar call assert_match('^foo\s\+bar\s*$', s:get_statusline()) + set statusline=foo%=bar%=baz + call assert_match('^foo\s\+bar\s\+baz\s*$', s:get_statusline()) + set statusline=foo%=bar%=baz%=qux + call assert_match('^foo\s\+bar\s\+baz\s\+qux\s*$', s:get_statusline()) " Test min/max width, leading zeroes, left/right justify. set statusline=%04B -- cgit From 20c9f4b3521fa7ab5c5997c0ec1a3df2b5bd0dbe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 14 Feb 2023 08:29:05 +0800 Subject: vim-patch:9.0.1307: setting 'formatoptions' with :let doesn't check for errors (#22252) Problem: Setting 'formatoptions' with :let doesn't check for errors. Solution: Pass "errbuf" to set_string_option(). (Yegappan Lakshmanan, closes vim/vim#11974, closes vim/vim#11972) https://github.com/vim/vim/commit/32ff96ef018eb1a5bea0953648b4892a6ee71658 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_options.vim | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index f51de94bac..43cc3632e6 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -434,6 +434,8 @@ func Test_set_errors() call assert_fails('set fileencoding=latin1', 'E21:') set modifiable& " call assert_fails('set t_#-&', 'E522:') + call assert_fails('let &formatoptions = "?"', 'E539:') + call assert_fails('call setbufvar("", "&formatoptions", "?")', 'E539:') endfunc func CheckWasSet(name) @@ -1300,5 +1302,44 @@ func Test_endoffile_default() call delete('Xtestout') endfunc +" Test for setting the 'lines' and 'columns' options to a minimum value +func Test_set_min_lines_columns() + let save_lines = &lines + let save_columns = &columns + + let after =<< trim END + set laststatus=1 + set nomore + let msg = [] + let v:errmsg = '' + silent! let &columns=0 + call add(msg, v:errmsg) + silent! set columns=0 + call add(msg, v:errmsg) + silent! call setbufvar('', '&columns', 0) + call add(msg, v:errmsg) + "call writefile(msg, 'XResultsetminlines') + silent! let &lines=0 + call add(msg, v:errmsg) + silent! set lines=0 + call add(msg, v:errmsg) + silent! call setbufvar('', '&lines', 0) + call add(msg, v:errmsg) + call writefile(msg, 'XResultsetminlines') + qall! + END + if RunVim([], after, '') + call assert_equal(['E594: Need at least 12 columns', + \ 'E594: Need at least 12 columns: columns=0', + \ 'E594: Need at least 12 columns', + \ 'E593: Need at least 2 lines', + \ 'E593: Need at least 2 lines: lines=0', + \ 'E593: Need at least 2 lines',], readfile('XResultsetminlines')) + endif + + call delete('XResultsetminlines') + let &lines = save_lines + let &columns = save_columns +endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From 968cd1ed933c039b8d60b0110bc6b539c71e387d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 07:25:16 +0800 Subject: vim-patch:9.0.1309: scrolling two lines with even line count and 'scrolloff' set Problem: Scrolling two lines with even line count and 'scrolloff' set. Solution: Adjust how the topline is computed. (closes vim/vim#10545) https://github.com/vim/vim/commit/1d6539cf36a7b6d1afe76fb6316fe662f543bf60 Cherry-pick test_scroll_opt.vim changes from patch 8.2.1432. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_scroll_opt.vim | 20 +++++++++++++++++++- src/nvim/testdir/test_scrollbind.vim | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_scroll_opt.vim b/src/nvim/testdir/test_scroll_opt.vim index 77920eb8b0..64f4ced470 100644 --- a/src/nvim/testdir/test_scroll_opt.vim +++ b/src/nvim/testdir/test_scroll_opt.vim @@ -1,5 +1,4 @@ " Test for reset 'scroll' -" func Test_reset_scroll() let scr = &l:scroll @@ -34,3 +33,22 @@ func Test_reset_scroll() quit! endfunc + +func Test_scolloff_even_line_count() + new + resize 6 + setlocal scrolloff=3 + call setline(1, range(20)) + normal 2j + call assert_equal(1, getwininfo(win_getid())[0].topline) + normal j + call assert_equal(1, getwininfo(win_getid())[0].topline) + normal j + call assert_equal(2, getwininfo(win_getid())[0].topline) + normal j + call assert_equal(3, getwininfo(win_getid())[0].topline) + + bwipe! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_scrollbind.vim b/src/nvim/testdir/test_scrollbind.vim index 6c5488be05..f67a559c60 100644 --- a/src/nvim/testdir/test_scrollbind.vim +++ b/src/nvim/testdir/test_scrollbind.vim @@ -217,8 +217,8 @@ end of window 2 \ '7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', \ '56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', \ 'UTSRQPONMLKJIHGREDCBA9876543210 02', - \ '. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11', - \ '. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11', + \ '. line 10 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 10', + \ '. line 10 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 10', \ ''], getline(1, '$')) enew! -- cgit From a2dd7fa97bab06be2b357e34af0ed0a194774d70 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 07:41:09 +0800 Subject: vim-patch:9.0.1310: 'splitkeep' test has failures Problem: 'splitkeep' test has failures. Solution: Adjust expected cursor line position. https://github.com/vim/vim/commit/fdbd14e89207dca95549f298ee468793da852086 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_window_cmd.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index c25b1f1157..4a8a1b11f1 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -1651,9 +1651,16 @@ func Test_splitkeep_options() call assert_equal(1, line("w0")) call assert_equal(curpos, getcurpos()) - " Scroll when cursor becomes invalid in insert mode + " Scroll when cursor becomes invalid in insert mode. norm Lic - call assert_equal(curpos, getcurpos()) + call assert_equal(curpos[0], getcurpos()[0], 'run ' .. run) + + " The line number might be one less because of round-off. + call assert_inrange(curpos[1] - 1, curpos[1], getcurpos()[1], 'run ' .. run) + + call assert_equal(curpos[2], getcurpos()[2], 'run ' .. run) + call assert_equal(curpos[3], getcurpos()[3], 'run ' .. run) + call assert_equal(curpos[4], getcurpos()[4], 'run ' .. run) " No scroll when topline not equal to 1 only | execute "norm gg5\" | split | wincmd k -- cgit From 0bb3a373d32e150af3909e3873be91f34df211dc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Feb 2023 07:41:39 +0800 Subject: vim-patch:9.0.1312: Cursor position wrong when splitting window in insert mode Problem: Cursor position wrong when splitting window in insert mode. Solution: Pass the actual mode to win_fix_cursor(). (Luuk van Baal, closes vim/vim#11999, https://github.com/vim/vim/commit/bc3dc298b37820a8212e7d839e882e07d6cc98c8 Co-authored-by: Luuk van Baal --- src/nvim/testdir/test_window_cmd.vim | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 4a8a1b11f1..8b9457ae1d 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -1653,14 +1653,7 @@ func Test_splitkeep_options() " Scroll when cursor becomes invalid in insert mode. norm Lic - call assert_equal(curpos[0], getcurpos()[0], 'run ' .. run) - - " The line number might be one less because of round-off. - call assert_inrange(curpos[1] - 1, curpos[1], getcurpos()[1], 'run ' .. run) - - call assert_equal(curpos[2], getcurpos()[2], 'run ' .. run) - call assert_equal(curpos[3], getcurpos()[3], 'run ' .. run) - call assert_equal(curpos[4], getcurpos()[4], 'run ' .. run) + call assert_equal(curpos, getcurpos(), 'run ' .. run) " No scroll when topline not equal to 1 only | execute "norm gg5\" | split | wincmd k -- cgit From dea311b33d7be6c76ba2a48e604a112ae1dc61d6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Feb 2023 08:14:24 +0800 Subject: test(old): run some part of 'cpoptions' tests --- src/nvim/testdir/test_cpoptions.vim | 78 +++++++++++++-------------- src/nvim/testdir/test_normal.vim | 100 ++++++++++++++++++----------------- src/nvim/testdir/test_substitute.vim | 23 ++++---- 3 files changed, 102 insertions(+), 99 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cpoptions.vim b/src/nvim/testdir/test_cpoptions.vim index b9307ab30b..1427c8accc 100644 --- a/src/nvim/testdir/test_cpoptions.vim +++ b/src/nvim/testdir/test_cpoptions.vim @@ -217,33 +217,33 @@ endfunc " Test for the 'g' flag in 'cpo' (jump to line 1 when re-editing a file) func Test_cpo_g() - throw 'Skipped: Nvim does not support cpoptions flag "g"' let save_cpo = &cpo new test_cpoptions.vim set cpo-=g normal 20G edit call assert_equal(20, line('.')) - set cpo+=g - edit - call assert_equal(1, line('.')) + " Nvim: no "g" flag in 'cpoptions'. + " set cpo+=g + " edit + " call assert_equal(1, line('.')) close! let &cpo = save_cpo endfunc " Test for inserting text in a line with only spaces ('H' flag in 'cpoptions') func Test_cpo_H() - throw 'Skipped: Nvim does not support cpoptions flag "H"' let save_cpo = &cpo new set cpo-=H call setline(1, ' ') normal! Ia call assert_equal(' a', getline(1)) - set cpo+=H - call setline(1, ' ') - normal! Ia - call assert_equal(' a ', getline(1)) + " Nvim: no "H" flag in 'cpoptions'. + " set cpo+=H + " call setline(1, ' ') + " normal! Ia + " call assert_equal(' a ', getline(1)) close! let &cpo = save_cpo endfunc @@ -560,15 +560,15 @@ endfunc " Test for the 'w' flag in 'cpo' ('cw' on a blank character changes only one " character) func Test_cpo_w() - throw 'Skipped: Nvim does not support cpoptions flag "w"' let save_cpo = &cpo new - set cpo+=w - call setline(1, 'here are some words') - norm! 1gg0elcwZZZ - call assert_equal('hereZZZ are some words', getline('.')) - norm! 1gg2elcWYYY - call assert_equal('hereZZZ areYYY some words', getline('.')) + " Nvim: no "w" flag in 'cpoptions'. + " set cpo+=w + " call setline(1, 'here are some words') + " norm! 1gg0elcwZZZ + " call assert_equal('hereZZZ are some words', getline('.')) + " norm! 1gg2elcWYYY + " call assert_equal('hereZZZ areYYY some words', getline('.')) set cpo-=w call setline(1, 'here are some words') norm! 1gg0elcwZZZ @@ -745,16 +745,16 @@ endfunc " Test for the '*' flag in 'cpo' (':*' is same as ':@') func Test_cpo_star() - throw 'Skipped: Nvim does not support cpoptions flag "*"' let save_cpo = &cpo let x = 0 new set cpo-=* let @a = 'let x += 1' call assert_fails('*a', 'E20:') - set cpo+=* - *a - call assert_equal(1, x) + " Nvim: no "*" flag in 'cpoptions'. + " set cpo+=* + " *a + " call assert_equal(1, x) close! let &cpo = save_cpo endfunc @@ -815,7 +815,6 @@ endfunc " Test for the '#' flag in 'cpo' (count before 'D', 'o' and 'O' operators) func Test_cpo_hash() - throw 'Skipped: Nvim does not support cpoptions flag "#"' let save_cpo = &cpo new set cpo-=# @@ -827,14 +826,15 @@ func Test_cpo_hash() normal gg2Otwo call assert_equal(['two', 'two', 'three', 'four', 'four'], getline(1, '$')) %d - set cpo+=# - call setline(1, ['one', 'two', 'three']) - normal gg2D - call assert_equal(['', 'two', 'three'], getline(1, '$')) - normal gg2oone - call assert_equal(['', 'one', 'two', 'three'], getline(1, '$')) - normal gg2Ozero - call assert_equal(['zero', '', 'one', 'two', 'three'], getline(1, '$')) + " Nvim: no "#" flag in 'cpoptions'. + " set cpo+=# + " call setline(1, ['one', 'two', 'three']) + " normal gg2D + " call assert_equal(['', 'two', 'three'], getline(1, '$')) + " normal gg2oone + " call assert_equal(['', 'one', 'two', 'three'], getline(1, '$')) + " normal gg2Ozero + " call assert_equal(['zero', '', 'one', 'two', 'three'], getline(1, '$')) close! let &cpo = save_cpo endfunc @@ -858,16 +858,16 @@ endfunc " Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern) func Test_cpo_backslash() - throw 'Skipped: Nvim does not support cpoptions flag "\"' let save_cpo = &cpo new call setline(1, ['', " \\-string"]) set cpo-=\ exe 'normal gg/[ \-]' .. "\n" call assert_equal(3, col('.')) - set cpo+=\ - exe 'normal gg/[ \-]' .. "\n" - call assert_equal(2, col('.')) + " Nvim: no "\" flag in 'cpoptions'. + " set cpo+=\ + " exe 'normal gg/[ \-]' .. "\n" + " call assert_equal(2, col('.')) close! let &cpo = save_cpo endfunc @@ -877,7 +877,6 @@ endfunc " Test for the '{' flag in 'cpo' (the "{" and "}" commands stop at a { " character at the start of a line) func Test_cpo_brace() - throw 'Skipped: Nvim does not support cpoptions flag "{"' let save_cpo = &cpo new call setline(1, ['', '{', ' int i;', '}', '']) @@ -886,11 +885,12 @@ func Test_cpo_brace() call assert_equal(5, line('.')) normal G{ call assert_equal(1, line('.')) - set cpo+={ - normal gg} - call assert_equal(2, line('.')) - normal G{ - call assert_equal(2, line('.')) + " Nvim: no "{" flag in 'cpoptions'. + " set cpo+={ + " normal gg} + " call assert_equal(2, line('.')) + " normal G{ + " call assert_equal(2, line('.')) close! let &cpo = save_cpo endfunc diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 2aaa1ff830..390e179f13 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2254,61 +2254,63 @@ func Test_normal29_brace() " set cpo+={ " 1 " norm! 0d2} - " let expected =<< trim [DATA] - " { - " This is no paragraph - " unless the '{' is set - " in 'cpoptions' - " } - " .IP - " The nroff macros IP separates a paragraph - " That means, it must be a '.' - " followed by IP - " .LPIt does not matter, if afterwards some - " more characters follow. - " .SHAlso section boundaries from the nroff - " macros terminate a paragraph. That means - " a character like this: - " .NH - " End of text here - " - " [DATA] + + let expected =<< trim [DATA] + { + This is no paragraph + unless the '{' is set + in 'cpoptions' + } + .IP + The nroff macros IP separates a paragraph + That means, it must be a '.' + followed by IP + .LPIt does not matter, if afterwards some + more characters follow. + .SHAlso section boundaries from the nroff + macros terminate a paragraph. That means + a character like this: + .NH + End of text here + + [DATA] " call assert_equal(expected, getline(1, '$')) - " + " $ " norm! d} - " let expected =<< trim [DATA] - " { - " This is no paragraph - " unless the '{' is set - " in 'cpoptions' - " } - " .IP - " The nroff macros IP separates a paragraph - " That means, it must be a '.' - " followed by IP - " .LPIt does not matter, if afterwards some - " more characters follow. - " .SHAlso section boundaries from the nroff - " macros terminate a paragraph. That means - " a character like this: - " .NH - " End of text here - " - " [DATA] + + let expected =<< trim [DATA] + { + This is no paragraph + unless the '{' is set + in 'cpoptions' + } + .IP + The nroff macros IP separates a paragraph + That means, it must be a '.' + followed by IP + .LPIt does not matter, if afterwards some + more characters follow. + .SHAlso section boundaries from the nroff + macros terminate a paragraph. That means + a character like this: + .NH + End of text here + + [DATA] " call assert_equal(expected, getline(1, '$')) - " + " norm! gg} " norm! d5} - " - " let expected =<< trim [DATA] - " { - " This is no paragraph - " unless the '{' is set - " in 'cpoptions' - " } - - " [DATA] + + let expected =<< trim [DATA] + { + This is no paragraph + unless the '{' is set + in 'cpoptions' + } + + [DATA] " call assert_equal(expected, getline(1, '$')) " Jumping to a fold should open the fold diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index c99a0d456d..b2abbae168 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -296,15 +296,15 @@ endfunc " Test for *:s%* on :substitute. func Test_sub_cmd_6() - throw 'Skipped: Nvim does not support cpoptions flag "/"' set magic& - set cpo+=/ + " Nvim: no "/" flag in 'cpoptions'. + " set cpo+=/ " List entry format: [input, cmd, output] let tests = [ ['A', 's/A/a/', ['a']], \ ['B', 's/B/%/', ['a']], \ ] - call Run_SubCmd_Tests(tests) + " call Run_SubCmd_Tests(tests) set cpo-=/ let tests = [ ['C', 's/C/c/', ['c']], @@ -585,10 +585,11 @@ endfunc func Test_sub_replace_6() set magic& + " Nvim: no "/" flag in 'cpoptions'. " set cpo+=/ call assert_equal('a', substitute('A', 'A', 'a', '')) call assert_equal('%', substitute('B', 'B', '%', '')) - " set cpo-=/ + set cpo-=/ call assert_equal('c', substitute('C', 'C', 'c', '')) call assert_equal('%', substitute('D', 'D', '%', '')) endfunc @@ -853,13 +854,13 @@ func Test_sub_with_no_last_pat() call assert_equal([], readfile('Xresult')) endif - " Nvim does not support cpoptions flag "/"' - " let lines =<< trim [SCRIPT] - " set cpo+=/ - " call assert_fails('s/abc/%/', 'E33:') - " call writefile(v:errors, 'Xresult') - " qall! - " [SCRIPT] + let lines =<< trim [SCRIPT] + set cpo+=/ + call assert_fails('s/abc/%/', 'E33:') + call writefile(v:errors, 'Xresult') + qall! + [SCRIPT] + " Nvim: no "/" flag in 'cpoptions'. " call writefile(lines, 'Xscript') " if RunVim([], [], '--clean -S Xscript') " call assert_equal([], readfile('Xresult')) -- cgit From f6a6db3e248dd6360dbd55574321ddc216848c13 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Feb 2023 07:59:22 +0800 Subject: vim-patch:8.2.0148: mapping related function in wrong source file Problem: Mapping related function in wrong source file. Solution: Move the function. Add a few more test cases. (Yegappan Lakshmanan, closes vim/vim#5528) https://github.com/vim/vim/commit/7f51bbe0d19f1f0cb0321326f45a17b4f5155f89 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/setup.vim | 8 +++++--- src/nvim/testdir/test_mapping.vim | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index f895287469..25ac2d1239 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -26,9 +26,11 @@ if exists('s:did_load') set viewoptions& set viewoptions+=options set switchbuf= - " Make "Q" switch to Ex mode. - " This does not work for all tests. - nnoremap Q gQ + if g:testname !~ 'test_mapping.vim$' + " Make "Q" switch to Ex mode. + " This does not work for all tests. + nnoremap Q gQ + endif endif " Common preparations for running tests. diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 5c5a65d4ca..6cf19306ec 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -934,6 +934,39 @@ func Test_abbr_remove() call assert_equal({}, maparg('foo', 'i', 1, 1)) endfunc +" Trigger an abbreviation using a special key +func Test_abbr_trigger_special() + new + iabbr teh the + call feedkeys("iteh\\", 'xt') + call assert_equal('the', getline(1)) + iunab teh + close! +endfunc + +" Test for '<' in 'cpoptions' +func Test_map_cpo_special_keycode() + set cpo-=< + imap xk Test + let d = maparg('xk', 'i', 0, 1) + call assert_equal(['x\k', 'Test', 'i'], [d.lhs, d.rhs, d.mode]) + call feedkeys(":imap x\\\"\", 'tx') + call assert_equal('"imap x\k', @:) + iunmap xk + " Nvim: no "<" flag in 'cpoptions'. + " set cpo+=< + " imap xk Test + " let d = maparg('xk', 'i', 0, 1) + " call assert_equal(['xk', 'Test', 'i'], [d.lhs, d.rhs, d.mode]) + " call feedkeys(":imap x\\\"\", 'tx') + " call assert_equal('"imap xk', @:) + " iunmap xk + set cpo-=< + " Modifying 'cpo' above adds some default mappings, remove them + mapclear + mapclear! +endfunc + func Test_map_cmdkey_redo() func SelectDash() call search('^---\n\zs', 'bcW') -- cgit From 75dab3cf0781f664ac866f511df2fb2c06aa7d17 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 06:52:56 +0800 Subject: fix(mappings): make "<" escaping in completion match Vim --- src/nvim/testdir/test_autocmd.vim | 2 +- src/nvim/testdir/test_cmdline.vim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 30d30c8b29..6d7f1649b3 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2720,7 +2720,7 @@ func Test_autocmd_bufreadpre() close close call delete('XAutocmdBufReadPre.txt') - " set cpo-=g + set cpo-=g endfunc " FileChangedShell tested in test_filechanged.vim diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index cf1d56ae38..64bfb142e7 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -340,7 +340,7 @@ func Test_map_completion() call feedkeys(":map \\"\", 'xt') call assert_equal('"map ', getreg(':')) call feedkeys(":map \\"\", 'xt') - " call assert_equal("\"map ", getreg(':')) + call assert_equal("\"map ", getreg(':')) unmap " set cpo+=< @@ -369,7 +369,7 @@ func Test_map_completion() call feedkeys(":map \\"\", 'xt') call assert_equal('"map ', getreg(':')) unmap - " set cpo-=k + set cpo-=k call assert_fails('call feedkeys(":map \\\\%(\\\"\", "xt")', 'E53:') -- cgit From afe34d92a7f28245a96748d70b5e073715b94e22 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 06:50:58 +0800 Subject: vim-patch:9.0.1315: escaping for completion of map command not properly tested Problem: Escaping for completion of map command not properly tested. Solution: Add a few test cases. (closes vim/vim#12009) https://github.com/vim/vim/commit/c3a26c6bff666a368b0a22d35d2e00aa62770f8c --- src/nvim/testdir/test_cmdline.vim | 6 +++++- src/nvim/testdir/test_cpoptions.vim | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 64bfb142e7..d568b5d425 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -330,17 +330,21 @@ func Test_map_completion() call assert_equal('"map ', getreg(':')) call feedkeys(":map \\\"\", 'xt') call assert_equal("\"map \", getreg(':')) + call feedkeys(":map \\\"\", 'xt') + call assert_equal("\"map x", getreg(':')) unmap ,f unmap ,g unmap unmap x - set cpo-=< cpo-=B cpo-=k + set cpo-=< cpo-=k map left call feedkeys(":map \\"\", 'xt') call assert_equal('"map ', getreg(':')) call feedkeys(":map \\"\", 'xt') call assert_equal("\"map ", getreg(':')) + call feedkeys(":map \\\\"\", 'xt') + call assert_equal("\"map \x", getreg(':')) unmap " set cpo+=< diff --git a/src/nvim/testdir/test_cpoptions.vim b/src/nvim/testdir/test_cpoptions.vim index 1427c8accc..846671a646 100644 --- a/src/nvim/testdir/test_cpoptions.vim +++ b/src/nvim/testdir/test_cpoptions.vim @@ -68,15 +68,20 @@ endfunc func Test_cpo_B() let save_cpo = &cpo new + imap xk Test set cpo-=B iabbr abc ab\d exe "normal iabc " call assert_equal('abd ', getline(1)) + call feedkeys(":imap x\\\"\", 'tx') + call assert_equal('"imap x\\k', @:) %d set cpo+=B iabbr abc ab\d exe "normal iabc " call assert_equal('abd ', getline(1)) + call feedkeys(":imap x\\\"\", 'tx') + call assert_equal('"imap x\k', @:) close! let &cpo = save_cpo endfunc @@ -195,7 +200,8 @@ func Test_cpo_f() set cpo+=f read test_cpoptions.vim call assert_equal('test_cpoptions.vim', @%) - close! + + bwipe! let &cpo = save_cpo endfunc @@ -428,7 +434,7 @@ func Test_cpo_O() let &cpo = save_cpo endfunc -" Test for the 'p' flag in 'cpo' is in the test_lispwords.vim file. +" Test for the 'p' flag in 'cpo' is in the test_lispindent.vim file. " Test for the 'P' flag in 'cpo' (appending to a file sets the current file " name) @@ -444,7 +450,8 @@ func Test_cpo_P() set cpo+=P write >> XfileCpoP call assert_equal('XfileCpoP', @%) - close! + + bwipe! call delete('XfileCpoP') let &cpo = save_cpo endfunc -- cgit From 2f6413797499a1bdac28c20a491e8ea3be33bda3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 19 Feb 2023 01:27:32 +0100 Subject: vim-patch:9.0.1319: PRQL files are not recognized (#22319) Problem: PRQL files are not recognized. Solution: Add a filetype pattern for PRQL files. (Matthias Queitsch, closes vim/vim#12018) https://github.com/vim/vim/commit/9de960ace0f017fcfeaf64a2f6492f0f88b11fdb Co-authored-by: Matthias Queitsch --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 0264e203d9..576f2c9f2b 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -550,6 +550,7 @@ let s:filename_checks = { \ 'spyce': ['file.spy', 'file.spi'], \ 'sql': ['file.tyb', 'file.typ', 'file.tyc', 'file.pkb', 'file.pks'], \ 'sqlj': ['file.sqlj'], + \ 'prql': ['file.prql'], \ 'sqr': ['file.sqr', 'file.sqi'], \ 'squid': ['squid.conf'], \ 'squirrel': ['file.nut'], -- cgit From cbd4480f97a913e0e356ec02f652b693b0195767 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Sun, 19 Feb 2023 01:33:02 +0100 Subject: vim-patch:9.0.1324: "gj" and "gk" do not move correctly over a closed fold (#22320) Problem: "gj" and "gk" do not move correctly over a closed fold. Solution: Use the same code as used for "j"/"k" to go to the next/previous line. (Luuk van Baal, closes vim/vim#12007) https://github.com/vim/vim/commit/441a7a94482f704b66253b8d08130f27b6b13736 --- src/nvim/testdir/test_fold.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 9014948fb4..2f5c93ca2d 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -1548,4 +1548,11 @@ func Test_expand_fold_at_bottom_of_buffer() bwipe! endfunc +func Test_fold_screenrow_motion() + call setline(1, repeat(['aaaa'], 5)) + 1,4fold + norm Ggkzo + call assert_equal(1, line('.')) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 8784f064f15e5ae0b6bc85c2972ec16c64656e2b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 Feb 2023 08:24:49 +0800 Subject: vim-patch:9.0.1329: completion of map includes simplified ones (#22335) Problem: Completion of map includes simplified ones. Solution: Do not complete simplified mappings. (closes vim/vim#12013) https://github.com/vim/vim/commit/997b8a015cd39141866e953651d55c705275cbd6 --- src/nvim/testdir/test_mapping.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 6cf19306ec..e25c3c333e 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -759,11 +759,12 @@ func Test_mapcomplete() call feedkeys(":abbr! \\\"\", 'tx') call assert_equal("\"abbr! \x01", @:) - " Multiple matches for a map - nmap ,f /H - omap ,f /H + " When multiple matches have the same {lhs}, it should only appear once. + " The simplified form should also not be included. + nmap , /H + omap , /H call feedkeys(":map ,\\\"\", 'tx') - call assert_equal('"map ,f', @:) + call assert_equal('"map ,', @:) mapclear endfunc -- cgit From 93c627b90b4955967943b7a47fe63b094a0c50e6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 Feb 2023 23:02:05 +0800 Subject: vim-patch:9.0.1331: illegal memory access when using :ball in Visual mode (#22343) Problem: Illegal memory access when using :ball in Visual mode. Solution: Stop Visual mode when using :ball. (Pavel Mayorov, closes vim/vim#11923) https://github.com/vim/vim/commit/e1121b139480f53d1b06f84f3e4574048108fa0b Co-authored-by: Pavel Mayorov --- src/nvim/testdir/test_visual.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 1e9629c2c4..350c69fe4e 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1536,4 +1536,25 @@ func Test_switch_buffer_ends_visual_mode() exe 'bwipe!' buf2 endfunc +" Check fix for the heap-based buffer overflow bug found in the function +" utfc_ptr2len and reported at +" https://huntr.dev/bounties/ae933869-a1ec-402a-bbea-d51764c6618e +func Test_heap_buffer_overflow() + enew + set updatecount=0 + + norm R0 + split other + norm R000 + exe "norm \l" + ball + call assert_equal(getpos("."), getpos("v")) + call assert_equal('n', mode()) + norm zW + + %bwipe! + set updatecount& +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 3507474611a03d88137a1d97666515b551c39cb3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 Feb 2023 23:55:42 +0800 Subject: vim-patch:9.0.1332: crash when using buffer-local user command in cmdline window (#22346) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Crash when using buffer-local user command in cmdline window. (Karl Yngve Lervåg) Solution: Use the right buffer to find the user command. (closes vim/vim#12030, closes vim/vim#12029) https://github.com/vim/vim/commit/b444ee761a2956a996a75d923281c51fa1a759f3 --- src/nvim/testdir/test_usercommands.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 6910361345..898f7a59f1 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -736,6 +736,15 @@ func Test_buflocal_ambiguous_usercmd() bw! endfunc +" Test for using buffer-local user command from cmdwin. +func Test_buflocal_usercmd_cmdwin() + new + command -buffer TestCmd edit Test + " This used to crash Vim + call assert_fails("norm q::TestCmd\", 'E11:') + bw! +endfunc + " Test for using a multibyte character in a user command func Test_multibyte_in_usercmd() command SubJapanesePeriodToDot exe "%s/\u3002/./g" -- cgit From fec1181ecde75de1754f1d27a7ba7cbf2b9f43d6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 21 Feb 2023 17:43:53 +0800 Subject: test(legacy/prompt_buffer_spec): align script with oldtest more (#22354) --- src/nvim/testdir/test_prompt_buffer.vim | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_prompt_buffer.vim b/src/nvim/testdir/test_prompt_buffer.vim index b8f6c5240c..b1288b4892 100644 --- a/src/nvim/testdir/test_prompt_buffer.vim +++ b/src/nvim/testdir/test_prompt_buffer.vim @@ -10,8 +10,7 @@ source screendump.vim func CanTestPromptBuffer() " We need to use a terminal window to be able to feed keys without leaving " Insert mode. - " Nvim's terminal implementation differs from Vim's - " CheckFeature terminal + CheckFeature terminal " TODO: make the tests work on MS-Windows CheckNotMSWindows @@ -56,7 +55,6 @@ func WriteScript(name) endfunc func Test_prompt_basic() - throw 'skipped: TODO' call CanTestPromptBuffer() let scriptName = 'XpromptscriptBasic' call WriteScript(scriptName) @@ -77,7 +75,6 @@ func Test_prompt_basic() endfunc func Test_prompt_editing() - throw 'skipped: TODO' call CanTestPromptBuffer() let scriptName = 'XpromptscriptEditing' call WriteScript(scriptName) @@ -108,7 +105,6 @@ func Test_prompt_editing() endfunc func Test_prompt_switch_windows() - throw 'skipped: TODO' call CanTestPromptBuffer() let scriptName = 'XpromptSwitchWindows' call WriteScript(scriptName) @@ -226,7 +222,6 @@ func Test_prompt_buffer_getbufinfo() endfunc func Test_prompt_while_writing_to_hidden_buffer() - throw 'skipped: TODO' call CanTestPromptBuffer() CheckUnix -- cgit From d1b34b74580fc09d86144c35e24a1a8a0d531b36 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 22 Feb 2023 10:58:15 +0100 Subject: vim-patch:9.0.1337: yuck files are not recognized (#22358) Problem: Yuck files are not recognized. Solution: Add a filetype pattern for yuck files. (Amaan Qureshi, closes vim/vim#12033) https://github.com/vim/vim/commit/cfce5cf542db20c7beba5b4211c0ae3305a64a43 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 576f2c9f2b..af33b5b051 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -665,6 +665,7 @@ let s:filename_checks = { \ 'yacc': ['file.yy', 'file.yxx', 'file.y++'], \ 'yaml': ['file.yaml', 'file.yml', '.clangd', '.clang-format', '.clang-tidy'], \ 'yang': ['file.yang'], + \ 'yuck': ['file.yuck'], \ 'z8a': ['file.z8a'], \ 'zig': ['file.zig'], \ 'zimbu': ['file.zu'], -- cgit From 8c339aa04b2a1ca99a297b2eada8ebc6218f5f1c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 23 Feb 2023 17:52:33 +0100 Subject: vim-patch:9.0.1346: Starlark files are not recognized (#22380) Problem: Starlark files are not recognized. Solution: Add patterns for Starlark files. (Amaan Qureshi, closes vim/vim#12049) https://github.com/vim/vim/commit/ca06b30073de22dc120b532e90fbee2a10ef9772 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index af33b5b051..a69ac5462e 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -560,6 +560,7 @@ let s:filename_checks = { \ 'sshconfig': ['ssh_config', '/.ssh/config', '/etc/ssh/ssh_config.d/file.conf', 'any/etc/ssh/ssh_config.d/file.conf', 'any/.ssh/config', 'any/.ssh/file.conf'], \ 'sshdconfig': ['sshd_config', '/etc/ssh/sshd_config.d/file.conf', 'any/etc/ssh/sshd_config.d/file.conf'], \ 'st': ['file.st'], + \ 'starlark': ['file.ipd', 'file.star', 'file.starlark'], \ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'], \ 'stp': ['file.stp'], \ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp', '/etc/sudoers', 'any/etc/sudoers.d/file'], -- cgit From 5e1308b7caa89b458cc97d2db956379aa54ed68a Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 23 Feb 2023 16:12:01 -0500 Subject: vim-patch:9.0.1348: Un-grammar files are not recognized (#22383) Problem: Un-grammar files are not recognized. Solution: Add patterns for Un-grammar files. (Amaan Qureshi, closes vim/vim#12034) https://github.com/vim/vim/commit/44e08c1cf83f5a50f8b21613551304a6651c1161 --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index a69ac5462e..d37a194f50 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -609,6 +609,7 @@ let s:filename_checks = { \ 'typescript': ['file.mts', 'file.cts'], \ 'typescript.glimmer': ['file.gts'], \ 'typescriptreact': ['file.tsx'], + \ 'ungrammar': ['file.ungram'], \ 'uc': ['file.uc'], \ 'udevconf': ['/etc/udev/udev.conf', 'any/etc/udev/udev.conf'], \ 'udevperm': ['/etc/udev/permissions.d/file.permissions', 'any/etc/udev/permissions.d/file.permissions'], -- cgit From 904d0995837a2569ae640f5253da3dd4569fec6f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Feb 2023 15:03:28 +0800 Subject: vim-patch:8.2.2449: Vim9: flatten() always changes the list type Problem: Vim9: flatten() always changes the list type. Solution: Disallow using flatten() and add flattennew(). https://github.com/vim/vim/commit/3b690069730805a147d45d92eaca4dc838272d1d Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_flatten.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_flatten.vim b/src/nvim/testdir/test_flatten.vim index 99086611e1..d8abc1ad68 100644 --- a/src/nvim/testdir/test_flatten.vim +++ b/src/nvim/testdir/test_flatten.vim @@ -79,3 +79,14 @@ func Test_flatten() call assert_equal([1, 2, 1, 2], flatten(l:x, 2)) call assert_equal([2, l:x], l:y) endfunc + +func Test_flattennew() + let l = [1, [2, [3, 4]], 5] + call assert_equal([1, 2, 3, 4, 5], flattennew(l)) + call assert_equal([1, [2, [3, 4]], 5], l) + + call assert_equal([1, 2, [3, 4], 5], flattennew(l, 1)) + call assert_equal([1, [2, [3, 4]], 5], l) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From d9263688bf0282918f5a9801dae8b85e4c85bd7e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Feb 2023 15:24:38 +0800 Subject: vim-patch:8.2.4627: flatten() does not use maxdepth correctly Problem: flatten() does not use maxdepth correctly. Solution: Use a recursive implementation. (closes vim/vim#10020) https://github.com/vim/vim/commit/acf7d73a7f5cdd63b34de777a4ce5eb3e2ba0ab3 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_flatten.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_flatten.vim b/src/nvim/testdir/test_flatten.vim index d8abc1ad68..aa91060313 100644 --- a/src/nvim/testdir/test_flatten.vim +++ b/src/nvim/testdir/test_flatten.vim @@ -78,6 +78,14 @@ func Test_flatten() call add(y, x) " l:y = [2, [1, [...]]] call assert_equal([1, 2, 1, 2], flatten(l:x, 2)) call assert_equal([2, l:x], l:y) + + let l4 = [ 1, [ 11, [ 101, [ 1001 ] ] ] ] + call assert_equal(l4, flatten(deepcopy(l4), 0)) + call assert_equal([1, 11, [101, [1001]]], flatten(deepcopy(l4), 1)) + call assert_equal([1, 11, 101, [1001]], flatten(deepcopy(l4), 2)) + call assert_equal([1, 11, 101, 1001], flatten(deepcopy(l4), 3)) + call assert_equal([1, 11, 101, 1001], flatten(deepcopy(l4), 4)) + call assert_equal([1, 11, 101, 1001], flatten(deepcopy(l4))) endfunc func Test_flattennew() @@ -87,6 +95,14 @@ func Test_flattennew() call assert_equal([1, 2, [3, 4], 5], flattennew(l, 1)) call assert_equal([1, [2, [3, 4]], 5], l) + + let l4 = [ 1, [ 11, [ 101, [ 1001 ] ] ] ] + call assert_equal(l4, flatten(deepcopy(l4), 0)) + call assert_equal([1, 11, [101, [1001]]], flattennew(l4, 1)) + call assert_equal([1, 11, 101, [1001]], flattennew(l4, 2)) + call assert_equal([1, 11, 101, 1001], flattennew(l4, 3)) + call assert_equal([1, 11, 101, 1001], flattennew(l4, 4)) + call assert_equal([1, 11, 101, 1001], flattennew(l4)) endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From 4297127f14fa1b9062db7de0d63981887ebed063 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 24 Feb 2023 15:34:52 +0100 Subject: vim-patch:9.0.1350: CPON files are not recognized (#22392) Problem: CPON files are not recognized. Solution: Add patterns for CPON files. (Amaan Qureshi, closes vim/vim#12053) https://github.com/vim/vim/commit/c2254764bcada43eea894eb5852a26d5ac5ca8b0 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index d37a194f50..f77c926319 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -126,6 +126,7 @@ let s:filename_checks = { \ 'confini': ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'], \ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'], \ 'cook': ['file.cook'], + \ 'cpon': ['file.cpon'], \ 'cpp': ['file.cxx', 'file.c++', 'file.hh', 'file.hxx', 'file.hpp', 'file.ipp', 'file.moc', 'file.tcc', 'file.inl', 'file.tlh'], \ 'cqlang': ['file.cql'], \ 'crm': ['file.crm'], -- cgit From 15cce77b383d0b0bfdaa1415cdde005cc43267d0 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 24 Feb 2023 17:50:37 +0100 Subject: vim-patch:9.0.1351: Dhall files are not recognized (#22393) Problem: Dhall files are not recognized. Solution: Add patterns for Dhall files. (Amaan Qureshi, closes vim/vim#12052) https://github.com/vim/vim/commit/def5521752abefe12db8cc3111a3b205ad1ac929 Co-authored-by: Amaan Qureshi --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index f77c926319..96ab5620ec 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -157,6 +157,7 @@ let s:filename_checks = { \ 'denyhosts': ['denyhosts.conf'], \ 'desc': ['file.desc'], \ 'desktop': ['file.desktop', '.directory', 'file.directory'], + \ 'dhall': ['file.dhall'], \ 'dictconf': ['dict.conf', '.dictrc'], \ 'dictdconf': ['dictd.conf', 'dictdfile.conf', 'dictd-file.conf'], \ 'diff': ['file.diff', 'file.rej'], -- cgit From 5e846978e3bf85ea5ae5b505af267c01e98f6135 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 08:32:20 +0800 Subject: vim-patch:9.0.1354: "gr CTRL-G" stays in virtual replace mode Problem: "gr CTRL-G" stays in virtual replace mode. (Pierre Ganty) Solution: Prepend CTRL-V before control characters. (closes vim/vim#12045) https://github.com/vim/vim/commit/d6a4ea3aa0d3f4a886ea900e94bf4e8ca8ae8d63 Cherry-pick Test_edit_gr_special() from patch 9.0.1347. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_edit.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 89a9179e60..58e0232f29 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -2080,6 +2080,20 @@ func Test_edit_CTRL_hat() bwipe! endfunc +" Test "gr" followed by an Insert mode command does get out of Insert mode. +func Test_edit_gr_special() + enew + call setline(1, ['abcdef', 'xxxxxx']) + exe "normal! gr\lx" + call assert_equal("\def", getline(1)) + + call setline(1, 'abcdef') + exe "normal! 0gr\lx" + call assert_equal("\def", getline(1)) + + bwipe! +endfunc + " Weird long file name was going over the end of NameBuff func Test_edit_overlong_file_name() CheckUnix -- cgit From 6644742c26e4d8da999cf00754b6e6ee0ba0618f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 23:02:01 +0800 Subject: vim-patch:9.0.1356: cannot cancel "gr" with Esc Problem: Cannot cancel "gr" with Esc. Solution: Make "gr" do nothing. (closes vim/vim#12064) https://github.com/vim/vim/commit/4f026ea9f1ad9db262f0dba522768c84e5ae37b4 N/A patches for version.c: vim-patch:9.0.1347: "gr CTRL-O" stays in Insert mode Problem: "gr CTRL-O" stays in Insert mode. (Pierre Ganty) Solution: Do not set restart_edit when "cmdchar" is 'v'. (closes vim/vim#12045) https://github.com/vim/vim/commit/2824d1ee325ea61855c26f77e7a4e095b9606720 vim-patch:9.0.1349: "gr" with a count fails Problem: "gr" with a count fails. Solution: Break out of the loop only after using the count. https://github.com/vim/vim/commit/3ddb1182b7b8d376e59b444f6b3e213f0dcd3417 --- src/nvim/testdir/test_edit.vim | 15 +-------------- src/nvim/testdir/test_normal.vim | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 58e0232f29..b6078a1e22 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -580,6 +580,7 @@ func Test_edit_CTRL_G() call assert_equal([0, 3, 7, 0], getpos('.')) call feedkeys("i\j\", 'tnix') call assert_equal([0, 3, 6, 0], getpos('.')) + call assert_nobeep("normal! i\\") bw! endfunc @@ -2080,20 +2081,6 @@ func Test_edit_CTRL_hat() bwipe! endfunc -" Test "gr" followed by an Insert mode command does get out of Insert mode. -func Test_edit_gr_special() - enew - call setline(1, ['abcdef', 'xxxxxx']) - exe "normal! gr\lx" - call assert_equal("\def", getline(1)) - - call setline(1, 'abcdef') - exe "normal! 0gr\lx" - call assert_equal("\def", getline(1)) - - bwipe! -endfunc - " Weird long file name was going over the end of NameBuff func Test_edit_overlong_file_name() CheckUnix diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 390e179f13..5d8e1913a2 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -3283,9 +3283,9 @@ func Test_delete_until_paragraph() endfunc " Test for the gr (virtual replace) command -" Test for the bug fixed by 7.4.387 func Test_gr_command() enew! + " Test for the bug fixed by 7.4.387 let save_cpo = &cpo call append(0, ['First line', 'Second line', 'Third line']) exe "normal i\u" @@ -3298,10 +3298,12 @@ func Test_gr_command() normal 4gro call assert_equal('ooooecond line', getline(2)) let &cpo = save_cpo + normal! ggvegrx call assert_equal('xxxxx line', getline(1)) exe "normal! gggr\122" call assert_equal('zxxxx line', getline(1)) + set virtualedit=all normal! 15|grl call assert_equal('zxxxx line l', getline(1)) @@ -3309,8 +3311,25 @@ func Test_gr_command() set nomodifiable call assert_fails('normal! grx', 'E21:') call assert_fails('normal! gRx', 'E21:') + call assert_nobeep("normal! gr\") set modifiable& - enew! + + call assert_nobeep("normal! gr\") + call assert_beeps("normal! cgr\") + + call assert_equal('zxxxx line l', getline(1)) + exe "normal! 2|gr\\" + call assert_equal("z\xx line l", getline(1)) + + call setline(1, 'abcdef') + exe "normal! 0gr\lx" + call assert_equal("\def", getline(1)) + + call setline(1, 'abcdef') + exe "normal! 0gr\lx" + call assert_equal("\def", getline(1)) + + bwipe! endfunc func Test_nv_hat_count() -- cgit From 0972d7a12468d6914a70e453af85c307b167c55b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 23:13:12 +0800 Subject: vim-patch:9.0.0196: finding value in list may require a for loop Problem: Finding value in list may require a for loop. Solution: Add indexof(). (Yegappan Lakshmanan, closes vim/vim#10903) https://github.com/vim/vim/commit/b218655d5a485f5b193fb18d7240837d42b89812 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_blob.vim | 27 ++++++++++++++++++++++ src/nvim/testdir/test_listdict.vim | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 046acb81e1..4c5632c81f 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -364,4 +364,31 @@ func Test_blob2string() call assert_equal(v, string(b)) endfunc +" Test for the indexof() function +func Test_indexof() + let b = 0zdeadbeef + call assert_equal(0, indexof(b, {i, v -> v == 0xde})) + call assert_equal(3, indexof(b, {i, v -> v == 0xef})) + call assert_equal(-1, indexof(b, {i, v -> v == 0x1})) + call assert_equal(1, indexof(b, "v:val == 0xad")) + call assert_equal(-1, indexof(b, "v:val == 0xff")) + + call assert_equal(-1, indexof(0z, "v:val == 0x0")) + call assert_equal(-1, indexof(v:_null_blob, "v:val == 0xde")) + call assert_equal(-1, indexof(b, v:_null_string)) + " Nvim doesn't have null functions + " call assert_equal(-1, indexof(b, test_null_function())) + + let b = 0z01020102 + call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0})) + call assert_equal(2, indexof(b, "v:val == 0x01", #{startidx: -2})) + call assert_equal(-1, indexof(b, "v:val == 0x01", #{startidx: 5})) + call assert_equal(0, indexof(b, "v:val == 0x01", #{startidx: -5})) + call assert_equal(0, indexof(b, "v:val == 0x01", v:_null_dict)) + + " failure cases + call assert_fails('let i = indexof(b, "val == 0xde")', 'E121:') + call assert_fails('let i = indexof(b, {})', 'E1256:') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index 9ecd83265a..4c51119d16 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -1067,4 +1067,50 @@ func Test_null_dict() call assert_equal({}, {}) endfunc +" Test for the indexof() function +func Test_indexof() + let l = [#{color: 'red'}, #{color: 'blue'}, #{color: 'green'}] + call assert_equal(0, indexof(l, {i, v -> v.color == 'red'})) + call assert_equal(2, indexof(l, {i, v -> v.color == 'green'})) + call assert_equal(-1, indexof(l, {i, v -> v.color == 'grey'})) + call assert_equal(1, indexof(l, "v:val.color == 'blue'")) + call assert_equal(-1, indexof(l, "v:val.color == 'cyan'")) + + let l = [#{n: 10}, #{n: 10}, #{n: 20}] + call assert_equal(0, indexof(l, "v:val.n == 10", #{startidx: 0})) + call assert_equal(1, indexof(l, "v:val.n == 10", #{startidx: -2})) + call assert_equal(-1, indexof(l, "v:val.n == 10", #{startidx: 4})) + call assert_equal(-1, indexof(l, "v:val.n == 10", #{startidx: -4})) + call assert_equal(0, indexof(l, "v:val.n == 10", v:_null_dict)) + + call assert_equal(-1, indexof([], {i, v -> v == 'a'})) + call assert_equal(-1, indexof(v:_null_list, {i, v -> v == 'a'})) + call assert_equal(-1, indexof(l, v:_null_string)) + " Nvim doesn't have null functions + " call assert_equal(-1, indexof(l, test_null_function())) + + " failure cases + call assert_fails('let i = indexof(l, "v:val == ''cyan''")', 'E735:') + call assert_fails('let i = indexof(l, "color == ''cyan''")', 'E121:') + call assert_fails('let i = indexof(l, {})', 'E1256:') + call assert_fails('let i = indexof({}, "v:val == 2")', 'E1226:') + call assert_fails('let i = indexof([], "v:val == 2", [])', 'E1206:') + + func TestIdx(k, v) + return a:v.n == 20 + endfunc + call assert_equal(2, indexof(l, function("TestIdx"))) + delfunc TestIdx + func TestIdx(k, v) + return {} + endfunc + call assert_fails('let i = indexof(l, function("TestIdx"))', 'E728:') + delfunc TestIdx + func TestIdx(k, v) + throw "IdxError" + endfunc + call assert_fails('let i = indexof(l, function("TestIdx"))', 'E605:') + delfunc TestIdx +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 1f8cef53deb4b91a7249affca77bfb89ce0949b4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Feb 2023 00:00:01 +0800 Subject: vim-patch:9.0.0204: indexof() may leak memory Problem: indexof() may leak memory. Solution: Free allocated values. (Yegappan Lakshmanan, closes vim/vim#10916) https://github.com/vim/vim/commit/63acae13f57c5ad4c8ec3146d0c458550b9e984e Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_blob.vim | 1 + src/nvim/testdir/test_listdict.vim | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 4c5632c81f..cf03d2011c 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -372,6 +372,7 @@ func Test_indexof() call assert_equal(-1, indexof(b, {i, v -> v == 0x1})) call assert_equal(1, indexof(b, "v:val == 0xad")) call assert_equal(-1, indexof(b, "v:val == 0xff")) + call assert_equal(-1, indexof(b, {_, v -> "v == 0xad"})) call assert_equal(-1, indexof(0z, "v:val == 0x0")) call assert_equal(-1, indexof(v:_null_blob, "v:val == 0xde")) diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index 4c51119d16..37c1ee8307 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -1083,7 +1083,13 @@ func Test_indexof() call assert_equal(-1, indexof(l, "v:val.n == 10", #{startidx: -4})) call assert_equal(0, indexof(l, "v:val.n == 10", v:_null_dict)) + let s = ["a", "b", "c"] + call assert_equal(2, indexof(s, {_, v -> v == 'c'})) + call assert_equal(-1, indexof(s, {_, v -> v == 'd'})) + call assert_equal(-1, indexof(s, {_, v -> "v == 'd'"})) + call assert_equal(-1, indexof([], {i, v -> v == 'a'})) + call assert_equal(-1, indexof([1, 2, 3], {_, v -> "v == 2"})) call assert_equal(-1, indexof(v:_null_list, {i, v -> v == 'a'})) call assert_equal(-1, indexof(l, v:_null_string)) " Nvim doesn't have null functions -- cgit From 2c9fbe34b20266ef5ab54f6ed14fb38eef60430d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Feb 2023 10:10:42 +0800 Subject: vim-patch:8.2.2336: Vim9: not possible to extend dictionary with different type (#22425) Problem: Vim9: it is not possible to extend a dictionary with different item types. Solution: Add extendnew(). (closes vim/vim#7666) https://github.com/vim/vim/commit/b0e6b513648db7035046613431a4aa9d71ef4653 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_listdict.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index 37c1ee8307..fa22bad0cb 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -881,6 +881,18 @@ func Test_listdict_extend() call assert_equal([1, 5, 7, 1, 5, 7], l) endfunc +func Test_listdict_extendnew() + " Test extendnew() with lists + let l = [1, 2, 3] + call assert_equal([1, 2, 3, 4, 5], extendnew(l, [4, 5])) + call assert_equal([1, 2, 3], l) + + " Test extend() with dictionaries. + let d = {'a': {'b': 'B'}} + call assert_equal({'a': {'b': 'B'}, 'c': 'cc'}, extendnew(d, {'c': 'cc'})) + call assert_equal({'a': {'b': 'B'}}, d) +endfunc + func s:check_scope_dict(x, fixed) func s:gen_cmd(cmd, x) return substitute(a:cmd, '\ Date: Mon, 27 Feb 2023 23:27:09 +0800 Subject: vim-patch:9.0.1361: extendnew() not sufficiently tested (#22434) Problem: extendnew() not sufficiently tested. Solution: Add a few more test cases for extendnew(). (closes vim/vim#12075) https://github.com/vim/vim/commit/341f3876b34f47fdb1c82b0ad9bae448be73a220 --- src/nvim/testdir/test_listdict.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index fa22bad0cb..a6a1c736c4 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -886,11 +886,15 @@ func Test_listdict_extendnew() let l = [1, 2, 3] call assert_equal([1, 2, 3, 4, 5], extendnew(l, [4, 5])) call assert_equal([1, 2, 3], l) + lockvar l + call assert_equal([1, 2, 3, 4, 5], extendnew(l, [4, 5])) - " Test extend() with dictionaries. + " Test extendnew() with dictionaries. let d = {'a': {'b': 'B'}} call assert_equal({'a': {'b': 'B'}, 'c': 'cc'}, extendnew(d, {'c': 'cc'})) call assert_equal({'a': {'b': 'B'}}, d) + lockvar d + call assert_equal({'a': {'b': 'B'}, 'c': 'cc'}, extendnew(d, {'c': 'cc'})) endfunc func s:check_scope_dict(x, fixed) -- cgit From 2a8e6a2f1a8e047a8efd84764d9a332bbd6ae96d Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 27 Feb 2023 15:08:31 -0500 Subject: vim-patch:9.0.1360: Cue files are not recognized (#22439) Problem: Cue files are not recognized. Solution: Add patterns for Cue files. (Amaan Qureshi, closes vim/vim#12067) https://github.com/vim/vim/commit/80c5b2c0f78b24e52c73bb162dda3ad85acd7e82 --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 96ab5620ec..148f8b6d42 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -140,6 +140,7 @@ let s:filename_checks = { \ 'csv': ['file.csv'], \ 'cucumber': ['file.feature'], \ 'cuda': ['file.cu', 'file.cuh'], + \ 'cue': ['file.cue'], \ 'cupl': ['file.pld'], \ 'cuplsim': ['file.si'], \ 'cvs': ['cvs123'], -- cgit From 1b632e99f231baca8a640502a352aa68aee0568a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 08:26:00 +0800 Subject: vim-patch:9.0.1362: ml_get error when going to another tab (#22443) Problem: ml_get error when going to another tab. (Daniel J. Perry) Solution: Do not call update_topline() if "curwin" is invalid. (closes vim/vim#11907) https://github.com/vim/vim/commit/99ad3a8bb95c6f860545a050472b6181e33bac1a Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_tabpage.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index b97aa409d8..c20c798c49 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -846,4 +846,19 @@ func Test_lastused_tabpage() tabonly! endfunc +" this was giving ml_get errors +func Test_tabpage_last_line() + enew + call setline(1, repeat(['a'], &lines + 5)) + $ + tabnew + call setline(1, repeat(['b'], &lines + 20)) + $ + tabNext + call assert_equal('a', getline('.')) + + bwipe! + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From adfa55ba99febaa1eb5ebe1800ec5f94c4b4b664 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Feb 2023 14:36:20 +0800 Subject: vim-patch:8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate Problem: Vim9: blob tests for legacy and Vim9 script are separate. Solution: Add CheckLegacyAndVim9Success(). Make blob index assign work. https://github.com/vim/vim/commit/68452177ca4cda4a9d5f93892e437447cf9404c8 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 130 ++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 60 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index cf03d2011c..6c3558e273 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -1,5 +1,7 @@ " Tests for the Blob types +source vim9.vim + func TearDown() " Run garbage collection after every test call test_garbagecollect_now() @@ -9,73 +11,81 @@ endfunc " Blob creation from constant func Test_blob_create() - let b = 0zDEADBEEF - call assert_equal(v:t_blob, type(b)) - call assert_equal(4, len(b)) - call assert_equal(0xDE, b[0]) - call assert_equal(0xAD, b[1]) - call assert_equal(0xBE, b[2]) - call assert_equal(0xEF, b[3]) - call assert_fails('let x = b[4]') - - call assert_equal(0xDE, get(b, 0)) - call assert_equal(0xEF, get(b, 3)) - - call assert_fails('let b = 0z1', 'E973:') - call assert_fails('let b = 0z1x', 'E973:') - call assert_fails('let b = 0z12345', 'E973:') - - call assert_equal(0z, v:_null_blob) - - let b = 0z001122.33445566.778899.aabbcc.dd - call assert_equal(0z00112233445566778899aabbccdd, b) - call assert_fails('let b = 0z1.1') - call assert_fails('let b = 0z.') - call assert_fails('let b = 0z001122.') - call assert_fails('call get("", 1)', 'E896:') - call assert_equal(0, len(v:_null_blob)) + let lines =<< trim END + VAR b = 0zDEADBEEF + call assert_equal(v:t_blob, type(b)) + call assert_equal(4, len(b)) + call assert_equal(0xDE, b[0]) + call assert_equal(0xAD, b[1]) + call assert_equal(0xBE, b[2]) + call assert_equal(0xEF, b[3]) + call assert_fails('VAR x = b[4]') + + call assert_equal(0xDE, get(b, 0)) + call assert_equal(0xEF, get(b, 3)) + + call assert_fails('VAR b = 0z1', 'E973:') + call assert_fails('VAR b = 0z1x', 'E973:') + call assert_fails('VAR b = 0z12345', 'E973:') + + call assert_equal(0z, v:_null_blob) + + LET b = 0z001122.33445566.778899.aabbcc.dd + call assert_equal(0z00112233445566778899aabbccdd, b) + call assert_fails('VAR b = 0z1.1') + call assert_fails('VAR b = 0z.') + call assert_fails('VAR b = 0z001122.') + call assert_fails('call get("", 1)', 'E896:') + call assert_equal(0, len(v:_null_blob)) + END + call CheckLegacyAndVim9Success(lines) endfunc " assignment to a blob func Test_blob_assign() + let lines =<< trim END + VAR b = 0zDEADBEEF + VAR b2 = b[1 : 2] + call assert_equal(0zADBE, b2) + + VAR bcopy = b[:] + call assert_equal(b, bcopy) + call assert_false(b is bcopy) + + LET b = 0zDEADBEEF + LET b2 = b + call assert_true(b is b2) + LET b[:] = 0z11223344 + call assert_equal(0z11223344, b) + call assert_equal(0z11223344, b2) + call assert_true(b is b2) + + LET b = 0zDEADBEEF + LET b[3 :] = 0z66 + call assert_equal(0zDEADBE66, b) + LET b[: 1] = 0z8899 + call assert_equal(0z8899BE66, b) + + LET b = 0zDEADBEEF + LET b += 0z99 + call assert_equal(0zDEADBEEF99, b) + + VAR l = [0z12] + VAR m = deepcopy(l) + LET m[0] = 0z34 #" E742 or E741 should not occur. + END + call CheckLegacyAndVim9Success(lines) + + " TODO: move to above once it works let b = 0zDEADBEEF - let b2 = b[1:2] - call assert_equal(0zADBE, b2) - - let bcopy = b[:] - call assert_equal(b, bcopy) - call assert_false(b is bcopy) - - let b = 0zDEADBEEF - let b2 = b - call assert_true(b is b2) - let b[:] = 0z11223344 - call assert_equal(0z11223344, b) - call assert_equal(0z11223344, b2) - call assert_true(b is b2) + call assert_fails('let b[2 : 3] = 0z112233', 'E972:') + call assert_fails('let b[2 : 3] = 0z11', 'E972:') + call assert_fails('let b[3 : 2] = 0z', 'E979:') - let b = 0zDEADBEEF - let b[3:] = 0z66 - call assert_equal(0zDEADBE66, b) - let b[:1] = 0z8899 - call assert_equal(0z8899BE66, b) - - call assert_fails('let b[2:3] = 0z112233', 'E972:') - call assert_fails('let b[2:3] = 0z11', 'E972:') - call assert_fails('let b[3:2] = 0z', 'E979:') - - let b = 0zDEADBEEF - let b += 0z99 - call assert_equal(0zDEADBEEF99, b) - - call assert_fails('let b .= 0z33', 'E734:') - call assert_fails('let b .= "xx"', 'E734:') + call assert_fails('let b ..= 0z33', 'E734:') + call assert_fails('let b ..= "xx"', 'E734:') call assert_fails('let b += "xx"', 'E734:') - call assert_fails('let b[1:1] .= 0z55', 'E734:') - - let l = [0z12] - let m = deepcopy(l) - let m[0] = 0z34 " E742 or E741 should not occur. + call assert_fails('let b[1 : 1] ..= 0z55', 'E734:') endfunc func Test_blob_get_range() -- cgit From c554e989786be30fa306efcd7e504ba7cb97cb3b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 13:30:08 +0800 Subject: vim-patch:8.2.2765: Vim9: not all blob operations work Problem: Vim9: not all blob operations work. Solution: Run more tests also with Vim9 script and :def functions. Fix what doesn't work. https://github.com/vim/vim/commit/0e3ff1919603ee4c4a347fdf761dbdbdeb068015 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 51 +++++++++++++++++++++++++++++++++--------- src/nvim/testdir/vim9.vim | 4 ++-- 2 files changed, 43 insertions(+), 12 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 6c3558e273..86e16b372b 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -76,16 +76,47 @@ func Test_blob_assign() END call CheckLegacyAndVim9Success(lines) - " TODO: move to above once it works - let b = 0zDEADBEEF - call assert_fails('let b[2 : 3] = 0z112233', 'E972:') - call assert_fails('let b[2 : 3] = 0z11', 'E972:') - call assert_fails('let b[3 : 2] = 0z', 'E979:') - - call assert_fails('let b ..= 0z33', 'E734:') - call assert_fails('let b ..= "xx"', 'E734:') - call assert_fails('let b += "xx"', 'E734:') - call assert_fails('let b[1 : 1] ..= 0z55', 'E734:') + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b[2 : 3] = 0z112233 + END + call CheckLegacyAndVim9Failure(lines, 'E972:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b[2 : 3] = 0z11 + END + call CheckLegacyAndVim9Failure(lines, 'E972:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b[3 : 2] = 0z + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b ..= 0z33 + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b ..= "xx" + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b += "xx" + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + + let lines =<< trim END + VAR b = 0zDEADBEEF + LET b[1 : 1] ..= 0z55 + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) endfunc func Test_blob_get_range() diff --git a/src/nvim/testdir/vim9.vim b/src/nvim/testdir/vim9.vim index 3c0ff2b2dd..e1343d51f1 100644 --- a/src/nvim/testdir/vim9.vim +++ b/src/nvim/testdir/vim9.vim @@ -98,9 +98,9 @@ endfunc " Use ' #"' for a comment func CheckLegacyAndVim9Failure(lines, error) if type(a:error) == type('string') - let legacyError = error + let legacyError = a:error else - let legacyError = error[0] + let legacyError = a:error[0] endif let legacylines = a:lines->deepcopy()->map({_, v -> -- cgit From 761a559dbfed99e588d7f306c89331907b2d5a92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 14:27:47 +0800 Subject: vim-patch:8.2.2777: Vim9: blob operations not tested in all ways Problem: Vim9: blob operations not tested in all ways. Solution: Run tests with CheckLegacyAndVim9Success(). Make blob assign with index work. https://github.com/vim/vim/commit/51e933261b984db014e858d79387a826d2626fb6 Cherry-pick related changes from patches 8.2.{0633,0634}. N/A patches for version.c: vim-patch:8.2.2779: memory access error in remove() for blob Problem: Memory access error in remove() for blob. Solution: Adjust length for memmove(). https://github.com/vim/vim/commit/f7e92aae1581203306a340b4c0059cc74adea9d6 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 214 ++++++++++++++++++++++++++++------------- 1 file changed, 147 insertions(+), 67 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 86e16b372b..e9d694e4c6 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -120,86 +120,166 @@ func Test_blob_assign() endfunc func Test_blob_get_range() + let lines =<< trim END + VAR b = 0z0011223344 + call assert_equal(0z2233, b[2 : 3]) + call assert_equal(0z223344, b[2 : -1]) + call assert_equal(0z00, b[0 : -5]) + call assert_equal(0z, b[0 : -11]) + call assert_equal(0z44, b[-1 :]) + call assert_equal(0z0011223344, b[:]) + call assert_equal(0z0011223344, b[: -1]) + call assert_equal(0z, b[5 : 6]) + call assert_equal(0z0011, b[-10 : 1]) + END + call CheckLegacyAndVim9Success(lines) + + " legacy script white space let b = 0z0011223344 call assert_equal(0z2233, b[2:3]) - call assert_equal(0z223344, b[2:-1]) - call assert_equal(0z00, b[0:-5]) - call assert_equal(0z, b[0:-11]) - call assert_equal(0z44, b[-1:]) - call assert_equal(0z0011223344, b[:]) - call assert_equal(0z0011223344, b[:-1]) - call assert_equal(0z, b[5:6]) - call assert_equal(0z0011, b[-10:1]) endfunc func Test_blob_get() - let b = 0z0011223344 - call assert_equal(0x00, get(b, 0)) - call assert_equal(0x22, get(b, 2, 999)) - call assert_equal(0x44, get(b, 4)) - call assert_equal(0x44, get(b, -1)) - call assert_equal(-1, get(b, 5)) - call assert_equal(999, get(b, 5, 999)) - call assert_equal(-1, get(b, -8)) - call assert_equal(999, get(b, -8, 999)) - call assert_equal(10, get(v:_null_blob, 2, 10)) - - call assert_equal(0x00, b[0]) - call assert_equal(0x22, b[2]) - call assert_equal(0x44, b[4]) - call assert_equal(0x44, b[-1]) - call assert_fails('echo b[5]', 'E979:') - call assert_fails('echo b[-8]', 'E979:') + let lines =<< trim END + VAR b = 0z0011223344 + call assert_equal(0x00, get(b, 0)) + call assert_equal(0x22, get(b, 2, 999)) + call assert_equal(0x44, get(b, 4)) + call assert_equal(0x44, get(b, -1)) + call assert_equal(-1, get(b, 5)) + call assert_equal(999, get(b, 5, 999)) + call assert_equal(-1, get(b, -8)) + call assert_equal(999, get(b, -8, 999)) + call assert_equal(10, get(v:_null_blob, 2, 10)) + + call assert_equal(0x00, b[0]) + call assert_equal(0x22, b[2]) + call assert_equal(0x44, b[4]) + call assert_equal(0x44, b[-1]) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + VAR b = 0z0011223344 + echo b[5] + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0z0011223344 + echo b[-8] + END + call CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_to_string() - let b = 0z00112233445566778899aabbccdd - call assert_equal('0z00112233.44556677.8899AABB.CCDD', string(b)) - call assert_equal(b, eval(string(b))) - call remove(b, 4, -1) - call assert_equal('0z00112233', string(b)) - call remove(b, 0, 3) - call assert_equal('0z', string(b)) + let lines =<< trim END + VAR b = 0z00112233445566778899aabbccdd + call assert_equal('0z00112233.44556677.8899AABB.CCDD', string(b)) + call assert_equal(b, eval(string(b))) + call remove(b, 4, -1) + call assert_equal('0z00112233', string(b)) + call remove(b, 0, 3) + call assert_equal('0z', string(b)) + call assert_equal('0z', string(v:_null_blob)) + END + call CheckLegacyAndVim9Success(lines) endfunc func Test_blob_compare() - let b1 = 0z0011 - let b2 = 0z1100 - let b3 = 0z001122 - call assert_true(b1 == b1) - call assert_false(b1 == b2) - call assert_false(b1 == b3) - call assert_true(b1 != b2) - call assert_true(b1 != b3) - call assert_true(b1 == 0z0011) - call assert_fails('echo b1 == 9', 'E977:') - call assert_fails('echo b1 != 9', 'E977:') - - call assert_false(b1 is b2) - let b2 = b1 - call assert_true(b1 == b2) - call assert_true(b1 is b2) - let b2 = copy(b1) - call assert_true(b1 == b2) - call assert_false(b1 is b2) - let b2 = b1[:] - call assert_true(b1 == b2) - call assert_false(b1 is b2) - - call assert_fails('let x = b1 > b2') - call assert_fails('let x = b1 < b2') - call assert_fails('let x = b1 - b2') - call assert_fails('let x = b1 / b2') - call assert_fails('let x = b1 * b2') + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR b3 = 0z001122 + call assert_true(b1 == b1) + call assert_false(b1 == b2) + call assert_false(b1 == b3) + call assert_true(b1 != b2) + call assert_true(b1 != b3) + call assert_true(b1 == 0z0011) + + call assert_false(b1 is b2) + LET b2 = b1 + call assert_true(b1 == b2) + call assert_true(b1 is b2) + LET b2 = copy(b1) + call assert_true(b1 == b2) + call assert_false(b1 is b2) + LET b2 = b1[:] + call assert_true(b1 == b2) + call assert_false(b1 is b2) + call assert_true(b1 isnot b2) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + VAR b1 = 0z0011 + echo b1 == 9 + END + call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + + let lines =<< trim END + VAR b1 = 0z0011 + echo b1 != 9 + END + call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR x = b1 > b2 + END + call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR x = b1 < b2 + END + call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR x = b1 - b2 + END + call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR x = b1 / b2 + END + call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + + let lines =<< trim END + VAR b1 = 0z0011 + VAR b2 = 0z1100 + VAR x = b1 * b2 + END + call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) endfunc -" test for range assign -func Test_blob_range_assign() - let b = 0z00 - let b[1] = 0x11 - let b[2] = 0x22 - call assert_equal(0z001122, b) - call assert_fails('let b[4] = 0x33', 'E979:') +func Test_blob_index_assign() + let lines =<< trim END + VAR b = 0z00 + LET b[1] = 0x11 + LET b[2] = 0x22 + call assert_equal(0z001122, b) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + VAR b = 0z00 + LET b[2] = 0x33 + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0z00 + LET b[-2] = 0x33 + END + call CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_for_loop() -- cgit From 0ded757c31bf02d6cd27fc7b580e85ff7953604e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 15:46:53 +0800 Subject: vim-patch:8.2.2780: Vim9: for loop over blob doesn't work Problem: Vim9: for loop over blob doesn't work. Solution: Make it work. https://github.com/vim/vim/commit/d551d6c268e435e2fbba22775510fbd0a54477f6 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index e9d694e4c6..454be05363 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -283,33 +283,36 @@ func Test_blob_index_assign() endfunc func Test_blob_for_loop() - let blob = 0z00010203 - let i = 0 - for byte in blob - call assert_equal(i, byte) - let i += 1 - endfor - call assert_equal(4, i) - - let blob = 0z00 - call remove(blob, 0) - call assert_equal(0, len(blob)) - for byte in blob - call assert_error('loop over empty blob') - endfor - - let blob = 0z0001020304 - let i = 0 - for byte in blob - call assert_equal(i, byte) - if i == 1 + let lines =<< trim END + VAR blob = 0z00010203 + VAR i = 0 + for byte in blob + call assert_equal(i, byte) + LET i += 1 + endfor + call assert_equal(4, i) + + LET blob = 0z00 call remove(blob, 0) - elseif i == 3 - call remove(blob, 3) - endif - let i += 1 - endfor - call assert_equal(5, i) + call assert_equal(0, len(blob)) + for byte in blob + call assert_report('loop over empty blob') + endfor + + LET blob = 0z0001020304 + LET i = 0 + for byte in blob + call assert_equal(i, byte) + if i == 1 + call remove(blob, 0) + elseif i == 3 + call remove(blob, 3) + endif + LET i += 1 + endfor + call assert_equal(5, i) + END + call CheckLegacyAndVim9Success(lines) endfunc func Test_blob_concatenate() -- cgit From 88b70e7d4650795210222a598cbb233bf7fc98f8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 15:50:35 +0800 Subject: vim-patch:8.2.2782: Vim9: blob operations not fully tested Problem: Vim9: blob operations not fully tested. Solution: Make more blob tests run in Vim9 script. Fix filter(). Make insert() give an error for a null blob, like add(). https://github.com/vim/vim/commit/39211cba723a2cb58a97c7e08826713164b86efc vim-patch:8.2.3284: no error for insert() or remove() changing a locked blob Problem: No error for insert() or remove() changing a locked blob. Solution: Check a blob is not locked before changing it. (Sean Dewar, closes vim/vim#8696) https://github.com/vim/vim/commit/80d7395dcfe96158428da6bb3d28a6eee1244e28 Co-authored-by: Bram Moolenaar Co-authored-by: Sean Dewar --- src/nvim/testdir/test_blob.vim | 337 ++++++++++++++++++++++++++++++----------- src/nvim/testdir/vim9.vim | 4 + 2 files changed, 250 insertions(+), 91 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 454be05363..99b8c6083a 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -347,51 +347,101 @@ endfunc " Test removing items in blob func Test_blob_func_remove() - " Test removing 1 element - let b = 0zDEADBEEF - call assert_equal(0xDE, remove(b, 0)) - call assert_equal(0zADBEEF, b) + let lines =<< trim END + #" Test removing 1 element + VAR b = 0zDEADBEEF + call assert_equal(0xDE, remove(b, 0)) + call assert_equal(0zADBEEF, b) - let b = 0zDEADBEEF - call assert_equal(0xEF, remove(b, -1)) - call assert_equal(0zDEADBE, b) + LET b = 0zDEADBEEF + call assert_equal(0xEF, remove(b, -1)) + call assert_equal(0zDEADBE, b) - let b = 0zDEADBEEF - call assert_equal(0xAD, remove(b, 1)) - call assert_equal(0zDEBEEF, b) + LET b = 0zDEADBEEF + call assert_equal(0xAD, remove(b, 1)) + call assert_equal(0zDEBEEF, b) - " Test removing range of element(s) - let b = 0zDEADBEEF - call assert_equal(0zBE, remove(b, 2, 2)) - call assert_equal(0zDEADEF, b) + #" Test removing range of element(s) + LET b = 0zDEADBEEF + call assert_equal(0zBE, remove(b, 2, 2)) + call assert_equal(0zDEADEF, b) - let b = 0zDEADBEEF - call assert_equal(0zADBE, remove(b, 1, 2)) - call assert_equal(0zDEEF, b) + LET b = 0zDEADBEEF + call assert_equal(0zADBE, remove(b, 1, 2)) + call assert_equal(0zDEEF, b) + END + call CheckLegacyAndVim9Success(lines) " Test invalid cases - let b = 0zDEADBEEF - call assert_fails("call remove(b, 5)", 'E979:') - call assert_fails("call remove(b, 1, 5)", 'E979:') - call assert_fails("call remove(b, 3, 2)", 'E979:') - call assert_fails("call remove(1, 0)", 'E896:') - call assert_fails("call remove(b, b)", 'E974:') - call assert_fails("call remove(b, 1, [])", 'E745:') - call assert_fails("call remove(v:_null_blob, 1, 2)", 'E979:') - - " Translated from v8.2.3284 - let b = 0zDEADBEEF - lockvar b - call assert_fails('call remove(b, 0)', 'E741:') - unlockvar b + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(b, 5) + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(b, 1, 5) + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(b, 3, 2) + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(1, 0) + END + call CheckLegacyAndVim9Failure(lines, 'E896:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(b, b) + END + call CheckLegacyAndVim9Failure(lines, 'E974:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(b, 1, []) + END + call CheckLegacyAndVim9Failure(lines, 'E745:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call remove(v:_null_blob, 1, 2) + END + call CheckLegacyAndVim9Failure(lines, 'E979:') + + let lines =<< trim END + let b = 0zDEADBEEF + lockvar b + call remove(b, 0) + unlockvar b + END + call CheckScriptFailure(lines, 'E741:') + + " can only check at script level, not in a :def function + let lines =<< trim END + vim9script + var b = 0zDEADBEEF + lockvar b + remove(b, 0) + END + call CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_read_write() - let b = 0zDEADBEEF - call writefile(b, 'Xblob') - let br = readfile('Xblob', 'B') - call assert_equal(b, br) - call delete('Xblob') + let lines =<< trim END + VAR b = 0zDEADBEEF + call writefile(b, 'Xblob') + VAR br = readfile('Xblob', 'B') + call assert_equal(b, br) + call delete('Xblob') + END + call CheckLegacyAndVim9Success(lines) " This was crashing when calling readfile() with a directory. call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') @@ -399,85 +449,190 @@ endfunc " filter() item in blob func Test_blob_filter() - call assert_equal(v:_null_blob, filter(v:_null_blob, '0')) - call assert_equal(0z, filter(0zDEADBEEF, '0')) - call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE')) - call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE')) - call assert_equal(0zDEADBE, filter(0zDEADBEEF, 'v:val != 0xEF')) - call assert_equal(0zDEADBEEF, filter(0zDEADBEEF, '1')) - call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) - call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) + let lines =<< trim END + call assert_equal(v:_null_blob, filter(v:_null_blob, '0')) + call assert_equal(0z, filter(0zDEADBEEF, '0')) + call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE')) + call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE')) + call assert_equal(0zDEADBE, filter(0zDEADBEEF, 'v:val != 0xEF')) + call assert_equal(0zDEADBEEF, filter(0zDEADBEEF, '1')) + call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) + call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) + END + call CheckLegacyAndVim9Success(lines) endfunc " map() item in blob func Test_blob_map() - call assert_equal(0zDFAEBFF0, map(0zDEADBEEF, 'v:val + 1')) - call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) - call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) + let lines =<< trim END + call assert_equal(0zDFAEBFF0, map(0zDEADBEEF, 'v:val + 1')) + call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) + call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) + END + call CheckLegacyAndVim9Success(lines) - call assert_fails("call map(0z00, '[9]')", 'E978:') + let lines =<< trim END + call map(0z00, '[9]') + END + call CheckLegacyAndVim9Failure(lines, 'E978:') endfunc func Test_blob_index() - call assert_equal(2, index(0zDEADBEEF, 0xBE)) - call assert_equal(-1, index(0zDEADBEEF, 0)) - call assert_equal(2, index(0z11111111, 0x11, 2)) - call assert_equal(3, 0z11110111->index(0x11, 2)) - call assert_equal(2, index(0z11111111, 0x11, -2)) - call assert_equal(3, index(0z11110111, 0x11, -2)) - call assert_equal(0, index(0z11110111, 0x11, -10)) - call assert_fails("echo index(0z11110111, 0x11, [])", 'E745:') - call assert_equal(-1, index(v:_null_blob, 1)) - - call assert_fails('call index("asdf", 0)', 'E897:') + let lines =<< trim END + call assert_equal(2, index(0zDEADBEEF, 0xBE)) + call assert_equal(-1, index(0zDEADBEEF, 0)) + call assert_equal(2, index(0z11111111, 0x11, 2)) + call assert_equal(3, 0z11110111->index(0x11, 2)) + call assert_equal(2, index(0z11111111, 0x11, -2)) + call assert_equal(3, index(0z11110111, 0x11, -2)) + call assert_equal(0, index(0z11110111, 0x11, -10)) + call assert_equal(-1, index(v:_null_blob, 1)) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + echo index(0z11110111, 0x11, []) + END + call CheckLegacyAndVim9Failure(lines, 'E745:') + + let lines =<< trim END + call index("asdf", 0) + END + call CheckLegacyAndVim9Failure(lines, 'E897:') endfunc func Test_blob_insert() - let b = 0zDEADBEEF - call insert(b, 0x33) - call assert_equal(0z33DEADBEEF, b) - - let b = 0zDEADBEEF - call insert(b, 0x33, 2) - call assert_equal(0zDEAD33BEEF, b) - - call assert_fails('call insert(b, -1)', 'E475:') - call assert_fails('call insert(b, 257)', 'E475:') - call assert_fails('call insert(b, 0, [9])', 'E745:') - call assert_fails('call insert(b, 0, -20)', 'E475:') - call assert_fails('call insert(b, 0, 20)', 'E475:') - call assert_fails('call insert(b, [])', 'E745:') + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, 0x33) + call assert_equal(0z33DEADBEEF, b) + + LET b = 0zDEADBEEF + call insert(b, 0x33, 2) + call assert_equal(0zDEAD33BEEF, b) + END + call CheckLegacyAndVim9Success(lines) + + " only works in legacy script call assert_equal(0, insert(v:_null_blob, 0x33)) - " Translated from v8.2.3284 - let b = 0zDEADBEEF - lockvar b - call assert_fails('call insert(b, 3)', 'E741:') - unlockvar b + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, -1) + END + call CheckLegacyAndVim9Failure(lines, 'E475:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, 257) + END + call CheckLegacyAndVim9Failure(lines, 'E475:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, 0, [9]) + END + call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E745:']) + + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, 0, -20) + END + call CheckLegacyAndVim9Failure(lines, 'E475:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, 0, 20) + END + call CheckLegacyAndVim9Failure(lines, 'E475:') + + let lines =<< trim END + VAR b = 0zDEADBEEF + call insert(b, []) + END + call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E745:']) + + let lines =<< trim END + insert(v:_null_blob, 0x33) + END + call CheckDefExecAndScriptFailure(lines, 'E1131:') + + let lines =<< trim END + let b = 0zDEADBEEF + lockvar b + call insert(b, 3) + unlockvar b + END + call CheckScriptFailure(lines, 'E741:') + + let lines =<< trim END + vim9script + var b = 0zDEADBEEF + lockvar b + insert(b, 3) + END + call CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_reverse() - call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) - call assert_equal(0zBEADDE, reverse(0zDEADBE)) - call assert_equal(0zADDE, reverse(0zDEAD)) - call assert_equal(0zDE, reverse(0zDE)) - call assert_equal(0z, reverse(v:_null_blob)) + let lines =<< trim END + call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) + call assert_equal(0zBEADDE, reverse(0zDEADBE)) + call assert_equal(0zADDE, reverse(0zDEAD)) + call assert_equal(0zDE, reverse(0zDE)) + call assert_equal(0z, reverse(v:_null_blob)) + END + call CheckLegacyAndVim9Success(lines) +endfunc + +func Test_blob_json_encode() + let lines =<< trim END + #" call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) + call assert_equal('[222, 173, 190, 239]', json_encode(0zDEADBEEF)) + call assert_equal('[]', json_encode(0z)) + END + call CheckLegacyAndVim9Success(lines) endfunc func Test_blob_lock() - let b = 0z112233 - lockvar b - call assert_fails('let b = 0z44', 'E741:') - unlockvar b - let b = 0z44 + let lines =<< trim END + let b = 0z112233 + lockvar b + unlockvar b + let b = 0z44 + END + call CheckScriptSuccess(lines) + + let lines =<< trim END + vim9script + var b = 0z112233 + lockvar b + unlockvar b + b = 0z44 + END + call CheckScriptSuccess(lines) + + let lines =<< trim END + let b = 0z112233 + lockvar b + let b = 0z44 + END + call CheckScriptFailure(lines, 'E741:') + + let lines =<< trim END + vim9script + var b = 0z112233 + lockvar b + b = 0z44 + END + call CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_sort() if has('float') - call assert_fails('call sort([1.0, 0z11], "f")', 'E975:') - else - call assert_fails('call sort(["abc", 0z11], "f")', 'E702:') + call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') endif + call CheckLegacyAndVim9Failure(['call sort(["abc", 0z11], "f")'], 'E892:') endfunc " The following used to cause an out-of-bounds memory access diff --git a/src/nvim/testdir/vim9.vim b/src/nvim/testdir/vim9.vim index e1343d51f1..2cc3d88aa8 100644 --- a/src/nvim/testdir/vim9.vim +++ b/src/nvim/testdir/vim9.vim @@ -34,6 +34,10 @@ func CheckScriptSuccess(lines) endtry endfunc +func CheckDefExecAndScriptFailure(lines, error, lnum = -3) + return +endfunc + " Check that "lines" inside a legacy function has no error. func CheckLegacySuccess(lines) let cwd = getcwd() -- cgit From 55d30c459c878224507e90f2a6c1657cdd070668 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 16:06:56 +0800 Subject: vim-patch:8.2.2783: duplicate code for setting byte in blob, blob test may fail Problem: Duplicate code for setting byte in blob, blob test may fail. Solution: Call blob_set_append(). Test sort failure with "N". https://github.com/vim/vim/commit/e8209b91b9974da95899b51dba4058b411d04d5b Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 99b8c6083a..b1859f9dfe 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -632,7 +632,7 @@ func Test_blob_sort() if has('float') call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') endif - call CheckLegacyAndVim9Failure(['call sort(["abc", 0z11], "f")'], 'E892:') + call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') endfunc " The following used to cause an out-of-bounds memory access -- cgit From bfa0bc7df0ca527fcec49dbd2055f1bac438663e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 19:04:32 +0800 Subject: vim-patch:9.0.0795: readblob() always reads the whole file Problem: readblob() always reads the whole file. Solution: Add arguments to read part of the file. (Ken Takata, closes vim/vim#11402) https://github.com/vim/vim/commit/11df3aeee548b959ccd4b9a4d3c44651eab6b3ce Remove trailing whitespace in test as done in patch 9.0.1257. Move the help for rand() before range(). Co-authored-by: K.Takata --- src/nvim/testdir/test_blob.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index b1859f9dfe..dd37fb2f11 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -439,10 +439,29 @@ func Test_blob_read_write() call writefile(b, 'Xblob') VAR br = readfile('Xblob', 'B') call assert_equal(b, br) + VAR br2 = readblob('Xblob') + call assert_equal(b, br2) + VAR br3 = readblob('Xblob', 1) + call assert_equal(b[1 :], br3) + VAR br4 = readblob('Xblob', 1, 2) + call assert_equal(b[1 : 2], br4) + VAR br5 = readblob('Xblob', -3) + call assert_equal(b[-3 :], br5) + VAR br6 = readblob('Xblob', -3, 2) + call assert_equal(b[-3 : -2], br6) + + VAR br1e = readblob('Xblob', 10000) + call assert_equal(0z, br1e) + VAR br2e = readblob('Xblob', -10000) + call assert_equal(0z, br2e) + call delete('Xblob') END call CheckLegacyAndVim9Success(lines) + call assert_fails("call readblob('notexist')", 'E484:') + " TODO: How do we test for the E485 error? + " This was crashing when calling readfile() with a directory. call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') endfunc -- cgit From 4bd0611d7b07b56fc5a9e121669a313166ba540f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 19:23:28 +0800 Subject: vim-patch:9.0.0803: readblob() cannot read from character device Problem: readblob() cannot read from character device. Solution: Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407) https://github.com/vim/vim/commit/43625762a9751cc6e6e4d8f54fbc8b82d98fb20d S_ISCHR is always defined in Nvim. Co-authored-by: K.Takata --- src/nvim/testdir/test_blob.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index dd37fb2f11..5fc232119c 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -459,6 +459,11 @@ func Test_blob_read_write() END call CheckLegacyAndVim9Success(lines) + if filereadable('/dev/random') + let b = readblob('/dev/random', 0, 10) + call assert_equal(10, len(b)) + endif + call assert_fails("call readblob('notexist')", 'E484:') " TODO: How do we test for the E485 error? -- cgit From 7aad75e293e3a01e292308ca2058e35083b83280 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 19:29:59 +0800 Subject: vim-patch:9.0.0810: readblob() returns empty when trying to read too much Problem: readblob() returns empty when trying to read too much. Solution: Return what is available. https://github.com/vim/vim/commit/5b2a3d77d320d76f12b1666938a9d58c2a848205 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 5fc232119c..b01d9309fa 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -450,10 +450,17 @@ func Test_blob_read_write() VAR br6 = readblob('Xblob', -3, 2) call assert_equal(b[-3 : -2], br6) + #" reading past end of file, empty result VAR br1e = readblob('Xblob', 10000) call assert_equal(0z, br1e) - VAR br2e = readblob('Xblob', -10000) - call assert_equal(0z, br2e) + + #" reading too much, result is truncated + VAR blong = readblob('Xblob', -1000) + call assert_equal(b, blong) + LET blong = readblob('Xblob', -10, 8) + call assert_equal(b, blong) + LET blong = readblob('Xblob', 0, 10) + call assert_equal(b, blong) call delete('Xblob') END -- cgit From f6b9791212e86bac3e8128035dec2bfc5016927f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 20:18:52 +0800 Subject: vim-patch:8.2.3438: cannot manipulate blobs Problem: Cannot manipulate blobs. Solution: Add blob2list() and list2blob(). (Yegappan Lakshmanan, closes vim/vim#8868) https://github.com/vim/vim/commit/5dfe467432638fac2e0156a2f9cd0d9eb569fb39 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_blob.vim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index b01d9309fa..28df120b78 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -666,6 +666,45 @@ func Test_blob_sort() call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') endfunc +" Tests for the blob2list() function +func Test_blob2list() + call assert_fails('let v = blob2list(10)', 'E1238: Blob required for argument 1') + eval 0zFFFF->blob2list()->assert_equal([255, 255]) + let tests = [[0z0102, [1, 2]], + \ [0z00, [0]], + \ [0z, []], + \ [0z00000000, [0, 0, 0, 0]], + \ [0zAABB.CCDD, [170, 187, 204, 221]]] + for t in tests + call assert_equal(t[0]->blob2list(), t[1]) + endfor + exe 'let v = 0z' .. repeat('000102030405060708090A0B0C0D0E0F', 64) + call assert_equal(1024, blob2list(v)->len()) + call assert_equal([4, 8, 15], [v[100], v[1000], v[1023]]) + call assert_equal([], blob2list(v:_null_blob)) +endfunc + +" Tests for the list2blob() function +func Test_list2blob() + call assert_fails('let b = list2blob(0z10)', 'E1211: List required for argument 1') + let tests = [[[1, 2], 0z0102], + \ [[0], 0z00], + \ [[], 0z], + \ [[0, 0, 0, 0], 0z00000000], + \ [[170, 187, 204, 221], 0zAABB.CCDD], + \ ] + for t in tests + call assert_equal(t[0]->list2blob(), t[1]) + endfor + call assert_fails('let b = list2blob([1, []])', 'E745:') + call assert_fails('let b = list2blob([-1])', 'E1239:') + call assert_fails('let b = list2blob([256])', 'E1239:') + let b = range(16)->repeat(64)->list2blob() + call assert_equal(1024, b->len()) + call assert_equal([4, 8, 15], [b[100], b[1000], b[1023]]) + call assert_equal(0z, list2blob(v:_null_list)) +endfunc + " The following used to cause an out-of-bounds memory access func Test_blob2string() let v = '0z' .. repeat('01010101.', 444) -- cgit From ccac34af766bee70d4f2a3cd69b54977849f567d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 20:38:16 +0800 Subject: vim-patch:8.2.3446: not enough tests for empty string arguments Problem: Not enough tests for empty string arguments. Solution: Add tests, fix type check. (Yegappan Lakshmanan, closes vim/vim#8881) https://github.com/vim/vim/commit/820d5525cae707f39571c6abc2aa6a9e66ed171e Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_blob.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 28df120b78..f889da987a 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -691,10 +691,11 @@ func Test_list2blob() \ [[0], 0z00], \ [[], 0z], \ [[0, 0, 0, 0], 0z00000000], + \ [[255, 255], 0zFFFF], \ [[170, 187, 204, 221], 0zAABB.CCDD], \ ] for t in tests - call assert_equal(t[0]->list2blob(), t[1]) + call assert_equal(t[1], t[0]->list2blob()) endfor call assert_fails('let b = list2blob([1, []])', 'E745:') call assert_fails('let b = list2blob([-1])', 'E1239:') -- cgit From 65af4241996021b2067d2adc97cc2c83c616cbb6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 20:59:59 +0800 Subject: vim-patch:8.2.4668: buffer allocation failures insufficiently tested Problem: Buffer allocation failures insufficiently tested. Solution: Add tests for memory allocation failures. (Yegappan Lakshmanan, closes vim/vim#10064) https://github.com/vim/vim/commit/0dac1ab5791819ee9a496273eea38f69a217ac45 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_buffer.vim | 71 ++++++++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_swap.vim | 1 - 2 files changed, 71 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim index 9220cc17b9..90e97ae167 100644 --- a/src/nvim/testdir/test_buffer.vim +++ b/src/nvim/testdir/test_buffer.vim @@ -451,4 +451,75 @@ func Test_buffer_maxmem() " set maxmem& maxmemtot& endfunc +" Test for a allocation failure when adding a new buffer +func Test_buflist_alloc_failure() + CheckFunction test_alloc_fail + %bw! + + edit Xfile1 + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('edit Xfile2', 'E342:') + + " test for bufadd() + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('call bufadd("Xbuffer")', 'E342:') + + " test for setting the arglist + edit Xfile2 + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('next Xfile3', 'E342:') + + " test for setting the alternate buffer name when writing a file + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('write Xother', 'E342:') + call delete('Xother') + + " test for creating a buffer using bufnr() + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails("call bufnr('Xnewbuf', v:true)", 'E342:') + + " test for renaming buffer using :file + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('file Xnewfile', 'E342:') + + " test for creating a buffer for a popup window + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('call popup_create("mypop", {})', 'E342:') + + if has('terminal') + " test for creating a buffer for a terminal window + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('call term_start(&shell)', 'E342:') + %bw! + endif + + " test for loading a new buffer after wiping out all the buffers + edit Xfile4 + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('%bw!', 'E342:') + + " test for :checktime loading the buffer + call writefile(['one'], 'Xfile5') + if has('unix') + edit Xfile5 + " sleep for some time to make sure the timestamp is different + sleep 200m + call writefile(['two'], 'Xfile5') + set autoread + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('checktime', 'E342:') + set autoread& + bw! + endif + + " test for :vimgrep loading a dummy buffer + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('vimgrep two Xfile5', 'E342:') + call delete('Xfile5') + + " test for quickfix command loading a buffer + call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index cf46b4c5bd..ceadc1d85a 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -235,7 +235,6 @@ func Test_swap_recover() autocmd SwapExists * let v:swapchoice = 'r' augroup END - call mkdir('Xswap') let $Xswap = 'foo' " Check for issue #4369. set dir=Xswap// -- cgit From 1e513fd112767e57f2b39dfaa395c83cb4f6a9f7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 21:01:36 +0800 Subject: vim-patch:8.2.4670: memory allocation failures for new tab page not tested Problem: Memory allocation failures for new tab page not tested. Solution: Add tests with failing memory allocation. (Yegappan Lakshmanan, closes vim/vim#10067) https://github.com/vim/vim/commit/72bb47e38f6805050ed6d969f17591bed71f83d4 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_blob.vim | 41 ++++++++++++++++++++++++++++++++ src/nvim/testdir/test_buffer.vim | 26 ++++++++++---------- src/nvim/testdir/test_tabpage.vim | 24 +++++++++++++++++++ src/nvim/testdir/test_window_cmd.vim | 46 ++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 13 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index f889da987a..310582240c 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -1,5 +1,6 @@ " Tests for the Blob types +source check.vim source vim9.vim func TearDown() @@ -714,6 +715,46 @@ func Test_blob2string() call assert_equal(v, string(b)) endfunc +" Test for blob allocation failure +func Test_blob_alloc_failure() + CheckFunction test_alloc_fail + " blob variable + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let v = 0z10', 'E342:') + + " blob slice + let v = 0z1020 + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = v[0:0]', 'E342:') + call assert_equal(0z1020, x) + + " blob remove() + let v = 0z10203040 + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = remove(v, 1, 2)', 'E342:') + call assert_equal(0, x) + + " list2blob() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let a = list2blob([1, 2, 4])', 'E342:') + call assert_equal(0, a) + + " mapnew() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = mapnew(0z1234, {_, v -> 1})', 'E342:') + call assert_equal(0, x) + + " copy() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = copy(v)', 'E342:') + call assert_equal(0z, x) + + " readblob() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = readblob("test_blob.vim")', 'E342:') + call assert_equal(0, x) +endfunc + " Test for the indexof() function func Test_indexof() let b = 0zdeadbeef diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim index 90e97ae167..98eba83f73 100644 --- a/src/nvim/testdir/test_buffer.vim +++ b/src/nvim/testdir/test_buffer.vim @@ -451,51 +451,51 @@ func Test_buffer_maxmem() " set maxmem& maxmemtot& endfunc -" Test for a allocation failure when adding a new buffer +" Test for buffer allocation failure func Test_buflist_alloc_failure() CheckFunction test_alloc_fail %bw! edit Xfile1 - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('edit Xfile2', 'E342:') " test for bufadd() - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('call bufadd("Xbuffer")', 'E342:') " test for setting the arglist edit Xfile2 - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('next Xfile3', 'E342:') " test for setting the alternate buffer name when writing a file - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('write Xother', 'E342:') call delete('Xother') " test for creating a buffer using bufnr() - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails("call bufnr('Xnewbuf', v:true)", 'E342:') " test for renaming buffer using :file - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('file Xnewfile', 'E342:') " test for creating a buffer for a popup window - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('call popup_create("mypop", {})', 'E342:') if has('terminal') " test for creating a buffer for a terminal window - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('call term_start(&shell)', 'E342:') %bw! endif " test for loading a new buffer after wiping out all the buffers edit Xfile4 - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('%bw!', 'E342:') " test for :checktime loading the buffer @@ -506,19 +506,19 @@ func Test_buflist_alloc_failure() sleep 200m call writefile(['two'], 'Xfile5') set autoread - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('checktime', 'E342:') set autoread& bw! endif " test for :vimgrep loading a dummy buffer - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('vimgrep two Xfile5', 'E342:') call delete('Xfile5') " test for quickfix command loading a buffer - call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) + call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:') endfunc diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index c20c798c49..db23a36dd4 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -846,6 +846,30 @@ func Test_lastused_tabpage() tabonly! endfunc +" Test for tabpage allocation failure +func Test_tabpage_alloc_failure() + CheckFunction test_alloc_fail + call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0) + call assert_fails('tabnew', 'E342:') + + call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0) + edit Xfile1 + call assert_fails('tabedit Xfile2', 'E342:') + call assert_equal(1, winnr('$')) + call assert_equal(1, tabpagenr('$')) + call assert_equal('Xfile1', @%) + + new + call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0) + call assert_fails('wincmd T', 'E342:') + bw! + + call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0) + call assert_fails('tab split', 'E342:') + call assert_equal(2, winnr('$')) + call assert_equal(1, tabpagenr('$')) +endfunc + " this was giving ml_get errors func Test_tabpage_last_line() enew diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 8b9457ae1d..34614832a9 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -1525,6 +1525,52 @@ func Test_win_move_statusline() %bwipe! endfunc +" Test for window allocation failure +func Test_window_alloc_failure() + CheckFunction test_alloc_fail + %bw! + + " test for creating a new window above current window + call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + call assert_fails('above new', 'E342:') + call assert_equal(1, winnr('$')) + + " test for creating a new window below current window + call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + call assert_fails('below new', 'E342:') + call assert_equal(1, winnr('$')) + + " test for popup window creation failure + call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + call assert_fails('call popup_create("Hello", {})', 'E342:') + call assert_equal([], popup_list()) + + call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + call assert_fails('split', 'E342:') + call assert_equal(1, winnr('$')) + + edit Xfile1 + edit Xfile2 + call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + call assert_fails('sb Xfile1', 'E342:') + call assert_equal(1, winnr('$')) + call assert_equal('Xfile2', @%) + %bw! + + " FIXME: The following test crashes Vim + " test for new tabpage creation failure + " call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) + " call assert_fails('tabnew', 'E342:') + " call assert_equal(1, tabpagenr('$')) + " call assert_equal(1, winnr('$')) + + " This test messes up the internal Vim window/frame information. So the + " Test_window_cmd_cmdwin_with_vsp() test fails after running this test. + " Open a new tab and close everything else to fix this issue. + tabnew + tabonly +endfunc + func Test_win_equal_last_status() let save_lines = &lines set lines=20 -- cgit From 278aeee3aed753d1084597378e653395bd472c42 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 21:07:56 +0800 Subject: vim-patch:9.0.0430: cannot use repeat() with a blob Problem: Cannot use repeat() with a blob. Solution: Implement blob repeat. (closes vim/vim#11090) https://github.com/vim/vim/commit/375141e1f80dced9be738568a3418f65813f4a2f Co-authored-by: Bakudankun --- src/nvim/testdir/test_blob.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 310582240c..2c145f2019 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -715,6 +715,18 @@ func Test_blob2string() call assert_equal(v, string(b)) endfunc +func Test_blob_repeat() + call assert_equal(0z, repeat(0z00, 0)) + call assert_equal(0z00, repeat(0z00, 1)) + call assert_equal(0z0000, repeat(0z00, 2)) + call assert_equal(0z00000000, repeat(0z0000, 2)) + + call assert_equal(0z, repeat(0z12, 0)) + call assert_equal(0z, repeat(0z1234, 0)) + call assert_equal(0z1234, repeat(0z1234, 1)) + call assert_equal(0z12341234, repeat(0z1234, 2)) +endfunc + " Test for blob allocation failure func Test_blob_alloc_failure() CheckFunction test_alloc_fail -- cgit From cf07f2baabd3a1a072102e0cacb6d70509ada044 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 12:29:20 +0100 Subject: feat(edit)!: remove old c implementation of hebrew keymap This feature has long been obsolete. The 'keymap' option can be used to support language keymaps, including hebrew and hebrewp (phonetic mapping). There is no need to keep the old c code with hardcoded keymaps for some languages. --- src/nvim/testdir/test_charsearch.vim | 1 + src/nvim/testdir/test_cmdline.vim | 3 ++- src/nvim/testdir/test_edit.vim | 4 +++- src/nvim/testdir/test_paste.vim | 7 ++++--- src/nvim/testdir/test_startup.vim | 8 ++++---- 5 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_charsearch.vim b/src/nvim/testdir/test_charsearch.vim index 54e0a62ce5..f8f3e958ca 100644 --- a/src/nvim/testdir/test_charsearch.vim +++ b/src/nvim/testdir/test_charsearch.vim @@ -86,6 +86,7 @@ endfunc " Test for character search with 'hkmap' func Test_charsearch_hkmap() + throw "Skipped: Nvim does not support 'hkmap'" new set hkmap call setline(1, "ùðáâ÷ëòéïçìêöî") diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index d568b5d425..1dceb43e5d 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -2111,7 +2111,8 @@ func Test_cmdline_revins() call assert_equal("\"abc\", @:) set allowrevins call feedkeys(":\"abc\xyz\\", 'xt') - call assert_equal('"abcñèæ', @:) + " call assert_equal('"abcñèæ', @:) + call assert_equal('"abcxyz', @:) set allowrevins& endfunc diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index b6078a1e22..075f78ec76 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -516,7 +516,8 @@ func Test_edit_CTRL_() call setline(1, ['abc']) call cursor(1, 1) call feedkeys("i\xyz\", 'tnix') - call assert_equal(["æèñabc"], getline(1, '$')) + " call assert_equal(["æèñabc"], getline(1, '$')) + call assert_equal(["zyxabc"], getline(1, '$')) call assert_true(&revins) call setline(1, ['abc']) call cursor(1, 1) @@ -1913,6 +1914,7 @@ endfunc " Test for 'hkmap' and 'hkmapp' func Test_edit_hkmap() + throw "Skipped: Nvim does not support 'hkmap'" CheckFeature rightleft if has('win32') && !has('gui') " Test fails on the MS-Windows terminal version diff --git a/src/nvim/testdir/test_paste.vim b/src/nvim/testdir/test_paste.vim index dad3c2c6a0..923f4f42a6 100644 --- a/src/nvim/testdir/test_paste.vim +++ b/src/nvim/testdir/test_paste.vim @@ -20,7 +20,8 @@ endfunc func Test_paste_opt_restore() set autoindent expandtab ruler showmatch if has('rightleft') - set revins hkmap + " set hkmap + set revins endif set smarttab softtabstop=3 textwidth=27 wrapmargin=12 if has('vartabs') @@ -33,7 +34,7 @@ func Test_paste_opt_restore() call assert_false(&expandtab) if has('rightleft') call assert_false(&revins) - call assert_false(&hkmap) + " call assert_false(&hkmap) endif call assert_false(&ruler) call assert_false(&showmatch) @@ -51,7 +52,7 @@ func Test_paste_opt_restore() call assert_true(&expandtab) if has('rightleft') call assert_true(&revins) - call assert_true(&hkmap) + " call assert_true(&hkmap) endif call assert_true(&ruler) call assert_true(&showmatch) diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 1ee1d0dfe3..8216b1a894 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -389,7 +389,7 @@ endfunc " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). func Test_A_F_H_arg() let after =<< trim [CODE] - call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout") + call writefile([&rightleft, &arabic, 0, &hkmap, &keymap], "Xtestout") qall [CODE] @@ -397,17 +397,17 @@ func Test_A_F_H_arg() " 'encoding' is not utf-8. if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A') let lines = readfile('Xtestout') - call assert_equal(['1', '1', '0', '0'], lines) + call assert_equal(['1', '1', '0', '0', 'arabic'], lines) endif if has('farsi') && RunVim([], after, '-F') let lines = readfile('Xtestout') - call assert_equal(['1', '0', '1', '0'], lines) + call assert_equal(['1', '0', '1', '0', '???'], lines) endif if has('rightleft') && RunVim([], after, '-H') let lines = readfile('Xtestout') - call assert_equal(['1', '0', '0', '1'], lines) + call assert_equal(['1', '0', '0', '0', 'hebrew'], lines) endif call delete('Xtestout') -- cgit From 999fe9468862e22fa5317585f67f5cb32683fc15 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Mar 2023 08:17:09 +0800 Subject: vim-patch:9.0.1365: dead test code (#22461) Problem: Dead test code. Solution: Remove code that depends on Farsi, which has been removed. (closes vim/vim#12084) https://github.com/vim/vim/commit/f0300fc7b81e63c2584dc3a763dedea4184d17e5 --- src/nvim/testdir/test_startup.vim | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 8216b1a894..da467ea23f 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -386,8 +386,8 @@ func Test_m_M_R() call delete('Xtestout') endfunc -" Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). -func Test_A_F_H_arg() +" Test the -A and -H arguments (Arabic and Hebrew modes). +func Test_A_H_arg() let after =<< trim [CODE] call writefile([&rightleft, &arabic, 0, &hkmap, &keymap], "Xtestout") qall @@ -400,11 +400,6 @@ func Test_A_F_H_arg() call assert_equal(['1', '1', '0', '0', 'arabic'], lines) endif - if has('farsi') && RunVim([], after, '-F') - let lines = readfile('Xtestout') - call assert_equal(['1', '0', '1', '0', '???'], lines) - endif - if has('rightleft') && RunVim([], after, '-H') let lines = readfile('Xtestout') call assert_equal(['1', '0', '0', '0', 'hebrew'], lines) -- cgit From f25d126b186e187f539a909824804d4bc88380e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Mar 2023 23:23:39 +0800 Subject: vim-patch:8.2.{1949,2781} (#22451) vim-patch:8.2.2781: add() silently skips when adding to null list or blob Problem: Add() silently skips when adding to null list or blob. Solution: Give an error in Vim9 script. Allocate blob when it is NULL like with list and dict. https://github.com/vim/vim/commit/b7c21afef14bba0208f2c40d47c050a004eb2f34 Do not implicitly change a NULL blob/dict/list to an empty one. N/A patches for version.c: vim-patch:8.2.1949: Vim9: using extend() on null dict is silently ignored Problem: Vim9: using extend() on null dict is silently ignored. Solution: Give an error message. Initialize a dict variable with an empty dictionary. (closes vim/vim#7251) https://github.com/vim/vim/commit/348be7ed07d164970ec0004bc278e254eb0cf5bf N/A because Nvim's current behavior is an error message as a locked list/dict, which is more consistent. Ref #4615. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_blob.vim | 56 +++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 2c145f2019..920ceb826d 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -317,27 +317,59 @@ func Test_blob_for_loop() endfunc func Test_blob_concatenate() - let b = 0z0011 - let b += 0z2233 - call assert_equal(0z00112233, b) + let lines =<< trim END + VAR b = 0z0011 + LET b += 0z2233 + call assert_equal(0z00112233, b) - call assert_fails('let b += "a"') - call assert_fails('let b += 88') + LET b = 0zDEAD + 0zBEEF + call assert_equal(0zDEADBEEF, b) + END + call CheckLegacyAndVim9Success(lines) - let b = 0zDEAD + 0zBEEF - call assert_equal(0zDEADBEEF, b) + let lines =<< trim END + VAR b = 0z0011 + LET b += "a" + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + + let lines =<< trim END + VAR b = 0z0011 + LET b += 88 + END + call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) endfunc func Test_blob_add() + let lines =<< trim END + VAR b = 0z0011 + call add(b, 0x22) + call assert_equal(0z001122, b) + END + call CheckLegacyAndVim9Success(lines) + + " Only works in legacy script let b = 0z0011 - call add(b, 0x22) - call assert_equal(0z001122, b) call add(b, '51') - call assert_equal(0z00112233, b) + call assert_equal(0z001133, b) call assert_equal(1, add(v:_null_blob, 0x22)) - call assert_fails('call add(b, [9])', 'E745:') - call assert_fails('call add("", 0x01)', 'E897:') + let lines =<< trim END + VAR b = 0z0011 + call add(b, [9]) + END + call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E745:']) + + let lines =<< trim END + VAR b = 0z0011 + call add("", 0x01) + END + call CheckLegacyAndVim9Failure(lines, 'E897:') + + let lines =<< trim END + add(v:_null_blob, 0x22) + END + call CheckDefExecAndScriptFailure(lines, 'E1131:') endfunc func Test_blob_empty() -- cgit From fdb6b4d2e729211f0526ce75c6a3fcc636859bfd Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 2 Mar 2023 17:29:03 -0500 Subject: vim-patch:9.0.1368: Bass files are not recognized (#22485) Problem: Bass files are not recognized. Solution: Add patterns for Bass files. (Amaan Qureshi, closes vim/vim#12088) https://github.com/vim/vim/commit/4ed914b18a47192f79f342bea5e8f59e120d5260 --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 148f8b6d42..eb00cb98ca 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -80,6 +80,7 @@ let s:filename_checks = { \ 'awk': ['file.awk', 'file.gawk'], \ 'b': ['file.mch', 'file.ref', 'file.imp'], \ 'basic': ['file.bas', 'file.bi', 'file.bm'], + \ 'bass': ['file.bass'], \ 'bc': ['file.bc'], \ 'bdf': ['file.bdf'], \ 'beancount': ['file.beancount'], -- cgit From 361de6d54d41fc0fc8f8a89ec779696f3f7bb46e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 Mar 2023 07:44:16 +0800 Subject: vim-patch:9.0.1371: ballooneval interferes with Insert completion (#22487) Problem: Ballooneval interferes with Insert completion. Solution: Ignore mouse-move events when completing. (closes vim/vim#12094, closes vim/vim#12092) https://github.com/vim/vim/commit/440d4cb55b84fd4b188630abc4a1312598649af0 --- src/nvim/testdir/test_ins_complete.vim | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index ec1379a378..af0856331d 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -375,6 +375,54 @@ func Test_completefunc_info() set completefunc& endfunc +" Test that mouse scrolling/movement should not interrupt completion. +func Test_mouse_scroll_move_during_completion() + new + com! -buffer TestCommand1 echo 'TestCommand1' + com! -buffer TestCommand2 echo 'TestCommand2' + call setline(1, ['', '', '', '', '']) + call cursor(5, 1) + + " Without completion menu scrolling can move text. + set completeopt-=menu wrap + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_notequal(1, winsaveview().topline) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(1, winsaveview().topline) + set nowrap + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_notequal(0, winsaveview().leftcol) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(0, winsaveview().leftcol) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + + " With completion menu scrolling cannot move text. + set completeopt+=menu wrap + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(1, winsaveview().topline) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(1, winsaveview().topline) + set nowrap + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(0, winsaveview().leftcol) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + call assert_equal(0, winsaveview().leftcol) + call feedkeys("ccT\\\\", 'tx') + call assert_equal('TestCommand2', getline('.')) + + bwipe! + set completeopt& wrap& +endfunc + " Check that when using feedkeys() typeahead does not interrupt searching for " completions. func Test_compl_feedkeys() -- cgit From 4a3594f60e854db56589f30cec4fc16c8a46fe30 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 Mar 2023 07:41:57 +0800 Subject: vim-patch:9.0.0991: crash when reading help index with various options set Problem: Crash when reading help index with various options set. (Marius Gedminas) Solution: Do not set wlv.c_extra to NUL when wlv.p_extra is NULL. (closes vim/vim#11651) https://github.com/vim/vim/commit/c67c89c7589253215d57bad588edcf83a9403560 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_breakindent.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim index 2e377aa434..b61c9a570d 100644 --- a/src/nvim/testdir/test_breakindent.vim +++ b/src/nvim/testdir/test_breakindent.vim @@ -1075,4 +1075,22 @@ func Test_breakindent_column() bwipeout! endfunc +func Test_linebreak_list() + " This was setting wlv.c_extra to NUL while wlv.p_extra is NULL + filetype plugin on + syntax enable + edit! $VIMRUNTIME/doc/index.txt + /v_P + + setlocal list + setlocal listchars=tab:>- + setlocal linebreak + setlocal nowrap + setlocal filetype=help + redraw! + + bwipe! +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From bcf077414cf6f1a5701d68f848320008d6d89919 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 Mar 2023 07:44:11 +0800 Subject: vim-patch:9.0.1373: wrong text displayed when using both 'linebreak' and 'list' Problem: Wrong text displayed when using both 'linebreak' and 'list'. Solution: Only set "c_extra" to NUL when "p_extra" is not empty. (Hirohito Higashi, closes vim/vim#12065) https://github.com/vim/vim/commit/194555c001f2b8576483ef34511450b6e9b5e3fd Cherry-pick a change from patch 9.0.0153. Co-authored-by: h-east --- src/nvim/testdir/test_listlbr.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_listlbr.vim b/src/nvim/testdir/test_listlbr.vim index 1cbdba5d76..a746779e73 100644 --- a/src/nvim/testdir/test_listlbr.vim +++ b/src/nvim/testdir/test_listlbr.vim @@ -73,6 +73,30 @@ func Test_linebreak_with_nolist() call s:close_windows() endfunc +func Test_linebreak_with_list_and_number() + call s:test_windows('setl list listchars+=tab:>-') + call setline(1, ["abcdefg\thijklmnopqrstu", "v"]) + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect_nonumber = [ +\ "abcdefg>------------", +\ "hijklmnopqrstu$ ", +\ "v$ ", +\ "~ ", +\ ] + call s:compare_lines(expect_nonumber, lines) + + setl number + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect_number = [ +\ " 1 abcdefg>--------", +\ " hijklmnopqrstu$ ", +\ " 2 v$ ", +\ "~ ", +\ ] + call s:compare_lines(expect_number, lines) + call s:close_windows() +endfunc + func Test_should_break() call s:test_windows('setl sbr=+ nolist') call setline(1, "1\t" . repeat('a', winwidth(0)-2)) -- cgit From a88c18c24efe2b0d91882a48c4dedae9b8269806 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 Mar 2023 22:24:12 +0800 Subject: vim-patch:9.0.0527: long sign text may overflow buffer (#22496) Problem: Long sign text may overflow buffer. Solution: Use a larger buffer. Prevent for overflow. https://github.com/vim/vim/commit/2b1ddf19f8f14365d0b998b4ac12ca85c0923475 Don't change the size of extra[] as it's already large enough. N/A patches for version.c: vim-patch:9.0.0523: more compiler warnings for arguments in small version Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_signs.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim index 8311955a15..129f1c1a0c 100644 --- a/src/nvim/testdir/test_signs.vim +++ b/src/nvim/testdir/test_signs.vim @@ -196,6 +196,20 @@ func Test_sign() \ bufnr('%'), 'E155:') endfunc +func Test_sign_many_bytes() + new + set signcolumn=number + set number + call setline(1, 'some text') + " composing characters can use many bytes, check for overflow + sign define manyBytes text=▶᷄᷅᷆◀᷄᷅᷆᷇ + sign place 17 line=1 name=manyBytes + redraw + + bwipe! + sign undefine manyBytes +endfunc + " Undefining placed sign is not recommended. " Quoting :help sign " -- cgit From 446c353a507834a3cbe9007b06e7e0c2c46b5ac7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Mar 2023 08:39:54 +0800 Subject: vim-patch:9.0.1376: accessing invalid memory with put in Visual block mode (#22505) Problem: Accessing invalid memory with put in Visual block mode. Solution: Adjust the cursor column if needed. https://github.com/vim/vim/commit/1c73b65229c25e3c1fd8824ba958f7cc4d604f9c Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_put.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim index 97af3699a8..25fc5a2f04 100644 --- a/src/nvim/testdir/test_put.vim +++ b/src/nvim/testdir/test_put.vim @@ -235,5 +235,16 @@ func Test_put_visual_mode() set selection& endfunc +func Test_put_visual_block_mode() + enew + exe "norm 0R\\V" + sil exe "norm \c \" + set ve=all + sil norm vz=p + + bwipe! + set ve= +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 0a897f89c52b92cb518dae1c92de22ca1d170d2a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Mar 2023 10:25:18 +0800 Subject: vim-patch:partial:9.0.0013: reproducing memory access errors can be difficult Problem: Reproducing memory access errors can be difficult. Solution: When testing, copy each line to allocated memory, so that valgrind can detect accessing memory before and/or after it. Fix uncovered problems. https://github.com/vim/vim/commit/fa4873ccfc10e0f278dc46f39d00136fab059b19 Since test_override() is N/A, enable ml_get_alloc_lines when ASAN is enabled instead, so it also applies to functional tests. Use xstrdup() to copy the line as ml_line_len looks hard to port. Squash the test changes from patch 9.0.0016. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_breakindent.vim | 10 +++++----- src/nvim/testdir/test_edit.vim | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim index b61c9a570d..0d1753182e 100644 --- a/src/nvim/testdir/test_breakindent.vim +++ b/src/nvim/testdir/test_breakindent.vim @@ -10,7 +10,9 @@ CheckOption breakindent source view_util.vim source screendump.vim -let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" +func SetUp() + let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" +endfunc func s:screen_lines(lnum, width) abort return ScreenLines([a:lnum, a:lnum + 2], a:width) @@ -837,12 +839,12 @@ func Test_breakindent20_list() call s:compare_lines(expect, lines) " check formatlistpat indent with different list levels let &l:flp = '^\s*\*\+\s\+' - redraw! %delete _ call setline(1, ['* Congress shall make no law', \ '*** Congress shall make no law', \ '**** Congress shall make no law']) norm! 1gg + redraw! let expect = [ \ "* Congress shall ", \ " make no law ", @@ -956,9 +958,9 @@ func Test_no_spurious_match() let @/ = '\%>3v[y]' redraw! call searchcount().total->assert_equal(1) + " cleanup set hls&vim - let s:input = "\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" bwipeout! endfunc @@ -1023,8 +1025,6 @@ func Test_no_extra_indent() endfunc func Test_breakindent_column() - " restore original - let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" call s:test_windows('setl breakindent breakindentopt=column:10') redraw! " 1) default: does not indent, too wide :( diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 075f78ec76..e4c21d9932 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1890,6 +1890,9 @@ func Test_edit_insertmode_ex_edit() call writefile(lines, 'Xtest_edit_insertmode_ex_edit') let buf = RunVimInTerminal('-S Xtest_edit_insertmode_ex_edit', #{rows: 6}) + " Somehow this can be very slow with valgrind. A separate TermWait() works + " better than a longer time with WaitForAssert() (why?) + call TermWait(buf, 1000) call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, 6))}) call term_sendkeys(buf, "\\") call WaitForAssert({-> assert_notmatch('^-- INSERT --\s*$', term_getline(buf, 6))}) -- cgit From 089f962d6a18bd91d89998e16834b822ab2adf9f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 5 Mar 2023 08:08:04 +0800 Subject: vim-patch:9.0.1378: illegal memory access when using virtual editing (#22527) Problem: Illegal memory access when using virtual editing. Solution: Make sure "startspaces" is not negative. https://github.com/vim/vim/commit/c99cbf8f289bdda5d4a77d7ec415850a520330ba Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_virtualedit.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim index 20a5f87517..a2baf276ac 100644 --- a/src/nvim/testdir/test_virtualedit.vim +++ b/src/nvim/testdir/test_virtualedit.vim @@ -88,6 +88,16 @@ func Test_edit_change() set virtualedit= endfunc +func Test_edit_special_char() + new + se ve=all + norm a0 + sil! exe "norm o00000\k Date: Sun, 5 Mar 2023 08:34:58 +0800 Subject: test(old): make getting an unused PID work (#22529) --- src/nvim/testdir/test_swap.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index ceadc1d85a..4241f4fd69 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -435,6 +435,12 @@ func s:get_unused_pid(base) if job_status(j) ==# 'dead' return job_info(j).process endif + elseif has('nvim') + let j = jobstart('echo') + let pid = jobpid(j) + if jobwait([j])[0] >= 0 + return pid + endif endif " Must add four for MS-Windows to see it as a different one. return a:base + 4 -- cgit From 419819b6245e120aba8897e3ddea711b2cd0246c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 5 Mar 2023 09:18:42 +0800 Subject: vim-patch:9.0.1380: CTRL-X on 2**64 subtracts two (#22530) Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes vim/vim#12103) https://github.com/vim/vim/commit/5fb78c3fa5c996c08a65431d698bd2c251eef5c7 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_increment.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_increment.vim b/src/nvim/testdir/test_increment.vim index 3c2b88ef9f..433b2b4471 100644 --- a/src/nvim/testdir/test_increment.vim +++ b/src/nvim/testdir/test_increment.vim @@ -841,6 +841,22 @@ func Test_increment_unsigned() set nrformats-=unsigned endfunc +func Test_in_decrement_large_number() + " NOTE: 18446744073709551616 == 2^64 + call setline(1, '18446744073709551616') + exec "norm! gg0\" + call assert_equal('18446744073709551615', getline(1)) + + exec "norm! gg0\" + call assert_equal('18446744073709551614', getline(1)) + + exec "norm! gg0\" + call assert_equal('18446744073709551615', getline(1)) + + exec "norm! gg0\" + call assert_equal('-18446744073709551615', getline(1)) +endfunc + func Test_normal_increment_with_virtualedit() set virtualedit=all -- cgit From 1cfe83c2a2d5d1d5dcc37bdcdb9dba4107e41de7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 5 Mar 2023 14:47:51 +0800 Subject: vim-patch:9.0.0736: quickfix listing does not handle very long messages Problem: Quickfix listing does not handle very long messages. Solution: Use a growarray instead of a fixed size buffer. (Yegappan Lakshmanan, closes vim/vim#11357) https://github.com/vim/vim/commit/f8412c9d7cc487dacf47a217ae947da68a525c53 Override Test_very_long_error_line() with a rewrite that doesn't use deferred delete and string interpolation. Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_quickfix.vim | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 8dc4173d60..fedc486e62 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -6220,6 +6220,66 @@ func Test_loclist_replace_autocmd() call setloclist(0, [], 'f') endfunc +" Test for a very long error line and a very long information line +func Test_very_long_error_line() + let msg = repeat('abcdefghijklmn', 146) + let emsg = 'Xlonglines.c:1:' . msg + call writefile([msg, emsg], 'Xerror', 'D') + cfile 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 + +" 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() + cexpr ["a.c:20:12: error: expected ';' before ':' token", + \ ' 20 | Afunc():', '', ' | ^'] + copen + call assert_equal(["a.c|20 col 12| error: expected ';' before ':' token", + \ '|| 20 | Afunc():', '|| ', + \ '|| | ^'], getline(1, '$')) + cclose + + let l = execute('clist!')->split("\n") + call assert_equal([" 1 a.c:20 col 12: error: expected ';' before ':' token", + \ ' 2: 20 | Afunc():', ' 3: ', ' 4: | ^'], l) + + call setqflist([], 'f') +endfunc + func s:QfTf(_) endfunc -- cgit From e389b189021cb6b72cfd7583ce6fb5d8d3346d45 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 6 Mar 2023 07:52:11 +0800 Subject: vim-patch:9.0.1385: g'Esc is considered an error (#22544) Problem: g'Esc is considered an error. Solution: Make g'Esc silently abandon the command. (closes vim/vim#12110) https://github.com/vim/vim/commit/f86dea8119f3141e3d2c680219036d1511101f9b --- src/nvim/testdir/test_normal.vim | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 5d8e1913a2..582596748f 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2540,6 +2540,8 @@ func Test_normal33_g_cmd2() norm! g'a call assert_equal('>', a[-1:]) call assert_equal(1, line('.')) + call assert_nobeep("normal! g`\") + call assert_nobeep("normal! g'\") " Test for g; and g, norm! g; @@ -3315,7 +3317,8 @@ func Test_gr_command() set modifiable& call assert_nobeep("normal! gr\") - call assert_beeps("normal! cgr\") + call assert_nobeep("normal! cgr\") + call assert_beeps("normal! cgrx") call assert_equal('zxxxx line l', getline(1)) exe "normal! 2|gr\\" @@ -3895,4 +3898,36 @@ func Test_mouse_shape_after_failed_change() call delete('Xmouseshapes') endfunc +" Test that mouse shape is restored to Normal mode after cancelling "gr". +func Test_mouse_shape_after_cancelling_gr() + CheckFeature mouseshape + CheckCanRunGui + + let lines =<< trim END + vim9script + var mouse_shapes = [] + + feedkeys('gr') + timer_start(50, (_) => { + mouse_shapes += [getmouseshape()] + timer_start(50, (_) => { + feedkeys("\") + timer_start(50, (_) => { + mouse_shapes += [getmouseshape()] + timer_start(50, (_) => { + writefile(mouse_shapes, 'Xmouseshapes') + quit + }) + }) + }) + }) + END + call writefile(lines, 'Xmouseshape.vim', 'D') + call RunVim([], [], "-g -S Xmouseshape.vim") + sleep 300m + call assert_equal(['beam', 'arrow'], readfile('Xmouseshapes')) + + call delete('Xmouseshapes') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From b0620ffe5a2e16d6d52e803978c90d0ffb030908 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 6 Mar 2023 16:45:57 +0800 Subject: vim-patch:9.0.1386: options test fails with some window width (#22548) Problem: Options test fails with some window width. Solution: Adjust what text the test checks with. (closes vim/vim#12111) https://github.com/vim/vim/commit/30585e03a7ce6cf985f93ca30275bf4dae0d87cc --- src/nvim/testdir/test_normal.vim | 3 +++ src/nvim/testdir/test_options.vim | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 582596748f..48e6bc5298 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2540,8 +2540,11 @@ func Test_normal33_g_cmd2() norm! g'a call assert_equal('>', a[-1:]) call assert_equal(1, line('.')) + let v:errmsg = '' call assert_nobeep("normal! g`\") + call assert_equal('', v:errmsg) call assert_nobeep("normal! g'\") + call assert_equal('', v:errmsg) " Test for g; and g, norm! g; diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 43cc3632e6..b6b982e92e 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -890,8 +890,9 @@ func Test_debug_option() exe "normal \" call assert_equal('Beep!', Screenline(&lines)) call assert_equal('line 4:', Screenline(&lines - 1)) - " only match the final colon in the line that shows the source - call assert_match(':$', Screenline(&lines - 2)) + " also check a line above, with a certain window width the colon is there + call assert_match('Test_debug_option:$', + \ Screenline(&lines - 3) .. Screenline(&lines - 2)) set debug& endfunc -- cgit From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- src/nvim/testdir/Make_all.mak | 1 - src/nvim/testdir/Makefile | 154 - src/nvim/testdir/README.txt | 121 - src/nvim/testdir/check.vim | 217 - src/nvim/testdir/dotest.in | 3 - src/nvim/testdir/load.vim | 32 - src/nvim/testdir/pyxfile/py2_magic.py | 4 - src/nvim/testdir/pyxfile/py2_shebang.py | 4 - src/nvim/testdir/pyxfile/py3_magic.py | 4 - src/nvim/testdir/pyxfile/py3_shebang.py | 4 - src/nvim/testdir/pyxfile/pyx.py | 2 - src/nvim/testdir/runnvim.sh | 88 - src/nvim/testdir/runnvim.vim | 58 - src/nvim/testdir/runtest.vim | 485 -- src/nvim/testdir/samples/memfile_test.c | 148 - src/nvim/testdir/samples/quickfix.txt | 4 - src/nvim/testdir/samples/re.freeze.txt | 6 - src/nvim/testdir/sautest/autoload/foo.vim | 15 - src/nvim/testdir/sautest/autoload/footest.vim | 5 - src/nvim/testdir/sautest/autoload/globone.vim | 1 - src/nvim/testdir/sautest/autoload/globtwo.vim | 1 - src/nvim/testdir/sautest/autoload/sourced.vim | 3 - src/nvim/testdir/screendump.vim | 2 - src/nvim/testdir/script_util.vim | 69 - src/nvim/testdir/setup.vim | 85 - src/nvim/testdir/shared.vim | 389 -- src/nvim/testdir/suite.sh | 10 - src/nvim/testdir/summarize.vim | 62 - src/nvim/testdir/term_util.vim | 13 - src/nvim/testdir/test.sh | 91 - src/nvim/testdir/test1.in | 13 - src/nvim/testdir/test1.ok | 1 - src/nvim/testdir/test_alot.vim | 31 - src/nvim/testdir/test_alot_latin.vim | 7 - src/nvim/testdir/test_alot_utf8.vim | 14 - src/nvim/testdir/test_arabic.vim | 587 -- src/nvim/testdir/test_arglist.vim | 748 --- src/nvim/testdir/test_assert.vim | 363 -- src/nvim/testdir/test_autochdir.vim | 130 - src/nvim/testdir/test_autocmd.vim | 3630 ----------- src/nvim/testdir/test_autoload.vim | 25 - src/nvim/testdir/test_backspace_opt.vim | 141 - src/nvim/testdir/test_backup.vim | 89 - src/nvim/testdir/test_behave.vim | 29 - src/nvim/testdir/test_blob.vim | 830 --- src/nvim/testdir/test_blockedit.vim | 132 - src/nvim/testdir/test_breakindent.vim | 1096 ---- src/nvim/testdir/test_buffer.vim | 525 -- src/nvim/testdir/test_bufline.vim | 296 - src/nvim/testdir/test_bufwintabinfo.vim | 187 - src/nvim/testdir/test_cd.vim | 256 - src/nvim/testdir/test_cdo.vim | 216 - src/nvim/testdir/test_changedtick.vim | 95 - src/nvim/testdir/test_changelist.vim | 107 - src/nvim/testdir/test_charsearch.vim | 99 - src/nvim/testdir/test_charsearch_utf8.vim | 19 - src/nvim/testdir/test_checkpath.vim | 121 - src/nvim/testdir/test_cindent.vim | 5428 ----------------- src/nvim/testdir/test_cjk_linebreak.vim | 97 - src/nvim/testdir/test_clientserver.vim | 195 - src/nvim/testdir/test_close_count.vim | 174 - src/nvim/testdir/test_cmdline.vim | 3586 ----------- src/nvim/testdir/test_command_count.vim | 196 - src/nvim/testdir/test_comments.vim | 277 - src/nvim/testdir/test_comparators.vim | 9 - src/nvim/testdir/test_compiler.vim | 78 - src/nvim/testdir/test_conceal.vim | 284 - src/nvim/testdir/test_const.vim | 294 - src/nvim/testdir/test_cpoptions.vim | 934 --- src/nvim/testdir/test_cursor_func.vim | 481 -- src/nvim/testdir/test_cursorline.vim | 354 -- src/nvim/testdir/test_curswant.vim | 23 - src/nvim/testdir/test_debugger.vim | 1237 ---- src/nvim/testdir/test_delete.vim | 110 - src/nvim/testdir/test_diffmode.vim | 1647 ----- src/nvim/testdir/test_digraph.vim | 604 -- src/nvim/testdir/test_display.vim | 482 -- src/nvim/testdir/test_edit.vim | 2105 ------- src/nvim/testdir/test_environ.vim | 89 - src/nvim/testdir/test_erasebackword.vim | 19 - src/nvim/testdir/test_escaped_glob.vim | 34 - src/nvim/testdir/test_eval_stuff.vim | 392 -- src/nvim/testdir/test_ex_equal.vim | 32 - src/nvim/testdir/test_ex_mode.vim | 243 - src/nvim/testdir/test_ex_undo.vim | 19 - src/nvim/testdir/test_ex_z.vim | 108 - src/nvim/testdir/test_excmd.vim | 750 --- src/nvim/testdir/test_exec_while_if.vim | 43 - src/nvim/testdir/test_execute_func.vim | 176 - src/nvim/testdir/test_exists.vim | 331 - src/nvim/testdir/test_exists_autocmd.vim | 26 - src/nvim/testdir/test_exit.vim | 135 - src/nvim/testdir/test_expand.vim | 229 - src/nvim/testdir/test_expand_func.vim | 146 - src/nvim/testdir/test_expr.vim | 676 --- src/nvim/testdir/test_expr_utf8.vim | 34 - src/nvim/testdir/test_file_perm.vim | 30 - src/nvim/testdir/test_file_size.vim | 58 - src/nvim/testdir/test_filechanged.vim | 274 - src/nvim/testdir/test_fileformat.vim | 309 - src/nvim/testdir/test_filetype.vim | 2055 ------- src/nvim/testdir/test_filter_cmd.vim | 190 - src/nvim/testdir/test_filter_map.vim | 108 - src/nvim/testdir/test_find_complete.vim | 163 - src/nvim/testdir/test_findfile.vim | 255 - src/nvim/testdir/test_fixeol.vim | 118 - src/nvim/testdir/test_flatten.vim | 108 - src/nvim/testdir/test_float_func.vim | 369 -- src/nvim/testdir/test_fnameescape.vim | 27 - src/nvim/testdir/test_fnamemodify.vim | 104 - src/nvim/testdir/test_fold.vim | 1558 ----- src/nvim/testdir/test_functions.vim | 2568 -------- src/nvim/testdir/test_ga.vim | 43 - src/nvim/testdir/test_getcwd.vim | 112 - src/nvim/testdir/test_getvar.vim | 155 - src/nvim/testdir/test_gf.vim | 303 - src/nvim/testdir/test_glob2regpat.vim | 32 - src/nvim/testdir/test_global.vim | 131 - src/nvim/testdir/test_gn.vim | 221 - src/nvim/testdir/test_goto.vim | 442 -- src/nvim/testdir/test_gui.vim | 43 - src/nvim/testdir/test_help.vim | 229 - src/nvim/testdir/test_help_tagjump.vim | 322 - src/nvim/testdir/test_hide.vim | 97 - src/nvim/testdir/test_highlight.vim | 868 --- src/nvim/testdir/test_history.vim | 252 - src/nvim/testdir/test_hlsearch.vim | 88 - src/nvim/testdir/test_increment.vim | 913 --- src/nvim/testdir/test_increment_dbcs.vim | 31 - src/nvim/testdir/test_indent.vim | 279 - src/nvim/testdir/test_input.vim | 61 - src/nvim/testdir/test_ins_complete.vim | 2240 ------- src/nvim/testdir/test_ins_complete_no_halt.vim | 51 - src/nvim/testdir/test_interrupt.vim | 32 - src/nvim/testdir/test_join.vim | 447 -- src/nvim/testdir/test_jumplist.vim | 107 - src/nvim/testdir/test_lambda.vim | 334 -- src/nvim/testdir/test_langmap.vim | 89 - src/nvim/testdir/test_largefile.vim | 29 - src/nvim/testdir/test_let.vim | 478 -- src/nvim/testdir/test_lineending.vim | 19 - src/nvim/testdir/test_lispindent.vim | 129 - src/nvim/testdir/test_listchars.vim | 695 --- src/nvim/testdir/test_listdict.vim | 1138 ---- src/nvim/testdir/test_listlbr.vim | 333 -- src/nvim/testdir/test_listlbr_utf8.vim | 282 - src/nvim/testdir/test_makeencoding.py | 69 - src/nvim/testdir/test_makeencoding.vim | 125 - src/nvim/testdir/test_maparg.vim | 325 - src/nvim/testdir/test_mapping.vim | 1227 ---- src/nvim/testdir/test_marks.vim | 320 - src/nvim/testdir/test_match.vim | 442 -- src/nvim/testdir/test_matchadd_conceal.vim | 422 -- src/nvim/testdir/test_matchadd_conceal_utf8.vim | 39 - src/nvim/testdir/test_matchfuzzy.vim | 263 - src/nvim/testdir/test_menu.vim | 574 -- src/nvim/testdir/test_messages.vim | 530 -- src/nvim/testdir/test_method.vim | 174 - src/nvim/testdir/test_mksession.vim | 1027 ---- src/nvim/testdir/test_mksession_utf8.vim | 105 - src/nvim/testdir/test_modeline.vim | 376 -- src/nvim/testdir/test_move.vim | 70 - src/nvim/testdir/test_nested_function.vim | 63 - src/nvim/testdir/test_normal.vim | 3936 ------------ src/nvim/testdir/test_number.vim | 359 -- src/nvim/testdir/test_options.vim | 1346 ----- src/nvim/testdir/test_packadd.vim | 437 -- src/nvim/testdir/test_partial.vim | 361 -- src/nvim/testdir/test_paste.vim | 77 - src/nvim/testdir/test_perl.vim | 311 - src/nvim/testdir/test_plus_arg_edit.vim | 47 - src/nvim/testdir/test_popup.vim | 1263 ---- src/nvim/testdir/test_preview.vim | 64 - src/nvim/testdir/test_profile.vim | 596 -- src/nvim/testdir/test_prompt_buffer.vim | 257 - src/nvim/testdir/test_put.vim | 250 - src/nvim/testdir/test_python2.vim | 173 - src/nvim/testdir/test_python3.vim | 192 - src/nvim/testdir/test_pyx2.vim | 81 - src/nvim/testdir/test_pyx3.vim | 81 - src/nvim/testdir/test_quickfix.vim | 6296 -------------------- src/nvim/testdir/test_quotestar.vim | 155 - src/nvim/testdir/test_random.vim | 59 - src/nvim/testdir/test_recover.vim | 467 -- src/nvim/testdir/test_regex_char_classes.vim | 297 - src/nvim/testdir/test_regexp_latin.vim | 1094 ---- src/nvim/testdir/test_regexp_utf8.vim | 603 -- src/nvim/testdir/test_registers.vim | 800 --- src/nvim/testdir/test_reltime.vim | 31 - src/nvim/testdir/test_rename.vim | 120 - src/nvim/testdir/test_retab.vim | 117 - src/nvim/testdir/test_ruby.vim | 417 -- src/nvim/testdir/test_scriptnames.vim | 32 - src/nvim/testdir/test_scroll_opt.vim | 54 - src/nvim/testdir/test_scrollbind.vim | 272 - src/nvim/testdir/test_search.vim | 2109 ------- src/nvim/testdir/test_search_stat.vim | 448 -- src/nvim/testdir/test_searchpos.vim | 30 - src/nvim/testdir/test_selectmode.vim | 210 - src/nvim/testdir/test_set.vim | 48 - src/nvim/testdir/test_sha256.vim | 22 - src/nvim/testdir/test_shell.vim | 209 - src/nvim/testdir/test_shift.vim | 117 - src/nvim/testdir/test_signals.vim | 165 - src/nvim/testdir/test_signs.vim | 2047 ------- src/nvim/testdir/test_sleep.vim | 27 - src/nvim/testdir/test_smartindent.vim | 136 - src/nvim/testdir/test_sort.vim | 1524 ----- src/nvim/testdir/test_source.vim | 113 - src/nvim/testdir/test_source_utf8.vim | 61 - src/nvim/testdir/test_spell.vim | 1467 ----- src/nvim/testdir/test_spell_utf8.vim | 832 --- src/nvim/testdir/test_spellfile.vim | 1066 ---- src/nvim/testdir/test_startup.vim | 1278 ---- src/nvim/testdir/test_startup_utf8.vim | 82 - src/nvim/testdir/test_stat.vim | 228 - src/nvim/testdir/test_statusline.vim | 613 -- src/nvim/testdir/test_substitute.vim | 1386 ----- src/nvim/testdir/test_suspend.vim | 63 - src/nvim/testdir/test_swap.vim | 588 -- src/nvim/testdir/test_syn_attr.vim | 51 - src/nvim/testdir/test_syntax.vim | 981 --- src/nvim/testdir/test_system.vim | 145 - src/nvim/testdir/test_tab.vim | 90 - src/nvim/testdir/test_tabline.vim | 207 - src/nvim/testdir/test_tabpage.vim | 888 --- src/nvim/testdir/test_tagcase.vim | 74 - src/nvim/testdir/test_tagfunc.vim | 417 -- src/nvim/testdir/test_tagjump.vim | 1615 ----- src/nvim/testdir/test_taglist.vim | 281 - src/nvim/testdir/test_termcodes.vim | 63 - src/nvim/testdir/test_textformat.vim | 1307 ---- src/nvim/testdir/test_textobjects.vim | 646 -- src/nvim/testdir/test_timers.vim | 458 -- src/nvim/testdir/test_true_false.vim | 155 - src/nvim/testdir/test_trycatch.vim | 2333 -------- src/nvim/testdir/test_undo.vim | 805 --- src/nvim/testdir/test_unlet.vim | 67 - src/nvim/testdir/test_user_func.vim | 504 -- src/nvim/testdir/test_usercommands.vim | 759 --- src/nvim/testdir/test_utf8.vim | 331 - src/nvim/testdir/test_utf8_comparisons.vim | 94 - src/nvim/testdir/test_vartabs.vim | 448 -- src/nvim/testdir/test_version.vim | 26 - src/nvim/testdir/test_viminfo.vim | 26 - src/nvim/testdir/test_vimscript.vim | 7284 ----------------------- src/nvim/testdir/test_virtualedit.vim | 612 -- src/nvim/testdir/test_visual.vim | 1560 ----- src/nvim/testdir/test_winbuf_close.vim | 231 - src/nvim/testdir/test_window_cmd.vim | 1879 ------ src/nvim/testdir/test_window_id.vim | 142 - src/nvim/testdir/test_windows_home.vim | 120 - src/nvim/testdir/test_wnext.vim | 101 - src/nvim/testdir/test_wordcount.vim | 104 - src/nvim/testdir/test_writefile.vim | 963 --- src/nvim/testdir/unix.vim | 15 - src/nvim/testdir/view_util.vim | 64 - src/nvim/testdir/vim9.vim | 116 - 258 files changed, 120891 deletions(-) delete mode 100644 src/nvim/testdir/Make_all.mak delete mode 100644 src/nvim/testdir/Makefile delete mode 100644 src/nvim/testdir/README.txt delete mode 100644 src/nvim/testdir/check.vim delete mode 100644 src/nvim/testdir/dotest.in delete mode 100644 src/nvim/testdir/load.vim delete mode 100644 src/nvim/testdir/pyxfile/py2_magic.py delete mode 100644 src/nvim/testdir/pyxfile/py2_shebang.py delete mode 100644 src/nvim/testdir/pyxfile/py3_magic.py delete mode 100644 src/nvim/testdir/pyxfile/py3_shebang.py delete mode 100644 src/nvim/testdir/pyxfile/pyx.py delete mode 100755 src/nvim/testdir/runnvim.sh delete mode 100644 src/nvim/testdir/runnvim.vim delete mode 100644 src/nvim/testdir/runtest.vim delete mode 100644 src/nvim/testdir/samples/memfile_test.c delete mode 100644 src/nvim/testdir/samples/quickfix.txt delete mode 100644 src/nvim/testdir/samples/re.freeze.txt delete mode 100644 src/nvim/testdir/sautest/autoload/foo.vim delete mode 100644 src/nvim/testdir/sautest/autoload/footest.vim delete mode 100644 src/nvim/testdir/sautest/autoload/globone.vim delete mode 100644 src/nvim/testdir/sautest/autoload/globtwo.vim delete mode 100644 src/nvim/testdir/sautest/autoload/sourced.vim delete mode 100644 src/nvim/testdir/screendump.vim delete mode 100644 src/nvim/testdir/script_util.vim delete mode 100644 src/nvim/testdir/setup.vim delete mode 100644 src/nvim/testdir/shared.vim delete mode 100644 src/nvim/testdir/suite.sh delete mode 100644 src/nvim/testdir/summarize.vim delete mode 100644 src/nvim/testdir/term_util.vim delete mode 100644 src/nvim/testdir/test.sh delete mode 100644 src/nvim/testdir/test1.in delete mode 100644 src/nvim/testdir/test1.ok delete mode 100644 src/nvim/testdir/test_alot.vim delete mode 100644 src/nvim/testdir/test_alot_latin.vim delete mode 100644 src/nvim/testdir/test_alot_utf8.vim delete mode 100644 src/nvim/testdir/test_arabic.vim delete mode 100644 src/nvim/testdir/test_arglist.vim delete mode 100644 src/nvim/testdir/test_assert.vim delete mode 100644 src/nvim/testdir/test_autochdir.vim delete mode 100644 src/nvim/testdir/test_autocmd.vim delete mode 100644 src/nvim/testdir/test_autoload.vim delete mode 100644 src/nvim/testdir/test_backspace_opt.vim delete mode 100644 src/nvim/testdir/test_backup.vim delete mode 100644 src/nvim/testdir/test_behave.vim delete mode 100644 src/nvim/testdir/test_blob.vim delete mode 100644 src/nvim/testdir/test_blockedit.vim delete mode 100644 src/nvim/testdir/test_breakindent.vim delete mode 100644 src/nvim/testdir/test_buffer.vim delete mode 100644 src/nvim/testdir/test_bufline.vim delete mode 100644 src/nvim/testdir/test_bufwintabinfo.vim delete mode 100644 src/nvim/testdir/test_cd.vim delete mode 100644 src/nvim/testdir/test_cdo.vim delete mode 100644 src/nvim/testdir/test_changedtick.vim delete mode 100644 src/nvim/testdir/test_changelist.vim delete mode 100644 src/nvim/testdir/test_charsearch.vim delete mode 100644 src/nvim/testdir/test_charsearch_utf8.vim delete mode 100644 src/nvim/testdir/test_checkpath.vim delete mode 100644 src/nvim/testdir/test_cindent.vim delete mode 100644 src/nvim/testdir/test_cjk_linebreak.vim delete mode 100644 src/nvim/testdir/test_clientserver.vim delete mode 100644 src/nvim/testdir/test_close_count.vim delete mode 100644 src/nvim/testdir/test_cmdline.vim delete mode 100644 src/nvim/testdir/test_command_count.vim delete mode 100644 src/nvim/testdir/test_comments.vim delete mode 100644 src/nvim/testdir/test_comparators.vim delete mode 100644 src/nvim/testdir/test_compiler.vim delete mode 100644 src/nvim/testdir/test_conceal.vim delete mode 100644 src/nvim/testdir/test_const.vim delete mode 100644 src/nvim/testdir/test_cpoptions.vim delete mode 100644 src/nvim/testdir/test_cursor_func.vim delete mode 100644 src/nvim/testdir/test_cursorline.vim delete mode 100644 src/nvim/testdir/test_curswant.vim delete mode 100644 src/nvim/testdir/test_debugger.vim delete mode 100644 src/nvim/testdir/test_delete.vim delete mode 100644 src/nvim/testdir/test_diffmode.vim delete mode 100644 src/nvim/testdir/test_digraph.vim delete mode 100644 src/nvim/testdir/test_display.vim delete mode 100644 src/nvim/testdir/test_edit.vim delete mode 100644 src/nvim/testdir/test_environ.vim delete mode 100644 src/nvim/testdir/test_erasebackword.vim delete mode 100644 src/nvim/testdir/test_escaped_glob.vim delete mode 100644 src/nvim/testdir/test_eval_stuff.vim delete mode 100644 src/nvim/testdir/test_ex_equal.vim delete mode 100644 src/nvim/testdir/test_ex_mode.vim delete mode 100644 src/nvim/testdir/test_ex_undo.vim delete mode 100644 src/nvim/testdir/test_ex_z.vim delete mode 100644 src/nvim/testdir/test_excmd.vim delete mode 100644 src/nvim/testdir/test_exec_while_if.vim delete mode 100644 src/nvim/testdir/test_execute_func.vim delete mode 100644 src/nvim/testdir/test_exists.vim delete mode 100644 src/nvim/testdir/test_exists_autocmd.vim delete mode 100644 src/nvim/testdir/test_exit.vim delete mode 100644 src/nvim/testdir/test_expand.vim delete mode 100644 src/nvim/testdir/test_expand_func.vim delete mode 100644 src/nvim/testdir/test_expr.vim delete mode 100644 src/nvim/testdir/test_expr_utf8.vim delete mode 100644 src/nvim/testdir/test_file_perm.vim delete mode 100644 src/nvim/testdir/test_file_size.vim delete mode 100644 src/nvim/testdir/test_filechanged.vim delete mode 100644 src/nvim/testdir/test_fileformat.vim delete mode 100644 src/nvim/testdir/test_filetype.vim delete mode 100644 src/nvim/testdir/test_filter_cmd.vim delete mode 100644 src/nvim/testdir/test_filter_map.vim delete mode 100644 src/nvim/testdir/test_find_complete.vim delete mode 100644 src/nvim/testdir/test_findfile.vim delete mode 100644 src/nvim/testdir/test_fixeol.vim delete mode 100644 src/nvim/testdir/test_flatten.vim delete mode 100644 src/nvim/testdir/test_float_func.vim delete mode 100644 src/nvim/testdir/test_fnameescape.vim delete mode 100644 src/nvim/testdir/test_fnamemodify.vim delete mode 100644 src/nvim/testdir/test_fold.vim delete mode 100644 src/nvim/testdir/test_functions.vim delete mode 100644 src/nvim/testdir/test_ga.vim delete mode 100644 src/nvim/testdir/test_getcwd.vim delete mode 100644 src/nvim/testdir/test_getvar.vim delete mode 100644 src/nvim/testdir/test_gf.vim delete mode 100644 src/nvim/testdir/test_glob2regpat.vim delete mode 100644 src/nvim/testdir/test_global.vim delete mode 100644 src/nvim/testdir/test_gn.vim delete mode 100644 src/nvim/testdir/test_goto.vim delete mode 100644 src/nvim/testdir/test_gui.vim delete mode 100644 src/nvim/testdir/test_help.vim delete mode 100644 src/nvim/testdir/test_help_tagjump.vim delete mode 100644 src/nvim/testdir/test_hide.vim delete mode 100644 src/nvim/testdir/test_highlight.vim delete mode 100644 src/nvim/testdir/test_history.vim delete mode 100644 src/nvim/testdir/test_hlsearch.vim delete mode 100644 src/nvim/testdir/test_increment.vim delete mode 100644 src/nvim/testdir/test_increment_dbcs.vim delete mode 100644 src/nvim/testdir/test_indent.vim delete mode 100644 src/nvim/testdir/test_input.vim delete mode 100644 src/nvim/testdir/test_ins_complete.vim delete mode 100644 src/nvim/testdir/test_ins_complete_no_halt.vim delete mode 100644 src/nvim/testdir/test_interrupt.vim delete mode 100644 src/nvim/testdir/test_join.vim delete mode 100644 src/nvim/testdir/test_jumplist.vim delete mode 100644 src/nvim/testdir/test_lambda.vim delete mode 100644 src/nvim/testdir/test_langmap.vim delete mode 100644 src/nvim/testdir/test_largefile.vim delete mode 100644 src/nvim/testdir/test_let.vim delete mode 100644 src/nvim/testdir/test_lineending.vim delete mode 100644 src/nvim/testdir/test_lispindent.vim delete mode 100644 src/nvim/testdir/test_listchars.vim delete mode 100644 src/nvim/testdir/test_listdict.vim delete mode 100644 src/nvim/testdir/test_listlbr.vim delete mode 100644 src/nvim/testdir/test_listlbr_utf8.vim delete mode 100644 src/nvim/testdir/test_makeencoding.py delete mode 100644 src/nvim/testdir/test_makeencoding.vim delete mode 100644 src/nvim/testdir/test_maparg.vim delete mode 100644 src/nvim/testdir/test_mapping.vim delete mode 100644 src/nvim/testdir/test_marks.vim delete mode 100644 src/nvim/testdir/test_match.vim delete mode 100644 src/nvim/testdir/test_matchadd_conceal.vim delete mode 100644 src/nvim/testdir/test_matchadd_conceal_utf8.vim delete mode 100644 src/nvim/testdir/test_matchfuzzy.vim delete mode 100644 src/nvim/testdir/test_menu.vim delete mode 100644 src/nvim/testdir/test_messages.vim delete mode 100644 src/nvim/testdir/test_method.vim delete mode 100644 src/nvim/testdir/test_mksession.vim delete mode 100644 src/nvim/testdir/test_mksession_utf8.vim delete mode 100644 src/nvim/testdir/test_modeline.vim delete mode 100644 src/nvim/testdir/test_move.vim delete mode 100644 src/nvim/testdir/test_nested_function.vim delete mode 100644 src/nvim/testdir/test_normal.vim delete mode 100644 src/nvim/testdir/test_number.vim delete mode 100644 src/nvim/testdir/test_options.vim delete mode 100644 src/nvim/testdir/test_packadd.vim delete mode 100644 src/nvim/testdir/test_partial.vim delete mode 100644 src/nvim/testdir/test_paste.vim delete mode 100644 src/nvim/testdir/test_perl.vim delete mode 100644 src/nvim/testdir/test_plus_arg_edit.vim delete mode 100644 src/nvim/testdir/test_popup.vim delete mode 100644 src/nvim/testdir/test_preview.vim delete mode 100644 src/nvim/testdir/test_profile.vim delete mode 100644 src/nvim/testdir/test_prompt_buffer.vim delete mode 100644 src/nvim/testdir/test_put.vim delete mode 100644 src/nvim/testdir/test_python2.vim delete mode 100644 src/nvim/testdir/test_python3.vim delete mode 100644 src/nvim/testdir/test_pyx2.vim delete mode 100644 src/nvim/testdir/test_pyx3.vim delete mode 100644 src/nvim/testdir/test_quickfix.vim delete mode 100644 src/nvim/testdir/test_quotestar.vim delete mode 100644 src/nvim/testdir/test_random.vim delete mode 100644 src/nvim/testdir/test_recover.vim delete mode 100644 src/nvim/testdir/test_regex_char_classes.vim delete mode 100644 src/nvim/testdir/test_regexp_latin.vim delete mode 100644 src/nvim/testdir/test_regexp_utf8.vim delete mode 100644 src/nvim/testdir/test_registers.vim delete mode 100644 src/nvim/testdir/test_reltime.vim delete mode 100644 src/nvim/testdir/test_rename.vim delete mode 100644 src/nvim/testdir/test_retab.vim delete mode 100644 src/nvim/testdir/test_ruby.vim delete mode 100644 src/nvim/testdir/test_scriptnames.vim delete mode 100644 src/nvim/testdir/test_scroll_opt.vim delete mode 100644 src/nvim/testdir/test_scrollbind.vim delete mode 100644 src/nvim/testdir/test_search.vim delete mode 100644 src/nvim/testdir/test_search_stat.vim delete mode 100644 src/nvim/testdir/test_searchpos.vim delete mode 100644 src/nvim/testdir/test_selectmode.vim delete mode 100644 src/nvim/testdir/test_set.vim delete mode 100644 src/nvim/testdir/test_sha256.vim delete mode 100644 src/nvim/testdir/test_shell.vim delete mode 100644 src/nvim/testdir/test_shift.vim delete mode 100644 src/nvim/testdir/test_signals.vim delete mode 100644 src/nvim/testdir/test_signs.vim delete mode 100644 src/nvim/testdir/test_sleep.vim delete mode 100644 src/nvim/testdir/test_smartindent.vim delete mode 100644 src/nvim/testdir/test_sort.vim delete mode 100644 src/nvim/testdir/test_source.vim delete mode 100644 src/nvim/testdir/test_source_utf8.vim delete mode 100644 src/nvim/testdir/test_spell.vim delete mode 100644 src/nvim/testdir/test_spell_utf8.vim delete mode 100644 src/nvim/testdir/test_spellfile.vim delete mode 100644 src/nvim/testdir/test_startup.vim delete mode 100644 src/nvim/testdir/test_startup_utf8.vim delete mode 100644 src/nvim/testdir/test_stat.vim delete mode 100644 src/nvim/testdir/test_statusline.vim delete mode 100644 src/nvim/testdir/test_substitute.vim delete mode 100644 src/nvim/testdir/test_suspend.vim delete mode 100644 src/nvim/testdir/test_swap.vim delete mode 100644 src/nvim/testdir/test_syn_attr.vim delete mode 100644 src/nvim/testdir/test_syntax.vim delete mode 100644 src/nvim/testdir/test_system.vim delete mode 100644 src/nvim/testdir/test_tab.vim delete mode 100644 src/nvim/testdir/test_tabline.vim delete mode 100644 src/nvim/testdir/test_tabpage.vim delete mode 100644 src/nvim/testdir/test_tagcase.vim delete mode 100644 src/nvim/testdir/test_tagfunc.vim delete mode 100644 src/nvim/testdir/test_tagjump.vim delete mode 100644 src/nvim/testdir/test_taglist.vim delete mode 100644 src/nvim/testdir/test_termcodes.vim delete mode 100644 src/nvim/testdir/test_textformat.vim delete mode 100644 src/nvim/testdir/test_textobjects.vim delete mode 100644 src/nvim/testdir/test_timers.vim delete mode 100644 src/nvim/testdir/test_true_false.vim delete mode 100644 src/nvim/testdir/test_trycatch.vim delete mode 100644 src/nvim/testdir/test_undo.vim delete mode 100644 src/nvim/testdir/test_unlet.vim delete mode 100644 src/nvim/testdir/test_user_func.vim delete mode 100644 src/nvim/testdir/test_usercommands.vim delete mode 100644 src/nvim/testdir/test_utf8.vim delete mode 100644 src/nvim/testdir/test_utf8_comparisons.vim delete mode 100644 src/nvim/testdir/test_vartabs.vim delete mode 100644 src/nvim/testdir/test_version.vim delete mode 100644 src/nvim/testdir/test_viminfo.vim delete mode 100644 src/nvim/testdir/test_vimscript.vim delete mode 100644 src/nvim/testdir/test_virtualedit.vim delete mode 100644 src/nvim/testdir/test_visual.vim delete mode 100644 src/nvim/testdir/test_winbuf_close.vim delete mode 100644 src/nvim/testdir/test_window_cmd.vim delete mode 100644 src/nvim/testdir/test_window_id.vim delete mode 100644 src/nvim/testdir/test_windows_home.vim delete mode 100644 src/nvim/testdir/test_wnext.vim delete mode 100644 src/nvim/testdir/test_wordcount.vim delete mode 100644 src/nvim/testdir/test_writefile.vim delete mode 100644 src/nvim/testdir/unix.vim delete mode 100644 src/nvim/testdir/view_util.vim delete mode 100644 src/nvim/testdir/vim9.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/Make_all.mak b/src/nvim/testdir/Make_all.mak deleted file mode 100644 index b917877422..0000000000 --- a/src/nvim/testdir/Make_all.mak +++ /dev/null @@ -1 +0,0 @@ -# Tests may depend on the existence of this file. diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile deleted file mode 100644 index 9511b311e6..0000000000 --- a/src/nvim/testdir/Makefile +++ /dev/null @@ -1,154 +0,0 @@ -# vim: noet ts=8 -# Makefile to run all tests for Vim -# - -ifeq ($(OS),Windows_NT) - NVIM_PRG ?= ../../../build/bin/nvim.exe -else - NVIM_PRG ?= ../../../build/bin/nvim -endif -ROOT := ../../.. - -export SHELL := sh -export NVIM_PRG := $(NVIM_PRG) -export TMPDIR := $(abspath X-test-tmpdir) - -ifeq ($(OS),Windows_NT) - FIXFF = fixff -else - FIXFF = -endif - -# Tests using runtest.vim. -NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin -NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT))) -# Ignored tests. -# test_largefile: uses too much resources to run on CI. -NEW_TESTS_IGNORE := \ - test_largefile \ - -NEW_TESTS := $(sort $(basename $(notdir $(wildcard test_*.vim)))) -NEW_TESTS_RES := $(addsuffix .res,$(filter-out $(NEW_TESTS_ALOT) $(NEW_TESTS_IN_ALOT) $(NEW_TESTS_IGNORE),$(NEW_TESTS)) $(NEW_TESTS_ALOT)) - - -ifdef VALGRIND_GDB - VGDB := --vgdb=yes \ - --vgdb-error=0 -endif - -ifdef USE_VALGRIND - VALGRIND_TOOL := --tool=memcheck \ - --leak-check=yes \ - --track-origins=yes -# VALGRIND_TOOL := exp-sgcheck - TOOL := valgrind -q \ - -q \ - $(VALGRIND_TOOL) \ - --suppressions=../../.valgrind.supp \ - --error-exitcode=123 \ - --log-file=valgrind-\%p.$* \ - $(VGDB) \ - --trace-children=yes -else - ifdef USE_GDB - TOOL = gdb --args - endif -endif - -nongui: nolog $(FIXFF) newtests report - -.gdbinit: - @echo "[OLDTEST-PREP] Setting up .gdbinit" - @echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit - -report: - $(NVIM_PRG) -u NONE $(NO_INITS) -S summarize.vim messages - @echo - @echo 'Test results:' - @cat test_result.log - @/bin/sh -c "if test -f test.log; \ - then echo TEST FAILURE; exit 1; \ - else echo ALL DONE; \ - fi" - -test1.out: $(NVIM_PRG) - -NO_PLUGINS = --noplugin --headless -# In vim, if the -u command line option is specified, compatible is turned on -# and viminfo is not read. Unlike vim, neovim reads viminfo and requires the -# -i command line option. -NO_INITS = -U NONE -i NONE $(NO_PLUGINS) - -# TODO: find a way to avoid changing the distributed files. -fixff: - -$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \ - *.in *.ok - -$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \ - dotest.in - -# Execute an individual new style test, e.g.: -# make test_largefile -$(NEW_TESTS): - rm -f $@.res test.log messages - @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res - @cat messages - @if test -f test.log; then \ - exit 1; \ - fi - -RM_ON_RUN := test.out X* viminfo -RM_ON_START := test.ok -RUN_VIM := $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in - -# Delete files that may interfere with running tests. This includes some files -# that may result from working on the tests, not only from running them. -CLEAN_FILES := *.out \ - *.failed \ - *.res \ - *.rej \ - *.orig \ - *.tlog \ - test.log \ - test_result.log \ - messages \ - $(RM_ON_RUN) \ - $(RM_ON_START) \ - valgrind.* \ - .*.swp \ - .*.swo \ - .gdbinit \ - $(TMPDIR) \ - del -clean: - $(RM) -rf $(CLEAN_FILES) - -test1.out: .gdbinit test1.in - @echo "[OLDTEST-PREP] Running test1" - @rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize - @mkdir -p $(TMPDIR) - @/bin/sh runnvim.sh $(ROOT) $(NVIM_PRG) $* $(RUN_VIM) $*.in - @rm -f wrongtermsize - @rm -rf X* viminfo - -nolog: - @echo "[OLDTEST-PREP] Removing test.log and messages" - @rm -f test.log messages - - -# New style of tests uses Vim script with assert calls. These are easier -# to write and a lot easier to read and debug. -# Limitation: Only works with the +eval feature. -RUN_VIMTEST = $(TOOL) $(NVIM_PRG) -u unix.vim - -newtests: newtestssilent - @/bin/sh -c "if test -f messages && grep -q 'FAILED' messages; then \ - cat messages && cat test.log; \ - fi" - -newtestssilent: $(NEW_TESTS_RES) - -%.res: %.vim .gdbinit - @echo "[OLDTEST] Running" $* - @rm -rf $*.failed test.ok $(RM_ON_RUN) - @mkdir -p $(TMPDIR) - @/bin/sh runnvim.sh $(ROOT) $(NVIM_PRG) $* $(RUN_VIMTEST) $(NO_INITS) -u NONE --cmd "set shortmess-=F" -S runtest.vim $*.vim diff --git a/src/nvim/testdir/README.txt b/src/nvim/testdir/README.txt deleted file mode 100644 index b8bc52f1e6..0000000000 --- a/src/nvim/testdir/README.txt +++ /dev/null @@ -1,121 +0,0 @@ -This directory contains tests for various Vim features. -For testing an indent script see runtime/indent/testdir/README.txt. - -If it makes sense, add a new test method to an already existing file. You may -want to separate it from other tests with comment lines. - -TO ADD A NEW STYLE TEST: - -1) Create a test_.vim file. -2) Add test_.res to NEW_TESTS_RES in Make_all.mak in alphabetical - order. -3) Also add an entry "test_" to NEW_TESTS in Make_all.mak. -4) Use make test_ to run a single test. - -At 2), instead of running the test separately, it can be included in -"test_alot". Do this for quick tests without side effects. The test runs a -bit faster, because Vim doesn't have to be started, one Vim instance runs many -tests. - -At 4), to run a test in GUI, add "GUI_FLAG=-g" to the make command. - - -What you can use (see test_assert.vim for an example): - -- Call assert_equal(), assert_true(), assert_false(), etc. - -- Use assert_fails() to check for expected errors. - -- Use try/catch to avoid an exception aborts the test. - -- Use test_alloc_fail() to have memory allocation fail. This makes it possible - to check memory allocation failures are handled gracefully. You need to - change the source code to add an ID to the allocation. Add a new one to - alloc_id_T, before aid_last. - -- Use test_override() to make Vim behave differently, e.g. if char_avail() - must return FALSE for a while. E.g. to trigger the CursorMovedI autocommand - event. See test_cursor_func.vim for an example. - -- If the bug that is being tested isn't fixed yet, you can throw an exception - with "Skipped" so that it's clear this still needs work. E.g.: throw - "Skipped: Bug with and popupmenu not fixed yet" - -- The following environment variables are recognized and can be set to - influence the behavior of the test suite (see runtest.vim for details) - - - $TEST_MAY_FAIL=Test_channel_one - ignore those failing tests - - $TEST_FILTER=Test_channel - only run test that match this pattern - - $TEST_SKIP_PAT=Test_channel - skip tests that match this pattern - - $TEST_NO_RETRY=yes - do not try to re-run failing tests - You can also set them in Vim: - :let $TEST_MAY_FAIL = 'Test_channel_one' - :let $TEST_FILTER = '_set_mode' - :let $TEST_SKIP_PAT = 'Test_loop_forever' - :let $TEST_NO_RETRY = 'yes' - Use an empty string to revert, e.g.: - :let $TEST_FILTER = '' - -- See the start of runtest.vim for more help. - - -TO ADD A SCREEN DUMP TEST: - -Mostly the same as writing a new style test. Additionally, see help on -"terminal-dumptest". Put the reference dump in "dumps/Test_func_name.dump". - - -OLD STYLE TESTS: - -There are a few tests that are used when Vim was built without the +eval -feature. These cannot use the "assert" functions, therefore they consist of a -.in file that contains Normal mode commands between STARTTEST and ENDTEST. -They modify the file and the result gets written in the test.out file. This -is then compared with the .ok file. If they are equal the test passed. If -they differ the test failed. - - -RUNNING THE TESTS: - -To run a single test from the src directory: - - $ make test_ - -The below commands should be run from the src/testdir directory. - -To run a single test: - - $ make test_.res - -The file 'messages' contains the messages generated by the test script. If a -test fails, then the test.log file contains the error messages. If all the -tests are successful, then this file will be an empty file. - -- To run a single test function from a test script: - - $ ../vim -u NONE -S runtest.vim .vim - -- To execute only specific test functions, add a second argument: - - $ ../vim -u NONE -S runtest.vim test_channel.vim open_delay - - -- To run all the tests: - - $ make - -- To run the test on MS-Windows using the MSVC nmake: - - > nmake -f Make_dos.mak - -- To run the tests with GUI Vim: - - $ make GUI_FLAG=-g - - or - - $ make VIMPROG=../gvim - -- To cleanup the temporary files after running the tests: - - $ make clean diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim deleted file mode 100644 index 680a59006b..0000000000 --- a/src/nvim/testdir/check.vim +++ /dev/null @@ -1,217 +0,0 @@ -source shared.vim -source term_util.vim - -command -nargs=1 MissingFeature throw 'Skipped: ' .. .. ' feature missing' - -" Command to check for the presence of a feature. -command -nargs=1 CheckFeature call CheckFeature() -func CheckFeature(name) - " if !has(a:name, 1) - " throw 'Checking for non-existent feature ' .. a:name - " endif - if !has(a:name) - MissingFeature a:name - endif -endfunc - -" Command to check for the absence of a feature. -command -nargs=1 CheckNotFeature call CheckNotFeature() -func CheckNotFeature(name) - " if !has(a:name, 1) - " throw 'Checking for non-existent feature ' .. a:name - " endif - if has(a:name) - throw 'Skipped: ' .. a:name .. ' feature present' - endif -endfunc - -" Command to check for the presence of a working option. -command -nargs=1 CheckOption call CheckOption() -func CheckOption(name) - if !exists('&' .. a:name) - throw 'Checking for non-existent option ' .. a:name - endif - if !exists('+' .. a:name) - throw 'Skipped: ' .. a:name .. ' option not supported' - endif -endfunc - -" Command to check for the presence of a function. -command -nargs=1 CheckFunction call CheckFunction() -func CheckFunction(name) - if !exists('*' .. a:name) - throw 'Skipped: ' .. a:name .. ' function missing' - endif -endfunc - -" Command to check for the presence of an Ex command -command -nargs=1 CheckCommand call CheckCommand() -func CheckCommand(name) - if !exists(':' .. a:name) - throw 'Skipped: ' .. a:name .. ' command not supported' - endif -endfunc - -" Command to check for the presence of a shell command -command -nargs=1 CheckExecutable call CheckExecutable() -func CheckExecutable(name) - if !executable(a:name) - throw 'Skipped: ' .. a:name .. ' program not executable' - endif -endfunc - -" Command to check for the presence of python. Argument should have been -" obtained with PythonProg() -func CheckPython(name) - if a:name == '' - throw 'Skipped: python command not available' - endif -endfunc - -" Command to check for running on MS-Windows -command CheckMSWindows call CheckMSWindows() -func CheckMSWindows() - if !has('win32') - throw 'Skipped: only works on MS-Windows' - endif -endfunc - -" Command to check for NOT running on MS-Windows -command CheckNotMSWindows call CheckNotMSWindows() -func CheckNotMSWindows() - if has('win32') - throw 'Skipped: does not work on MS-Windows' - endif -endfunc - -" Command to check for running on Unix -command CheckUnix call CheckUnix() -func CheckUnix() - if !has('unix') - throw 'Skipped: only works on Unix' - endif -endfunc - -" Command to check for running on Linux -command CheckLinux call CheckLinux() -func CheckLinux() - if !has('linux') - throw 'Skipped: only works on Linux' - endif -endfunc - -" Command to check that making screendumps is supported. -" Caller must source screendump.vim -command CheckScreendump call CheckScreendump() -func CheckScreendump() - if !CanRunVimInTerminal() - throw 'Skipped: cannot make screendumps' - endif -endfunc - -" Command to check that we can Run Vim in a terminal window -command CheckRunVimInTerminal call CheckRunVimInTerminal() -func CheckRunVimInTerminal() - if !CanRunVimInTerminal() - throw 'Skipped: cannot run Vim in a terminal window' - endif -endfunc - -" Command to check that we can run the GUI -command CheckCanRunGui call CheckCanRunGui() -func CheckCanRunGui() - if !has('gui') || ($DISPLAY == "" && !has('gui_running')) - throw 'Skipped: cannot start the GUI' - endif -endfunc - -" Command to Check for an environment variable -command -nargs=1 CheckEnv call CheckEnv() -func CheckEnv(name) - if empty(eval('$' .. a:name)) - throw 'Skipped: Environment variable ' .. a:name .. ' is not set' - endif -endfunc - -" Command to check that we are using the GUI -command CheckGui call CheckGui() -func CheckGui() - if !has('gui_running') - throw 'Skipped: only works in the GUI' - endif -endfunc - -" Command to check that not currently using the GUI -command CheckNotGui call CheckNotGui() -func CheckNotGui() - if has('gui_running') - throw 'Skipped: only works in the terminal' - endif -endfunc - -" Command to check that test is not running as root -command CheckNotRoot call CheckNotRoot() -func CheckNotRoot() - if IsRoot() - throw 'Skipped: cannot run test as root' - endif -endfunc - -" Command to check that the current language is English -command CheckEnglish call CheckEnglish() -func CheckEnglish() - if v:lang != "C" && v:lang !~ '^[Ee]n' - throw 'Skipped: only works in English language environment' - endif -endfunc - -" Command to check for not running under ASAN -command CheckNotAsan call CheckNotAsan() -func CheckNotAsan() - if execute('version') =~# '-fsanitize=[a-z,]*\' - throw 'Skipped: does not work with ASAN' - endif -endfunc - -" Command to check for not running under valgrind -command CheckNotValgrind call CheckNotValgrind() -func CheckNotValgrind() - if RunningWithValgrind() - throw 'Skipped: does not work well with valgrind' - endif -endfunc - -" Command to check for X11 based GUI -command CheckX11BasedGui call CheckX11BasedGui() -func CheckX11BasedGui() - if !g:x11_based_gui - throw 'Skipped: requires X11 based GUI' - endif -endfunc - -" Command to check for satisfying any of the conditions. -" e.g. CheckAnyOf Feature:bsd Feature:sun Linux -command -nargs=+ CheckAnyOf call CheckAnyOf() -func CheckAnyOf(...) - let excp = [] - for arg in a:000 - try - exe 'Check' .. substitute(arg, ':', ' ', '') - return - catch /^Skipped:/ - let excp += [substitute(v:exception, '^Skipped:\s*', '', '')] - endtry - endfor - throw 'Skipped: ' .. join(excp, '; ') -endfunc - -" Command to check for satisfying all of the conditions. -" e.g. CheckAllOf Unix Gui Option:ballooneval -command -nargs=+ CheckAllOf call CheckAllOf() -func CheckAllOf(...) - for arg in a:000 - exe 'Check' .. substitute(arg, ':', ' ', '') - endfor -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/dotest.in b/src/nvim/testdir/dotest.in deleted file mode 100644 index 2ef4576f4e..0000000000 --- a/src/nvim/testdir/dotest.in +++ /dev/null @@ -1,3 +0,0 @@ -:set nomore -:map dotest /^STARTTEST j:set ff=unix cpo-=A :.,/ENDTEST/-1w! Xdotest :set ff& cpo+=A nj0:so! Xdotest dotest -dotest diff --git a/src/nvim/testdir/load.vim b/src/nvim/testdir/load.vim deleted file mode 100644 index 5697ee7304..0000000000 --- a/src/nvim/testdir/load.vim +++ /dev/null @@ -1,32 +0,0 @@ -" Also used by: test/functional/helpers.lua - -function! s:load_factor() abort - let timeout = 200 - let times = [] - - for _ in range(5) - let g:val = 0 - let start = reltime() - call timer_start(timeout, {-> nvim_set_var('val', 1)}) - while 1 - sleep 10m - if g:val == 1 - let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000) - break - endif - endwhile - call insert(times, g:waited_in_ms, 0) - endfor - - let longest = max(times) - let factor = (longest + 50.0) / timeout - - return factor -endfunction - -" Compute load factor only once. -let g:test_load_factor = s:load_factor() - -function! LoadAdjust(num) abort - return float2nr(ceil(a:num * g:test_load_factor)) -endfunction diff --git a/src/nvim/testdir/pyxfile/py2_magic.py b/src/nvim/testdir/pyxfile/py2_magic.py deleted file mode 100644 index 819892fd16..0000000000 --- a/src/nvim/testdir/pyxfile/py2_magic.py +++ /dev/null @@ -1,4 +0,0 @@ -# requires python 2.x - -import sys -print(sys.version) diff --git a/src/nvim/testdir/pyxfile/py2_shebang.py b/src/nvim/testdir/pyxfile/py2_shebang.py deleted file mode 100644 index 13bfc491ec..0000000000 --- a/src/nvim/testdir/pyxfile/py2_shebang.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/python2 - -import sys -print(sys.version) diff --git a/src/nvim/testdir/pyxfile/py3_magic.py b/src/nvim/testdir/pyxfile/py3_magic.py deleted file mode 100644 index d4b7ee0071..0000000000 --- a/src/nvim/testdir/pyxfile/py3_magic.py +++ /dev/null @@ -1,4 +0,0 @@ -# requires python 3.x - -import sys -print(sys.version) diff --git a/src/nvim/testdir/pyxfile/py3_shebang.py b/src/nvim/testdir/pyxfile/py3_shebang.py deleted file mode 100644 index ec05808ca4..0000000000 --- a/src/nvim/testdir/pyxfile/py3_shebang.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/python3 - -import sys -print(sys.version) diff --git a/src/nvim/testdir/pyxfile/pyx.py b/src/nvim/testdir/pyxfile/pyx.py deleted file mode 100644 index 261a6512c0..0000000000 --- a/src/nvim/testdir/pyxfile/pyx.py +++ /dev/null @@ -1,2 +0,0 @@ -import sys -print(sys.version) diff --git a/src/nvim/testdir/runnvim.sh b/src/nvim/testdir/runnvim.sh deleted file mode 100755 index 4d8ea0527d..0000000000 --- a/src/nvim/testdir/runnvim.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash - -main() {( - local separator="================================================================================" - local oldesttest= - if test "$1" = "--oldesttest" ; then - shift - oldesttest=1 - fi - local root="$1" ; shift - local nvim_prg="$1" ; shift - local test_name="$1" ; shift - - local tlog="$test_name.tlog" - - export NVIM_TEST_ARGC=$# - local arg - local i=0 - # shellcheck disable=SC2034 # (unused "arg", used in "eval"). - for arg ; do - eval "export NVIM_TEST_ARG$i=\"\$arg\"" - i=$(( i+1 )) - done - - BUILD_DIR="$(dirname "$nvim_prg")/.." - export BUILD_DIR - export FAILED=0 - - . $(dirname $0)/test.sh - - # Redirect XDG_CONFIG_HOME so users local config doesn't interfere - export XDG_CONFIG_HOME="$root" - - export VIMRUNTIME="$root/runtime" - if ! "$nvim_prg" \ - -u NONE -i NONE \ - --headless \ - --cmd 'set shortmess+=I noswapfile noundofile nomore' \ - -S runnvim.vim \ - "$tlog" > "out-$tlog" 2> "err-$tlog" - then - fail "$test_name" "Nvim exited with non-zero code" - fi - { - echo "Stdout of :terminal runner" - echo "$separator" - cat "out-$tlog" - echo "$separator" - echo "Stderr of :terminal runner" - echo "$separator" - cat "err-$tlog" - echo "$separator" - } >> "$tlog" - if test "$oldesttest" = 1 ; then - if ! diff -q test.out "$test_name.ok" > /dev/null 2>&1 ; then - if test -f test.out ; then - fail "$test_name" "Oldest test .out file differs from .ok file" - { - echo "Diff between test.out and $test_name.ok" - echo "$separator" - diff -a test.out "$test_name.ok" - echo "$separator" - } >> "$tlog" - else - echo "No output in test.out" >> "$tlog" - fi - fi - fi - valgrind_check . - if test -n "$LOG_DIR" ; then - check_sanitizer "$LOG_DIR" - fi - check_core_dumps - if test "$FAILED" = 1 ; then - cat "$tlog" - fi - rm -f "$tlog" - if test "$FAILED" = 1 ; then - echo "Test $test_name failed, see output above and summary for more details" >> test.log - # When Neovim crashed/aborted it might not have created messages. - # test.log itself is used as an indicator to exit non-zero in the Makefile. - if ! test -f message; then - cp -a test.log messages - fi - fi -)} - -main "$@" diff --git a/src/nvim/testdir/runnvim.vim b/src/nvim/testdir/runnvim.vim deleted file mode 100644 index a46e2d3fc0..0000000000 --- a/src/nvim/testdir/runnvim.vim +++ /dev/null @@ -1,58 +0,0 @@ -let s:logger = {'d_events': []} -function s:logger.on_stdout(id, data, event) - call add(self.d_events, [a:event, a:data]) -endfunction -let s:logger.on_stderr = s:logger.on_stdout -function s:logger.on_exit(id, data, event) - call add(self.d_events, [a:event, ['']]) -endfunction - -" Replace non-printable chars by special sequence, or "<%x>". -let s:escaped_char = {"\n": '\n', "\r": '\r', "\t": '\t'} -function! s:escape_non_printable(char) abort - let r = get(s:escaped_char, a:char) - return r is 0 ? printf('<%x>', char2nr(a:char)) : r -endfunction - -function Main() - let argc = +$NVIM_TEST_ARGC - let args = [] - for i in range(argc) - call add(args, eval("$NVIM_TEST_ARG" . i)) - endfor - set lines=25 - set columns=80 - enew - let job = termopen(args, s:logger) - let results = jobwait([job], 5 * 60 * 1000) - " TODO(ZyX-I): Get colors - let screen = getline(1, '$') - bwipeout! " kills the job always. - let stringified_events = map(s:logger.d_events, - \'v:val[0] . ": " . ' . - \'join(map(v:val[1], '. - \ '''substitute(v:val, '. - \ '"\\v\\C(\\p@!.|\\<)", '. - \ '"\\=s:escape_non_printable(submatch(0))", '. - \ '"g")''), '. - \ '''\n'')') - call setline(1, [ - \ 'Job exited with code ' . results[0], - \ printf('Screen (%u lines)', len(screen)), - \ repeat('=', 80), - \] + screen + [ - \ repeat('=', 80), - \ printf('Events (%u lines):', len(stringified_events)), - \ repeat('=', 80), - \] + stringified_events + [ - \ repeat('=', 80), - \]) - write - if results[0] != 0 - cquit - else - qall - endif -endfunction - -call Main() diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim deleted file mode 100644 index 3c5699af73..0000000000 --- a/src/nvim/testdir/runtest.vim +++ /dev/null @@ -1,485 +0,0 @@ -" This script is sourced while editing the .vim file with the tests. -" When the script is successful the .res file will be created. -" Errors are appended to the test.log file. -" -" To execute only specific test functions, add a second argument. It will be -" matched against the names of the Test_ function. E.g.: -" ../vim -u NONE -S runtest.vim test_channel.vim open_delay -" The output can be found in the "messages" file. -" -" If the environment variable $TEST_FILTER is set then only test functions -" matching this pattern are executed. E.g. for sh/bash: -" export TEST_FILTER=Test_channel -" For csh: -" setenv TEST_FILTER Test_channel -" -" While working on a test you can make $TEST_NO_RETRY non-empty to not retry: -" export TEST_NO_RETRY=yes -" -" To ignore failure for tests that are known to fail in a certain environment, -" set $TEST_MAY_FAIL to a comma separated list of function names. E.g. for -" sh/bash: -" export TEST_MAY_FAIL=Test_channel_one,Test_channel_other -" The failure report will then not be included in the test.log file and -" "make test" will not fail. -" -" The test script may contain anything, only functions that start with -" "Test_" are special. These will be invoked and should contain assert -" functions. See test_assert.vim for an example. -" -" It is possible to source other files that contain "Test_" functions. This -" can speed up testing, since Vim does not need to restart. But be careful -" that the tests do not interfere with each other. -" -" If an error cannot be detected properly with an assert function add the -" error to the v:errors list: -" call add(v:errors, 'test foo failed: Cannot find xyz') -" -" If preparation for each Test_ function is needed, define a SetUp function. -" It will be called before each Test_ function. -" -" If cleanup after each Test_ function is needed, define a TearDown function. -" It will be called after each Test_ function. -" -" When debugging a test it can be useful to add messages to v:errors: -" call add(v:errors, "this happened") - - -" Check that the screen size is at least 24 x 80 characters. -if &lines < 24 || &columns < 80 - let error = 'Screen size too small! Tests require at least 24 lines with 80 characters, got ' .. &lines .. ' lines with ' .. &columns .. ' characters' - echoerr error - split test.log - $put =error - write - split messages - call append(line('$'), '') - call append(line('$'), 'From ' . expand('%') . ':') - call append(line('$'), error) - write - qa! -endif - -if has('reltime') - let s:start_time = reltime() -endif - -" Always use forward slashes. -set shellslash - -" Common with all tests on all systems. -source setup.vim - -" For consistency run all tests with 'nocompatible' set. -" This also enables use of line continuation. -set nocp viminfo+=nviminfo - -" Use utf-8 by default, instead of whatever the system default happens to be. -" Individual tests can overrule this at the top of the file. -set encoding=utf-8 - -" REDIR_TEST_TO_NULL has a very permissive SwapExists autocommand which is for -" the test_name.vim file itself. Replace it here with a more restrictive one, -" so we still catch mistakes. -let s:test_script_fname = expand('%') -au! SwapExists * call HandleSwapExists() -func HandleSwapExists() - if exists('g:ignoreSwapExists') - return - endif - " Ignore finding a swap file for the test script (the user might be - " editing it and do ":make test_name") and the output file. - " Report finding another swap file and chose 'q' to avoid getting stuck. - if expand('') == 'messages' || expand('') =~ s:test_script_fname - let v:swapchoice = 'e' - else - call assert_report('Unexpected swap file: ' .. v:swapname) - let v:swapchoice = 'q' - endif -endfunc - -" Avoid stopping at the "hit enter" prompt -set nomore - -" Output all messages in English. -lang mess C - -" Nvim: append runtime from build dir, which contains the generated doc/tags. -let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/runtime/' - -let s:t_bold = &t_md -let s:t_normal = &t_me -if has('win32') - " avoid prompt that is long or contains a line break - let $PROMPT = '$P$G' -endif - -if has('mac') - " In MacOS, when starting a shell in a terminal, a bash deprecation warning - " message is displayed. This breaks the terminal test. Disable the warning - " message. - let $BASH_SILENCE_DEPRECATION_WARNING = 1 -endif - -" Prepare for calling test_garbagecollect_now(). -let v:testing = 1 - -" Support function: get the alloc ID by name. -func GetAllocId(name) - exe 'split ' . s:srcdir . '/alloc.h' - let top = search('typedef enum') - if top == 0 - call add(v:errors, 'typedef not found in alloc.h') - endif - let lnum = search('aid_' . a:name . ',') - if lnum == 0 - call add(v:errors, 'Alloc ID ' . a:name . ' not defined') - endif - close - return lnum - top - 1 -endfunc - -func RunTheTest(test) - echo 'Executing ' . a:test - if has('reltime') - let func_start = reltime() - endif - - " Avoid stopping at the "hit enter" prompt - set nomore - - " Avoid a three second wait when a message is about to be overwritten by the - " mode message. - set noshowmode - - " Some tests wipe out buffers. To be consistent, always wipe out all - " buffers. - %bwipe! - - " The test may change the current directory. Save and restore the - " directory after executing the test. - let save_cwd = getcwd() - - " Align Nvim defaults to Vim. - source setup.vim - - if exists("*SetUp") - try - call SetUp() - catch - call add(v:errors, 'Caught exception in SetUp() before ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) - endtry - endif - - au VimLeavePre * call EarlyExit(g:testfunc) - if a:test =~ 'Test_nocatch_' - " Function handles errors itself. This avoids skipping commands after the - " error. - let g:skipped_reason = '' - exe 'call ' . a:test - if g:skipped_reason != '' - call add(s:messages, ' Skipped') - call add(s:skipped, 'SKIPPED ' . a:test . ': ' . g:skipped_reason) - endif - else - try - exe 'call ' . a:test - catch /^\cskipped/ - call add(s:messages, ' Skipped') - call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) - catch - call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) - endtry - endif - au! VimLeavePre - - " In case 'insertmode' was set and something went wrong, make sure it is - " reset to avoid trouble with anything else. - set noinsertmode - - if exists("*TearDown") - try - call TearDown() - catch - call add(v:errors, 'Caught exception in TearDown() after ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) - endtry - endif - - " Clear any autocommands and put back the catch-all for SwapExists. - au! - au SwapExists * call HandleSwapExists() - - " Close any extra tab pages and windows and make the current one not modified. - while tabpagenr('$') > 1 - let winid = win_getid() - quit! - if winid == win_getid() - echoerr 'Could not quit window' - break - endif - endwhile - - while 1 - let wincount = winnr('$') - if wincount == 1 - break - endif - bwipe! - if wincount == winnr('$') - " Did not manage to close a window. - only! - break - endif - endwhile - - exe 'cd ' . save_cwd - - let message = 'Executed ' . a:test - if has('reltime') - let message ..= repeat(' ', 50 - len(message)) - let time = reltime(func_start) - if has('float') && reltimefloat(time) > 0.1 - let message = s:t_bold .. message - endif - let message ..= ' in ' .. reltimestr(time) .. ' seconds' - if has('float') && reltimefloat(time) > 0.1 - let message ..= s:t_normal - endif - endif - call add(s:messages, message) - let s:done += 1 -endfunc - -func AfterTheTest(func_name) - if len(v:errors) > 0 - if match(s:may_fail_list, '^' .. a:func_name) >= 0 - let s:fail_expected += 1 - call add(s:errors_expected, 'Found errors in ' . g:testfunc . ':') - call extend(s:errors_expected, v:errors) - else - let s:fail += 1 - call add(s:errors, 'Found errors in ' . g:testfunc . ':') - call extend(s:errors, v:errors) - endif - let v:errors = [] - endif -endfunc - -func EarlyExit(test) - " It's OK for the test we use to test the quit detection. - if a:test != 'Test_zz_quit_detected()' - call add(v:errors, v:errmsg) - call add(v:errors, 'Test caused Vim to exit: ' . a:test) - endif - - call FinishTesting() -endfunc - -" This function can be called by a test if it wants to abort testing. -func FinishTesting() - call AfterTheTest('') - - " Don't write viminfo on exit. - set viminfo= - - " Clean up files created by setup.vim - call delete('XfakeHOME', 'rf') - - if s:fail == 0 && s:fail_expected == 0 - " Success, create the .res file so that make knows it's done. - exe 'split ' . fnamemodify(g:testname, ':r') . '.res' - write - endif - - if len(s:errors) > 0 - " Append errors to test.log - split test.log - call append(line('$'), '') - call append(line('$'), 'From ' . g:testname . ':') - call append(line('$'), s:errors) - write - endif - - if s:done == 0 - if s:filtered > 0 - let message = "NO tests match $TEST_FILTER: '" .. $TEST_FILTER .. "'" - else - let message = 'NO tests executed' - endif - else - if s:filtered > 0 - call add(s:messages, "Filtered " .. s:filtered .. " tests with $TEST_FILTER") - endif - let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test') - endif - if s:done > 0 && has('reltime') - let message = s:t_bold .. message .. repeat(' ', 40 - len(message)) - let message ..= ' in ' .. reltimestr(reltime(s:start_time)) .. ' seconds' - let message ..= s:t_normal - endif - echo message - call add(s:messages, message) - if s:fail > 0 - let message = s:fail . ' FAILED:' - echo message - call add(s:messages, message) - call extend(s:messages, s:errors) - endif - if s:fail_expected > 0 - let message = s:fail_expected . ' FAILED (matching $TEST_MAY_FAIL):' - echo message - call add(s:messages, message) - call extend(s:messages, s:errors_expected) - endif - - " Add SKIPPED messages - call extend(s:messages, s:skipped) - - " Append messages to the file "messages" - split messages - call append(line('$'), '') - call append(line('$'), 'From ' . g:testname . ':') - call append(line('$'), s:messages) - write - - qall! -endfunc - -" Source the test script. First grab the file name, in case the script -" navigates away. g:testname can be used by the tests. -let g:testname = expand('%') -let s:done = 0 -let s:fail = 0 -let s:fail_expected = 0 -let s:errors = [] -let s:errors_expected = [] -let s:messages = [] -let s:skipped = [] -if expand('%') =~ 'test_vimscript.vim' - " this test has intentional errors, don't use try/catch. - source % -else - try - source % - catch /^\cskipped/ - call add(s:messages, ' Skipped') - call add(s:skipped, 'SKIPPED ' . expand('%') . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) - catch - let s:fail += 1 - call add(s:errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint) - endtry -endif - -" Names of flaky tests. -let s:flaky_tests = [ - \ 'Test_autocmd_SafeState()', - \ 'Test_cursorhold_insert()', - \ 'Test_exit_callback_interval()', - \ 'Test_map_timeout_with_timer_interrupt()', - \ 'Test_out_cb()', - \ 'Test_popup_and_window_resize()', - \ 'Test_quoteplus()', - \ 'Test_quotestar()', - \ 'Test_reltime()', - \ 'Test_state()', - \ 'Test_term_mouse_double_click_to_create_tab()', - \ 'Test_term_mouse_multiple_clicks_to_visually_select()', - \ 'Test_terminal_composing_unicode()', - \ 'Test_terminal_redir_file()', - \ 'Test_terminal_tmap()', - \ 'Test_timer_oneshot()', - \ 'Test_timer_paused()', - \ 'Test_timer_repeat_many()', - \ 'Test_timer_repeat_three()', - \ 'Test_timer_stop_all_in_callback()', - \ 'Test_timer_stop_in_callback()', - \ 'Test_timer_with_partial_callback()', - \ 'Test_termwinscroll()', - \ ] - -" Locate Test_ functions and execute them. -redir @q -silent function /^Test_ -redir END -let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g')) - -" If there is an extra argument filter the function names against it. -if argc() > 1 - let s:tests = filter(s:tests, 'v:val =~ argv(1)') -endif - -" If the environment variable $TEST_FILTER is set then filter the function -" names against it. -let s:filtered = 0 -if $TEST_FILTER != '' - let s:filtered = len(s:tests) - let s:tests = filter(s:tests, 'v:val =~ $TEST_FILTER') - let s:filtered -= len(s:tests) -endif - -let s:may_fail_list = [] -if $TEST_MAY_FAIL != '' - " Split the list at commas and add () to make it match g:testfunc. - let s:may_fail_list = split($TEST_MAY_FAIL, ',')->map({i, v -> v .. '()'}) -endif - -" Execute the tests in alphabetical order. -for g:testfunc in sort(s:tests) - " Silence, please! - set belloff=all - let prev_error = '' - let total_errors = [] - let g:run_nr = 1 - - " A test can set g:test_is_flaky to retry running the test. - let g:test_is_flaky = 0 - - call RunTheTest(g:testfunc) - - " Repeat a flaky test. Give up when: - " - $TEST_NO_RETRY is not empty - " - it fails again with the same message - " - it fails five times (with a different message) - if len(v:errors) > 0 - \ && $TEST_NO_RETRY == '' - \ && (index(s:flaky_tests, g:testfunc) >= 0 - \ || g:test_is_flaky) - while 1 - call add(s:messages, 'Found errors in ' . g:testfunc . ':') - call extend(s:messages, v:errors) - - call add(total_errors, 'Run ' . g:run_nr . ':') - call extend(total_errors, v:errors) - - if g:run_nr >= 5 || prev_error == v:errors[0] - call add(total_errors, 'Flaky test failed too often, giving up') - let v:errors = total_errors - break - endif - - call add(s:messages, 'Flaky test failed, running it again') - - " Flakiness is often caused by the system being very busy. Sleep a - " couple of seconds to have a higher chance of succeeding the second - " time. - sleep 2 - - let prev_error = v:errors[0] - let v:errors = [] - let g:run_nr += 1 - - call RunTheTest(g:testfunc) - - if len(v:errors) == 0 - " Test passed on rerun. - break - endif - endwhile - endif - - call AfterTheTest(g:testfunc) -endfor - -call FinishTesting() - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/samples/memfile_test.c b/src/nvim/testdir/samples/memfile_test.c deleted file mode 100644 index 73f67fb250..0000000000 --- a/src/nvim/testdir/samples/memfile_test.c +++ /dev/null @@ -1,148 +0,0 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - -// uncrustify:off - -/* vi:set ts=8 sts=4 sw=4 noet: - * - * VIM - Vi IMproved by Bram Moolenaar - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -/* - * memfile_test.c: Unittests for memfile.c - * Mostly by Ivan Krasilnikov. - */ - -#undef NDEBUG -#include - -/* Must include main.c because it contains much more than just main() */ -#define NO_VIM_MAIN -#include "main.c" - -/* This file has to be included because the tested functions are static */ -#include "memfile.c" - -#define index_to_key(i) ((i) ^ 15167) -#define TEST_COUNT 50000 - -/* - * Test mf_hash_*() functions. - */ - static void -test_mf_hash(void) -{ - mf_hashtab_T ht; - mf_hashitem_T *item; - blocknr_T key; - size_t i; - size_t num_buckets; - - mf_hash_init(&ht); - - /* insert some items and check invariants */ - for (i = 0; i < TEST_COUNT; i++) - { - assert(ht.mht_count == i); - - /* check that number of buckets is a power of 2 */ - num_buckets = ht.mht_mask + 1; - assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0); - - /* check load factor */ - assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR)); - - if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR)) - { - /* first expansion shouldn't have occurred yet */ - assert(num_buckets == MHT_INIT_SIZE); - assert(ht.mht_buckets == ht.mht_small_buckets); - } - else - { - assert(num_buckets > MHT_INIT_SIZE); - assert(ht.mht_buckets != ht.mht_small_buckets); - } - - key = index_to_key(i); - assert(mf_hash_find(&ht, key) == NULL); - - /* allocate and add new item */ - item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE); - assert(item != NULL); - item->mhi_key = key; - mf_hash_add_item(&ht, item); - - assert(mf_hash_find(&ht, key) == item); - - if (ht.mht_mask + 1 != num_buckets) - { - /* hash table was expanded */ - assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR); - assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR)); - } - } - - /* check presence of inserted items */ - for (i = 0; i < TEST_COUNT; i++) - { - key = index_to_key(i); - item = mf_hash_find(&ht, key); - assert(item != NULL); - assert(item->mhi_key == key); - } - - /* delete some items */ - for (i = 0; i < TEST_COUNT; i++) - { - if (i % 100 < 70) - { - key = index_to_key(i); - item = mf_hash_find(&ht, key); - assert(item != NULL); - assert(item->mhi_key == key); - - mf_hash_rem_item(&ht, item); - assert(mf_hash_find(&ht, key) == NULL); - - mf_hash_add_item(&ht, item); - assert(mf_hash_find(&ht, key) == item); - - mf_hash_rem_item(&ht, item); - assert(mf_hash_find(&ht, key) == NULL); - - vim_free(item); - } - } - - /* check again */ - for (i = 0; i < TEST_COUNT; i++) - { - key = index_to_key(i); - item = mf_hash_find(&ht, key); - - if (i % 100 < 70) - { - assert(item == NULL); - } - else - { - assert(item != NULL); - assert(item->mhi_key == key); - } - } - - /* free hash table and all remaining items */ - mf_hash_free_all(&ht); -} - - int -main(void) -{ - test_mf_hash(); - return 0; -} diff --git a/src/nvim/testdir/samples/quickfix.txt b/src/nvim/testdir/samples/quickfix.txt deleted file mode 100644 index 2de3835473..0000000000 --- a/src/nvim/testdir/samples/quickfix.txt +++ /dev/null @@ -1,4 +0,0 @@ -samples/quickfix.txt:1:1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -samples/quickfix.txt:2:1:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -samples/quickfix.txt:3:1:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc -samples/quickfix.txt:4:1:dddddddddd diff --git a/src/nvim/testdir/samples/re.freeze.txt b/src/nvim/testdir/samples/re.freeze.txt deleted file mode 100644 index d768c23c5e..0000000000 --- a/src/nvim/testdir/samples/re.freeze.txt +++ /dev/null @@ -1,6 +0,0 @@ -:set re=0 or 2 -Search for the pattern: /\s\+\%#\@55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 - diff --git a/src/nvim/testdir/sautest/autoload/foo.vim b/src/nvim/testdir/sautest/autoload/foo.vim deleted file mode 100644 index 21d33a0f4d..0000000000 --- a/src/nvim/testdir/sautest/autoload/foo.vim +++ /dev/null @@ -1,15 +0,0 @@ -let g:loaded_foo_vim += 1 - -let foo#bar = {} - -func foo#bar.echo() - let g:called_foo_bar_echo += 1 -endfunc - -func foo#addFoo(head) - return a:head .. 'foo' -endfunc - -func foo#() - return 'empty' -endfunc diff --git a/src/nvim/testdir/sautest/autoload/footest.vim b/src/nvim/testdir/sautest/autoload/footest.vim deleted file mode 100644 index 1e78963a10..0000000000 --- a/src/nvim/testdir/sautest/autoload/footest.vim +++ /dev/null @@ -1,5 +0,0 @@ -" Autoload script used by test_listdict.vim, test_exists.vim and test_let.vim -let footest#x = 1 -func footest#F() - return 0 -endfunc diff --git a/src/nvim/testdir/sautest/autoload/globone.vim b/src/nvim/testdir/sautest/autoload/globone.vim deleted file mode 100644 index 98c9a10582..0000000000 --- a/src/nvim/testdir/sautest/autoload/globone.vim +++ /dev/null @@ -1 +0,0 @@ -" used by Test_globpath() diff --git a/src/nvim/testdir/sautest/autoload/globtwo.vim b/src/nvim/testdir/sautest/autoload/globtwo.vim deleted file mode 100644 index 98c9a10582..0000000000 --- a/src/nvim/testdir/sautest/autoload/globtwo.vim +++ /dev/null @@ -1 +0,0 @@ -" used by Test_globpath() diff --git a/src/nvim/testdir/sautest/autoload/sourced.vim b/src/nvim/testdir/sautest/autoload/sourced.vim deleted file mode 100644 index f69f00cb53..0000000000 --- a/src/nvim/testdir/sautest/autoload/sourced.vim +++ /dev/null @@ -1,3 +0,0 @@ -let g:loaded_sourced_vim += 1 -func! sourced#something() -endfunc diff --git a/src/nvim/testdir/screendump.vim b/src/nvim/testdir/screendump.vim deleted file mode 100644 index 8afff1da91..0000000000 --- a/src/nvim/testdir/screendump.vim +++ /dev/null @@ -1,2 +0,0 @@ -source shared.vim -source term_util.vim diff --git a/src/nvim/testdir/script_util.vim b/src/nvim/testdir/script_util.vim deleted file mode 100644 index 28d6a621d6..0000000000 --- a/src/nvim/testdir/script_util.vim +++ /dev/null @@ -1,69 +0,0 @@ -" Functions shared by the tests for Vim Script - -" Commands to track the execution path of a script -com! XpathINIT let g:Xpath = '' -com! -nargs=1 -bar Xpath let g:Xpath ..= -com! XloopINIT let g:Xloop = 1 -com! -nargs=1 -bar Xloop let g:Xpath ..= .. g:Xloop -com! XloopNEXT let g:Xloop += 1 - -" MakeScript() - Make a script file from a function. {{{2 -" -" Create a script that consists of the body of the function a:funcname. -" Replace any ":return" by a ":finish", any argument variable by a global -" variable, and every ":call" by a ":source" for the next following argument -" in the variable argument list. This function is useful if similar tests are -" to be made for a ":return" from a function call or a ":finish" in a script -" file. -func MakeScript(funcname, ...) - let script = tempname() - execute "redir! >" . script - execute "function" a:funcname - redir END - execute "edit" script - " Delete the "function" and the "endfunction" lines. Do not include the - " word "function" in the pattern since it might be translated if LANG is - " set. When MakeScript() is being debugged, this deletes also the debugging - " output of its line 3 and 4. - exec '1,/.*' . a:funcname . '(.*)/d' - /^\d*\s*endfunction\>/,$d - %s/^\d*//e - %s/return/finish/e - %s/\ 0 - let cnt = cnt + 1 - s/\) - diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim deleted file mode 100644 index 25ac2d1239..0000000000 --- a/src/nvim/testdir/setup.vim +++ /dev/null @@ -1,85 +0,0 @@ -if exists('s:did_load') - " Align Nvim defaults to Vim. - set backspace= - set complete=.,w,b,u,t,i - set directory& - set directory^=. - set display= - set fillchars=vert:\|,foldsep:\|,fold:- - set formatoptions=tcq - set fsync - set laststatus=1 - set listchars=eol:$ - set joinspaces - set nohidden nosmarttab noautoindent noautoread noruler noshowcmd - set nohlsearch noincsearch - set nrformats=bin,octal,hex - set shortmess=filnxtToOS - set sidescroll=0 - set tags=./tags,tags - set undodir& - set undodir^=. - set wildoptions= - set startofline - set sessionoptions& - set sessionoptions+=options - set viewoptions& - set viewoptions+=options - set switchbuf= - if g:testname !~ 'test_mapping.vim$' - " Make "Q" switch to Ex mode. - " This does not work for all tests. - nnoremap Q gQ - endif -endif - -" Common preparations for running tests. - -" Only load this once. -if exists('s:did_load') - finish -endif -let s:did_load = 1 - -" Clear Nvim default mappings and menus. -mapclear -mapclear! -aunmenu * -tlunmenu * - -" roughly equivalent to test_setmouse() in Vim -func Ntest_setmouse(row, col) - call nvim_input_mouse('move', '', '', 0, a:row - 1, a:col - 1) -endfunc - -" Prevent Nvim log from writing to stderr. -let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' - - -" Make sure 'runtimepath' and 'packpath' does not include $HOME. -set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after -let &packpath = &rtp - -" Avoid storing shell history. -let $HISTFILE = "" - -" Use default shell on Windows to avoid segfault, caused by TUI -if has('win32') - let $SHELL = '' - let $TERM = '' - let &shell = empty($COMSPEC) ? exepath('cmd.exe') : $COMSPEC - set shellcmdflag=/s/c shellxquote=\" shellredir=>%s\ 2>&1 - let &shellpipe = &shellredir -endif - -" Detect user modules for language providers -let $PYTHONUSERBASE = $HOME . '/.local' -if executable('gem') - let $GEM_PATH = system('gem env gempath') -endif - -" Make sure $HOME does not get read or written. -let $HOME = expand(getcwd() . '/XfakeHOME') -if !isdirectory($HOME) - call mkdir($HOME) -endif diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim deleted file mode 100644 index 33f6d9a2d0..0000000000 --- a/src/nvim/testdir/shared.vim +++ /dev/null @@ -1,389 +0,0 @@ -" Functions shared by several tests. - -" Only load this script once. -if exists('*PythonProg') - finish -endif - -source view_util.vim - -" {Nvim} -" Filepath captured from output may be truncated, like this: -" /home/va...estdir/X-test-tmpdir/nvimxbXN4i/10 -" Get last 2 segments, then combine with $TMPDIR. -func! Fix_truncated_tmpfile(fname) - " sanity check - if $TMPDIR ==# '' - throw '$TMPDIR is empty' - endif - let tmpdir_tail = fnamemodify(substitute($TMPDIR, '[\/]\+$', '', 'g'), ':t') - if tmpdir_tail ==# '' - throw 'empty tmpdir_tail' - endif - if a:fname !~# tmpdir_tail - throw printf('$TMPDIR (%s) not in fname: %s', tmpdir_tail, a:fname) - endif - let last2segments = matchstr(a:fname, '[\/][^\/]\+[\/][^\/]\+$') - return $TMPDIR.last2segments -endfunc - -" Get the name of the Python executable. -" Also keeps it in s:python. -func PythonProg() - " This test requires the Python command to run the test server. - " This most likely only works on Unix and Windows. - if has('unix') - " We also need the job feature or the pkill command to make sure the server - " can be stopped. - if !(executable('python') && (has('job') || executable('pkill'))) - return '' - endif - let s:python = 'python' - elseif has('win32') - " Use Python Launcher for Windows (py.exe) if available. - if executable('py.exe') - let s:python = 'py.exe' - elseif executable('python.exe') - let s:python = 'python.exe' - else - return '' - endif - else - return '' - endif - return s:python -endfunc - -" Run "cmd". Returns the job if using a job. -func RunCommand(cmd) - " Running an external command can occasionally be slow or fail. - let g:test_is_flaky = 1 - - let job = 0 - if has('job') - let job = job_start(a:cmd, {"stoponexit": "hup"}) - call job_setoptions(job, {"stoponexit": "kill"}) - elseif has('win32') - exe 'silent !start cmd /c start "test_channel" ' . a:cmd - else - exe 'silent !' . a:cmd . '&' - endif - return job -endfunc - -" Read the port number from the Xportnr file. -func GetPort() - let l = [] - " with 200 it sometimes failed - for i in range(400) - try - let l = readfile("Xportnr") - catch - endtry - if len(l) >= 1 - break - endif - sleep 10m - endfor - call delete("Xportnr") - - if len(l) == 0 - " Can't make the connection, give up. - return 0 - endif - return l[0] -endfunc - -" Run a Python server for "cmd" and call "testfunc". -" Always kills the server before returning. -func RunServer(cmd, testfunc, args) - " The Python program writes the port number in Xportnr. - call delete("Xportnr") - - if len(a:args) == 1 - let arg = ' ' . a:args[0] - else - let arg = '' - endif - let pycmd = s:python . " " . a:cmd . arg - - try - let g:currentJob = RunCommand(pycmd) - - " Wait for up to 2 seconds for the port number to be there. - let port = GetPort() - if port == 0 - call assert_false(1, "Can't start " . a:cmd) - return - endif - - call call(function(a:testfunc), [port]) - catch - call assert_false(1, 'Caught exception: "' . v:exception . '" in ' . v:throwpoint) - finally - call s:kill_server(a:cmd) - endtry -endfunc - -func s:kill_server(cmd) - if has('job') - if exists('g:currentJob') - call job_stop(g:currentJob) - unlet g:currentJob - endif - elseif has('win32') - let cmd = substitute(a:cmd, ".py", '', '') - call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"') - else - call system("pkill -f " . a:cmd) - endif -endfunc - -" Wait for up to five seconds for "expr" to become true. "expr" can be a -" stringified expression to evaluate, or a funcref without arguments. -" Using a lambda works best. Example: -" call WaitFor({-> status == "ok"}) -" -" A second argument can be used to specify a different timeout in msec. -" -" When successful the time slept is returned. -" When running into the timeout an exception is thrown, thus the function does -" not return. -func WaitFor(expr, ...) - let timeout = get(a:000, 0, 5000) - let slept = s:WaitForCommon(a:expr, v:null, timeout) - if slept < 0 - throw 'WaitFor() timed out after ' . timeout . ' msec' - endif - return slept -endfunc - -" Wait for up to five seconds for "assert" to return zero. "assert" must be a -" (lambda) function containing one assert function. Example: -" call WaitForAssert({-> assert_equal("dead", job_status(job)}) -" -" A second argument can be used to specify a different timeout in msec. -" -" Return zero for success, one for failure (like the assert function). -func WaitForAssert(assert, ...) - let timeout = get(a:000, 0, 5000) - if s:WaitForCommon(v:null, a:assert, timeout) < 0 - return 1 - endif - return 0 -endfunc - -" Common implementation of WaitFor() and WaitForAssert(). -" Either "expr" or "assert" is not v:null -" Return the waiting time for success, -1 for failure. -func s:WaitForCommon(expr, assert, timeout) - " using reltime() is more accurate, but not always available - let slept = 0 - if exists('*reltimefloat') - let start = reltime() - endif - - while 1 - if type(a:expr) == v:t_func - let success = a:expr() - elseif type(a:assert) == v:t_func - let success = a:assert() == 0 - else - let success = eval(a:expr) - endif - if success - return slept - endif - - if slept >= a:timeout - break - endif - if type(a:assert) == v:t_func - " Remove the error added by the assert function. - call remove(v:errors, -1) - endif - - sleep 10m - if exists('*reltimefloat') - let slept = float2nr(reltimefloat(reltime(start)) * 1000) - else - let slept += 10 - endif - endwhile - - return -1 " timed out -endfunc - - -" Wait for up to a given milliseconds. -" With the +timers feature this waits for key-input by getchar(), Resume() -" feeds key-input and resumes process. Return time waited in milliseconds. -" Without +timers it uses simply :sleep. -func Standby(msec) - if has('timers') && exists('*reltimefloat') - let start = reltime() - let g:_standby_timer = timer_start(a:msec, function('s:feedkeys')) - call getchar() - return float2nr(reltimefloat(reltime(start)) * 1000) - else - execute 'sleep ' a:msec . 'm' - return a:msec - endif -endfunc - -func Resume() - if exists('g:_standby_timer') - call timer_stop(g:_standby_timer) - call s:feedkeys(0) - unlet g:_standby_timer - endif -endfunc - -func s:feedkeys(timer) - call feedkeys('x', 'nt') -endfunc - -" Get $VIMPROG to run the Vim executable. -" The Makefile writes it as the first line in the "vimcmd" file. -" Nvim: uses $NVIM_TEST_ARG0. -func GetVimProg() - if empty($NVIM_TEST_ARG0) - " Assume the script was sourced instead of running "make". - return v:progpath - endif - if has('win32') - return substitute($NVIM_TEST_ARG0, '/', '\\', 'g') - else - return $NVIM_TEST_ARG0 - endif -endfunc - -let g:valgrind_cnt = 1 - -" Get the command to run Vim, with -u NONE and --headless arguments. -" If there is an argument use it instead of "NONE". -func GetVimCommand(...) - if a:0 == 0 - let name = 'NONE' - else - let name = a:1 - endif - let cmd = GetVimProg() - let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '') - if cmd !~ '-u '. name - let cmd = cmd . ' -u ' . name - endif - let cmd .= ' --headless -i NONE' - let cmd = substitute(cmd, 'VIMRUNTIME=\S\+', '', '') - - " If using valgrind, make sure every run uses a different log file. - if cmd =~ 'valgrind.*--log-file=' - let cmd = substitute(cmd, '--log-file=\(\S*\)', '--log-file=\1.' . g:valgrind_cnt, '') - let g:valgrind_cnt += 1 - endif - - return cmd -endfunc - -" Return one when it looks like the tests are run with valgrind, which means -" that everything is much slower. -func RunningWithValgrind() - return GetVimCommand() =~ '\' -endfunc - -" Get the command to run Vim, with --clean instead of "-u NONE". -func GetVimCommandClean() - let cmd = GetVimCommand() - let cmd = substitute(cmd, '-u NONE', '--clean', '') - let cmd = substitute(cmd, '--headless', '', '') - - " Force using utf-8, Vim may pick up something else from the environment. - " let cmd ..= ' --cmd "set enc=utf8" ' - - " Optionally run Vim under valgrind - " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd - - return cmd -endfunc - -" Get the command to run Vim, with --clean, and force to run in terminal so it -" won't start a new GUI. -func GetVimCommandCleanTerm() - " Add -v to have gvim run in the terminal (if possible) - return GetVimCommandClean() .. ' -v ' -endfunc - -" Run Vim, using the "vimcmd" file and "-u NORC". -" "before" is a list of Vim commands to be executed before loading plugins. -" "after" is a list of Vim commands to be executed after loading plugins. -" Plugins are not loaded, unless 'loadplugins' is set in "before". -" Return 1 if Vim could be executed. -func RunVim(before, after, arguments) - return RunVimPiped(a:before, a:after, a:arguments, '') -endfunc - -func RunVimPiped(before, after, arguments, pipecmd) - let cmd = GetVimCommand() - let args = '' - if len(a:before) > 0 - call writefile(a:before, 'Xbefore.vim') - let args .= ' --cmd "so Xbefore.vim"' - endif - if len(a:after) > 0 - call writefile(a:after, 'Xafter.vim') - let args .= ' -S Xafter.vim' - endif - - " Optionally run Vim under valgrind - " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd - - let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' - " Nvim does not support -Z flag, remove it. - exe "silent !" . a:pipecmd . cmd . args . ' ' . substitute(a:arguments, '-Z', '', 'g') - - if len(a:before) > 0 - call delete('Xbefore.vim') - endif - if len(a:after) > 0 - call delete('Xafter.vim') - endif - return 1 -endfunc - -func IsRoot() - if !has('unix') - return v:false - elseif $USER == 'root' || system('id -un') =~ '\' - return v:true - endif - return v:false -endfunc - -" Get all messages but drop the maintainer entry. -func GetMessages() - redir => result - redraw | messages - redir END - let msg_list = split(result, "\n") - " if msg_list->len() > 0 && msg_list[0] =~ 'Messages maintainer:' - " return msg_list[1:] - " endif - return msg_list -endfunc - -" Run the list of commands in 'cmds' and look for 'errstr' in exception. -" Note that assert_fails() cannot be used in some places and this function -" can be used. -func AssertException(cmds, errstr) - let save_exception = '' - try - for cmd in a:cmds - exe cmd - endfor - catch - let save_exception = v:exception - endtry - call assert_match(a:errstr, save_exception) -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/suite.sh b/src/nvim/testdir/suite.sh deleted file mode 100644 index bf5a16fd89..0000000000 --- a/src/nvim/testdir/suite.sh +++ /dev/null @@ -1,10 +0,0 @@ -fail() { - local test_name="$1" - local message="$2" - - : "${message:=Test $test_name failed}" - - local full_msg="$test_name :: $message" - echo "Failed: $full_msg" - export FAILED=1 -} diff --git a/src/nvim/testdir/summarize.vim b/src/nvim/testdir/summarize.vim deleted file mode 100644 index da5856a2e7..0000000000 --- a/src/nvim/testdir/summarize.vim +++ /dev/null @@ -1,62 +0,0 @@ -set cpo&vim -if 1 - " This is executed only with the eval feature - set nocompatible - set viminfo= - func Count(match, type) - if a:type ==# 'executed' - let g:executed += (a:match+0) - elseif a:type ==# 'failed' - let g:failed += a:match+0 - elseif a:type ==# 'skipped' - let g:skipped += 1 - call extend(g:skipped_output, ["\t" .. a:match]) - endif - endfunc - - let g:executed = 0 - let g:skipped = 0 - let g:failed = 0 - let g:skipped_output = [] - let g:failed_output = [] - let output = [""] - - if $TEST_FILTER != '' - call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"]) - endif - - try - " This uses the :s command to just fetch and process the output of the - " tests, it doesn't actually replace anything. - " And it uses "silent" to avoid reporting the number of matches. - silent %s/Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn - silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn - silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn - - call extend(output, ["Skipped:"]) - call extend(output, skipped_output) - - call extend(output, [ - \ "", - \ "-------------------------------", - \ printf("Executed: %5d Tests", g:executed), - \ printf(" Skipped: %5d Tests", g:skipped), - \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed), - \ "", - \ ]) - if filereadable('test.log') - " outputs and indents the failed test result - call extend(output, ["", "Failures: "]) - let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)}) - call extend(output, map(failed_output, { v,k -> "\t".k})) - " Add a final newline - call extend(output, [""]) - endif - - catch " Catch-all - finally - call writefile(output, 'test_result.log') " overwrites an existing file - endtry -endif - -q! diff --git a/src/nvim/testdir/term_util.vim b/src/nvim/testdir/term_util.vim deleted file mode 100644 index 5ff09e25b4..0000000000 --- a/src/nvim/testdir/term_util.vim +++ /dev/null @@ -1,13 +0,0 @@ -" Functions about terminal shared by several tests - -" Only load this script once. -if exists('*CanRunVimInTerminal') - finish -endif - -func CanRunVimInTerminal() - " Nvim: always false, we use Lua screen-tests instead. - return 0 -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test.sh b/src/nvim/testdir/test.sh deleted file mode 100644 index affdc308d1..0000000000 --- a/src/nvim/testdir/test.sh +++ /dev/null @@ -1,91 +0,0 @@ -fail() { - local test_name="$1" - local message="$2" - - : "${message:=Test $test_name failed}" - - local full_msg="$test_name :: $message" - echo "Failed: $full_msg" - export FAILED=1 -} - -print_core() { - local app="$1" - local core="$2" - if test "$app" = quiet ; then - echo "Found core $core" - return 0 - fi - echo "======= Core file $core =======" - if test "${CI_OS_NAME}" = osx ; then - lldb -Q -o "bt all" -f "${app}" -c "${core}" - else - gdb -n -batch -ex 'thread apply all bt full' "${app}" -c "${core}" - fi -} - -check_core_dumps() { - local del= - if test "$1" = "--delete" ; then - del=1 - shift - fi - local app="${1:-${BUILD_DIR}/bin/nvim}" - local cores - if test "${CI_OS_NAME}" = osx ; then - cores="$(find /cores/ -type f -print)" - local _sudo='sudo' - else - cores="$(find ./ -type f \( -name 'core.*' -o -name core -o -name nvim.core \) -print)" - local _sudo= - fi - - if test -z "${cores}" ; then - return - fi - local core - for core in $cores; do - if test "$del" = "1" ; then - print_core "$app" "$core" >&2 - "$_sudo" rm "$core" - else - print_core "$app" "$core" - fi - done - if test "$app" != quiet ; then - fail 'cores' 'Core dumps found' - fi -} - -check_logs() { - # Iterate through each log to remove an useless warning. - # shellcheck disable=SC2044 - for log in $(find "${1}" -type f -name "${2}"); do - sed -i "${log}" \ - -e '/Warning: noted but unhandled ioctl/d' \ - -e '/could cause spurious value errors to appear/d' \ - -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d' - done - - # Now do it again, but only consider files with size > 0. - local err="" - # shellcheck disable=SC2044 - for log in $(find "${1}" -type f -name "${2}" -size +0); do - cat "${log}" - err=1 - rm "${log}" - done - if test -n "${err}" ; then - fail 'logs' 'Runtime errors detected.' - fi -} - -valgrind_check() { - check_logs "${1}" "valgrind-*" -} - -check_sanitizer() { - if test -n "${CLANG_SANITIZER}"; then - check_logs "${1}" "*san.*" | cat - fi -} diff --git a/src/nvim/testdir/test1.in b/src/nvim/testdir/test1.in deleted file mode 100644 index 272500cd25..0000000000 --- a/src/nvim/testdir/test1.in +++ /dev/null @@ -1,13 +0,0 @@ -First a simple test to check if the test script works. - -STARTTEST -:" If columns or lines are too small, create wrongtermsize. -:" (Some tests will fail. When columns and/or lines are small) -:if &lines < 24 || &columns < 80 | sp another | w! wrongtermsize | qa! | endif -:" -:" Write a single line to test.out to check if testing works at all. -:%d -athis is a test:w! test.out -:qa! -ENDTEST - diff --git a/src/nvim/testdir/test1.ok b/src/nvim/testdir/test1.ok deleted file mode 100644 index 90bfcb5106..0000000000 --- a/src/nvim/testdir/test1.ok +++ /dev/null @@ -1 +0,0 @@ -this is a test diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim deleted file mode 100644 index a3d240f27e..0000000000 --- a/src/nvim/testdir/test_alot.vim +++ /dev/null @@ -1,31 +0,0 @@ -" A series of tests that can run in one Vim invocation. -" This makes testing go faster, since Vim doesn't need to restart. - -source test_backup.vim -source test_behave.vim -source test_compiler.vim -source test_ex_equal.vim -source test_ex_undo.vim -source test_ex_z.vim -source test_ex_mode.vim -source test_expand.vim -source test_expand_func.vim -source test_file_perm.vim -source test_fnamemodify.vim -source test_ga.vim -source test_glob2regpat.vim -source test_global.vim -source test_move.vim -source test_put.vim -source test_reltime.vim -source test_scroll_opt.vim -source test_searchpos.vim -source test_set.vim -source test_shift.vim -source test_sha256.vim -source test_tabline.vim -source test_tagcase.vim -source test_tagfunc.vim -source test_unlet.vim -source test_version.vim -source test_wnext.vim diff --git a/src/nvim/testdir/test_alot_latin.vim b/src/nvim/testdir/test_alot_latin.vim deleted file mode 100644 index 23a404cac1..0000000000 --- a/src/nvim/testdir/test_alot_latin.vim +++ /dev/null @@ -1,7 +0,0 @@ -" A series of tests that can run in one Vim invocation. -" This makes testing go faster, since Vim doesn't need to restart. - -" These tests use latin1 'encoding'. Setting 'encoding' is in the individual -" files, so that they can be run by themselves. - -source test_regexp_latin.vim diff --git a/src/nvim/testdir/test_alot_utf8.vim b/src/nvim/testdir/test_alot_utf8.vim deleted file mode 100644 index 77f5ede4c8..0000000000 --- a/src/nvim/testdir/test_alot_utf8.vim +++ /dev/null @@ -1,14 +0,0 @@ -" A series of tests that can run in one Vim invocation. -" This makes testing go faster, since Vim doesn't need to restart. - -" These tests use utf8 'encoding'. Setting 'encoding' is already done in -" runtest.vim. - -source test_charsearch_utf8.vim -source test_expr_utf8.vim -source test_mksession_utf8.vim -source test_regexp_utf8.vim -source test_source_utf8.vim -source test_startup_utf8.vim -source test_utf8.vim -source test_utf8_comparisons.vim diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim deleted file mode 100644 index 272937387d..0000000000 --- a/src/nvim/testdir/test_arabic.vim +++ /dev/null @@ -1,587 +0,0 @@ -" Simplistic testing of Arabic mode. -" NOTE: This just checks if the code works. If you know Arabic please add -" functional tests that check the shaping works with real text. - -source check.vim -CheckFeature arabic - -source view_util.vim - -" Return list of Unicode characters at line lnum. -" Combining characters are treated as a single item. -func s:get_chars(lnum) - call cursor(a:lnum, 1) - let chars = [] - let numchars = strchars(getline('.'), 1) - for i in range(1, numchars) - exe 'norm ' i . '|' - let c = execute('ascii') - let c = substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g') - let c = substitute(c, ',\s*Oct\(al\)\=\s\d*\(, Digr ..\)\=', '', 'g') - call add(chars, c) - endfor - return chars -endfunc - -func Test_arabic_toggle() - set arabic - call assert_equal(1, &rightleft) - call assert_equal(1, &arabicshape) - call assert_equal('arabic', &keymap) - call assert_equal(1, &delcombine) - - set iminsert=1 imsearch=1 - set arabic& - call assert_equal(0, &rightleft) - call assert_equal(1, &arabicshape) - call assert_equal('arabic', &keymap) - call assert_equal(1, &delcombine) - call assert_equal(0, &iminsert) - call assert_equal(-1, &imsearch) - - set arabicshape& keymap= delcombine& -endfunc - -func Test_arabic_input() - new - set arabic - " Typing sghl in Arabic insert mode should show the - " Arabic word 'Salaam' i.e. 'peace', spelled: - " SEEN, LAM, ALEF, MEEM. - " See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left - call feedkeys('isghl!', 'tx') - call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0]) - call assert_equal([ - \ 'U+0633', - \ 'U+0644 U+0627', - \ 'U+0645', - \ 'U+21'], s:get_chars(1)) - - " Without shaping, it should give individual Arabic letters. - set noarabicshape - call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, &columns)[0]) - call assert_equal([ - \ 'U+0633', - \ 'U+0644', - \ 'U+0627', - \ 'U+0645', - \ 'U+21'], s:get_chars(1)) - - set arabic& arabicshape& - bwipe! -endfunc - -func Test_arabic_toggle_keymap() - new - set arabic - call feedkeys("i12\12\12", 'tx') - call assert_match("^ *٢١21٢١$", ScreenLines(1, &columns)[0]) - call assert_equal('١٢12١٢', getline('.')) - set arabic& - bwipe! -endfunc - -func Test_delcombine() - new - set arabic - call feedkeys("isghl\\", 'tx') - call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0]) - call assert_equal(['U+0633', 'U+0644'], s:get_chars(1)) - - " Now the same with 'nodelcombine' - set nodelcombine - %d - call feedkeys("isghl\\", 'tx') - call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0]) - call assert_equal(['U+0633'], s:get_chars(1)) - set arabic& - bwipe! -endfunc - -" Values from src/arabic.h (not all used yet) -let s:a_COMMA = "\u060C" -let s:a_SEMICOLON = "\u061B" -let s:a_QUESTION = "\u061F" -let s:a_HAMZA = "\u0621" -let s:a_ALEF_MADDA = "\u0622" -let s:a_ALEF_HAMZA_ABOVE = "\u0623" -let s:a_WAW_HAMZA = "\u0624" -let s:a_ALEF_HAMZA_BELOW = "\u0625" -let s:a_YEH_HAMZA = "\u0626" -let s:a_ALEF = "\u0627" -let s:a_BEH = "\u0628" -let s:a_TEH_MARBUTA = "\u0629" -let s:a_TEH = "\u062a" -let s:a_THEH = "\u062b" -let s:a_JEEM = "\u062c" -let s:a_HAH = "\u062d" -let s:a_KHAH = "\u062e" -let s:a_DAL = "\u062f" -let s:a_THAL = "\u0630" -let s:a_REH = "\u0631" -let s:a_ZAIN = "\u0632" -let s:a_SEEN = "\u0633" -let s:a_SHEEN = "\u0634" -let s:a_SAD = "\u0635" -let s:a_DAD = "\u0636" -let s:a_TAH = "\u0637" -let s:a_ZAH = "\u0638" -let s:a_AIN = "\u0639" -let s:a_GHAIN = "\u063a" -let s:a_TATWEEL = "\u0640" -let s:a_FEH = "\u0641" -let s:a_QAF = "\u0642" -let s:a_KAF = "\u0643" -let s:a_LAM = "\u0644" -let s:a_MEEM = "\u0645" -let s:a_NOON = "\u0646" -let s:a_HEH = "\u0647" -let s:a_WAW = "\u0648" -let s:a_ALEF_MAKSURA = "\u0649" -let s:a_YEH = "\u064a" - -let s:a_FATHATAN = "\u064b" -let s:a_DAMMATAN = "\u064c" -let s:a_KASRATAN = "\u064d" -let s:a_FATHA = "\u064e" -let s:a_DAMMA = "\u064f" -let s:a_KASRA = "\u0650" -let s:a_SHADDA = "\u0651" -let s:a_SUKUN = "\u0652" - -let s:a_MADDA_ABOVE = "\u0653" -let s:a_HAMZA_ABOVE = "\u0654" -let s:a_HAMZA_BELOW = "\u0655" - -let s:a_ZERO = "\u0660" -let s:a_ONE = "\u0661" -let s:a_TWO = "\u0662" -let s:a_THREE = "\u0663" -let s:a_FOUR = "\u0664" -let s:a_FIVE = "\u0665" -let s:a_SIX = "\u0666" -let s:a_SEVEN = "\u0667" -let s:a_EIGHT = "\u0668" -let s:a_NINE = "\u0669" -let s:a_PERCENT = "\u066a" -let s:a_DECIMAL = "\u066b" -let s:a_THOUSANDS = "\u066c" -let s:a_STAR = "\u066d" -let s:a_MINI_ALEF = "\u0670" - -let s:a_s_FATHATAN = "\ufe70" -let s:a_m_TATWEEL_FATHATAN = "\ufe71" -let s:a_s_DAMMATAN = "\ufe72" - -let s:a_s_KASRATAN = "\ufe74" - -let s:a_s_FATHA = "\ufe76" -let s:a_m_FATHA = "\ufe77" -let s:a_s_DAMMA = "\ufe78" -let s:a_m_DAMMA = "\ufe79" -let s:a_s_KASRA = "\ufe7a" -let s:a_m_KASRA = "\ufe7b" -let s:a_s_SHADDA = "\ufe7c" -let s:a_m_SHADDA = "\ufe7d" -let s:a_s_SUKUN = "\ufe7e" -let s:a_m_SUKUN = "\ufe7f" - -let s:a_s_HAMZA = "\ufe80" -let s:a_s_ALEF_MADDA = "\ufe81" -let s:a_f_ALEF_MADDA = "\ufe82" -let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83" -let s:a_f_ALEF_HAMZA_ABOVE = "\ufe84" -let s:a_s_WAW_HAMZA = "\ufe85" -let s:a_f_WAW_HAMZA = "\ufe86" -let s:a_s_ALEF_HAMZA_BELOW = "\ufe87" -let s:a_f_ALEF_HAMZA_BELOW = "\ufe88" -let s:a_s_YEH_HAMZA = "\ufe89" -let s:a_f_YEH_HAMZA = "\ufe8a" -let s:a_i_YEH_HAMZA = "\ufe8b" -let s:a_m_YEH_HAMZA = "\ufe8c" -let s:a_s_ALEF = "\ufe8d" -let s:a_f_ALEF = "\ufe8e" -let s:a_s_BEH = "\ufe8f" -let s:a_f_BEH = "\ufe90" -let s:a_i_BEH = "\ufe91" -let s:a_m_BEH = "\ufe92" -let s:a_s_TEH_MARBUTA = "\ufe93" -let s:a_f_TEH_MARBUTA = "\ufe94" -let s:a_s_TEH = "\ufe95" -let s:a_f_TEH = "\ufe96" -let s:a_i_TEH = "\ufe97" -let s:a_m_TEH = "\ufe98" -let s:a_s_THEH = "\ufe99" -let s:a_f_THEH = "\ufe9a" -let s:a_i_THEH = "\ufe9b" -let s:a_m_THEH = "\ufe9c" -let s:a_s_JEEM = "\ufe9d" -let s:a_f_JEEM = "\ufe9e" -let s:a_i_JEEM = "\ufe9f" -let s:a_m_JEEM = "\ufea0" -let s:a_s_HAH = "\ufea1" -let s:a_f_HAH = "\ufea2" -let s:a_i_HAH = "\ufea3" -let s:a_m_HAH = "\ufea4" -let s:a_s_KHAH = "\ufea5" -let s:a_f_KHAH = "\ufea6" -let s:a_i_KHAH = "\ufea7" -let s:a_m_KHAH = "\ufea8" -let s:a_s_DAL = "\ufea9" -let s:a_f_DAL = "\ufeaa" -let s:a_s_THAL = "\ufeab" -let s:a_f_THAL = "\ufeac" -let s:a_s_REH = "\ufead" -let s:a_f_REH = "\ufeae" -let s:a_s_ZAIN = "\ufeaf" -let s:a_f_ZAIN = "\ufeb0" -let s:a_s_SEEN = "\ufeb1" -let s:a_f_SEEN = "\ufeb2" -let s:a_i_SEEN = "\ufeb3" -let s:a_m_SEEN = "\ufeb4" -let s:a_s_SHEEN = "\ufeb5" -let s:a_f_SHEEN = "\ufeb6" -let s:a_i_SHEEN = "\ufeb7" -let s:a_m_SHEEN = "\ufeb8" -let s:a_s_SAD = "\ufeb9" -let s:a_f_SAD = "\ufeba" -let s:a_i_SAD = "\ufebb" -let s:a_m_SAD = "\ufebc" -let s:a_s_DAD = "\ufebd" -let s:a_f_DAD = "\ufebe" -let s:a_i_DAD = "\ufebf" -let s:a_m_DAD = "\ufec0" -let s:a_s_TAH = "\ufec1" -let s:a_f_TAH = "\ufec2" -let s:a_i_TAH = "\ufec3" -let s:a_m_TAH = "\ufec4" -let s:a_s_ZAH = "\ufec5" -let s:a_f_ZAH = "\ufec6" -let s:a_i_ZAH = "\ufec7" -let s:a_m_ZAH = "\ufec8" -let s:a_s_AIN = "\ufec9" -let s:a_f_AIN = "\ufeca" -let s:a_i_AIN = "\ufecb" -let s:a_m_AIN = "\ufecc" -let s:a_s_GHAIN = "\ufecd" -let s:a_f_GHAIN = "\ufece" -let s:a_i_GHAIN = "\ufecf" -let s:a_m_GHAIN = "\ufed0" -let s:a_s_FEH = "\ufed1" -let s:a_f_FEH = "\ufed2" -let s:a_i_FEH = "\ufed3" -let s:a_m_FEH = "\ufed4" -let s:a_s_QAF = "\ufed5" -let s:a_f_QAF = "\ufed6" -let s:a_i_QAF = "\ufed7" -let s:a_m_QAF = "\ufed8" -let s:a_s_KAF = "\ufed9" -let s:a_f_KAF = "\ufeda" -let s:a_i_KAF = "\ufedb" -let s:a_m_KAF = "\ufedc" -let s:a_s_LAM = "\ufedd" -let s:a_f_LAM = "\ufede" -let s:a_i_LAM = "\ufedf" -let s:a_m_LAM = "\ufee0" -let s:a_s_MEEM = "\ufee1" -let s:a_f_MEEM = "\ufee2" -let s:a_i_MEEM = "\ufee3" -let s:a_m_MEEM = "\ufee4" -let s:a_s_NOON = "\ufee5" -let s:a_f_NOON = "\ufee6" -let s:a_i_NOON = "\ufee7" -let s:a_m_NOON = "\ufee8" -let s:a_s_HEH = "\ufee9" -let s:a_f_HEH = "\ufeea" -let s:a_i_HEH = "\ufeeb" -let s:a_m_HEH = "\ufeec" -let s:a_s_WAW = "\ufeed" -let s:a_f_WAW = "\ufeee" -let s:a_s_ALEF_MAKSURA = "\ufeef" -let s:a_f_ALEF_MAKSURA = "\ufef0" -let s:a_s_YEH = "\ufef1" -let s:a_f_YEH = "\ufef2" -let s:a_i_YEH = "\ufef3" -let s:a_m_YEH = "\ufef4" -let s:a_s_LAM_ALEF_MADDA_ABOVE = "\ufef5" -let s:a_f_LAM_ALEF_MADDA_ABOVE = "\ufef6" -let s:a_s_LAM_ALEF_HAMZA_ABOVE = "\ufef7" -let s:a_f_LAM_ALEF_HAMZA_ABOVE = "\ufef8" -let s:a_s_LAM_ALEF_HAMZA_BELOW = "\ufef9" -let s:a_f_LAM_ALEF_HAMZA_BELOW = "\ufefa" -let s:a_s_LAM_ALEF = "\ufefb" -let s:a_f_LAM_ALEF = "\ufefc" - -let s:a_BYTE_ORDER_MARK = "\ufeff" - -func Test_shape_initial() - new - set arabicshape - - " Shaping arabic {testchar} non-arabic Tests chg_c_a2i(). - " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result - for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA], - \ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA], - \ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA], - \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE], - \ [s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_s_WAW_HAMZA], - \ [s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_BELOW], - \ [s:a_ALEF, s:a_s_GHAIN, s:a_s_ALEF], - \ [s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_s_TEH_MARBUTA], - \ [s:a_DAL, s:a_s_GHAIN, s:a_s_DAL], - \ [s:a_THAL, s:a_s_GHAIN, s:a_s_THAL], - \ [s:a_REH, s:a_s_GHAIN, s:a_s_REH], - \ [s:a_ZAIN, s:a_s_GHAIN, s:a_s_ZAIN], - \ [s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL], - \ [s:a_WAW, s:a_s_GHAIN, s:a_s_WAW], - \ [s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_s_ALEF_MAKSURA], - \ [s:a_BEH, s:a_f_GHAIN, s:a_i_BEH], - \ [s:a_TEH, s:a_f_GHAIN, s:a_i_TEH], - \ [s:a_THEH, s:a_f_GHAIN, s:a_i_THEH], - \ [s:a_JEEM, s:a_f_GHAIN, s:a_i_JEEM], - \ [s:a_HAH, s:a_f_GHAIN, s:a_i_HAH], - \ [s:a_KHAH, s:a_f_GHAIN, s:a_i_KHAH], - \ [s:a_SEEN, s:a_f_GHAIN, s:a_i_SEEN], - \ [s:a_SHEEN, s:a_f_GHAIN, s:a_i_SHEEN], - \ [s:a_SAD, s:a_f_GHAIN, s:a_i_SAD], - \ [s:a_DAD, s:a_f_GHAIN, s:a_i_DAD], - \ [s:a_TAH, s:a_f_GHAIN, s:a_i_TAH], - \ [s:a_ZAH, s:a_f_GHAIN, s:a_i_ZAH], - \ [s:a_AIN, s:a_f_GHAIN, s:a_i_AIN], - \ [s:a_GHAIN, s:a_f_GHAIN, s:a_i_GHAIN], - \ [s:a_FEH, s:a_f_GHAIN, s:a_i_FEH], - \ [s:a_QAF, s:a_f_GHAIN, s:a_i_QAF], - \ [s:a_KAF, s:a_f_GHAIN, s:a_i_KAF], - \ [s:a_LAM, s:a_f_GHAIN, s:a_i_LAM], - \ [s:a_MEEM, s:a_f_GHAIN, s:a_i_MEEM], - \ [s:a_NOON, s:a_f_GHAIN, s:a_i_NOON], - \ [s:a_HEH, s:a_f_GHAIN, s:a_i_HEH], - \ [s:a_YEH, s:a_f_GHAIN, s:a_i_YEH], - \ ] - call setline(1, s:a_GHAIN . pair[0] . ' ') - call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -func Test_shape_isolated() - new - set arabicshape - - " Shaping non-arabic {testchar} non-arabic Tests chg_c_a2s(). - " pair[0] = testchar, pair[1] = current-result - for pair in [[s:a_HAMZA, s:a_s_HAMZA], - \ [s:a_ALEF_MADDA, s:a_s_ALEF_MADDA], - \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_ALEF_HAMZA_ABOVE], - \ [s:a_WAW_HAMZA, s:a_s_WAW_HAMZA], - \ [s:a_ALEF_HAMZA_BELOW, s:a_s_ALEF_HAMZA_BELOW], - \ [s:a_YEH_HAMZA, s:a_s_YEH_HAMZA], - \ [s:a_ALEF, s:a_s_ALEF], - \ [s:a_TEH_MARBUTA, s:a_s_TEH_MARBUTA], - \ [s:a_DAL, s:a_s_DAL], - \ [s:a_THAL, s:a_s_THAL], - \ [s:a_REH, s:a_s_REH], - \ [s:a_ZAIN, s:a_s_ZAIN], - \ [s:a_TATWEEL, s:a_TATWEEL], - \ [s:a_WAW, s:a_s_WAW], - \ [s:a_ALEF_MAKSURA, s:a_s_ALEF_MAKSURA], - \ [s:a_BEH, s:a_s_BEH], - \ [s:a_TEH, s:a_s_TEH], - \ [s:a_THEH, s:a_s_THEH], - \ [s:a_JEEM, s:a_s_JEEM], - \ [s:a_HAH, s:a_s_HAH], - \ [s:a_KHAH, s:a_s_KHAH], - \ [s:a_SEEN, s:a_s_SEEN], - \ [s:a_SHEEN, s:a_s_SHEEN], - \ [s:a_SAD, s:a_s_SAD], - \ [s:a_DAD, s:a_s_DAD], - \ [s:a_TAH, s:a_s_TAH], - \ [s:a_ZAH, s:a_s_ZAH], - \ [s:a_AIN, s:a_s_AIN], - \ [s:a_GHAIN, s:a_s_GHAIN], - \ [s:a_FEH, s:a_s_FEH], - \ [s:a_QAF, s:a_s_QAF], - \ [s:a_KAF, s:a_s_KAF], - \ [s:a_LAM, s:a_s_LAM], - \ [s:a_MEEM, s:a_s_MEEM], - \ [s:a_NOON, s:a_s_NOON], - \ [s:a_HEH, s:a_s_HEH], - \ [s:a_YEH, s:a_s_YEH], - \ ] - call setline(1, ' ' . pair[0] . ' ') - call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -func Test_shape_iso_to_medial() - new - set arabicshape - - " Shaping arabic {testchar} arabic Tests chg_c_a2m(). - " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result, - " pair[3] = previous-result - for pair in [[s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA, s:a_s_BEH], - \[s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_f_ALEF_MADDA, s:a_i_BEH], - \[s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH], - \[s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_f_WAW_HAMZA, s:a_i_BEH], - \[s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH], - \[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_m_YEH_HAMZA, s:a_i_BEH], - \[s:a_ALEF, s:a_s_GHAIN, s:a_f_ALEF, s:a_i_BEH], - \[s:a_BEH, s:a_f_GHAIN, s:a_m_BEH, s:a_i_BEH], - \[s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_f_TEH_MARBUTA, s:a_i_BEH], - \[s:a_TEH, s:a_f_GHAIN, s:a_m_TEH, s:a_i_BEH], - \[s:a_THEH, s:a_f_GHAIN, s:a_m_THEH, s:a_i_BEH], - \[s:a_JEEM, s:a_f_GHAIN, s:a_m_JEEM, s:a_i_BEH], - \[s:a_HAH, s:a_f_GHAIN, s:a_m_HAH, s:a_i_BEH], - \[s:a_KHAH, s:a_f_GHAIN, s:a_m_KHAH, s:a_i_BEH], - \[s:a_DAL, s:a_s_GHAIN, s:a_f_DAL, s:a_i_BEH], - \[s:a_THAL, s:a_s_GHAIN, s:a_f_THAL, s:a_i_BEH], - \[s:a_REH, s:a_s_GHAIN, s:a_f_REH, s:a_i_BEH], - \[s:a_ZAIN, s:a_s_GHAIN, s:a_f_ZAIN, s:a_i_BEH], - \[s:a_SEEN, s:a_f_GHAIN, s:a_m_SEEN, s:a_i_BEH], - \[s:a_SHEEN, s:a_f_GHAIN, s:a_m_SHEEN, s:a_i_BEH], - \[s:a_SAD, s:a_f_GHAIN, s:a_m_SAD, s:a_i_BEH], - \[s:a_DAD, s:a_f_GHAIN, s:a_m_DAD, s:a_i_BEH], - \[s:a_TAH, s:a_f_GHAIN, s:a_m_TAH, s:a_i_BEH], - \[s:a_ZAH, s:a_f_GHAIN, s:a_m_ZAH, s:a_i_BEH], - \[s:a_AIN, s:a_f_GHAIN, s:a_m_AIN, s:a_i_BEH], - \[s:a_GHAIN, s:a_f_GHAIN, s:a_m_GHAIN, s:a_i_BEH], - \[s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL, s:a_i_BEH], - \[s:a_FEH, s:a_f_GHAIN, s:a_m_FEH, s:a_i_BEH], - \[s:a_QAF, s:a_f_GHAIN, s:a_m_QAF, s:a_i_BEH], - \[s:a_KAF, s:a_f_GHAIN, s:a_m_KAF, s:a_i_BEH], - \[s:a_LAM, s:a_f_GHAIN, s:a_m_LAM, s:a_i_BEH], - \[s:a_MEEM, s:a_f_GHAIN, s:a_m_MEEM, s:a_i_BEH], - \[s:a_NOON, s:a_f_GHAIN, s:a_m_NOON, s:a_i_BEH], - \[s:a_HEH, s:a_f_GHAIN, s:a_m_HEH, s:a_i_BEH], - \[s:a_WAW, s:a_s_GHAIN, s:a_f_WAW, s:a_i_BEH], - \[s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_f_ALEF_MAKSURA, s:a_i_BEH], - \[s:a_YEH, s:a_f_GHAIN, s:a_m_YEH, s:a_i_BEH], - \ ] - call setline(1, s:a_GHAIN . pair[0] . s:a_BEH) - call assert_equal([pair[1] . pair[2] . pair[3]], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -func Test_shape_final() - new - set arabicshape - - " Shaping arabic {testchar} arabic Tests chg_c_a2f(). - " pair[0] = testchar, pair[1] = current-result, pair[2] = previous-result - for pair in [[s:a_HAMZA, s:a_s_HAMZA, s:a_s_BEH], - \[s:a_ALEF_MADDA, s:a_f_ALEF_MADDA, s:a_i_BEH], - \[s:a_ALEF_HAMZA_ABOVE, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH], - \[s:a_WAW_HAMZA, s:a_f_WAW_HAMZA, s:a_i_BEH], - \[s:a_ALEF_HAMZA_BELOW, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH], - \[s:a_YEH_HAMZA, s:a_f_YEH_HAMZA, s:a_i_BEH], - \[s:a_ALEF, s:a_f_ALEF, s:a_i_BEH], - \[s:a_BEH, s:a_f_BEH, s:a_i_BEH], - \[s:a_TEH_MARBUTA, s:a_f_TEH_MARBUTA, s:a_i_BEH], - \[s:a_TEH, s:a_f_TEH, s:a_i_BEH], - \[s:a_THEH, s:a_f_THEH, s:a_i_BEH], - \[s:a_JEEM, s:a_f_JEEM, s:a_i_BEH], - \[s:a_HAH, s:a_f_HAH, s:a_i_BEH], - \[s:a_KHAH, s:a_f_KHAH, s:a_i_BEH], - \[s:a_DAL, s:a_f_DAL, s:a_i_BEH], - \[s:a_THAL, s:a_f_THAL, s:a_i_BEH], - \[s:a_REH, s:a_f_REH, s:a_i_BEH], - \[s:a_ZAIN, s:a_f_ZAIN, s:a_i_BEH], - \[s:a_SEEN, s:a_f_SEEN, s:a_i_BEH], - \[s:a_SHEEN, s:a_f_SHEEN, s:a_i_BEH], - \[s:a_SAD, s:a_f_SAD, s:a_i_BEH], - \[s:a_DAD, s:a_f_DAD, s:a_i_BEH], - \[s:a_TAH, s:a_f_TAH, s:a_i_BEH], - \[s:a_ZAH, s:a_f_ZAH, s:a_i_BEH], - \[s:a_AIN, s:a_f_AIN, s:a_i_BEH], - \[s:a_GHAIN, s:a_f_GHAIN, s:a_i_BEH], - \[s:a_TATWEEL, s:a_TATWEEL, s:a_i_BEH], - \[s:a_FEH, s:a_f_FEH, s:a_i_BEH], - \[s:a_QAF, s:a_f_QAF, s:a_i_BEH], - \[s:a_KAF, s:a_f_KAF, s:a_i_BEH], - \[s:a_LAM, s:a_f_LAM, s:a_i_BEH], - \[s:a_MEEM, s:a_f_MEEM, s:a_i_BEH], - \[s:a_NOON, s:a_f_NOON, s:a_i_BEH], - \[s:a_HEH, s:a_f_HEH, s:a_i_BEH], - \[s:a_WAW, s:a_f_WAW, s:a_i_BEH], - \[s:a_ALEF_MAKSURA, s:a_f_ALEF_MAKSURA, s:a_i_BEH], - \[s:a_YEH, s:a_f_YEH, s:a_i_BEH], - \ ] - call setline(1, ' ' . pair[0] . s:a_BEH) - call assert_equal([' ' . pair[1] . pair[2]], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -func Test_shape_combination_final() - new - set arabicshape - - " Shaping arabic {testchar} arabic Tests chg_c_laa2f(). - " pair[0] = testchar, pair[1] = current-result - for pair in [[s:a_ALEF_MADDA, s:a_f_LAM_ALEF_MADDA_ABOVE], - \ [s:a_ALEF_HAMZA_ABOVE, s:a_f_LAM_ALEF_HAMZA_ABOVE], - \ [s:a_ALEF_HAMZA_BELOW, s:a_f_LAM_ALEF_HAMZA_BELOW], - \ [s:a_ALEF, s:a_f_LAM_ALEF], - \ ] - " The test char is a composing char, put on s:a_LAM. - call setline(1, ' ' . s:a_LAM . pair[0] . s:a_BEH) - call assert_equal([' ' . pair[1] . s:a_i_BEH], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -func Test_shape_combination_isolated() - new - set arabicshape - - " Shaping arabic {testchar} arabic Tests chg_c_laa2i(). - " pair[0] = testchar, pair[1] = current-result - for pair in [[s:a_ALEF_MADDA, s:a_s_LAM_ALEF_MADDA_ABOVE], - \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_LAM_ALEF_HAMZA_ABOVE], - \ [s:a_ALEF_HAMZA_BELOW, s:a_s_LAM_ALEF_HAMZA_BELOW], - \ [s:a_ALEF, s:a_s_LAM_ALEF], - \ ] - " The test char is a composing char, put on s:a_LAM. - call setline(1, ' ' . s:a_LAM . pair[0] . ' ') - call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3)) - endfor - - set arabicshape& - bwipe! -endfunc - -" Test for entering arabic character in a search command -func Test_arabic_chars_in_search_cmd() - new - set arabic - call feedkeys("i\nsghl!\vim\", 'tx') - call cursor(1, 1) - call feedkeys("/^sghl!\vim$\\", 'tx') - call assert_equal([2, 1], [line('.'), col('.')]) - - " Try searching in left-to-right mode - set rightleftcmd= - call cursor(1, 1) - call feedkeys("/^sghl!\vim$\", 'tx') - call assert_equal([2, 1], [line('.'), col('.')]) - - set rightleftcmd& - set rightleft& - set arabic& - bwipe! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim deleted file mode 100644 index fb8b17cd16..0000000000 --- a/src/nvim/testdir/test_arglist.vim +++ /dev/null @@ -1,748 +0,0 @@ -" Test argument list commands - -source check.vim -source shared.vim -source term_util.vim - -func Reset_arglist() - args a | %argd -endfunc - -func Test_argidx() - args a b c - last - call assert_equal(2, argidx()) - %argdelete - call assert_equal(0, argidx()) - " doing it again doesn't result in an error - %argdelete - call assert_equal(0, argidx()) - call assert_fails('2argdelete', 'E16:') - - args a b c - call assert_equal(0, argidx()) - next - call assert_equal(1, argidx()) - next - call assert_equal(2, argidx()) - 1argdelete - call assert_equal(1, argidx()) - 1argdelete - call assert_equal(0, argidx()) - 1argdelete - call assert_equal(0, argidx()) -endfunc - -func Test_argadd() - call Reset_arglist() - - %argdelete - argadd a b c - call assert_equal(0, argidx()) - - %argdelete - argadd a - call assert_equal(0, argidx()) - argadd b c d - call assert_equal(0, argidx()) - - call Init_abc() - argadd x - call Assert_argc(['a', 'b', 'x', 'c']) - call assert_equal(1, argidx()) - - call Init_abc() - 0argadd x - call Assert_argc(['x', 'a', 'b', 'c']) - call assert_equal(2, argidx()) - - call Init_abc() - 1argadd x - call Assert_argc(['a', 'x', 'b', 'c']) - call assert_equal(2, argidx()) - - call Init_abc() - $argadd x - call Assert_argc(['a', 'b', 'c', 'x']) - call assert_equal(1, argidx()) - - call Init_abc() - $argadd x - +2argadd y - call Assert_argc(['a', 'b', 'c', 'x', 'y']) - call assert_equal(1, argidx()) - - %argd - edit d - arga - call assert_equal(1, len(argv())) - call assert_equal('d', get(argv(), 0, '')) - - %argd - edit some\ file - arga - call assert_equal(1, len(argv())) - call assert_equal('some file', get(argv(), 0, '')) - - %argd - new - arga - call assert_equal(0, len(argv())) - - if has('unix') - call assert_fails('argadd `Xdoes_not_exist`', 'E479:') - endif -endfunc - -func Test_argadd_empty_curbuf() - new - let curbuf = bufnr('%') - call writefile(['test', 'Xargadd'], 'Xargadd') - " must not re-use the current buffer. - argadd Xargadd - call assert_equal(curbuf, bufnr('%')) - call assert_equal('', bufname('%')) - call assert_equal(1, '$'->line()) - rew - call assert_notequal(curbuf, '%'->bufnr()) - call assert_equal('Xargadd', '%'->bufname()) - call assert_equal(2, line('$')) - - %argd - bwipe! -endfunc - -func Init_abc() - args a b c - next -endfunc - -func Assert_argc(l) - call assert_equal(len(a:l), argc()) - let i = 0 - while i < len(a:l) && i < argc() - call assert_equal(a:l[i], argv(i)) - let i += 1 - endwhile -endfunc - -" Test for [count]argument and [count]argdelete commands -" Ported from the test_argument_count.in test script -func Test_argument() - call Reset_arglist() - - let save_hidden = &hidden - set hidden - - let g:buffers = [] - augroup TEST - au BufEnter * call add(buffers, expand('%:t')) - augroup END - - argadd a b c d - $argu - $-argu - -argu - 1argu - +2argu - - augroup TEST - au! - augroup END - - call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers) - - call assert_equal("\na b [c] d ", execute(':args')) - - .argd - call assert_equal(['a', 'b', 'd'], argv()) - - -argd - call assert_equal(['a', 'd'], argv()) - - $argd - call assert_equal(['a'], argv()) - - 1arga c - 1arga b - $argu - $arga x - call assert_equal(['a', 'b', 'c', 'x'], argv()) - - 0arga y - call assert_equal(['y', 'a', 'b', 'c', 'x'], argv()) - - %argd - call assert_equal([], argv()) - - arga a b c d e f - 2,$-argd - call assert_equal(['a', 'f'], argv()) - - let &hidden = save_hidden - - let save_columns = &columns - let &columns = 79 - exe 'args ' .. join(range(1, 81)) - call assert_equal(join([ - \ '', - \ '[1] 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 ', - \ '2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 ', - \ '3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 ', - \ '4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 ', - \ '5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ', - \ ], "\n"), - \ execute('args')) - - " No trailing newline with one item per row. - let long_arg = repeat('X', 81) - exe 'args ' .. long_arg - call assert_equal("\n[".long_arg.']', execute('args')) - let &columns = save_columns - - " Setting argument list should fail when the current buffer has unsaved - " changes - %argd - enew! - set modified - call assert_fails('args x y z', 'E37:') - args! x y z - call assert_equal(['x', 'y', 'z'], argv()) - call assert_equal('x', expand('%:t')) - - last | enew | argu - call assert_equal('z', expand('%:t')) - - %argdelete - call assert_fails('argument', 'E163:') -endfunc - -func Test_list_arguments() - " Clean the argument list - arga a | %argd - - " four args half the screen width makes two lines with two columns - let aarg = repeat('a', &columns / 2 - 4) - let barg = repeat('b', &columns / 2 - 4) - let carg = repeat('c', &columns / 2 - 4) - let darg = repeat('d', &columns / 2 - 4) - exe 'argadd ' aarg barg carg darg - - redir => result - args - redir END - call assert_match('\[' . aarg . '] \+' . carg . '\n' . barg . ' \+' . darg, trim(result)) - - " if one arg is longer than half the screen make one column - exe 'argdel' aarg - let aarg = repeat('a', &columns / 2 + 2) - exe '0argadd' aarg - redir => result - args - redir END - call assert_match(aarg . '\n\[' . barg . ']\n' . carg . '\n' . darg, trim(result)) - - %argdelete -endfunc - -func Test_args_with_quote() - " Only on Unix can a file name include a double quote. - if has('unix') - args \"foobar - call assert_equal('"foobar', argv(0)) - %argdelete - endif -endfunc - -" Test for 0argadd and 0argedit -" Ported from the test_argument_0count.in test script -func Test_zero_argadd() - call Reset_arglist() - - arga a b c d - 2argu - 0arga added - call assert_equal(['added', 'a', 'b', 'c', 'd'], argv()) - - 2argu - arga third - call assert_equal(['added', 'a', 'third', 'b', 'c', 'd'], argv()) - - %argd - arga a b c d - 2argu - 0arge edited - call assert_equal(['edited', 'a', 'b', 'c', 'd'], argv()) - - 2argu - arga third - call assert_equal(['edited', 'a', 'third', 'b', 'c', 'd'], argv()) - - 2argu - argedit file\ with\ spaces another file - call assert_equal(['edited', 'a', 'file with spaces', 'another', 'file', 'third', 'b', 'c', 'd'], argv()) - call assert_equal('file with spaces', expand('%')) -endfunc - -" Test for argc() -func Test_argc() - call Reset_arglist() - call assert_equal(0, argc()) - argadd a b - call assert_equal(2, argc()) -endfunc - -" Test for arglistid() -func Test_arglistid() - call Reset_arglist() - arga a b - call assert_equal(0, arglistid()) - split - arglocal - call assert_equal(1, arglistid()) - tabnew | tabfirst - call assert_equal(0, arglistid(2)) - call assert_equal(1, arglistid(1, 1)) - call assert_equal(0, arglistid(2, 1)) - call assert_equal(1, arglistid(1, 2)) - tabonly | only | enew! - argglobal - call assert_equal(0, arglistid()) -endfunc - -" Tests for argv() and argc() -func Test_argv() - call Reset_arglist() - call assert_equal([], argv()) - call assert_equal("", argv(2)) - call assert_equal(0, argc()) - argadd a b c d - call assert_equal(4, argc()) - call assert_equal('c', argv(2)) - - let w1_id = win_getid() - split - let w2_id = win_getid() - arglocal - args e f g - tabnew - let w3_id = win_getid() - split - let w4_id = win_getid() - argglobal - tabfirst - call assert_equal(4, argc(w1_id)) - call assert_equal('b', argv(1, w1_id)) - call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w1_id)) - - call assert_equal(3, argc(w2_id)) - call assert_equal('f', argv(1, w2_id)) - call assert_equal(['e', 'f', 'g'], argv(-1, w2_id)) - - call assert_equal(3, argc(w3_id)) - call assert_equal('e', argv(0, w3_id)) - call assert_equal(['e', 'f', 'g'], argv(-1, w3_id)) - - call assert_equal(4, argc(w4_id)) - call assert_equal('c', argv(2, w4_id)) - call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w4_id)) - - call assert_equal(4, argc(-1)) - call assert_equal(3, argc()) - call assert_equal('d', argv(3, -1)) - call assert_equal(['a', 'b', 'c', 'd'], argv(-1, -1)) - tabonly | only | enew! - " Negative test cases - call assert_equal(-1, argc(100)) - call assert_equal('', argv(1, 100)) - call assert_equal([], argv(-1, 100)) - call assert_equal('', argv(10, -1)) -endfunc - -" Test for the :argedit command -func Test_argedit() - call Reset_arglist() - argedit a - call assert_equal(['a'], argv()) - call assert_equal('a', expand('%:t')) - argedit b - call assert_equal(['a', 'b'], argv()) - call assert_equal('b', expand('%:t')) - argedit a - call assert_equal(['a', 'b', 'a'], argv()) - call assert_equal('a', expand('%:t')) - " When file name case is ignored, an existing buffer with only case - " difference is re-used. - argedit C D - call assert_equal('C', expand('%:t')) - call assert_equal(['a', 'b', 'a', 'C', 'D'], argv()) - argedit c - if has('fname_case') - call assert_equal(['a', 'b', 'a', 'C', 'c', 'D'], argv()) - else - call assert_equal(['a', 'b', 'a', 'C', 'C', 'D'], argv()) - endif - 0argedit x - if has('fname_case') - call assert_equal(['x', 'a', 'b', 'a', 'C', 'c', 'D'], argv()) - else - call assert_equal(['x', 'a', 'b', 'a', 'C', 'C', 'D'], argv()) - endif - enew! | set modified - call assert_fails('argedit y', 'E37:') - argedit! y - if has('fname_case') - call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'c', 'D'], argv()) - else - call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'C', 'D'], argv()) - endif - %argd - bwipe! C - bwipe! D - - " :argedit reuses the current buffer if it is empty - %argd - " make sure to use a new buffer number for x when it is loaded - bw! x - new - let a = bufnr() - argedit x - call assert_equal(a, bufnr()) - call assert_equal('x', bufname()) - %argd - bw! x -endfunc - -" Test for the :argdedupe command -func Test_argdedupe() - call Reset_arglist() - argdedupe - call assert_equal([], argv()) - - args a a a aa b b a b aa - argdedupe - call assert_equal(['a', 'aa', 'b'], argv()) - - args a b c - argdedupe - call assert_equal(['a', 'b', 'c'], argv()) - - args a - argdedupe - call assert_equal(['a'], argv()) - - args a A b B - argdedupe - if has('fname_case') - call assert_equal(['a', 'A', 'b', 'B'], argv()) - else - call assert_equal(['a', 'b'], argv()) - endif - - args a b a c a b - last - argdedupe - next - call assert_equal('c', expand('%:t')) - - args a ./a - argdedupe - call assert_equal(['a'], argv()) - - %argd -endfunc - -" Test for the :argdelete command -func Test_argdelete() - call Reset_arglist() - args aa a aaa b bb - argdelete a* - call assert_equal(['b', 'bb'], argv()) - call assert_equal('aa', expand('%:t')) - last - argdelete % - call assert_equal(['b'], argv()) - call assert_fails('argdelete', 'E610:') - call assert_fails('1,100argdelete', 'E16:') - call assert_fails('argdel /\)/', 'E55:') - call assert_fails('1argdel 1', 'E474:') - - call Reset_arglist() - args a b c d - next - argdel - call Assert_argc(['a', 'c', 'd']) - %argdel - - call assert_fails('argdel does_not_exist', 'E480:') -endfunc - -func Test_argdelete_completion() - args foo bar - - call feedkeys(":argdelete \\\"\", 'tx') - call assert_equal('"argdelete bar foo', @:) - - call feedkeys(":argdelete x \\\"\", 'tx') - call assert_equal('"argdelete x bar foo', @:) - - %argd -endfunc - -" Tests for the :next, :prev, :first, :last, :rewind commands -func Test_argpos() - call Reset_arglist() - args a b c d - last - call assert_equal(3, argidx()) - call assert_fails('next', 'E165:') - prev - call assert_equal(2, argidx()) - Next - call assert_equal(1, argidx()) - first - call assert_equal(0, argidx()) - call assert_fails('prev', 'E164:') - 3next - call assert_equal(3, argidx()) - rewind - call assert_equal(0, argidx()) - %argd -endfunc - -" Test for autocommand that redefines the argument list, when doing ":all". -func Test_arglist_autocmd() - autocmd BufReadPost Xxx2 next Xxx2 Xxx1 - call writefile(['test file Xxx1'], 'Xxx1') - call writefile(['test file Xxx2'], 'Xxx2') - call writefile(['test file Xxx3'], 'Xxx3') - - new - " redefine arglist; go to Xxx1 - next! Xxx1 Xxx2 Xxx3 - " open window for all args; Reading Xxx2 will try to change the arglist and - " that will fail - call assert_fails("all", "E1156:") - call assert_equal('test file Xxx1', getline(1)) - wincmd w - call assert_equal('test file Xxx2', getline(1)) - wincmd w - call assert_equal('test file Xxx3', getline(1)) - - autocmd! BufReadPost Xxx2 - enew! | only - call delete('Xxx1') - call delete('Xxx2') - call delete('Xxx3') - argdelete Xxx* - bwipe! Xxx1 Xxx2 Xxx3 -endfunc - -func Test_arg_all_expand() - call writefile(['test file Xxx1'], 'Xx x') - next notexist Xx\ x runtest.vim - call assert_equal('notexist Xx\ x runtest.vim', expand('##')) - call delete('Xx x') -endfunc - -func Test_large_arg() - " Argument longer or equal to the number of columns used to cause - " access to invalid memory. - exe 'argadd ' .repeat('x', &columns) - args -endfunc - -func Test_argdo() - next! Xa.c Xb.c Xc.c - new - let l = [] - argdo call add(l, expand('%')) - call assert_equal(['Xa.c', 'Xb.c', 'Xc.c'], l) - bwipe Xa.c Xb.c Xc.c -endfunc - -" Test for quitting Vim with unedited files in the argument list -func Test_quit_with_arglist() - CheckRunVimInTerminal - let buf = RunVimInTerminal('', {'rows': 6}) - call term_sendkeys(buf, ":set nomore\n") - call term_sendkeys(buf, ":args a b c\n") - call term_sendkeys(buf, ":quit\n") - call term_wait(buf) - call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))}) - call StopVimInTerminal(buf) - - " Try :confirm quit with unedited files in arglist - let buf = RunVimInTerminal('', {'rows': 6}) - call term_sendkeys(buf, ":set nomore\n") - call term_sendkeys(buf, ":args a b c\n") - call term_sendkeys(buf, ":confirm quit\n") - call term_wait(buf) - call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', - \ term_getline(buf, 6))}) - call term_sendkeys(buf, "N") - call term_wait(buf) - call term_sendkeys(buf, ":confirm quit\n") - call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', - \ term_getline(buf, 6))}) - call term_sendkeys(buf, "Y") - call term_wait(buf) - call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) - only! - " When this test fails, swap files are left behind which breaks subsequent - " tests - call delete('.a.swp') - call delete('.b.swp') - call delete('.c.swp') -endfunc - -" Test for ":all" not working when in the cmdline window -func Test_all_not_allowed_from_cmdwin() - au BufEnter * all - next x - " Use try/catch here, somehow assert_fails() doesn't work on MS-Windows - " console. - let caught = 'no' - try - exe ":norm! 7q?apat\" - catch /E11:/ - let caught = 'yes' - endtry - call assert_equal('yes', caught) - au! BufEnter -endfunc - -func Test_clear_arglist_in_all() - n 0 00 000 0000 00000 000000 - au WinNew 0 n 0 - call assert_fails("all", "E1156") - au! * -endfunc - -" Test for the :all command -func Test_all_command() - %argdelete - - " :all command should not close windows with files in the argument list, - " but can rearrange the windows. - args Xargnew1 Xargnew2 - %bw! - edit Xargold1 - split Xargnew1 - let Xargnew1_winid = win_getid() - split Xargold2 - split Xargnew2 - let Xargnew2_winid = win_getid() - split Xargold3 - all - call assert_equal(2, winnr('$')) - call assert_equal([Xargnew1_winid, Xargnew2_winid], - \ [win_getid(1), win_getid(2)]) - call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')], - \ [winbufnr(1), winbufnr(2)]) - - " :all command should close windows for files which are not in the - " argument list in the current tab page. - %bw! - edit Xargold1 - split Xargold2 - tabedit Xargold3 - split Xargold4 - tabedit Xargold5 - tabfirst - all - call assert_equal(3, tabpagenr('$')) - call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')], tabpagebuflist(1)) - call assert_equal([bufnr('Xargold4'), bufnr('Xargold3')], tabpagebuflist(2)) - call assert_equal([bufnr('Xargold5')], tabpagebuflist(3)) - - " :tab all command should close windows for files which are not in the - " argument list across all the tab pages. - %bw! - edit Xargold1 - split Xargold2 - tabedit Xargold3 - split Xargold4 - tabedit Xargold5 - tabfirst - args Xargnew1 Xargnew2 - tab all - call assert_equal(2, tabpagenr('$')) - call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1)) - call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2)) - - " If a count is specified, then :all should open only that many windows. - %bw! - args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5 - all 3 - call assert_equal(3, winnr('$')) - call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2'), bufnr('Xargnew3')], - \ [winbufnr(1), winbufnr(2), winbufnr(3)]) - - " The :all command should not open more than 'tabpagemax' tab pages. - " If there are more files, then they should be opened in the last tab page. - %bw! - set tabpagemax=3 - tab all - call assert_equal(3, tabpagenr('$')) - call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1)) - call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2)) - call assert_equal([bufnr('Xargnew3'), bufnr('Xargnew4'), bufnr('Xargnew5')], - \ tabpagebuflist(3)) - set tabpagemax& - - " Without the 'hidden' option, modified buffers should not be closed. - args Xargnew1 Xargnew2 - %bw! - edit Xargtemp1 - call setline(1, 'temp buffer 1') - split Xargtemp2 - call setline(1, 'temp buffer 2') - all - call assert_equal(4, winnr('$')) - call assert_equal([bufnr('Xargtemp2'), bufnr('Xargtemp1'), bufnr('Xargnew1'), - \ bufnr('Xargnew2')], - \ [winbufnr(1), winbufnr(2), winbufnr(3), winbufnr(4)]) - - " With the 'hidden' option set, both modified and unmodified buffers in - " closed windows should be hidden. - set hidden - all - call assert_equal(2, winnr('$')) - call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')], - \ [winbufnr(1), winbufnr(2)]) - call assert_equal([1, 1, 0, 0], [getbufinfo('Xargtemp1')[0].hidden, - \ getbufinfo('Xargtemp2')[0].hidden, - \ getbufinfo('Xargnew1')[0].hidden, - \ getbufinfo('Xargnew2')[0].hidden]) - set nohidden - - " When 'winheight' is set to a large value, :all should open only one - " window. - args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5 - %bw! - set winheight=9999 - call assert_fails('all', 'E36:') - call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)]) - set winheight& - - " When 'winwidth' is set to a large value, :vert all should open only one - " window. - %bw! - set winwidth=9999 - call assert_fails('vert all', 'E36:') - call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)]) - set winwidth& - - " empty argument list tests - %bw! - %argdelete - call assert_equal('', execute('args')) - all - call assert_equal(1, winnr('$')) - - %argdelete - %bw! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_assert.vim b/src/nvim/testdir/test_assert.vim deleted file mode 100644 index 431908e95c..0000000000 --- a/src/nvim/testdir/test_assert.vim +++ /dev/null @@ -1,363 +0,0 @@ -" Test that the methods used for testing work. - -func Test_assert_false() - call assert_equal(0, assert_false(0)) - call assert_equal(0, assert_false(v:false)) - call assert_equal(0, v:false->assert_false()) - - call assert_equal(1, assert_false(123)) - call assert_match("Expected False but got 123", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, 123->assert_false()) - call assert_match("Expected False but got 123", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_true() - call assert_equal(0, assert_true(1)) - call assert_equal(0, assert_true(123)) - call assert_equal(0, assert_true(v:true)) - call assert_equal(0, v:true->assert_true()) - - call assert_equal(1, assert_true(0)) - call assert_match("Expected True but got 0", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, 0->assert_true()) - call assert_match("Expected True but got 0", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_equal() - let s = 'foo' - call assert_equal(0, assert_equal('foo', s)) - let n = 4 - call assert_equal(0, assert_equal(4, n)) - let l = [1, 2, 3] - call assert_equal(0, assert_equal([1, 2, 3], l)) - call assert_equal(v:_null_list, v:_null_list) - call assert_equal(v:_null_list, []) - call assert_equal([], v:_null_list) - - let s = 'foo' - call assert_equal(1, assert_equal('bar', s)) - call assert_match("Expected 'bar' but got 'foo'", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX') - call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0]) - call remove(v:errors, 0) - - " special characters are escaped - call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x') - call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''x''', v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_equal_dict() - call assert_equal(0, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 1})) - - call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 2, one: 3})) - call assert_match("Expected {'one': 1} but got {'one': 3} - 1 equal item omitted", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_equal(#{one: 1, two: 2}, #{two: 22, one: 11})) - call assert_match("Expected {'one': 1, 'two': 2} but got {'one': 11, 'two': 22}", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_equal(#{}, #{two: 2, one: 1})) - call assert_match("Expected {} but got {'one': 1, 'two': 2}", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_equal(#{two: 2, one: 1}, #{})) - call assert_match("Expected {'one': 1, 'two': 2} but got {}", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_equalfile() - call assert_equal(1, assert_equalfile('abcabc', 'xyzxyz')) - call assert_match("E485: Can't read file abcabc", v:errors[0]) - call remove(v:errors, 0) - - let goodtext = ["one", "two", "three"] - call writefile(goodtext, 'Xone') - call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz')) - call assert_match("E485: Can't read file xyzxyz", v:errors[0]) - call remove(v:errors, 0) - - call writefile(goodtext, 'Xtwo') - call assert_equal(0, assert_equalfile('Xone', 'Xtwo')) - - call writefile([goodtext[0]], 'Xone') - call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) - call assert_match("first file is shorter", v:errors[0]) - call remove(v:errors, 0) - - call writefile(goodtext, 'Xone') - call writefile([goodtext[0]], 'Xtwo') - call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) - call assert_match("second file is shorter", v:errors[0]) - call remove(v:errors, 0) - - call writefile(['1234X89'], 'Xone') - call writefile(['1234Y89'], 'Xtwo') - call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) - call assert_match('difference at byte 4, line 1 after "1234X" vs "1234Y"', v:errors[0]) - call remove(v:errors, 0) - - call writefile([repeat('x', 234) .. 'X'], 'Xone') - call writefile([repeat('x', 234) .. 'Y'], 'Xtwo') - call assert_equal(1, assert_equalfile('Xone', 'Xtwo')) - let xes = repeat('x', 134) - call assert_match('difference at byte 234, line 1 after "' .. xes .. 'X" vs "' .. xes .. 'Y"', v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message')) - call assert_match("a message: difference at byte 234, line 1 after", v:errors[0]) - call remove(v:errors, 0) - - call delete('Xone') - call delete('Xtwo') -endfunc - -func Test_assert_notequal() - let n = 4 - call assert_equal(0, assert_notequal('foo', n)) - let s = 'foo' - call assert_equal(0, assert_notequal([1, 2, 3], s)) - - call assert_equal(1, assert_notequal('foo', s)) - call assert_match("Expected not equal to 'foo'", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_report() - call assert_equal(1, assert_report('something is wrong')) - call assert_match('something is wrong', v:errors[0]) - call remove(v:errors, 0) - call assert_equal(1, 'also wrong'->assert_report()) - call assert_match('also wrong', v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_exception() - try - nocommand - catch - call assert_equal(0, assert_exception('E492:')) - endtry - - try - nocommand - catch - call assert_equal(1, assert_exception('E12345:')) - endtry - call assert_match("Expected 'E12345:' but got 'Vim:E492: ", v:errors[0]) - call remove(v:errors, 0) - - try - nocommand - catch - try - " illegal argument, get NULL for error - call assert_equal(1, assert_exception([])) - catch - call assert_equal(0, assert_exception('E730:')) - endtry - endtry - - call assert_equal(1, assert_exception('E492:')) - call assert_match('v:exception is not set', v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_wrong_error_type() - let save_verrors = v:errors - let v:['errors'] = {'foo': 3} - call assert_equal('yes', 'no') - let verrors = v:errors - let v:errors = save_verrors - call assert_equal(type([]), type(verrors)) -endfunc - -func Test_match() - call assert_equal(0, assert_match('^f.*b.*r$', 'foobar')) - - call assert_equal(1, assert_match('bar.*foo', 'foobar')) - call assert_match("Pattern 'bar.*foo' does not match 'foobar'", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_match('bar.*foo', 'foobar', 'wrong')) - call assert_match('wrong', v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong')) - call assert_match('wrong', v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_notmatch() - call assert_equal(0, assert_notmatch('foo', 'bar')) - call assert_equal(0, assert_notmatch('^foobar$', 'foobars')) - - call assert_equal(1, assert_notmatch('foo', 'foobar')) - call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, 'foobar'->assert_notmatch('foo')) - call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_assert_fail_fails() - call assert_equal(1, assert_fails('xxx', 'E12345')) - call assert_match("Expected 'E12345' but got 'E492:", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_fails('xxx', 'E9876', 'stupid')) - call assert_match("stupid: Expected 'E9876' but got 'E492:", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_fails('xxx', ['E9876'])) - call assert_match("Expected \\['E9876'\\] but got 'E492:", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_fails('xxx', ['E492:', 'E9876'])) - call assert_match("Expected \\['E492:', 'E9876'\\] but got 'E492:", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, assert_fails('echo', '', 'echo command')) - call assert_match("command did not fail: echo command", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(1, 'echo'->assert_fails('', 'echo command')) - call assert_match("command did not fail: echo command", v:errors[0]) - call remove(v:errors, 0) - - try - call assert_equal(1, assert_fails('xxx', [])) - catch - let exp = v:exception - endtry - call assert_match("E856: assert_fails() second argument", exp) - - try - call assert_equal(1, assert_fails('xxx', ['1', '2', '3'])) - catch - let exp = v:exception - endtry - call assert_match("E856: assert_fails() second argument", exp) - - try - call assert_equal(1, assert_fails('xxx', #{one: 1})) - catch - let exp = v:exception - endtry - call assert_match("E856: assert_fails() second argument", exp) - - try - call assert_equal(1, assert_fails('xxx', 'E492', '', 'burp')) - catch - let exp = v:exception - endtry - call assert_match("E1115: assert_fails() fourth argument must be a number", exp) - - try - call assert_equal(1, assert_fails('xxx', 'E492', '', 54, 123)) - catch - let exp = v:exception - endtry - call assert_match("E1116: assert_fails() fifth argument must be a string", exp) -endfunc - -func Test_assert_fails_in_try_block() - try - call assert_equal(0, assert_fails('throw "error"')) - endtry -endfunc - -func Test_assert_beeps() - new - call assert_equal(0, assert_beeps('normal h')) - - call assert_equal(1, assert_beeps('normal 0')) - call assert_match("command did not beep: normal 0", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(0, 'normal h'->assert_beeps()) - call assert_equal(1, 'normal 0'->assert_beeps()) - call assert_match("command did not beep: normal 0", v:errors[0]) - call remove(v:errors, 0) - - bwipe -endfunc - -func Test_assert_inrange() - call assert_equal(0, assert_inrange(7, 7, 7)) - call assert_equal(0, assert_inrange(5, 7, 5)) - call assert_equal(0, assert_inrange(5, 7, 6)) - call assert_equal(0, assert_inrange(5, 7, 7)) - - call assert_equal(1, assert_inrange(5, 7, 4)) - call assert_match("Expected range 5 - 7, but got 4", v:errors[0]) - call remove(v:errors, 0) - call assert_equal(1, assert_inrange(5, 7, 8)) - call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) - call remove(v:errors, 0) - - call assert_equal(0, 5->assert_inrange(5, 7)) - call assert_equal(0, 7->assert_inrange(5, 7)) - call assert_equal(1, 8->assert_inrange(5, 7)) - call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) - call remove(v:errors, 0) - - call assert_fails('call assert_inrange(1, 1)', 'E119:') - - if has('float') - call assert_equal(0, assert_inrange(7.0, 7, 7)) - call assert_equal(0, assert_inrange(7, 7.0, 7)) - call assert_equal(0, assert_inrange(7, 7, 7.0)) - call assert_equal(0, assert_inrange(5, 7, 5.0)) - call assert_equal(0, assert_inrange(5, 7, 6.0)) - call assert_equal(0, assert_inrange(5, 7, 7.0)) - - call assert_equal(1, assert_inrange(5, 7, 4.0)) - call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0]) - call remove(v:errors, 0) - call assert_equal(1, assert_inrange(5, 7, 8.0)) - call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) - call remove(v:errors, 0) - endif -endfunc - -func Test_assert_with_msg() - call assert_equal('foo', 'bar', 'testing') - call assert_match("testing: Expected 'foo' but got 'bar'", v:errors[0]) - call remove(v:errors, 0) -endfunc - -func Test_mouse_position() - let save_mouse = &mouse - set mouse=a - new - call setline(1, ['line one', 'line two']) - call assert_equal([0, 1, 1, 0], getpos('.')) - call Ntest_setmouse(1, 5) - call feedkeys("\", "xt") - call assert_equal([0, 1, 5, 0], getpos('.')) - call Ntest_setmouse(2, 20) - call feedkeys("\", "xt") - call assert_equal([0, 2, 8, 0], getpos('.')) - call Ntest_setmouse(5, 1) - call feedkeys("\", "xt") - call assert_equal([0, 2, 1, 0], getpos('.')) - bwipe! - let &mouse = save_mouse -endfunc - -" Must be last. -func Test_zz_quit_detected() - " Verify that if a test function ends Vim the test script detects this. - quit -endfunc diff --git a/src/nvim/testdir/test_autochdir.vim b/src/nvim/testdir/test_autochdir.vim deleted file mode 100644 index a8810047a0..0000000000 --- a/src/nvim/testdir/test_autochdir.vim +++ /dev/null @@ -1,130 +0,0 @@ -" Test 'autochdir' behavior - -source check.vim -CheckOption autochdir - -func Test_set_filename() - CheckFunction test_autochdir - let cwd = getcwd() - call test_autochdir() - set acd - - let s:li = [] - autocmd DirChanged auto call add(s:li, "autocd") - autocmd DirChanged auto call add(s:li, expand("")) - - new - w samples/Xtest - call assert_equal("Xtest", expand('%')) - call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', '')) - call assert_equal(["autocd", getcwd()], s:li) - - bwipe! - au! DirChanged - set noacd - call chdir(cwd) - call delete('samples/Xtest') -endfunc - -func Test_set_filename_other_window() - CheckFunction test_autochdir - let cwd = getcwd() - call test_autochdir() - call mkdir('Xa') - call mkdir('Xb') - call mkdir('Xc') - try - args Xa/aaa.txt Xb/bbb.txt - set acd - let winid = win_getid() - snext - call assert_equal('Xb', substitute(getcwd(), '.*/\([^/]*\)$', '\1', '')) - call win_execute(winid, 'file ' .. cwd .. '/Xc/ccc.txt') - call assert_equal('Xb', substitute(getcwd(), '.*/\([^/]*\)$', '\1', '')) - finally - set noacd - call chdir(cwd) - call delete('Xa', 'rf') - call delete('Xb', 'rf') - call delete('Xc', 'rf') - bwipe! aaa.txt - bwipe! bbb.txt - bwipe! ccc.txt - endtry -endfunc - -func Test_acd_win_execute() - CheckFunction test_autochdir - let cwd = getcwd() - set acd - call test_autochdir() - - call mkdir('Xfile') - let winid = win_getid() - new Xfile/file - call assert_match('testdir.Xfile$', getcwd()) - cd .. - call assert_match('testdir$', getcwd()) - call win_execute(winid, 'echo') - call assert_match('testdir$', getcwd()) - - bwipe! - set noacd - call chdir(cwd) - call delete('Xfile', 'rf') -endfunc - -func Test_verbose_pwd() - CheckFunction test_autochdir - let cwd = getcwd() - call test_autochdir() - - edit global.txt - call assert_match('\[global\].*testdir$', execute('verbose pwd')) - - call mkdir('Xautodir') - split Xautodir/local.txt - lcd Xautodir - call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd')) - - set acd - wincmd w - call assert_match('\[autochdir\].*testdir$', execute('verbose pwd')) - execute 'tcd' cwd - call assert_match('\[tabpage\].*testdir$', execute('verbose pwd')) - execute 'cd' cwd - call assert_match('\[global\].*testdir$', execute('verbose pwd')) - execute 'lcd' cwd - call assert_match('\[window\].*testdir$', execute('verbose pwd')) - edit - call assert_match('\[autochdir\].*testdir$', execute('verbose pwd')) - enew - wincmd w - call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd')) - wincmd w - call assert_match('\[window\].*testdir$', execute('verbose pwd')) - wincmd w - call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd')) - set noacd - call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd')) - wincmd w - call assert_match('\[window\].*testdir$', execute('verbose pwd')) - execute 'cd' cwd - call assert_match('\[global\].*testdir$', execute('verbose pwd')) - wincmd w - call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd')) - - bwipe! - call chdir(cwd) - call delete('Xautodir', 'rf') -endfunc - -func Test_multibyte() - " using an invalid character should not cause a crash - set wic - call assert_fails('tc *', has('win32') ? 'E480:' : 'E344:') - set nowic -endfunc - - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim deleted file mode 100644 index 6d7f1649b3..0000000000 --- a/src/nvim/testdir/test_autocmd.vim +++ /dev/null @@ -1,3630 +0,0 @@ -" Tests for autocommands - -source shared.vim -source check.vim -source term_util.vim -source screendump.vim -source load.vim - -func s:cleanup_buffers() abort - for bnr in range(1, bufnr('$')) - if bufloaded(bnr) && bufnr('%') != bnr - execute 'bd! ' . bnr - endif - endfor -endfunc - -func Test_vim_did_enter() - call assert_false(v:vim_did_enter) - - " This script will never reach the main loop, can't check if v:vim_did_enter - " becomes one. -endfunc - -" Test for the CursorHold autocmd -func Test_CursorHold_autocmd() - CheckRunVimInTerminal - call writefile(['one', 'two', 'three'], 'Xfile') - let before =<< trim END - set updatetime=10 - au CursorHold * call writefile([line('.')], 'Xoutput', 'a') - END - call writefile(before, 'Xinit') - let buf = RunVimInTerminal('-S Xinit Xfile', {}) - call term_sendkeys(buf, "G") - call term_wait(buf, 20) - call term_sendkeys(buf, "gg") - call term_wait(buf) - call WaitForAssert({-> assert_equal(['1'], readfile('Xoutput')[-1:-1])}) - call term_sendkeys(buf, "j") - call term_wait(buf) - call WaitForAssert({-> assert_equal(['1', '2'], readfile('Xoutput')[-2:-1])}) - call term_sendkeys(buf, "j") - call term_wait(buf) - call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('Xoutput')[-3:-1])}) - call StopVimInTerminal(buf) - - call delete('Xinit') - call delete('Xoutput') - call delete('Xfile') -endfunc - -if has('timers') - - func ExitInsertMode(id) - call feedkeys("\") - endfunc - - func Test_cursorhold_insert() - " Need to move the cursor. - call feedkeys("ggG", "xt") - - let g:triggered = 0 - au CursorHoldI * let g:triggered += 1 - set updatetime=20 - call timer_start(LoadAdjust(200), 'ExitInsertMode') - call feedkeys('a', 'x!') - call assert_equal(1, g:triggered) - unlet g:triggered - au! CursorHoldI - set updatetime& - endfunc - - func Test_cursorhold_insert_with_timer_interrupt() - CheckFeature job - " Need to move the cursor. - call feedkeys("ggG", "xt") - - " Confirm the timer invoked in exit_cb of the job doesn't disturb - " CursorHoldI event. - let g:triggered = 0 - au CursorHoldI * let g:triggered += 1 - set updatetime=500 - call job_start(has('win32') ? 'cmd /c echo:' : 'echo', - \ {'exit_cb': {-> timer_start(1000, 'ExitInsertMode')}}) - call feedkeys('a', 'x!') - call assert_equal(1, g:triggered) - unlet g:triggered - au! CursorHoldI - set updatetime& - endfunc - - func Test_cursorhold_insert_ctrl_x() - let g:triggered = 0 - au CursorHoldI * let g:triggered += 1 - set updatetime=20 - call timer_start(LoadAdjust(100), 'ExitInsertMode') - " CursorHoldI does not trigger after CTRL-X - call feedkeys("a\", 'x!') - call assert_equal(0, g:triggered) - unlet g:triggered - au! CursorHoldI - set updatetime& - endfunc - - func Test_OptionSet_modeline() - CheckFunction 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 - autocmd! - autocmd BufUnload * call add(s:li, "bufunload") - autocmd BufDelete * call add(s:li, "bufdelete") - autocmd BufWipeout * call add(s:li, "bufwipeout") - augroup END - - let s:li = [] - new - setlocal bufhidden= - bunload - call assert_equal(["bufunload", "bufdelete"], s:li) - - let s:li = [] - new - setlocal bufhidden=delete - bunload - call assert_equal(["bufunload", "bufdelete"], s:li) - - let s:li = [] - new - setlocal bufhidden=unload - bwipeout - call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li) - - au! test_bufunload_group - augroup! test_bufunload_group -endfunc - -" SEGV occurs in older versions. (At least 7.4.2005 or older) -func Test_autocmd_bufunload_with_tabnext() - tabedit - tabfirst - - augroup test_autocmd_bufunload_with_tabnext_group - autocmd! - autocmd BufUnload tabnext - augroup END - - quit - call assert_equal(2, tabpagenr('$')) - - autocmd! test_autocmd_bufunload_with_tabnext_group - augroup! test_autocmd_bufunload_with_tabnext_group - tablast - quit -endfunc - -func Test_argdelete_in_next() - au BufNew,BufEnter,BufLeave,BufWinEnter * argdel - call assert_fails('next a b', 'E1156:') - au! BufNew,BufEnter,BufLeave,BufWinEnter * -endfunc - -func Test_autocmd_bufwinleave_with_tabfirst() - tabedit - augroup sample - autocmd! - autocmd BufWinLeave tabfirst - augroup END - call setline(1, ['a', 'b', 'c']) - edit! a.txt - tabclose -endfunc - -" SEGV occurs in older versions. (At least 7.4.2321 or older) -func Test_autocmd_bufunload_avoiding_SEGV_01() - split aa.txt - let lastbuf = bufnr('$') - - augroup test_autocmd_bufunload - autocmd! - exe 'autocmd BufUnload ' . (lastbuf + 1) . 'bwipeout!' - augroup END - - call assert_fails('edit bb.txt', 'E937:') - - autocmd! test_autocmd_bufunload - augroup! test_autocmd_bufunload - bwipe! aa.txt - bwipe! bb.txt -endfunc - -" SEGV occurs in older versions. (At least 7.4.2321 or older) -func Test_autocmd_bufunload_avoiding_SEGV_02() - setlocal buftype=nowrite - let lastbuf = bufnr('$') - - augroup test_autocmd_bufunload - autocmd! - exe 'autocmd BufUnload ' . (lastbuf + 1) . 'bwipeout!' - augroup END - - normal! i1 - call assert_fails('edit a.txt', 'E517:') - - autocmd! test_autocmd_bufunload - augroup! test_autocmd_bufunload - bwipe! a.txt -endfunc - -func Test_autocmd_dummy_wipeout() - " prepare files - call writefile([''], 'Xdummywipetest1.txt') - call writefile([''], 'Xdummywipetest2.txt') - augroup test_bufunload_group - autocmd! - autocmd BufUnload * call add(s:li, "bufunload") - autocmd BufDelete * call add(s:li, "bufdelete") - autocmd BufWipeout * call add(s:li, "bufwipeout") - augroup END - - let s:li = [] - split Xdummywipetest1.txt - silent! vimgrep /notmatched/ Xdummywipetest* - call assert_equal(["bufunload", "bufwipeout"], s:li) - - bwipeout - call delete('Xdummywipetest1.txt') - call delete('Xdummywipetest2.txt') - au! test_bufunload_group - augroup! test_bufunload_group -endfunc - -func Test_win_tab_autocmd() - let g:record = [] - - augroup testing - au WinNew * call add(g:record, 'WinNew') - au WinClosed * call add(g:record, 'WinClosed') - au WinEnter * call add(g:record, 'WinEnter') - au WinLeave * call add(g:record, 'WinLeave') - au TabNew * call add(g:record, 'TabNew') - au TabClosed * call add(g:record, 'TabClosed') - au TabEnter * call add(g:record, 'TabEnter') - au TabLeave * call add(g:record, 'TabLeave') - augroup END - - split - tabnew - close - close - - call assert_equal([ - \ 'WinLeave', 'WinNew', 'WinEnter', - \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter', - \ 'WinLeave', 'TabLeave', 'WinClosed', 'TabClosed', 'WinEnter', 'TabEnter', - \ 'WinLeave', 'WinClosed', 'WinEnter' - \ ], g:record) - - let g:record = [] - tabnew somefile - tabnext - bwipe somefile - - call assert_equal([ - \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter', - \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', - \ 'WinClosed', 'TabClosed' - \ ], g:record) - - augroup testing - au! - augroup END - unlet g:record -endfunc - -func Test_WinResized() - CheckRunVimInTerminal - - let lines =<< trim END - set scrolloff=0 - call setline(1, ['111', '222']) - vnew - call setline(1, ['aaa', 'bbb']) - new - call setline(1, ['foo', 'bar']) - - let g:resized = 0 - au WinResized * let g:resized += 1 - - func WriteResizedEvent() - call writefile([json_encode(v:event)], 'XresizeEvent') - endfunc - au WinResized * call WriteResizedEvent() - END - call writefile(lines, 'Xtest_winresized', 'D') - let buf = RunVimInTerminal('-S Xtest_winresized', {'rows': 10}) - - " redraw now to avoid a redraw after the :echo command - call term_sendkeys(buf, ":redraw!\") - call TermWait(buf) - - call term_sendkeys(buf, ":echo g:resized\") - call WaitForAssert({-> assert_match('^0$', term_getline(buf, 10))}, 1000) - - " increase window height, two windows will be reported - call term_sendkeys(buf, "\+") - call TermWait(buf) - call term_sendkeys(buf, ":echo g:resized\") - call WaitForAssert({-> assert_match('^1$', term_getline(buf, 10))}, 1000) - - let event = readfile('XresizeEvent')[0]->json_decode() - call assert_equal({ - \ 'windows': [1002, 1001], - \ }, event) - - " increase window width, three windows will be reported - call term_sendkeys(buf, "\>") - call TermWait(buf) - call term_sendkeys(buf, ":echo g:resized\") - call WaitForAssert({-> assert_match('^2$', term_getline(buf, 10))}, 1000) - - let event = readfile('XresizeEvent')[0]->json_decode() - call assert_equal({ - \ 'windows': [1002, 1001, 1000], - \ }, event) - - call delete('XresizeEvent') - call StopVimInTerminal(buf) -endfunc - -func Test_WinScrolled() - CheckRunVimInTerminal - - let lines =<< trim END - set nowrap scrolloff=0 - for ii in range(1, 18) - call setline(ii, repeat(nr2char(96 + ii), ii * 2)) - endfor - let win_id = win_getid() - let g:matched = v:false - func WriteScrollEvent() - call writefile([json_encode(v:event)], 'XscrollEvent') - endfunc - execute 'au WinScrolled' win_id 'let g:matched = v:true' - let g:scrolled = 0 - au WinScrolled * let g:scrolled += 1 - au WinScrolled * let g:amatch = str2nr(expand('')) - au WinScrolled * let g:afile = str2nr(expand('')) - au WinScrolled * call WriteScrollEvent() - END - call writefile(lines, 'Xtest_winscrolled', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6}) - - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^0 ', term_getline(buf, 6))}, 1000) - - " Scroll left/right in Normal mode. - call term_sendkeys(buf, "zlzh:echo g:scrolled\") - call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 1, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': -1, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - " Scroll up/down in Normal mode. - call term_sendkeys(buf, "\\:echo g:scrolled\") - call WaitForAssert({-> assert_match('^4 ', term_getline(buf, 6))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': -1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - " Scroll up/down in Insert mode. - call term_sendkeys(buf, "Mi\\\i\\\") - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^6 ', term_getline(buf, 6))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': -1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - " Scroll the window horizontally to focus the last letter of the third line - " containing only six characters. Moving to the previous and shorter lines - " should trigger another autocommand as Vim has to make them visible. - call term_sendkeys(buf, "5zl2k") - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^8 ', term_getline(buf, 6))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 5, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': -5, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - " Ensure the command was triggered for the specified window ID. - call term_sendkeys(buf, ":echo g:matched\") - call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000) - - " Ensure the expansion of and matches the window ID. - call term_sendkeys(buf, ":echo g:amatch == win_id && g:afile == win_id\") - call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000) - - call delete('XscrollEvent') - call StopVimInTerminal(buf) -endfunc - -func Test_WinScrolled_mouse() - CheckRunVimInTerminal - - let lines =<< trim END - set nowrap scrolloff=0 - set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard= - call setline(1, ['foo']->repeat(32)) - split - let g:scrolled = 0 - au WinScrolled * let g:scrolled += 1 - END - call writefile(lines, 'Xtest_winscrolled_mouse', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10}) - - " With the upper split focused, send a scroll-down event to the unfocused one. - call test_setmouse(7, 1) - call term_sendkeys(buf, "\") - call TermWait(buf) - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^1', term_getline(buf, 10))}, 1000) - - " Again, but this time while we're in insert mode. - call term_sendkeys(buf, "i\\") - call TermWait(buf) - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000) - - call StopVimInTerminal(buf) -endfunc - -func Test_WinScrolled_close_curwin() - CheckRunVimInTerminal - - let lines =<< trim END - set nowrap scrolloff=0 - call setline(1, ['aaa', 'bbb']) - vsplit - au WinScrolled * close - au VimLeave * call writefile(['123456'], 'Xtestout') - END - call writefile(lines, 'Xtest_winscrolled_close_curwin', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6}) - - " This was using freed memory - call term_sendkeys(buf, "\") - call TermWait(buf) - call StopVimInTerminal(buf) - - " check the startup script finished to the end - call assert_equal(['123456'], readfile('Xtestout')) - call delete('Xtestout') -endfunc - -func Test_WinScrolled_once_only() - CheckRunVimInTerminal - - let lines =<< trim END - set cmdheight=2 - call setline(1, ['aaa', 'bbb']) - let trigger_count = 0 - func ShowInfo(id) - echo g:trigger_count g:winid winlayout() - endfunc - - vsplit - split - " use a timer to show the info after a redraw - au WinScrolled * let trigger_count += 1 | let winid = expand('') | call timer_start(100, 'ShowInfo') - wincmd j - wincmd l - END - call writefile(lines, 'Xtest_winscrolled_once', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_once', #{rows: 10, cols: 60, statusoff: 2}) - - call term_sendkeys(buf, "\") - call VerifyScreenDump(buf, 'Test_winscrolled_once_only_1', {}) - - call StopVimInTerminal(buf) -endfunc - -" Check that WinScrolled is not triggered immediately when defined and there -" are split windows. -func Test_WinScrolled_not_when_defined() - CheckRunVimInTerminal - - let lines =<< trim END - call setline(1, ['aaa', 'bbb']) - echo 'nothing happened' - func ShowTriggered(id) - echo 'triggered' - endfunc - END - call writefile(lines, 'Xtest_winscrolled_not', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_not', #{rows: 10, cols: 60, statusoff: 2}) - call term_sendkeys(buf, ":split\") - call TermWait(buf) - " use a timer to show the message after redrawing - call term_sendkeys(buf, ":au WinScrolled * call timer_start(100, 'ShowTriggered')\") - call VerifyScreenDump(buf, 'Test_winscrolled_not_when_defined_1', {}) - - call term_sendkeys(buf, "\") - call VerifyScreenDump(buf, 'Test_winscrolled_not_when_defined_2', {}) - - call StopVimInTerminal(buf) -endfunc - -func Test_WinScrolled_long_wrapped() - CheckRunVimInTerminal - - let lines =<< trim END - set scrolloff=0 - let height = winheight(0) - let width = winwidth(0) - let g:scrolled = 0 - au WinScrolled * let g:scrolled += 1 - call setline(1, repeat('foo', height * width)) - call cursor(1, height * width) - END - call writefile(lines, 'Xtest_winscrolled_long_wrapped', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_long_wrapped', {'rows': 6}) - - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^0 ', term_getline(buf, 6))}, 1000) - - call term_sendkeys(buf, 'gj') - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^1 ', term_getline(buf, 6))}, 1000) - - call term_sendkeys(buf, '0') - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) - - call term_sendkeys(buf, '$') - call term_sendkeys(buf, ":echo g:scrolled\") - call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000) - - call StopVimInTerminal(buf) -endfunc - -func Test_WinScrolled_diff() - CheckRunVimInTerminal - - let lines =<< trim END - set diffopt+=foldcolumn:0 - call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']) - vnew - call setline(1, ['d', 'e', 'f', 'g', 'h', 'i']) - windo diffthis - func WriteScrollEvent() - call writefile([json_encode(v:event)], 'XscrollEvent') - endfunc - au WinScrolled * call WriteScrollEvent() - END - call writefile(lines, 'Xtest_winscrolled_diff', 'D') - let buf = RunVimInTerminal('-S Xtest_winscrolled_diff', {'rows': 8}) - - call term_sendkeys(buf, "\") - call WaitForAssert({-> assert_match('^d', term_getline(buf, 3))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 1, 'topfill': 1, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': 1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1001': {'leftcol': 0, 'topline': 0, 'topfill': -1, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - call term_sendkeys(buf, "2\") - call WaitForAssert({-> assert_match('^f', term_getline(buf, 3))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 2, 'topfill': 2, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': 2, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1001': {'leftcol': 0, 'topline': 0, 'topfill': -2, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - call term_sendkeys(buf, "\") - call WaitForAssert({-> assert_match('^g', term_getline(buf, 3))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 2, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': 1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1001': {'leftcol': 0, 'topline': 1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - call term_sendkeys(buf, "2\") - call WaitForAssert({-> assert_match('^e', term_getline(buf, 3))}, 1000) - - let event = readfile('XscrollEvent')[0]->json_decode() - call assert_equal({ - \ 'all': {'leftcol': 0, 'topline': 3, 'topfill': 1, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1000': {'leftcol': 0, 'topline': -2, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}, - \ '1001': {'leftcol': 0, 'topline': -1, 'topfill': 1, 'width': 0, 'height': 0, 'skipcol': 0} - \ }, event) - - call StopVimInTerminal(buf) - call delete('XscrollEvent') -endfunc - -func Test_WinClosed() - " Test that the pattern is matched against the closed window's ID, and both - " and are set to it. - new - let winid = win_getid() - let g:matched = v:false - augroup test-WinClosed - autocmd! - execute 'autocmd WinClosed' winid 'let g:matched = v:true' - autocmd WinClosed * let g:amatch = str2nr(expand('')) - autocmd WinClosed * let g:afile = str2nr(expand('')) - augroup END - close - call assert_true(g:matched) - call assert_equal(winid, g:amatch) - call assert_equal(winid, g:afile) - - " Test that WinClosed is non-recursive. - new - new - call assert_equal(3, winnr('$')) - let g:triggered = 0 - augroup test-WinClosed - autocmd! - autocmd WinClosed * let g:triggered += 1 - autocmd WinClosed * 2 wincmd c - augroup END - close - call assert_equal(1, winnr('$')) - call assert_equal(1, g:triggered) - - autocmd! test-WinClosed - augroup! test-WinClosed - unlet g:matched - unlet g:amatch - unlet g:afile - unlet g:triggered -endfunc - -func Test_WinClosed_throws() - vnew - let bnr = bufnr() - call assert_equal(1, bufloaded(bnr)) - augroup test-WinClosed - autocmd WinClosed * throw 'foo' - augroup END - try - close - catch /.*/ - endtry - call assert_equal(0, bufloaded(bnr)) - - autocmd! test-WinClosed - augroup! test-WinClosed -endfunc - -func Test_WinClosed_throws_with_tabs() - tabnew - let bnr = bufnr() - call assert_equal(1, bufloaded(bnr)) - augroup test-WinClosed - autocmd WinClosed * throw 'foo' - augroup END - try - close - catch /.*/ - endtry - call assert_equal(0, bufloaded(bnr)) - - autocmd! test-WinClosed - augroup! test-WinClosed -endfunc - -" This used to trigger WinClosed twice for the same window, and the window's -" buffer was NULL in the second autocommand. -func Test_WinClosed_switch_tab() - edit Xa - split Xb - split Xc - tab split - new - augroup test-WinClosed - autocmd WinClosed * tabprev | bwipe! - augroup END - close - " Check that the tabline has been fully removed - call assert_equal([1, 1], win_screenpos(0)) - - autocmd! test-WinClosed - augroup! test-WinClosed - %bwipe! -endfunc - -func s:AddAnAutocmd() - augroup vimBarTest - au BufReadCmd * echo 'hello' - augroup END - call assert_equal(3, len(split(execute('au vimBarTest'), "\n"))) -endfunc - -func Test_early_bar() - " test that a bar is recognized before the {event} - call s:AddAnAutocmd() - augroup vimBarTest | au! | let done = 77 | augroup END - call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) - call assert_equal(77, done) - - call s:AddAnAutocmd() - augroup vimBarTest| au!| let done = 88 | augroup END - call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) - call assert_equal(88, done) - - " test that a bar is recognized after the {event} - call s:AddAnAutocmd() - augroup vimBarTest| au!BufReadCmd| let done = 99 | augroup END - call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) - call assert_equal(99, done) - - " test that a bar is recognized after the {group} - call s:AddAnAutocmd() - au! vimBarTest|echo 'hello' - call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) -endfunc - -func RemoveGroup() - autocmd! StartOK - augroup! StartOK -endfunc - -func Test_augroup_warning() - augroup TheWarning - au VimEnter * echo 'entering' - augroup END - call assert_match("TheWarning.*VimEnter", execute('au VimEnter')) - redir => res - augroup! TheWarning - redir END - call assert_match("W19:", res) - call assert_match("-Deleted-.*VimEnter", execute('au VimEnter')) - - " check "Another" does not take the pace of the deleted entry - augroup Another - augroup END - call assert_match("-Deleted-.*VimEnter", execute('au VimEnter')) - augroup! Another - - " no warning for postpone aucmd delete - augroup StartOK - au VimEnter * call RemoveGroup() - augroup END - call assert_match("StartOK.*VimEnter", execute('au VimEnter')) - redir => res - doautocmd VimEnter - redir END - call assert_notmatch("W19:", res) - au! VimEnter - - call assert_fails('augroup!', 'E471:') -endfunc - -func Test_BufReadCmdHelp() - " This used to cause access to free memory - au BufReadCmd * e +h - help - - au! BufReadCmd -endfunc - -func Test_BufReadCmdHelpJump() - " This used to cause access to free memory - au BufReadCmd * e +h{ - " } to fix highlighting - call assert_fails('help', 'E434:') - - au! BufReadCmd -endfunc - -" BufReadCmd is triggered for a "nofile" buffer. Check all values. -func Test_BufReadCmdNofile() - for val in ['nofile', - \ 'nowrite', - \ 'acwrite', - \ 'quickfix', - \ 'help', - "\ 'terminal', - \ 'prompt', - "\ 'popup', - \ ] - new somefile - exe 'set buftype=' .. val - au BufReadCmd somefile call setline(1, 'triggered') - edit - call assert_equal('triggered', getline(1)) - - au! BufReadCmd - bwipe! - endfor -endfunc - -func Test_augroup_deleted() - " This caused a crash before E936 was introduced - augroup x - call assert_fails('augroup! x', 'E936:') - au VimEnter * echo - augroup end - augroup! x - call assert_match("-Deleted-.*VimEnter", execute('au VimEnter')) - au! VimEnter -endfunc - -" Tests for autocommands on :close command. -" This used to be in test13. -func Test_three_windows() - " Clean up buffers, because in some cases this function fails. - call s:cleanup_buffers() - - " Write three files and open them, each in a window. - " Then go to next window, with autocommand that deletes the previous one. - " Do this twice, writing the file. - e! Xtestje1 - call setline(1, 'testje1') - w - sp Xtestje2 - call setline(1, 'testje2') - w - sp Xtestje3 - call setline(1, 'testje3') - w - wincmd w - au WinLeave Xtestje2 bwipe - wincmd w - call assert_equal('Xtestje1', expand('%')) - - au WinLeave Xtestje1 bwipe Xtestje3 - close - call assert_equal('Xtestje1', expand('%')) - - " Test deleting the buffer on a Unload event. If this goes wrong there - " will be the ATTENTION prompt. - e Xtestje1 - au! - au! BufUnload Xtestje1 bwipe - call assert_fails('e Xtestje3', 'E937:') - call assert_equal('Xtestje3', expand('%')) - - e Xtestje2 - sp Xtestje1 - call assert_fails('e', 'E937:') - call assert_equal('Xtestje1', expand('%')) - - " Test changing buffers in a BufWipeout autocommand. If this goes wrong - " there are ml_line errors and/or a Crash. - au! - only - e Xanother - e Xtestje1 - bwipe Xtestje2 - bwipe Xtestje3 - au BufWipeout Xtestje1 buf Xtestje1 - bwipe - call assert_equal('Xanother', expand('%')) - - only - - help - wincmd w - 1quit - call assert_equal('Xanother', expand('%')) - - au! - enew - call delete('Xtestje1') - call delete('Xtestje2') - call delete('Xtestje3') -endfunc - -func Test_BufEnter() - au! BufEnter - au Bufenter * let val = val . '+' - let g:val = '' - split NewFile - call assert_equal('+', g:val) - bwipe! - call assert_equal('++', g:val) - - " Also get BufEnter when editing a directory - call mkdir('Xdir') - split Xdir - call assert_equal('+++', g:val) - - " On MS-Windows we can't edit the directory, make sure we wipe the right - " buffer. - bwipe! Xdir - call delete('Xdir', 'd') - au! BufEnter - - " Editing a "nofile" buffer doesn't read the file but does trigger BufEnter - " for historic reasons. Also test other 'buftype' values. - for val in ['nofile', - \ 'nowrite', - \ 'acwrite', - \ 'quickfix', - \ 'help', - "\ 'terminal', - \ 'prompt', - "\ 'popup', - \ ] - new somefile - exe 'set buftype=' .. val - au BufEnter somefile call setline(1, 'some text') - edit - call assert_equal('some text', getline(1)) - bwipe! - au! BufEnter - endfor -endfunc - -" Closing a window might cause an endless loop -" E814 for older Vims -func Test_autocmd_bufwipe_in_SessLoadPost() - edit Xtest - tabnew - file Xsomething - set noswapfile - mksession! - - let content =<< trim [CODE] - set nocp noswapfile - let v:swapchoice = "e" - augroup test_autocmd_sessionload - autocmd! - autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!" - augroup END - - func WriteErrors() - call writefile([execute("messages")], "Xerrors") - endfunc - au VimLeave * call WriteErrors() - [CODE] - - call writefile(content, 'Xvimrc') - call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq') - let errors = join(readfile('Xerrors')) - call assert_match('E814', errors) - - set swapfile - for file in ['Session.vim', 'Xvimrc', 'Xerrors'] - call delete(file) - endfor -endfunc - -" Using :blast and :ball for many events caused a crash, because b_nwindows was -" not incremented correctly. -func Test_autocmd_blast_badd() - let content =<< trim [CODE] - au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* blast - edit foo1 - au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* ball - edit foo2 - call writefile(['OK'], 'Xerrors') - qall - [CODE] - - call writefile(content, 'XblastBall') - call system(GetVimCommand() .. ' --clean -S XblastBall') - call assert_match('OK', readfile('Xerrors')->join()) - - call delete('XblastBall') - call delete('Xerrors') -endfunc - -" SEGV occurs in older versions. -func Test_autocmd_bufwipe_in_SessLoadPost2() - tabnew - set noswapfile - mksession! - - let content =<< trim [CODE] - set nocp noswapfile - function! DeleteInactiveBufs() - tabfirst - let tabblist = [] - for i in range(1, tabpagenr(''$'')) - call extend(tabblist, tabpagebuflist(i)) - endfor - for b in range(1, bufnr(''$'')) - if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'') - exec ''bwipeout '' . b - endif - endfor - echomsg "SessionLoadPost DONE" - endfunction - au SessionLoadPost * call DeleteInactiveBufs() - - func WriteErrors() - call writefile([execute("messages")], "Xerrors") - endfunc - au VimLeave * call WriteErrors() - [CODE] - - call writefile(content, 'Xvimrc') - call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq') - let errors = join(readfile('Xerrors')) - " This probably only ever matches on unix. - call assert_notmatch('Caught deadly signal SEGV', errors) - call assert_match('SessionLoadPost DONE', errors) - - set swapfile - for file in ['Session.vim', 'Xvimrc', 'Xerrors'] - call delete(file) - endfor -endfunc - -func Test_empty_doau() - doau \| -endfunc - -func s:AutoCommandOptionSet(match) - let template = "Option: <%s>, OldVal: <%s>, OldValLocal: <%s>, OldValGlobal: <%s>, NewVal: <%s>, Scope: <%s>, Command: <%s>\n" - let item = remove(g:options, 0) - let expected = printf(template, item[0], item[1], item[2], item[3], item[4], item[5], item[6]) - let actual = printf(template, a:match, v:option_old, v:option_oldlocal, v:option_oldglobal, v:option_new, v:option_type, v:option_command) - let g:opt = [expected, actual] - "call assert_equal(expected, actual) -endfunc - -func Test_OptionSet() - CheckFunction test_override - CheckOption autochdir - - call test_override('starting', 1) - set nocp - au OptionSet * :call s:AutoCommandOptionSet(expand("")) - - " 1: Setting number option" - let g:options = [['number', 0, 0, 0, 1, 'global', 'set']] - set nu - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 2: Setting local number option" - let g:options = [['number', 1, 1, '', 0, 'local', 'setlocal']] - setlocal nonu - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 3: Setting global number option" - let g:options = [['number', 1, '', 1, 0, 'global', 'setglobal']] - setglobal nonu - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 4: Setting local autoindent option" - let g:options = [['autoindent', 0, 0, '', 1, 'local', 'setlocal']] - setlocal ai - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 5: Setting global autoindent option" - let g:options = [['autoindent', 0, '', 0, 1, 'global', 'setglobal']] - setglobal ai - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 6: Setting global autoindent option" - let g:options = [['autoindent', 1, 1, 1, 0, 'global', 'set']] - set ai! - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 6a: Setting global autoindent option" - let g:options = [['autoindent', 1, 1, 0, 0, 'global', 'set']] - noa setlocal ai - noa setglobal noai - set ai! - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " Should not print anything, use :noa - " 7: don't trigger OptionSet" - let g:options = [['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']] - noa set nonu - call assert_equal([['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 8: Setting several global list and number option" - let g:options = [['list', 0, 0, 0, 1, 'global', 'set'], ['number', 0, 0, 0, 1, 'global', 'set']] - set list nu - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 9: don't trigger OptionSet" - let g:options = [['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid'], ['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']] - noa set nolist nonu - call assert_equal([['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid'], ['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 10: Setting global acd" - let g:options = [['autochdir', 0, 0, '', 1, 'local', 'setlocal']] - setlocal acd - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 11: Setting global autoread (also sets local value)" - let g:options = [['autoread', 0, 0, 0, 1, 'global', 'set']] - set ar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 12: Setting local autoread" - let g:options = [['autoread', 1, 1, '', 1, 'local', 'setlocal']] - setlocal ar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 13: Setting global autoread" - let g:options = [['autoread', 1, '', 1, 0, 'global', 'setglobal']] - setglobal invar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 14: Setting option backspace through :let" - let g:options = [['backspace', '', '', '', 'eol,indent,start', 'global', 'set']] - let &bs = "eol,indent,start" - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 15: Setting option backspace through setbufvar()" - let g:options = [['backup', 0, 0, '', 1, 'local', 'setlocal']] - " try twice, first time, shouldn't trigger because option name is invalid, - " second time, it should trigger - let bnum = bufnr('%') - call assert_fails("call setbufvar(bnum, '&l:bk', 1)", 'E355:') - " should trigger, use correct option name - call setbufvar(bnum, '&backup', 1) - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 16: Setting number option using setwinvar" - let g:options = [['number', 0, 0, '', 1, 'local', 'setlocal']] - call setwinvar(0, '&number', 1) - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 17: Setting key option, shouldn't trigger" - let g:options = [['key', 'invalid', 'invalid1', 'invalid2', 'invalid3', 'invalid4', 'invalid5']] - setlocal key=blah - setlocal key= - call assert_equal([['key', 'invalid', 'invalid1', 'invalid2', 'invalid3', 'invalid4', 'invalid5']], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 18a: Setting string global option" - let oldval = &backupext - let g:options = [['backupext', oldval, oldval, oldval, 'foo', 'global', 'set']] - set backupext=foo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 18b: Resetting string global option" - let g:options = [['backupext', 'foo', 'foo', 'foo', oldval, 'global', 'set']] - set backupext& - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 18c: Setting global string global option" - let g:options = [['backupext', oldval, '', oldval, 'bar', 'global', 'setglobal']] - setglobal backupext=bar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 18d: Setting local string global option" - " As this is a global option this sets the global value even though - " :setlocal is used! - noa set backupext& " Reset global and local value (without triggering autocmd) - let g:options = [['backupext', oldval, oldval, '', 'baz', 'local', 'setlocal']] - setlocal backupext=baz - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 18e: Setting again string global option" - noa setglobal backupext=ext_global " Reset global and local value (without triggering autocmd) - noa setlocal backupext=ext_local " Sets the global(!) value! - let g:options = [['backupext', 'ext_local', 'ext_local', 'ext_local', 'fuu', 'global', 'set']] - set backupext=fuu - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 19a: Setting string global-local (to buffer) option" - let oldval = &tags - let g:options = [['tags', oldval, oldval, oldval, 'tagpath', 'global', 'set']] - set tags=tagpath - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 19b: Resetting string global-local (to buffer) option" - let g:options = [['tags', 'tagpath', 'tagpath', 'tagpath', oldval, 'global', 'set']] - set tags& - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 19c: Setting global string global-local (to buffer) option " - let g:options = [['tags', oldval, '', oldval, 'tagpath1', 'global', 'setglobal']] - setglobal tags=tagpath1 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 19d: Setting local string global-local (to buffer) option" - let g:options = [['tags', 'tagpath1', 'tagpath1', '', 'tagpath2', 'local', 'setlocal']] - setlocal tags=tagpath2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 19e: Setting again string global-local (to buffer) option" - " Note: v:option_old is the old global value for global-local string options - " but the old local value for all other kinds of options. - noa setglobal tags=tag_global " Reset global and local value (without triggering autocmd) - noa setlocal tags=tag_local - let g:options = [['tags', 'tag_global', 'tag_local', 'tag_global', 'tagpath', 'global', 'set']] - set tags=tagpath - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 19f: Setting string global-local (to buffer) option to an empty string" - " Note: v:option_old is the old global value for global-local string options - " but the old local value for all other kinds of options. - noa set tags=tag_global " Reset global and local value (without triggering autocmd) - noa setlocal tags= " empty string - let g:options = [['tags', 'tag_global', '', 'tag_global', 'tagpath', 'global', 'set']] - set tags=tagpath - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 20a: Setting string local (to buffer) option" - let oldval = &spelllang - let g:options = [['spelllang', oldval, oldval, oldval, 'elvish,klingon', 'global', 'set']] - set spelllang=elvish,klingon - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 20b: Resetting string local (to buffer) option" - let g:options = [['spelllang', 'elvish,klingon', 'elvish,klingon', 'elvish,klingon', oldval, 'global', 'set']] - set spelllang& - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 20c: Setting global string local (to buffer) option" - let g:options = [['spelllang', oldval, '', oldval, 'elvish', 'global', 'setglobal']] - setglobal spelllang=elvish - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 20d: Setting local string local (to buffer) option" - noa set spelllang& " Reset global and local value (without triggering autocmd) - let g:options = [['spelllang', oldval, oldval, '', 'klingon', 'local', 'setlocal']] - setlocal spelllang=klingon - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 20e: Setting again string local (to buffer) option" - " Note: v:option_old is the old global value for global-local string options - " but the old local value for all other kinds of options. - noa setglobal spelllang=spellglobal " Reset global and local value (without triggering autocmd) - noa setlocal spelllang=spelllocal - let g:options = [['spelllang', 'spelllocal', 'spelllocal', 'spellglobal', 'foo', 'global', 'set']] - set spelllang=foo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 21a: Setting string global-local (to window) option" - let oldval = &statusline - let g:options = [['statusline', oldval, oldval, oldval, 'foo', 'global', 'set']] - set statusline=foo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 21b: Resetting string global-local (to window) option" - " Note: v:option_old is the old global value for global-local string options - " but the old local value for all other kinds of options. - let g:options = [['statusline', 'foo', 'foo', 'foo', oldval, 'global', 'set']] - set statusline& - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 21c: Setting global string global-local (to window) option" - let g:options = [['statusline', oldval, '', oldval, 'bar', 'global', 'setglobal']] - setglobal statusline=bar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 21d: Setting local string global-local (to window) option" - noa set statusline& " Reset global and local value (without triggering autocmd) - let g:options = [['statusline', oldval, oldval, '', 'baz', 'local', 'setlocal']] - setlocal statusline=baz - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 21e: Setting again string global-local (to window) option" - " Note: v:option_old is the old global value for global-local string options - " but the old local value for all other kinds of options. - noa setglobal statusline=bar " Reset global and local value (without triggering autocmd) - noa setlocal statusline=baz - let g:options = [['statusline', 'bar', 'baz', 'bar', 'foo', 'global', 'set']] - set statusline=foo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 22a: Setting string local (to window) option" - let oldval = &foldignore - let g:options = [['foldignore', oldval, oldval, oldval, 'fo', 'global', 'set']] - set foldignore=fo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 22b: Resetting string local (to window) option" - let g:options = [['foldignore', 'fo', 'fo', 'fo', oldval, 'global', 'set']] - set foldignore& - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 22c: Setting global string local (to window) option" - let g:options = [['foldignore', oldval, '', oldval, 'bar', 'global', 'setglobal']] - setglobal foldignore=bar - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 22d: Setting local string local (to window) option" - noa set foldignore& " Reset global and local value (without triggering autocmd) - let g:options = [['foldignore', oldval, oldval, '', 'baz', 'local', 'setlocal']] - setlocal foldignore=baz - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 22e: Setting again string local (to window) option" - noa setglobal foldignore=glob " Reset global and local value (without triggering autocmd) - noa setlocal foldignore=loc - let g:options = [['foldignore', 'loc', 'loc', 'glob', 'fo', 'global', 'set']] - set foldignore=fo - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 23a: Setting global number global option" - noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) - noa setlocal cmdheight=1 " Sets the global(!) value! - let g:options = [['cmdheight', '1', '', '1', '2', 'global', 'setglobal']] - setglobal cmdheight=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 23b: Setting local number global option" - noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) - noa setlocal cmdheight=1 " Sets the global(!) value! - let g:options = [['cmdheight', '1', '1', '', '2', 'local', 'setlocal']] - setlocal cmdheight=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 23c: Setting again number global option" - noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) - noa setlocal cmdheight=1 " Sets the global(!) value! - let g:options = [['cmdheight', '1', '1', '1', '2', 'global', 'set']] - set cmdheight=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 23d: Setting again number global option" - noa set cmdheight=8 " Reset global and local value (without triggering autocmd) - let g:options = [['cmdheight', '8', '8', '8', '2', 'global', 'set']] - set cmdheight=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 24a: Setting global number global-local (to buffer) option" - noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) - noa setlocal undolevels=1 - let g:options = [['undolevels', '8', '', '8', '2', 'global', 'setglobal']] - setglobal undolevels=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 24b: Setting local number global-local (to buffer) option" - noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) - noa setlocal undolevels=1 - let g:options = [['undolevels', '1', '1', '', '2', 'local', 'setlocal']] - setlocal undolevels=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 24c: Setting again number global-local (to buffer) option" - noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) - noa setlocal undolevels=1 - let g:options = [['undolevels', '1', '1', '8', '2', 'global', 'set']] - set undolevels=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 24d: Setting again global number global-local (to buffer) option" - noa set undolevels=8 " Reset global and local value (without triggering autocmd) - let g:options = [['undolevels', '8', '8', '8', '2', 'global', 'set']] - set undolevels=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 25a: Setting global number local (to buffer) option" - noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) - noa setlocal wrapmargin=1 - let g:options = [['wrapmargin', '8', '', '8', '2', 'global', 'setglobal']] - setglobal wrapmargin=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 25b: Setting local number local (to buffer) option" - noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) - noa setlocal wrapmargin=1 - let g:options = [['wrapmargin', '1', '1', '', '2', 'local', 'setlocal']] - setlocal wrapmargin=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 25c: Setting again number local (to buffer) option" - noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) - noa setlocal wrapmargin=1 - let g:options = [['wrapmargin', '1', '1', '8', '2', 'global', 'set']] - set wrapmargin=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 25d: Setting again global number local (to buffer) option" - noa set wrapmargin=8 " Reset global and local value (without triggering autocmd) - let g:options = [['wrapmargin', '8', '8', '8', '2', 'global', 'set']] - set wrapmargin=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 26: Setting number global-local (to window) option. - " Such option does currently not exist. - - - " 27a: Setting global number local (to window) option" - noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) - noa setlocal foldcolumn=1 - let g:options = [['foldcolumn', '8', '', '8', '2', 'global', 'setglobal']] - setglobal foldcolumn=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 27b: Setting local number local (to window) option" - noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) - noa setlocal foldcolumn=1 - let g:options = [['foldcolumn', '1', '1', '', '2', 'local', 'setlocal']] - setlocal foldcolumn=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 27c: Setting again number local (to window) option" - noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) - noa setlocal foldcolumn=1 - let g:options = [['foldcolumn', '1', '1', '8', '2', 'global', 'set']] - set foldcolumn=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 27d: Setting again global number local (to window) option" - noa set foldcolumn=8 " Reset global and local value (without triggering autocmd) - let g:options = [['foldcolumn', '8', '8', '8', '2', 'global', 'set']] - set foldcolumn=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 28a: Setting global boolean global option" - noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) - noa setlocal wrapscan " Sets the global(!) value! - let g:options = [['wrapscan', '1', '', '1', '0', 'global', 'setglobal']] - setglobal nowrapscan - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 28b: Setting local boolean global option" - noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) - noa setlocal wrapscan " Sets the global(!) value! - let g:options = [['wrapscan', '1', '1', '', '0', 'local', 'setlocal']] - setlocal nowrapscan - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 28c: Setting again boolean global option" - noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) - noa setlocal wrapscan " Sets the global(!) value! - let g:options = [['wrapscan', '1', '1', '1', '0', 'global', 'set']] - set nowrapscan - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 28d: Setting again global boolean global option" - noa set nowrapscan " Reset global and local value (without triggering autocmd) - let g:options = [['wrapscan', '0', '0', '0', '1', 'global', 'set']] - set wrapscan - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 29a: Setting global boolean global-local (to buffer) option" - noa setglobal noautoread " Reset global and local value (without triggering autocmd) - noa setlocal autoread - let g:options = [['autoread', '0', '', '0', '1', 'global', 'setglobal']] - setglobal autoread - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 29b: Setting local boolean global-local (to buffer) option" - noa setglobal noautoread " Reset global and local value (without triggering autocmd) - noa setlocal autoread - let g:options = [['autoread', '1', '1', '', '0', 'local', 'setlocal']] - setlocal noautoread - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 29c: Setting again boolean global-local (to buffer) option" - noa setglobal noautoread " Reset global and local value (without triggering autocmd) - noa setlocal autoread - let g:options = [['autoread', '1', '1', '0', '1', 'global', 'set']] - set autoread - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 29d: Setting again global boolean global-local (to buffer) option" - noa set noautoread " Reset global and local value (without triggering autocmd) - let g:options = [['autoread', '0', '0', '0', '1', 'global', 'set']] - set autoread - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 30a: Setting global boolean local (to buffer) option" - noa setglobal nocindent " Reset global and local value (without triggering autocmd) - noa setlocal cindent - let g:options = [['cindent', '0', '', '0', '1', 'global', 'setglobal']] - setglobal cindent - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 30b: Setting local boolean local (to buffer) option" - noa setglobal nocindent " Reset global and local value (without triggering autocmd) - noa setlocal cindent - let g:options = [['cindent', '1', '1', '', '0', 'local', 'setlocal']] - setlocal nocindent - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 30c: Setting again boolean local (to buffer) option" - noa setglobal nocindent " Reset global and local value (without triggering autocmd) - noa setlocal cindent - let g:options = [['cindent', '1', '1', '0', '1', 'global', 'set']] - set cindent - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 30d: Setting again global boolean local (to buffer) option" - noa set nocindent " Reset global and local value (without triggering autocmd) - let g:options = [['cindent', '0', '0', '0', '1', 'global', 'set']] - set cindent - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 31: Setting boolean global-local (to window) option - " Currently no such option exists. - - - " 32a: Setting global boolean local (to window) option" - noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) - noa setlocal cursorcolumn - let g:options = [['cursorcolumn', '0', '', '0', '1', 'global', 'setglobal']] - setglobal cursorcolumn - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 32b: Setting local boolean local (to window) option" - noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) - noa setlocal cursorcolumn - let g:options = [['cursorcolumn', '1', '1', '', '0', 'local', 'setlocal']] - setlocal nocursorcolumn - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 32c: Setting again boolean local (to window) option" - noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) - noa setlocal cursorcolumn - let g:options = [['cursorcolumn', '1', '1', '0', '1', 'global', 'set']] - set cursorcolumn - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - " 32d: Setting again global boolean local (to window) option" - noa set nocursorcolumn " Reset global and local value (without triggering autocmd) - let g:options = [['cursorcolumn', '0', '0', '0', '1', 'global', 'set']] - set cursorcolumn - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " 33: Test autocommands when an option value is converted internally. - noa set backspace=1 " Reset global and local value (without triggering autocmd) - let g:options = [['backspace', 'indent,eol', 'indent,eol', 'indent,eol', '2', 'global', 'set']] - set backspace=2 - call assert_equal([], g:options) - call assert_equal(g:opt[0], g:opt[1]) - - - " Cleanup - au! OptionSet - " set tags& - for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp', 'backupext', 'tags', 'spelllang', 'statusline', 'foldignore', 'cmdheight', 'undolevels', 'wrapmargin', 'foldcolumn', 'wrapscan', 'autoread', 'cindent', 'cursorcolumn'] - exe printf(":set %s&vim", opt) - endfor - call test_override('starting', 0) - delfunc! AutoCommandOptionSet -endfunc - -func Test_OptionSet_diffmode() - CheckFunction test_override - call test_override('starting', 1) - " 18: Changing an option when entering diff mode - new - au OptionSet diff :let &l:cul = v:option_new - - call setline(1, ['buffer 1', 'line2', 'line3', 'line4']) - call assert_equal(0, &l:cul) - diffthis - call assert_equal(1, &l:cul) - - vnew - call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4']) - call assert_equal(0, &l:cul) - diffthis - call assert_equal(1, &l:cul) - - diffoff - call assert_equal(0, &l:cul) - call assert_equal(1, getwinvar(2, '&l:cul')) - bw! - - call assert_equal(1, &l:cul) - diffoff! - call assert_equal(0, &l:cul) - call assert_equal(0, getwinvar(1, '&l:cul')) - bw! - - " Cleanup - au! OptionSet - call test_override('starting', 0) -endfunc - -func Test_OptionSet_diffmode_close() - CheckFunction test_override - call test_override('starting', 1) - " 19: Try to close the current window when entering diff mode - " should not segfault - new - au OptionSet diff close - - call setline(1, ['buffer 1', 'line2', 'line3', 'line4']) - call assert_fails(':diffthis', 'E788') - call assert_equal(1, &diff) - vnew - call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4']) - call assert_fails(':diffthis', 'E788') - call assert_equal(1, &diff) - set diffopt-=closeoff - bw! - call assert_fails(':diffoff!', 'E788') - bw! - - " Cleanup - au! OptionSet - call test_override('starting', 0) - "delfunc! AutoCommandOptionSet -endfunc - -" Test for Bufleave autocommand that deletes the buffer we are about to edit. -func Test_BufleaveWithDelete() - new | edit Xfile1 - - augroup test_bufleavewithdelete - autocmd! - autocmd BufLeave Xfile1 bwipe Xfile2 - augroup END - - call assert_fails('edit Xfile2', 'E143:') - call assert_equal('Xfile1', bufname('%')) - - autocmd! test_bufleavewithdelete BufLeave Xfile1 - augroup! test_bufleavewithdelete - - new - bwipe! Xfile1 -endfunc - -" Test for autocommand that changes the buffer list, when doing ":ball". -func Test_Acmd_BufAll() - enew! - %bwipe! - call writefile(['Test file Xxx1'], 'Xxx1') - call writefile(['Test file Xxx2'], 'Xxx2') - call writefile(['Test file Xxx3'], 'Xxx3') - - " Add three files to the buffer list - split Xxx1 - close - split Xxx2 - close - split Xxx3 - close - - " Wipe the buffer when the buffer is opened - au BufReadPost Xxx2 bwipe - - call append(0, 'Test file Xxx4') - ball - - call assert_equal(2, winnr('$')) - call assert_equal('Xxx1', bufname(winbufnr(winnr('$')))) - wincmd t - - au! BufReadPost - %bwipe! - call delete('Xxx1') - call delete('Xxx2') - call delete('Xxx3') - enew! | only -endfunc - -" Test for autocommand that changes current buffer on BufEnter event. -" Check if modelines are interpreted for the correct buffer. -func Test_Acmd_BufEnter() - %bwipe! - call writefile(['start of test file Xxx1', - \ "\this is a test", - \ 'end of test file Xxx1'], 'Xxx1') - call writefile(['start of test file Xxx2', - \ 'vim: set noai :', - \ "\this is a test", - \ 'end of test file Xxx2'], 'Xxx2') - - au BufEnter Xxx2 brew - set ai modeline modelines=3 - edit Xxx1 - " edit Xxx2, autocmd will do :brew - edit Xxx2 - exe "normal G?this is a\" - " Append text with autoindent to this file - normal othis should be auto-indented - call assert_equal("\this should be auto-indented", getline('.')) - call assert_equal(3, line('.')) - " Remove autocmd and edit Xxx2 again - au! BufEnter Xxx2 - buf! Xxx2 - exe "normal G?this is a\" - " append text without autoindent to Xxx - normal othis should be in column 1 - call assert_equal("this should be in column 1", getline('.')) - call assert_equal(4, line('.')) - - %bwipe! - call delete('Xxx1') - call delete('Xxx2') - set ai&vim modeline&vim modelines&vim -endfunc - -" Test for issue #57 -" do not move cursor on when autoindent is set -func Test_ai_CTRL_O() - enew! - set ai - let save_fo = &fo - set fo+=r - exe "normal o# abcdef\2hi\\d0\" - exe "normal o# abcdef\2hi\d0\" - call assert_equal(['# abc', 'def', 'def'], getline(2, 4)) - - set ai&vim - let &fo = save_fo - enew! -endfunc - -" Test for autocommand that deletes the current buffer on BufLeave event. -" Also test deleting the last buffer, should give a new, empty buffer. -func Test_BufLeave_Wipe() - %bwipe! - let content = ['start of test file Xxx', - \ 'this is a test', - \ 'end of test file Xxx'] - call writefile(content, 'Xxx1') - call writefile(content, 'Xxx2') - - au BufLeave Xxx2 bwipe - edit Xxx1 - split Xxx2 - " delete buffer Xxx2, we should be back to Xxx1 - bwipe - call assert_equal('Xxx1', bufname('%')) - call assert_equal(1, winnr('$')) - - " Create an alternate buffer - %write! test.out - call assert_equal('test.out', bufname('#')) - " delete alternate buffer - bwipe test.out - call assert_equal('Xxx1', bufname('%')) - call assert_equal('', bufname('#')) - - au BufLeave Xxx1 bwipe - " delete current buffer, get an empty one - bwipe! - call assert_equal(1, line('$')) - call assert_equal('', bufname('%')) - let g:bufinfo = getbufinfo() - call assert_equal(1, len(g:bufinfo)) - - call delete('Xxx1') - call delete('Xxx2') - call delete('test.out') - %bwipe - au! BufLeave - - " check that bufinfo doesn't contain a pointer to freed memory - call test_garbagecollect_now() -endfunc - -func Test_QuitPre() - edit Xfoo - let winid = win_getid(winnr()) - split Xbar - au! QuitPre * let g:afile = expand('') - " Close the other window, should be correct. - exe win_id2win(winid) . 'q' - call assert_equal('Xfoo', g:afile) - - unlet g:afile - bwipe Xfoo - bwipe Xbar -endfunc - -func Test_Cmdline() - au! CmdlineChanged : let g:text = getcmdline() - let g:text = 0 - call feedkeys(":echom 'hello'\", 'xt') - call assert_equal("echom 'hello'", g:text) - au! CmdlineChanged - - au! CmdlineChanged : let g:entered = expand('') - let g:entered = 0 - call feedkeys(":echom 'hello'\", 'xt') - call assert_equal(':', g:entered) - au! CmdlineChanged - - autocmd CmdlineChanged : let g:log += [getcmdline()] - - let g:log = [] - cnoremap call setcmdline('ls') - call feedkeys(":\", 'xt') - call assert_equal(['ls'], g:log) - cunmap - - let g:log = [] - call feedkeys(":sign \\\\\\\", 'xt') - call assert_equal([ - \ 's', - \ 'si', - \ 'sig', - \ 'sign', - \ 'sign ', - \ 'sign define', - \ 'sign jump', - \ 'sign list', - \ 'sign jump', - \ 'sign define', - \ 'sign ', - \ ], g:log) - let g:log = [] - set wildmenu wildoptions+=pum - call feedkeys(":sign \\\\\\", 'xt') - call assert_equal([ - \ 's', - \ 'si', - \ 'sig', - \ 'sign', - \ 'sign ', - \ 'sign unplace', - \ 'sign jump', - \ 'sign define', - \ 'sign undefine', - \ 'sign unplace', - \ ], g:log) - set wildmenu& wildoptions& - - let g:log = [] - let @r = 'abc' - call feedkeys(":0\r1\\r2\\r3\", 'xt') - call assert_equal([ - \ '0', - \ '0a', - \ '0ab', - \ '0abc', - \ '0abc1', - \ '0abc1abc', - \ '0abc1abc2', - \ '0abc1abc2abc', - \ '0abc1abc2abc3', - \ ], g:log) - - unlet g:log - au! CmdlineChanged - - au! CmdlineEnter : let g:entered = expand('') - au! CmdlineLeave : let g:left = expand('') - let g:entered = 0 - let g:left = 0 - call feedkeys(":echo 'hello'\", 'xt') - call assert_equal(':', g:entered) - call assert_equal(':', g:left) - au! CmdlineEnter - au! CmdlineLeave - - let save_shellslash = &shellslash - set noshellslash - au! CmdlineEnter / let g:entered = expand('') - au! CmdlineLeave / let g:left = expand('') - let g:entered = 0 - let g:left = 0 - new - call setline(1, 'hello') - call feedkeys("/hello\", 'xt') - call assert_equal('/', g:entered) - call assert_equal('/', g:left) - bwipe! - au! CmdlineEnter - au! CmdlineLeave - let &shellslash = save_shellslash -endfunc - -" Test for BufWritePre autocommand that deletes or unloads the buffer. -func Test_BufWritePre() - %bwipe - au BufWritePre Xxx1 bunload - au BufWritePre Xxx2 bwipe - - call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1') - call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2') - - edit Xtest - e! Xxx2 - bdel Xtest - e Xxx1 - " write it, will unload it and give an error msg - call assert_fails('w', 'E203') - call assert_equal('Xxx2', bufname('%')) - edit Xtest - e! Xxx2 - bwipe Xtest - " write it, will delete the buffer and give an error msg - call assert_fails('w', 'E203') - call assert_equal('Xxx1', bufname('%')) - au! BufWritePre - call delete('Xxx1') - call delete('Xxx2') -endfunc - -" Test for BufUnload autocommand that unloads all the other buffers -func Test_bufunload_all() - call writefile(['Test file Xxx1'], 'Xxx1')" - call writefile(['Test file Xxx2'], 'Xxx2')" - - let content =<< trim [CODE] - func UnloadAllBufs() - let i = 1 - while i <= bufnr('$') - if i != bufnr('%') && bufloaded(i) - exe i . 'bunload' - endif - let i += 1 - endwhile - endfunc - au BufUnload * call UnloadAllBufs() - au VimLeave * call writefile(['Test Finished'], 'Xout') - set nohidden - edit Xxx1 - split Xxx2 - q - [CODE] - - call writefile(content, 'Xtest') - - call delete('Xout') - call system(GetVimCommandClean() .. ' -N --headless -S Xtest') - call assert_true(filereadable('Xout')) - - call delete('Xxx1') - call delete('Xxx2') - call delete('Xtest') - call delete('Xout') -endfunc - -" Some tests for buffer-local autocommands -func Test_buflocal_autocmd() - let g:bname = '' - edit xx - au BufLeave let g:bname = expand("%") - " here, autocommand for xx should trigger. - " but autocommand shall not apply to buffer named . - edit somefile - call assert_equal('xx', g:bname) - let g:bname = '' - " here, autocommand shall be auto-deleted - bwipe xx - " autocmd should not trigger - edit xx - call assert_equal('', g:bname) - " autocmd should not trigger - edit somefile - call assert_equal('', g:bname) - enew - unlet g:bname -endfunc - -" Test for "*Cmd" autocommands -func Test_Cmd_Autocmds() - call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx') - - enew! - au BufReadCmd XtestA 0r Xxx|$del - edit XtestA " will read text of Xxd instead - call assert_equal('start of Xxx', getline(1)) - - au BufWriteCmd XtestA call append(line("$"), "write") - write " will append a line to the file - call assert_equal('write', getline('$')) - call assert_fails('read XtestA', 'E484') " should not read anything - call assert_equal('write', getline(4)) - - " now we have: - " 1 start of Xxx - " 2 abc2 - " 3 end of Xxx - " 4 write - - au FileReadCmd XtestB '[r Xxx - 2r XtestB " will read Xxx below line 2 instead - call assert_equal('start of Xxx', getline(3)) - - " now we have: - " 1 start of Xxx - " 2 abc2 - " 3 start of Xxx - " 4 abc2 - " 5 end of Xxx - " 6 end of Xxx - " 7 write - - au FileWriteCmd XtestC '[,']copy $ - normal 4GA1 - 4,5w XtestC " will copy lines 4 and 5 to the end - call assert_equal("\tabc21", getline(8)) - call assert_fails('r XtestC', 'E484') " should not read anything - call assert_equal("end of Xxx", getline(9)) - - " now we have: - " 1 start of Xxx - " 2 abc2 - " 3 start of Xxx - " 4 abc21 - " 5 end of Xxx - " 6 end of Xxx - " 7 write - " 8 abc21 - " 9 end of Xxx - - let g:lines = [] - au FileAppendCmd XtestD call extend(g:lines, getline(line("'["), line("']"))) - w >>XtestD " will add lines to 'lines' - call assert_equal(9, len(g:lines)) - call assert_fails('$r XtestD', 'E484') " should not read anything - call assert_equal(9, line('$')) - call assert_equal('end of Xxx', getline('$')) - - au BufReadCmd XtestE 0r Xxx|$del - sp XtestE " split window with test.out - call assert_equal('end of Xxx', getline(3)) - - let g:lines = [] - exe "normal 2Goasdf\\\" - au BufWriteCmd XtestE call extend(g:lines, getline(0, '$')) - wall " will write other window to 'lines' - call assert_equal(4, len(g:lines), g:lines) - call assert_equal("asdf", g:lines[2]) - - au! BufReadCmd - au! BufWriteCmd - au! FileReadCmd - au! FileWriteCmd - au! FileAppendCmd - %bwipe! - call delete('Xxx') - enew! -endfunc - -func s:ReadFile() - setl noswapfile nomodified - let filename = resolve(expand(":p")) - execute 'read' fnameescape(filename) - 1d_ - exe 'file' fnameescape(filename) - setl buftype=acwrite -endfunc - -func s:WriteFile() - let filename = resolve(expand(":p")) - setl buftype= - noautocmd execute 'write' fnameescape(filename) - setl buftype=acwrite - setl nomodified -endfunc - -func Test_BufReadCmd() - autocmd BufReadCmd *.test call s:ReadFile() - autocmd BufWriteCmd *.test call s:WriteFile() - - call writefile(['one', 'two', 'three'], 'Xcmd.test') - edit Xcmd.test - call assert_match('Xcmd.test" line 1 of 3', execute('file')) - normal! Gofour - write - call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test')) - - bwipe! - call delete('Xcmd.test') - au! BufReadCmd - au! BufWriteCmd -endfunc - -func Test_BufWriteCmd() - autocmd BufWriteCmd Xbufwritecmd let g:written = 1 - new - file Xbufwritecmd - set buftype=acwrite - call mkdir('Xbufwritecmd') - write - " BufWriteCmd should be triggered even if a directory has the same name - call assert_equal(1, g:written) - call delete('Xbufwritecmd', 'd') - unlet g:written - au! BufWriteCmd - bwipe! -endfunc - -func SetChangeMarks(start, end) - exe a:start .. 'mark [' - exe a:end .. 'mark ]' -endfunc - -" Verify the effects of autocmds on '[ and '] -func Test_change_mark_in_autocmds() - edit! Xtest - call feedkeys("ia\b\c\d\u\", 'xtn') - - call SetChangeMarks(2, 3) - write - call assert_equal([1, 4], [line("'["), line("']")]) - - call SetChangeMarks(2, 3) - au BufWritePre * call assert_equal([1, 4], [line("'["), line("']")]) - write - au! BufWritePre - - if has('unix') - write XtestFilter - write >> XtestFilter - - call SetChangeMarks(2, 3) - " Marks are set to the entire range of the write - au FilterWritePre * call assert_equal([1, 4], [line("'["), line("']")]) - " '[ is adjusted to just before the line that will receive the filtered - " data - au FilterReadPre * call assert_equal([4, 4], [line("'["), line("']")]) - " The filtered data is read into the buffer, and the source lines are - " still present, so the range is after the source lines - au FilterReadPost * call assert_equal([5, 12], [line("'["), line("']")]) - %!cat XtestFilter - " After the filtered data is read, the original lines are deleted - call assert_equal([1, 8], [line("'["), line("']")]) - au! FilterWritePre,FilterReadPre,FilterReadPost - undo - - call SetChangeMarks(1, 4) - au FilterWritePre * call assert_equal([2, 3], [line("'["), line("']")]) - au FilterReadPre * call assert_equal([3, 3], [line("'["), line("']")]) - au FilterReadPost * call assert_equal([4, 11], [line("'["), line("']")]) - 2,3!cat XtestFilter - call assert_equal([2, 9], [line("'["), line("']")]) - au! FilterWritePre,FilterReadPre,FilterReadPost - undo - - call delete('XtestFilter') - endif - - call SetChangeMarks(1, 4) - au FileWritePre * call assert_equal([2, 3], [line("'["), line("']")]) - 2,3write Xtest2 - au! FileWritePre - - call SetChangeMarks(2, 3) - au FileAppendPre * call assert_equal([1, 4], [line("'["), line("']")]) - write >> Xtest2 - au! FileAppendPre - - call SetChangeMarks(1, 4) - au FileAppendPre * call assert_equal([2, 3], [line("'["), line("']")]) - 2,3write >> Xtest2 - au! FileAppendPre - - call SetChangeMarks(1, 1) - au FileReadPre * call assert_equal([3, 1], [line("'["), line("']")]) - au FileReadPost * call assert_equal([4, 11], [line("'["), line("']")]) - 3read Xtest2 - au! FileReadPre,FileReadPost - undo - - call SetChangeMarks(4, 4) - " When the line is 0, it's adjusted to 1 - au FileReadPre * call assert_equal([1, 4], [line("'["), line("']")]) - au FileReadPost * call assert_equal([1, 8], [line("'["), line("']")]) - 0read Xtest2 - au! FileReadPre,FileReadPost - undo - - call SetChangeMarks(4, 4) - " When the line is 0, it's adjusted to 1 - au FileReadPre * call assert_equal([1, 4], [line("'["), line("']")]) - au FileReadPost * call assert_equal([2, 9], [line("'["), line("']")]) - 1read Xtest2 - au! FileReadPre,FileReadPost - undo - - bwipe! - call delete('Xtest') - call delete('Xtest2') -endfunc - -func Test_Filter_noshelltemp() - CheckExecutable cat - - enew! - call setline(1, ['a', 'b', 'c', 'd']) - - let shelltemp = &shelltemp - set shelltemp - - let g:filter_au = 0 - au FilterWritePre * let g:filter_au += 1 - au FilterReadPre * let g:filter_au += 1 - au FilterReadPost * let g:filter_au += 1 - %!cat - call assert_equal(3, g:filter_au) - - if has('filterpipe') - set noshelltemp - - let g:filter_au = 0 - au FilterWritePre * let g:filter_au += 1 - au FilterReadPre * let g:filter_au += 1 - au FilterReadPost * let g:filter_au += 1 - %!cat - call assert_equal(0, g:filter_au) - endif - - au! FilterWritePre,FilterReadPre,FilterReadPost - let &shelltemp = shelltemp - bwipe! -endfunc - -func Test_TextYankPost() - enew! - call setline(1, ['foo']) - - let g:event = [] - au TextYankPost * let g:event = copy(v:event) - - call assert_equal({}, v:event) - call assert_fails('let v:event = {}', 'E46:') - call assert_fails('let v:event.mykey = 0', 'E742:') - - norm "ayiw - call assert_equal( - \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'visual': v:false, 'regtype': 'v'}, - \g:event) - norm y_ - call assert_equal( - \{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'visual': v:false, 'regtype': 'V'}, - \g:event) - norm Vy - call assert_equal( - \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'visual': v:true, 'regtype': 'V'}, - \g:event) - call feedkeys("\y", 'x') - call assert_equal( - \{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'visual': v:true, 'regtype': "\x161"}, - \g:event) - norm "xciwbar - call assert_equal( - \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'visual': v:false, 'regtype': 'v'}, - \g:event) - norm "bdiw - call assert_equal( - \{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'visual': v:false, 'regtype': 'v'}, - \g:event) - - call assert_equal({}, v:event) - - au! TextYankPost - unlet g:event - bwipe! -endfunc - -func Test_autocommand_all_events() - call assert_fails('au * * bwipe', 'E1155:') - call assert_fails('au * x bwipe', 'E1155:') - call assert_fails('au! * x bwipe', 'E1155:') -endfunc - -func Test_autocmd_user() - au User MyEvent let s:res = [expand(""), expand("")] - doautocmd User MyEvent - call assert_equal(['MyEvent', 'MyEvent'], s:res) - au! User - unlet s:res -endfunc - -function s:Before_test_dirchanged() - augroup test_dirchanged - autocmd! - augroup END - let s:li = [] - let s:dir_this = getcwd() - let s:dir_foo = s:dir_this . '/Xfoo' - call mkdir(s:dir_foo) - let s:dir_bar = s:dir_this . '/Xbar' - call mkdir(s:dir_bar) -endfunc - -function s:After_test_dirchanged() - call chdir(s:dir_this) - call delete(s:dir_foo, 'd') - call delete(s:dir_bar, 'd') - augroup test_dirchanged - autocmd! - augroup END -endfunc - -function Test_dirchanged_global() - call s:Before_test_dirchanged() - autocmd test_dirchanged DirChangedPre global call add(s:li, expand("") .. " pre cd " .. v:event.directory) - autocmd test_dirchanged DirChanged global call add(s:li, "cd:") - autocmd test_dirchanged DirChanged global call add(s:li, expand("")) - call chdir(s:dir_foo) - let expected = ["global pre cd " .. s:dir_foo, "cd:", s:dir_foo] - call assert_equal(expected, s:li) - call chdir(s:dir_foo) - call assert_equal(expected, s:li) - exe 'lcd ' .. fnameescape(s:dir_bar) - call assert_equal(expected, s:li) - - exe 'cd ' .. s:dir_foo - exe 'cd ' .. s:dir_bar - autocmd! test_dirchanged DirChanged global let g:result = expand("") - cd - - call assert_equal(s:dir_foo, substitute(g:result, '\\', '/', 'g')) - - call s:After_test_dirchanged() -endfunc - -function Test_dirchanged_local() - call s:Before_test_dirchanged() - autocmd test_dirchanged DirChanged window call add(s:li, "lcd:") - autocmd test_dirchanged DirChanged window call add(s:li, expand("")) - call chdir(s:dir_foo) - call assert_equal([], s:li) - exe 'lcd ' .. fnameescape(s:dir_bar) - call assert_equal(["lcd:", s:dir_bar], s:li) - exe 'lcd ' .. fnameescape(s:dir_bar) - call assert_equal(["lcd:", s:dir_bar], s:li) - call s:After_test_dirchanged() -endfunc - -function Test_dirchanged_auto() - CheckFunction test_autochdir - CheckOption autochdir - call s:Before_test_dirchanged() - call test_autochdir() - autocmd test_dirchanged DirChangedPre auto call add(s:li, "pre cd " .. v:event.directory) - autocmd test_dirchanged DirChanged auto call add(s:li, "auto:") - autocmd test_dirchanged DirChanged auto call add(s:li, expand("")) - set acd - cd .. - call assert_equal([], s:li) - exe 'edit ' . s:dir_foo . '/Xfile' - call assert_equal(s:dir_foo, getcwd()) - let expected = ["pre cd " .. s:dir_foo, "auto:", s:dir_foo] - call assert_equal(expected, s:li) - set noacd - bwipe! - call s:After_test_dirchanged() -endfunc - -" Test TextChangedI and TextChangedP -func Test_ChangedP() - throw 'Skipped: use test/functional/editor/completion_spec.lua' - new - call setline(1, ['foo', 'bar', 'foobar']) - call test_override("char_avail", 1) - set complete=. completeopt=menuone - - func! TextChangedAutocmd(char) - let g:autocmd .= a:char - endfunc - - au! TextChanged :call TextChangedAutocmd('N') - au! TextChangedI :call TextChangedAutocmd('I') - au! TextChangedP :call TextChangedAutocmd('P') - - call cursor(3, 1) - let g:autocmd = '' - call feedkeys("o\", 'tnix') - call assert_equal('I', g:autocmd) - - let g:autocmd = '' - call feedkeys("Sf", 'tnix') - call assert_equal('II', g:autocmd) - - let g:autocmd = '' - call feedkeys("Sf\", 'tnix') - call assert_equal('IIP', g:autocmd) - - let g:autocmd = '' - call feedkeys("Sf\\", 'tnix') - call assert_equal('IIPP', g:autocmd) - - let g:autocmd = '' - call feedkeys("Sf\\\", 'tnix') - call assert_equal('IIPPP', g:autocmd) - - let g:autocmd = '' - call feedkeys("Sf\\\\", 'tnix') - call assert_equal('IIPPPP', g:autocmd) - - call assert_equal(['foo', 'bar', 'foobar', 'foo'], getline(1, '$')) - " TODO: how should it handle completeopt=noinsert,noselect? - - " CleanUp - call test_override("char_avail", 0) - au! TextChanged - au! TextChangedI - au! TextChangedP - delfu TextChangedAutocmd - unlet! g:autocmd - set complete&vim completeopt&vim - - bw! -endfunc - -let g:setline_handled = v:false -func SetLineOne() - if !g:setline_handled - call setline(1, "(x)") - let g:setline_handled = v:true - endif -endfunc - -func Test_TextChangedI_with_setline() - CheckFunction test_override - new - call test_override('char_avail', 1) - autocmd TextChangedI call SetLineOne() - call feedkeys("i(\\", 'tx') - call assert_equal('(', getline(1)) - call assert_equal('x)', getline(2)) - undo - call assert_equal('', getline(1)) - call assert_equal('', getline(2)) - - call test_override('starting', 0) - bwipe! -endfunc - -func Test_Changed_FirstTime() - CheckFeature terminal - CheckNotGui - " Starting a terminal to run Vim is always considered flaky. - let g:test_is_flaky = 1 - - " Prepare file for TextChanged event. - call writefile([''], 'Xchanged.txt') - let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3}) - call assert_equal('running', term_getstatus(buf)) - " Wait for the ruler (in the status line) to be shown. - call WaitForAssert({-> assert_match('\ call writefile(['No'], 'Xchanged.txt')\") - call term_sendkeys(buf, "\\:qa!\") - call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))}) - call assert_equal([''], readfile('Xchanged.txt')) - - " clean up - call delete('Xchanged.txt') - bwipe! -endfunc - -func Test_autocmd_nested() - let g:did_nested = 0 - augroup Testing - au WinNew * edit somefile - au BufNew * let g:did_nested = 1 - augroup END - split - call assert_equal(0, g:did_nested) - close - bwipe! somefile - - " old nested argument still works - augroup Testing - au! - au WinNew * nested edit somefile - au BufNew * let g:did_nested = 1 - augroup END - split - call assert_equal(1, g:did_nested) - close - bwipe! somefile - - " New ++nested argument works - augroup Testing - au! - au WinNew * ++nested edit somefile - au BufNew * let g:did_nested = 1 - augroup END - split - call assert_equal(1, g:did_nested) - close - bwipe! somefile - - augroup Testing - au! - augroup END - - call assert_fails('au WinNew * ++nested ++nested echo bad', 'E983:') - call assert_fails('au WinNew * nested nested echo bad', 'E983:') -endfunc - -func Test_autocmd_nested_cursor_invalid() - set laststatus=0 - copen - cclose - call setline(1, ['foo', 'bar', 'baz']) - 3 - augroup nested_inv - autocmd User foo ++nested copen - autocmd BufAdd * let &laststatus = 2 - &laststatus - augroup END - doautocmd User foo - - augroup nested_inv - au! - augroup END - set laststatus& - cclose - bwipe! -endfunc - -func Test_autocmd_nested_keeps_cursor_pos() - enew - call setline(1, 'foo') - autocmd User foo ++nested normal! $a - autocmd InsertLeave * : - doautocmd User foo - call assert_equal([0, 1, 3, 0], getpos('.')) - - bwipe! -endfunc - -func Test_autocmd_nested_switch_window() - " run this in a separate Vim so that SafeState works - CheckRunVimInTerminal - - let lines =<< trim END - vim9script - ['()']->writefile('Xautofile') - autocmd VimEnter * ++nested edit Xautofile | split - autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.') - autocmd WinEnter * matchadd('ErrorMsg', 'pat') - END - call writefile(lines, 'Xautoscript') - let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10}) - call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {}) - - call StopVimInTerminal(buf) - call delete('Xautofile') - call delete('Xautoscript') -endfunc - -func Test_autocmd_once() - " Without ++once WinNew triggers twice - let g:did_split = 0 - augroup Testing - au WinNew * let g:did_split += 1 - augroup END - split - split - call assert_equal(2, g:did_split) - call assert_true(exists('#WinNew')) - close - close - - " With ++once WinNew triggers once - let g:did_split = 0 - augroup Testing - au! - au WinNew * ++once let g:did_split += 1 - augroup END - split - split - call assert_equal(1, g:did_split) - call assert_false(exists('#WinNew')) - close - close - - call assert_fails('au WinNew * ++once ++once echo bad', 'E983:') -endfunc - -func Test_autocmd_bufreadpre() - new - let b:bufreadpre = 1 - call append(0, range(100)) - w! XAutocmdBufReadPre.txt - autocmd BufReadPre :let b:bufreadpre += 1 - norm! 50gg - sp - norm! 100gg - wincmd p - let g:wsv1 = winsaveview() - wincmd p - let g:wsv2 = winsaveview() - " triggers BufReadPre, should not move the cursor in either window - " The topline may change one line in a large window. - edit - call assert_inrange(g:wsv2.topline - 1, g:wsv2.topline + 1, winsaveview().topline) - call assert_equal(g:wsv2.lnum, winsaveview().lnum) - call assert_equal(2, b:bufreadpre) - wincmd p - call assert_equal(g:wsv1.topline, winsaveview().topline) - call assert_equal(g:wsv1.lnum, winsaveview().lnum) - call assert_equal(2, b:bufreadpre) - " Now set the cursor position in an BufReadPre autocommand - " (even though the position will be invalid, this should make Vim reset the - " cursor position in the other window. - wincmd p - 1 " set cpo+=g - " won't do anything, but try to set the cursor on an invalid lnum - autocmd BufReadPre :norm! 70gg - " triggers BufReadPre, should not move the cursor in either window - e - call assert_equal(1, winsaveview().topline) - call assert_equal(1, winsaveview().lnum) - call assert_equal(3, b:bufreadpre) - wincmd p - call assert_equal(g:wsv1.topline, winsaveview().topline) - call assert_equal(g:wsv1.lnum, winsaveview().lnum) - call assert_equal(3, b:bufreadpre) - close - close - call delete('XAutocmdBufReadPre.txt') - set cpo-=g -endfunc - -" FileChangedShell tested in test_filechanged.vim - -" Tests for the following autocommands: -" - FileWritePre writing a compressed file -" - FileReadPost reading a compressed file -" - BufNewFile reading a file template -" - BufReadPre decompressing the file to be read -" - FilterReadPre substituting characters in the temp file -" - FilterReadPost substituting characters after filtering -" - FileReadPre set options for decompression -" - FileReadPost decompress the file -func Test_ReadWrite_Autocmds() - " Run this test only on Unix-like systems and if gzip is available - if !has('unix') || !executable("gzip") - return - endif - - " Make $GZIP empty, "-v" would cause trouble. - let $GZIP = "" - - " Use a FileChangedShell autocommand to avoid a prompt for 'Xtestfile.gz' - " being modified outside of Vim (noticed on Solaris). - au FileChangedShell * echo 'caught FileChangedShell' - - " Test for the FileReadPost, FileWritePre and FileWritePost autocmds - augroup Test1 - au! - au FileWritePre *.gz '[,']!gzip - au FileWritePost *.gz undo - au FileReadPost *.gz '[,']!gzip -d - augroup END - - new - set bin - call append(0, [ - \ 'line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 10 Abcdefghijklmnopqrstuvwxyz' - \ ]) - 1,9write! Xtestfile.gz - enew! | close - - new - " Read and decompress the testfile - 0read Xtestfile.gz - call assert_equal([ - \ 'line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 10 Abcdefghijklmnopqrstuvwxyz' - \ ], getline(1, 9)) - enew! | close - - augroup Test1 - au! - augroup END - - " Test for the FileAppendPre and FileAppendPost autocmds - augroup Test2 - au! - au BufNewFile *.c read Xtest.c - au FileAppendPre *.out '[,']s/new/NEW/ - au FileAppendPost *.out !cat Xtest.c >> test.out - augroup END - - call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c') - new foo.c " should load Xtest.c - call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4)) - w! >> test.out " append it to the output file - - let contents = readfile('test.out') - call assert_equal(' * Here is a NEW .c file', contents[2]) - call assert_equal(' * Here is a new .c file', contents[5]) - - call delete('test.out') - enew! | close - augroup Test2 - au! - augroup END - - " Test for the BufReadPre and BufReadPost autocmds - augroup Test3 - au! - " setup autocommands to decompress before reading and re-compress - " afterwards - au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand("")) - au BufReadPre *.gz call rename(expand(":r"), expand("")) - au BufReadPost *.gz call rename(expand(""), expand(":r")) - au BufReadPost *.gz exe '!gzip ' . shellescape(expand(":r")) - augroup END - - e! Xtestfile.gz " Edit compressed file - call assert_equal([ - \ 'line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 10 Abcdefghijklmnopqrstuvwxyz' - \ ], getline(1, 9)) - - w! >> test.out " Append it to the output file - - augroup Test3 - au! - augroup END - - " Test for the FilterReadPre and FilterReadPost autocmds. - set shelltemp " need temp files here - augroup Test4 - au! - au FilterReadPre *.out call rename(expand(""), expand("") . ".t") - au FilterReadPre *.out exe 'silent !sed s/e/E/ ' . shellescape(expand("")) . ".t >" . shellescape(expand("")) - au FilterReadPre *.out exe 'silent !rm ' . shellescape(expand("")) . '.t' - au FilterReadPost *.out '[,']s/x/X/g - augroup END - - e! test.out " Edit the output file - 1,$!cat - call assert_equal([ - \ 'linE 2 AbcdefghijklmnopqrstuvwXyz', - \ 'linE 3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - \ 'linE 4 AbcdefghijklmnopqrstuvwXyz', - \ 'linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - \ 'linE 6 AbcdefghijklmnopqrstuvwXyz', - \ 'linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - \ 'linE 8 AbcdefghijklmnopqrstuvwXyz', - \ 'linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - \ 'linE 10 AbcdefghijklmnopqrstuvwXyz' - \ ], getline(1, 9)) - call assert_equal([ - \ 'line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 10 Abcdefghijklmnopqrstuvwxyz' - \ ], readfile('test.out')) - - augroup Test4 - au! - augroup END - set shelltemp&vim - - " Test for the FileReadPre and FileReadPost autocmds. - augroup Test5 - au! - au FileReadPre *.gz exe 'silent !gzip -d ' . shellescape(expand("")) - au FileReadPre *.gz call rename(expand(":r"), expand("")) - au FileReadPost *.gz '[,']s/l/L/ - augroup END - - new - 0r Xtestfile.gz " Read compressed file - call assert_equal([ - \ 'Line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'Line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'Line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'Line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'Line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'Line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'Line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'Line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'Line 10 Abcdefghijklmnopqrstuvwxyz' - \ ], getline(1, 9)) - call assert_equal([ - \ 'line 2 Abcdefghijklmnopqrstuvwxyz', - \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 4 Abcdefghijklmnopqrstuvwxyz', - \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 6 Abcdefghijklmnopqrstuvwxyz', - \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 8 Abcdefghijklmnopqrstuvwxyz', - \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - \ 'line 10 Abcdefghijklmnopqrstuvwxyz' - \ ], readfile('Xtestfile.gz')) - - augroup Test5 - au! - augroup END - - au! FileChangedShell - call delete('Xtestfile.gz') - call delete('Xtest.c') - call delete('test.out') -endfunc - -func Test_throw_in_BufWritePre() - new - call setline(1, ['one', 'two', 'three']) - call assert_false(filereadable('Xthefile')) - augroup throwing - au BufWritePre X* throw 'do not write' - augroup END - try - w Xthefile - catch - let caught = 1 - endtry - call assert_equal(1, caught) - call assert_false(filereadable('Xthefile')) - - bwipe! - au! throwing -endfunc - -func Test_autocmd_in_try_block() - call mkdir('Xdir') - au BufEnter * let g:fname = expand('%') - try - edit Xdir/ - endtry - call assert_match('Xdir', g:fname) - - unlet g:fname - au! BufEnter - call delete('Xdir', 'rf') -endfunc - -func Test_autocmd_CmdWinEnter() - CheckRunVimInTerminal - " There is not cmdwin switch, so - " test for cmdline_hist - " (both are available with small builds) - CheckFeature cmdline_hist - let lines =<< trim END - let b:dummy_var = 'This is a dummy' - autocmd CmdWinEnter * quit - let winnr = winnr('$') - END - let filename = 'XCmdWinEnter' - call writefile(lines, filename) - let buf = RunVimInTerminal('-S '.filename, #{rows: 6}) - - call term_sendkeys(buf, "q:") - call term_wait(buf) - call term_sendkeys(buf, ":echo b:dummy_var\") - call WaitForAssert({-> assert_match('^This is a dummy', term_getline(buf, 6))}, 2000) - call term_sendkeys(buf, ":echo &buftype\") - call WaitForAssert({-> assert_notmatch('^nofile', term_getline(buf, 6))}, 1000) - call term_sendkeys(buf, ":echo winnr\") - call WaitForAssert({-> assert_match('^1', term_getline(buf, 6))}, 1000) - - " clean up - call StopVimInTerminal(buf) - call delete(filename) -endfunc - -func Test_autocmd_was_using_freed_memory() - pedit xx - n x - augroup winenter - au WinEnter * if winnr('$') > 2 | quit | endif - augroup END - " Nvim needs large 'winwidth' and 'nowinfixwidth' to crash - set winwidth=99999 nowinfixwidth - split - - augroup winenter - au! WinEnter - augroup END - - set winwidth& winfixwidth& - bwipe xx - bwipe x - pclose -endfunc - -func Test_BufWrite_lockmarks() - edit! Xtest - call setline(1, ['a', 'b', 'c', 'd']) - - " :lockmarks preserves the marks - call SetChangeMarks(2, 3) - lockmarks write - call assert_equal([2, 3], [line("'["), line("']")]) - - " *WritePre autocmds get the correct line range, but lockmarks preserves the - " original values for the user - augroup lockmarks - au! - au BufWritePre,FilterWritePre * call assert_equal([1, 4], [line("'["), line("']")]) - au FileWritePre * call assert_equal([3, 4], [line("'["), line("']")]) - augroup END - - lockmarks write - call assert_equal([2, 3], [line("'["), line("']")]) - - if executable('cat') - lockmarks %!cat - call assert_equal([2, 3], [line("'["), line("']")]) - endif - - lockmarks 3,4write Xtest2 - call assert_equal([2, 3], [line("'["), line("']")]) - - au! lockmarks - augroup! lockmarks - call delete('Xtest') - call delete('Xtest2') -endfunc - -func Test_FileType_spell() - if !isdirectory('/tmp') - throw "Skipped: requires /tmp directory" - endif - - " this was crashing with an invalid free() - setglobal spellfile=/tmp/en.utf-8.add - augroup crash - autocmd! - autocmd BufNewFile,BufReadPost crashfile setf somefiletype - autocmd BufNewFile,BufReadPost crashfile set ft=anotherfiletype - autocmd FileType anotherfiletype setlocal spell - augroup END - func! NoCrash() abort - edit /tmp/crashfile - endfunc - call NoCrash() - - au! crash - setglobal spellfile= -endfunc - -" this was wiping out the current buffer and using freed memory -func Test_SpellFileMissing_bwipe() - next 0 - au SpellFileMissing 0 bwipe - call assert_fails('set spell spelllang=0', 'E937:') - - au! SpellFileMissing - set nospell spelllang=en - bwipe -endfunc - -" Test closing a window or editing another buffer from a FileChangedRO handler -" in a readonly buffer -func Test_FileChangedRO_winclose() - augroup FileChangedROTest - au! - autocmd FileChangedRO * quit - augroup END - new - set readonly - call assert_fails('normal i', 'E788:') - close - augroup! FileChangedROTest - - augroup FileChangedROTest - au! - autocmd FileChangedRO * edit Xfile - augroup END - new - set readonly - call assert_fails('normal i', 'E788:') - close - augroup! FileChangedROTest -endfunc - -func LogACmd() - call add(g:logged, line('$')) -endfunc - -func Test_TermChanged() - throw 'skipped: Nvim does not support TermChanged event' - CheckNotGui - - enew! - tabnew - call setline(1, ['a', 'b', 'c', 'd']) - $ - au TermChanged * call LogACmd() - let g:logged = [] - let term_save = &term - set term=xterm - call assert_equal([1, 4], g:logged) - - au! TermChanged - let &term = term_save - bwipe! -endfunc - -" Test for FileReadCmd autocmd -func Test_autocmd_FileReadCmd() - func ReadFileCmd() - call append(line('$'), "v:cmdarg = " .. v:cmdarg) - endfunc - augroup FileReadCmdTest - au! - au FileReadCmd Xtest call ReadFileCmd() - augroup END - - new - read ++bin Xtest - read ++nobin Xtest - read ++edit Xtest - read ++bad=keep Xtest - read ++bad=drop Xtest - read ++bad=- Xtest - read ++ff=unix Xtest - read ++ff=dos Xtest - read ++ff=mac Xtest - read ++enc=utf-8 Xtest - - call assert_equal(['', - \ 'v:cmdarg = ++bin', - \ 'v:cmdarg = ++nobin', - \ 'v:cmdarg = ++edit', - \ 'v:cmdarg = ++bad=keep', - \ 'v:cmdarg = ++bad=drop', - \ 'v:cmdarg = ++bad=-', - \ 'v:cmdarg = ++ff=unix', - \ 'v:cmdarg = ++ff=dos', - \ 'v:cmdarg = ++ff=mac', - \ 'v:cmdarg = ++enc=utf-8'], getline(1, '$')) - - close! - augroup FileReadCmdTest - au! - augroup END - delfunc ReadFileCmd -endfunc - -" Test for passing invalid arguments to autocmd -func Test_autocmd_invalid_args() - " Additional character after * for event - call assert_fails('autocmd *a Xfile set ff=unix', 'E215:') - augroup Test - augroup END - " Invalid autocmd event - call assert_fails('autocmd Bufabc Xfile set ft=vim', 'E216:') - " Invalid autocmd event in a autocmd group - call assert_fails('autocmd Test Bufabc Xfile set ft=vim', 'E216:') - augroup! Test - " Execute all autocmds - call assert_fails('doautocmd * BufEnter', 'E217:') - call assert_fails('augroup! x1a2b3', 'E367:') - call assert_fails('autocmd BufNew pwd', 'E680:') - call assert_fails('autocmd BufNew \) set ff=unix', 'E55:') -endfunc - -" Test for deep nesting of autocmds -func Test_autocmd_deep_nesting() - autocmd BufEnter Xfile doautocmd BufEnter Xfile - call assert_fails('doautocmd BufEnter Xfile', 'E218:') - autocmd! BufEnter Xfile -endfunc - -" Tests for SigUSR1 autocmd event, which is only available on posix systems. -func Test_autocmd_sigusr1() - CheckUnix - - let g:sigusr1_passed = 0 - au Signal SIGUSR1 let g:sigusr1_passed = 1 - call system('kill -s usr1 ' . getpid()) - call WaitForAssert({-> assert_true(g:sigusr1_passed)}) - - au! Signal - unlet g:sigusr1_passed -endfunc - -" Test for BufReadPre autocmd deleting the file -func Test_BufReadPre_delfile() - augroup TestAuCmd - au! - autocmd BufReadPre Xfile call delete('Xfile') - augroup END - call writefile([], 'Xfile') - call assert_fails('new Xfile', 'E200:') - call assert_equal('Xfile', @%) - call assert_equal(1, &readonly) - call delete('Xfile') - augroup TestAuCmd - au! - augroup END - close! -endfunc - -" Test for BufReadPre autocmd changing the current buffer -func Test_BufReadPre_changebuf() - augroup TestAuCmd - au! - autocmd BufReadPre Xfile edit Xsomeotherfile - augroup END - call writefile([], 'Xfile') - call assert_fails('new Xfile', 'E201:') - call assert_equal('Xsomeotherfile', @%) - call assert_equal(1, &readonly) - call delete('Xfile') - augroup TestAuCmd - au! - augroup END - close! -endfunc - -" Test for BufWipeouti autocmd changing the current buffer when reading a file -" in an empty buffer with 'f' flag in 'cpo' -func Test_BufDelete_changebuf() - new - augroup TestAuCmd - au! - autocmd BufWipeout * let bufnr = bufadd('somefile') | exe "b " .. bufnr - augroup END - let save_cpo = &cpo - set cpo+=f - call assert_fails('r Xfile', ['E812:', 'E484:']) - call assert_equal('somefile', @%) - let &cpo = save_cpo - augroup TestAuCmd - au! - augroup END - close! -endfunc - -" Test for the temporary internal window used to execute autocmds -func Test_autocmd_window() - %bw! - edit one.txt - tabnew two.txt - vnew three.txt - tabnew four.txt - tabprevious - let g:blist = [] - augroup aucmd_win_test1 - au! - au BufEnter * call add(g:blist, [expand(''), - \ win_gettype(bufwinnr(expand('')))]) - augroup END - - doautoall BufEnter - call assert_equal([ - \ ['one.txt', 'autocmd'], - \ ['two.txt', ''], - \ ['four.txt', 'autocmd'], - \ ['three.txt', ''], - \ ], g:blist) - - augroup aucmd_win_test1 - au! - augroup END - augroup! aucmd_win_test1 - %bw! -endfunc - -" Test for trying to close the temporary window used for executing an autocmd -func Test_close_autocmd_window() - %bw! - edit one.txt - tabnew two.txt - augroup aucmd_win_test2 - au! - " Nvim makes aucmd_win the last window - " au BufEnter * if expand('') == 'one.txt' | 1close | endif - au BufEnter * if expand('') == 'one.txt' | close | endif - augroup END - - call assert_fails('doautoall BufEnter', 'E813:') - - augroup aucmd_win_test2 - au! - augroup END - augroup! aucmd_win_test2 - %bw! -endfunc - -" Test for trying to close the tab that has the temporary window for exeucing -" an autocmd. -func Test_close_autocmd_tab() - edit one.txt - tabnew two.txt - augroup aucmd_win_test - au! - au BufEnter * if expand('') == 'one.txt' | tabfirst | tabonly | endif - augroup END - - call assert_fails('doautoall BufEnter', 'E813:') - - tabonly - augroup aucmd_win_test - au! - augroup END - augroup! aucmd_win_test - %bwipe! -endfunc - -func Test_Visual_doautoall_redraw() - call setline(1, ['a', 'b']) - new - wincmd p - call feedkeys("G\", 'txn') - autocmd User Explode ++once redraw - doautoall User Explode - %bwipe! -endfunc - -" This was using freed memory. -func Test_BufNew_arglocal() - arglocal - au BufNew * arglocal - call assert_fails('drop xx', 'E1156:') - - au! BufNew -endfunc - -func Test_autocmd_closes_window() - au BufNew,BufWinLeave * e %e - file yyy - au BufNew,BufWinLeave * ball - n xxx - - %bwipe - au! BufNew - au! BufWinLeave -endfunc - -func Test_autocmd_quit_psearch() - sn aa bb - augroup aucmd_win_test - au! - au BufEnter,BufLeave,BufNew,WinEnter,WinLeave,WinNew * if winnr('$') > 1 | q | endif - augroup END - ps / - - augroup aucmd_win_test - au! - augroup END - new - pclose -endfunc - -" Fuzzer found some strange combination that caused a crash. -func Test_autocmd_normal_mess() - " For unknown reason this hangs on MS-Windows - CheckNotMSWindows - - augroup aucmd_normal_test - au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc - augroup END - " Nvim has removed :open - " call assert_fails('o4', 'E1159') - call assert_fails('e4', 'E1159') - silent! H - call assert_fails('e xx', 'E1159') - normal G - - augroup aucmd_normal_test - au! - augroup END -endfunc - -func Test_autocmd_closing_cmdwin() - " For unknown reason this hangs on MS-Windows - CheckNotMSWindows - - au BufWinLeave * nested q - call assert_fails("norm 7q?\n", 'E855:') - - au! BufWinLeave - new - only -endfunc - -func Test_autocmd_vimgrep() - augroup aucmd_vimgrep - au QuickfixCmdPre,BufNew,BufReadCmd * sb - " Nvim makes aucmd_win the last window - " au QuickfixCmdPre,BufNew,BufReadCmd * q9 - au QuickfixCmdPre,BufNew,BufReadCmd * exe 'q' .. (winnr('$') - (win_gettype(winnr('$')) == 'autocmd')) - augroup END - call assert_fails('lv ?a? foo', 'E926:') - - augroup aucmd_vimgrep - au! - augroup END -endfunc - -func Test_bufwipeout_changes_window() - " This should not crash, but we don't have any expectations about what - " happens, changing window in BufWipeout has unpredictable results. - tabedit - let g:window_id = win_getid() - topleft new - setlocal bufhidden=wipe - autocmd BufWipeout call win_gotoid(g:window_id) - tabprevious - +tabclose - - unlet g:window_id - au! BufWipeout - %bwipe! -endfunc - -func Test_v_event_readonly() - autocmd CompleteChanged * let v:event.width = 0 - call assert_fails("normal! i\\", 'E46:') - au! CompleteChanged - - autocmd DirChangedPre * let v:event.directory = '' - call assert_fails('cd .', 'E46:') - au! DirChangedPre - - autocmd ModeChanged * let v:event.new_mode = '' - call assert_fails('normal! cc', 'E46:') - au! ModeChanged - - autocmd TextYankPost * let v:event.operator = '' - call assert_fails('normal! yy', 'E46:') - au! TextYankPost -endfunc - -" Test for ModeChanged pattern -func Test_mode_changes() - let g:index = 0 - let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'n', 'V', 'v', 's', 'n'] - func! TestMode() - call assert_equal(g:mode_seq[g:index], get(v:event, "old_mode")) - call assert_equal(g:mode_seq[g:index + 1], get(v:event, "new_mode")) - call assert_equal(mode(1), get(v:event, "new_mode")) - let g:index += 1 - endfunc - - au ModeChanged * :call TestMode() - let g:n_to_any = 0 - au ModeChanged n:* let g:n_to_any += 1 - call feedkeys("i\vVca\\\\ggdG", 'tnix') - - let g:V_to_v = 0 - au ModeChanged V:v let g:V_to_v += 1 - call feedkeys("Vv\\", 'tnix') - call assert_equal(len(filter(g:mode_seq[1:], {idx, val -> val == 'n'})), g:n_to_any) - call assert_equal(1, g:V_to_v) - call assert_equal(len(g:mode_seq) - 1, g:index) - - let g:n_to_i = 0 - au ModeChanged n:i let g:n_to_i += 1 - let g:n_to_niI = 0 - au ModeChanged i:niI let g:n_to_niI += 1 - let g:niI_to_i = 0 - au ModeChanged niI:i let g:niI_to_i += 1 - let g:nany_to_i = 0 - au ModeChanged n*:i let g:nany_to_i += 1 - let g:i_to_n = 0 - au ModeChanged i:n let g:i_to_n += 1 - let g:nori_to_any = 0 - au ModeChanged [ni]:* let g:nori_to_any += 1 - let g:i_to_any = 0 - au ModeChanged i:* let g:i_to_any += 1 - let g:index = 0 - let g:mode_seq = ['n', 'i', 'niI', 'i', 'n'] - call feedkeys("a\l\", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(1, g:n_to_i) - call assert_equal(1, g:n_to_niI) - call assert_equal(1, g:niI_to_i) - call assert_equal(2, g:nany_to_i) - call assert_equal(1, g:i_to_n) - call assert_equal(2, g:i_to_any) - call assert_equal(3, g:nori_to_any) - - if has('terminal') - let g:mode_seq += ['c', 'n', 't', 'nt', 'c', 'nt', 'n'] - call feedkeys(":term\\N:bd!\", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(1, g:n_to_i) - call assert_equal(1, g:n_to_niI) - call assert_equal(1, g:niI_to_i) - call assert_equal(2, g:nany_to_i) - call assert_equal(1, g:i_to_n) - call assert_equal(2, g:i_to_any) - call assert_equal(5, g:nori_to_any) - endif - - let g:n_to_c = 0 - au ModeChanged n:c let g:n_to_c += 1 - let g:c_to_n = 0 - au ModeChanged c:n let g:c_to_n += 1 - let g:mode_seq += ['c', 'n', 'c', 'n'] - call feedkeys("q:\\", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(2, g:n_to_c) - call assert_equal(2, g:c_to_n) - unlet g:n_to_c - unlet g:c_to_n - - let g:n_to_v = 0 - au ModeChanged n:v let g:n_to_v += 1 - let g:v_to_n = 0 - au ModeChanged v:n let g:v_to_n += 1 - let g:mode_seq += ['v', 'n'] - call feedkeys("v\", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(1, g:n_to_v) - call assert_equal(1, g:v_to_n) - unlet g:n_to_v - unlet g:v_to_n - - au! ModeChanged - delfunc TestMode - unlet! g:mode_seq - unlet! g:index - unlet! g:n_to_any - unlet! g:V_to_v - unlet! g:n_to_i - unlet! g:n_to_niI - unlet! g:niI_to_i - unlet! g:nany_to_i - unlet! g:i_to_n - unlet! g:nori_to_any - unlet! g:i_to_any -endfunc - -func Test_recursive_ModeChanged() - au! ModeChanged * norm 0u - sil! norm  - au! ModeChanged -endfunc - -func Test_ModeChanged_starts_visual() - " This was triggering ModeChanged before setting VIsual, causing a crash. - au! ModeChanged * norm 0u - sil! norm  - - au! ModeChanged -endfunc - -func Test_noname_autocmd() - augroup test_noname_autocmd_group - autocmd! - autocmd BufEnter * call add(s:li, ["BufEnter", expand("")]) - autocmd BufDelete * call add(s:li, ["BufDelete", expand("")]) - autocmd BufLeave * call add(s:li, ["BufLeave", expand("")]) - autocmd BufUnload * call add(s:li, ["BufUnload", expand("")]) - autocmd BufWipeout * call add(s:li, ["BufWipeout", expand("")]) - augroup END - - let s:li = [] - edit foo - call assert_equal([['BufUnload', ''], ['BufDelete', ''], ['BufWipeout', ''], ['BufEnter', 'foo']], s:li) - - au! test_noname_autocmd_group - augroup! test_noname_autocmd_group -endfunc - -func Test_autocmd_split_dummy() - " Autocommand trying to split a window containing a dummy buffer. - auto BufReadPre * exe "sbuf " .. expand("") - " Avoid the "W11" prompt - au FileChangedShell * let v:fcs_choice = 'reload' - func Xautocmd_changelist() - cal writefile(['Xtestfile2:4:4'], 'Xerr') - edit Xerr - lex 'Xtestfile2:4:4' - endfunc - call Xautocmd_changelist() - " Should get E86, but it doesn't always happen (timing?) - silent! call Xautocmd_changelist() - - au! BufReadPre - au! FileChangedShell - delfunc Xautocmd_changelist - bwipe! Xerr - call delete('Xerr') -endfunc - -" This was crashing because there was only one window to execute autocommands -" in. -func Test_autocmd_nested_setbufvar() - CheckFeature python3 - - set hidden - edit Xaaa - edit Xbbb - call setline(1, 'bar') - enew - au BufWriteCmd Xbbb ++nested call setbufvar('Xaaa', '&ft', 'foo') | bw! Xaaa - au FileType foo call py3eval('vim.current.buffer.options["cindent"]') - wall - - au! BufWriteCmd - au! FileType foo - set nohidden - call delete('Xaaa') - call delete('Xbbb') - %bwipe! -endfunc - - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_autoload.vim b/src/nvim/testdir/test_autoload.vim deleted file mode 100644 index e89fe3943b..0000000000 --- a/src/nvim/testdir/test_autoload.vim +++ /dev/null @@ -1,25 +0,0 @@ -" Tests for autoload - -set runtimepath=./sautest - -func Test_autoload_dict_func() - let g:loaded_foo_vim = 0 - let g:called_foo_bar_echo = 0 - call g:foo#bar.echo() - call assert_equal(1, g:loaded_foo_vim) - call assert_equal(1, g:called_foo_bar_echo) - - eval 'bar'->g:foo#addFoo()->assert_equal('barfoo') - - " empty name works in legacy script - call assert_equal('empty', foo#()) -endfunc - -func Test_source_autoload() - let g:loaded_sourced_vim = 0 - source sautest/autoload/sourced.vim - call assert_equal(1, g:loaded_sourced_vim) -endfunc - - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_backspace_opt.vim b/src/nvim/testdir/test_backspace_opt.vim deleted file mode 100644 index 59e94d2898..0000000000 --- a/src/nvim/testdir/test_backspace_opt.vim +++ /dev/null @@ -1,141 +0,0 @@ -" Tests for 'backspace' settings - -func Test_backspace_option() - set backspace= - call assert_equal('', &backspace) - set backspace=indent - call assert_equal('indent', &backspace) - set backspace=eol - call assert_equal('eol', &backspace) - set backspace=start - call assert_equal('start', &backspace) - set backspace=nostop - call assert_equal('nostop', &backspace) - " Add the value - set backspace= - set backspace=indent - call assert_equal('indent', &backspace) - set backspace+=eol - call assert_equal('indent,eol', &backspace) - set backspace+=start - call assert_equal('indent,eol,start', &backspace) - set backspace+=nostop - call assert_equal('indent,eol,start,nostop', &backspace) - " Delete the value - set backspace-=nostop - call assert_equal('indent,eol,start', &backspace) - set backspace-=indent - call assert_equal('eol,start', &backspace) - set backspace-=start - call assert_equal('eol', &backspace) - set backspace-=eol - call assert_equal('', &backspace) - " Check the error - call assert_fails('set backspace=ABC', 'E474:') - call assert_fails('set backspace+=def', 'E474:') - " NOTE: Vim doesn't check following error... - "call assert_fails('set backspace-=ghi', 'E474:') - - " Check backwards compatibility with version 5.4 and earlier - set backspace=0 - call assert_equal('0', &backspace) - set backspace=1 - call assert_equal('1', &backspace) - set backspace=2 - call assert_equal('2', &backspace) - set backspace=3 - call assert_equal('3', &backspace) - call assert_fails('set backspace=4', 'E474:') - call assert_fails('set backspace=10', 'E474:') - - " Cleared when 'compatible' is set - " set compatible - " call assert_equal('', &backspace) - set nocompatible viminfo+=nviminfo -endfunc - -" Test with backspace set to the non-compatible setting -func Test_backspace_ctrl_u() - new - call append(0, [ - \ "1 this shouldn't be deleted", - \ "2 this shouldn't be deleted", - \ "3 this shouldn't be deleted", - \ "4 this should be deleted", - \ "5 this shouldn't be deleted", - \ "6 this shouldn't be deleted", - \ "7 this shouldn't be deleted", - \ "8 this shouldn't be deleted (not touched yet)"]) - call cursor(2, 1) - - " set compatible - set backspace=2 - - exe "normal Avim1\\\" - exe "normal Avim2\u\\\" - - set cpo-=< - inoremap - exe "normal Avim3\<*C-U>\\" - iunmap - exe "normal Avim4\\\\" - - " Test with backspace set to the compatible setting - set backspace= visualbell - exe "normal A vim5\A\\\\" - exe "normal A vim6\Azwei\u\\\" - - inoremap - exe "normal A vim7\<*C-U>\<*C-U>\\" - - call assert_equal([ - \ "1 this shouldn't be deleted", - \ "2 this shouldn't be deleted", - \ "3 this shouldn't be deleted", - \ "4 this should be deleted3", - \ "", - \ "6 this shouldn't be deleted vim5", - \ "7 this shouldn't be deleted vim6", - \ "8 this shouldn't be deleted (not touched yet) vim7", - \ ""], getline(1, '$')) - - " Reset values - set compatible&vim - set visualbell&vim - set backspace&vim - - " Test new nostop option - %d_ - let expected = "foo bar foobar" - call setline(1, expected) - call cursor(1, 8) - exe ":norm! ianotherone\" - call assert_equal(expected, getline(1)) - call cursor(1, 8) - exe ":norm! ianothertwo\" - call assert_equal(expected, getline(1)) - - let content = getline(1) - for value in ['indent,nostop', 'eol,nostop', 'indent,eol,nostop', 'indent,eol,start,nostop'] - exe ":set bs=".. value - %d _ - call setline(1, content) - let expected = " foobar" - call cursor(1, 8) - exe ":norm! ianotherone\" - call assert_equal(expected, getline(1), 'CTRL-U backspace value: '.. &bs) - let expected = "foo foobar" - call setline(1, content) - call cursor(1, 8) - exe ":norm! ianothertwo\" - call assert_equal(expected, getline(1), 'CTRL-W backspace value: '.. &bs) - endfor - - " Reset options - set compatible&vim - set visualbell&vim - set backspace&vim - close! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_backup.vim b/src/nvim/testdir/test_backup.vim deleted file mode 100644 index d304773da4..0000000000 --- a/src/nvim/testdir/test_backup.vim +++ /dev/null @@ -1,89 +0,0 @@ -" Tests for the backup function - -source check.vim - -func Test_backup() - set backup backupdir=. backupskip= - new - call setline(1, ['line1', 'line2']) - :f Xbackup.txt - :w! Xbackup.txt - " backup file is only created after - " writing a second time (before overwriting) - :w! Xbackup.txt - let l = readfile('Xbackup.txt~') - call assert_equal(['line1', 'line2'], l) - bw! - set backup&vim backupdir&vim backupskip&vim - call delete('Xbackup.txt') - call delete('Xbackup.txt~') -endfunc - -func Test_backup_backupskip() - set backup backupdir=. backupskip=*.txt - new - call setline(1, ['line1', 'line2']) - :f Xbackup.txt - :w! Xbackup.txt - " backup file is only created after - " writing a second time (before overwriting) - :w! Xbackup.txt - call assert_false(filereadable('Xbackup.txt~')) - bw! - set backup&vim backupdir&vim backupskip&vim - call delete('Xbackup.txt') - call delete('Xbackup.txt~') -endfunc - -func Test_backup2() - set backup backupdir=.// backupskip= - new - call setline(1, ['line1', 'line2', 'line3']) - :f Xbackup.txt - :w! Xbackup.txt - " backup file is only created after - " writing a second time (before overwriting) - :w! Xbackup.txt - sp *Xbackup.txt~ - call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) - let f = expand('%') - call assert_match('%testdir%Xbackup.txt\~', f) - bw! - bw! - call delete('Xbackup.txt') - call delete(f) - set backup&vim backupdir&vim backupskip&vim -endfunc - -func Test_backup2_backupcopy() - set backup backupdir=.// backupcopy=yes backupskip= - new - call setline(1, ['line1', 'line2', 'line3']) - :f Xbackup.txt - :w! Xbackup.txt - " backup file is only created after - " writing a second time (before overwriting) - :w! Xbackup.txt - sp *Xbackup.txt~ - call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) - let f = expand('%') - call assert_match('%testdir%Xbackup.txt\~', f) - bw! - bw! - call delete('Xbackup.txt') - call delete(f) - set backup&vim backupdir&vim backupcopy&vim backupskip&vim -endfunc - -" Test for using a non-existing directory as a backup directory -func Test_non_existing_backupdir() - throw 'Skipped: Nvim auto-creates backup directory' - set backupdir=./non_existing_dir backupskip= - call writefile(['line1'], 'Xfile') - new Xfile - call assert_fails('write', 'E510:') - set backupdir&vim backupskip&vim - call delete('Xfile') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_behave.vim b/src/nvim/testdir/test_behave.vim deleted file mode 100644 index c26bfe7ce3..0000000000 --- a/src/nvim/testdir/test_behave.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Test the :behave command - -func Test_behave() - behave mswin - call assert_equal('mouse,key', &selectmode) - call assert_equal('popup', &mousemodel) - call assert_equal('startsel,stopsel', &keymodel) - call assert_equal('exclusive', &selection) - - behave xterm - call assert_equal('', &selectmode) - call assert_equal('extend', &mousemodel) - call assert_equal('', &keymodel) - call assert_equal('inclusive', &selection) - - set selection& - set mousemodel& - set keymodel& - set selection& -endfunc - -func Test_behave_completion() - call feedkeys(":behave \\\"\", 'tx') - call assert_equal('"behave mswin xterm', @:) -endfunc - -func Test_behave_error() - call assert_fails('behave x', 'E475:') -endfunc diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim deleted file mode 100644 index 920ceb826d..0000000000 --- a/src/nvim/testdir/test_blob.vim +++ /dev/null @@ -1,830 +0,0 @@ -" Tests for the Blob types - -source check.vim -source vim9.vim - -func TearDown() - " Run garbage collection after every test - call test_garbagecollect_now() -endfunc - -" Tests for Blob type - -" Blob creation from constant -func Test_blob_create() - let lines =<< trim END - VAR b = 0zDEADBEEF - call assert_equal(v:t_blob, type(b)) - call assert_equal(4, len(b)) - call assert_equal(0xDE, b[0]) - call assert_equal(0xAD, b[1]) - call assert_equal(0xBE, b[2]) - call assert_equal(0xEF, b[3]) - call assert_fails('VAR x = b[4]') - - call assert_equal(0xDE, get(b, 0)) - call assert_equal(0xEF, get(b, 3)) - - call assert_fails('VAR b = 0z1', 'E973:') - call assert_fails('VAR b = 0z1x', 'E973:') - call assert_fails('VAR b = 0z12345', 'E973:') - - call assert_equal(0z, v:_null_blob) - - LET b = 0z001122.33445566.778899.aabbcc.dd - call assert_equal(0z00112233445566778899aabbccdd, b) - call assert_fails('VAR b = 0z1.1') - call assert_fails('VAR b = 0z.') - call assert_fails('VAR b = 0z001122.') - call assert_fails('call get("", 1)', 'E896:') - call assert_equal(0, len(v:_null_blob)) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -" assignment to a blob -func Test_blob_assign() - let lines =<< trim END - VAR b = 0zDEADBEEF - VAR b2 = b[1 : 2] - call assert_equal(0zADBE, b2) - - VAR bcopy = b[:] - call assert_equal(b, bcopy) - call assert_false(b is bcopy) - - LET b = 0zDEADBEEF - LET b2 = b - call assert_true(b is b2) - LET b[:] = 0z11223344 - call assert_equal(0z11223344, b) - call assert_equal(0z11223344, b2) - call assert_true(b is b2) - - LET b = 0zDEADBEEF - LET b[3 :] = 0z66 - call assert_equal(0zDEADBE66, b) - LET b[: 1] = 0z8899 - call assert_equal(0z8899BE66, b) - - LET b = 0zDEADBEEF - LET b += 0z99 - call assert_equal(0zDEADBEEF99, b) - - VAR l = [0z12] - VAR m = deepcopy(l) - LET m[0] = 0z34 #" E742 or E741 should not occur. - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b[2 : 3] = 0z112233 - END - call CheckLegacyAndVim9Failure(lines, 'E972:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b[2 : 3] = 0z11 - END - call CheckLegacyAndVim9Failure(lines, 'E972:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b[3 : 2] = 0z - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b ..= 0z33 - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b ..= "xx" - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b += "xx" - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) - - let lines =<< trim END - VAR b = 0zDEADBEEF - LET b[1 : 1] ..= 0z55 - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) -endfunc - -func Test_blob_get_range() - let lines =<< trim END - VAR b = 0z0011223344 - call assert_equal(0z2233, b[2 : 3]) - call assert_equal(0z223344, b[2 : -1]) - call assert_equal(0z00, b[0 : -5]) - call assert_equal(0z, b[0 : -11]) - call assert_equal(0z44, b[-1 :]) - call assert_equal(0z0011223344, b[:]) - call assert_equal(0z0011223344, b[: -1]) - call assert_equal(0z, b[5 : 6]) - call assert_equal(0z0011, b[-10 : 1]) - END - call CheckLegacyAndVim9Success(lines) - - " legacy script white space - let b = 0z0011223344 - call assert_equal(0z2233, b[2:3]) -endfunc - -func Test_blob_get() - let lines =<< trim END - VAR b = 0z0011223344 - call assert_equal(0x00, get(b, 0)) - call assert_equal(0x22, get(b, 2, 999)) - call assert_equal(0x44, get(b, 4)) - call assert_equal(0x44, get(b, -1)) - call assert_equal(-1, get(b, 5)) - call assert_equal(999, get(b, 5, 999)) - call assert_equal(-1, get(b, -8)) - call assert_equal(999, get(b, -8, 999)) - call assert_equal(10, get(v:_null_blob, 2, 10)) - - call assert_equal(0x00, b[0]) - call assert_equal(0x22, b[2]) - call assert_equal(0x44, b[4]) - call assert_equal(0x44, b[-1]) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - VAR b = 0z0011223344 - echo b[5] - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0z0011223344 - echo b[-8] - END - call CheckLegacyAndVim9Failure(lines, 'E979:') -endfunc - -func Test_blob_to_string() - let lines =<< trim END - VAR b = 0z00112233445566778899aabbccdd - call assert_equal('0z00112233.44556677.8899AABB.CCDD', string(b)) - call assert_equal(b, eval(string(b))) - call remove(b, 4, -1) - call assert_equal('0z00112233', string(b)) - call remove(b, 0, 3) - call assert_equal('0z', string(b)) - call assert_equal('0z', string(v:_null_blob)) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -func Test_blob_compare() - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR b3 = 0z001122 - call assert_true(b1 == b1) - call assert_false(b1 == b2) - call assert_false(b1 == b3) - call assert_true(b1 != b2) - call assert_true(b1 != b3) - call assert_true(b1 == 0z0011) - - call assert_false(b1 is b2) - LET b2 = b1 - call assert_true(b1 == b2) - call assert_true(b1 is b2) - LET b2 = copy(b1) - call assert_true(b1 == b2) - call assert_false(b1 is b2) - LET b2 = b1[:] - call assert_true(b1 == b2) - call assert_false(b1 is b2) - call assert_true(b1 isnot b2) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - VAR b1 = 0z0011 - echo b1 == 9 - END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) - - let lines =<< trim END - VAR b1 = 0z0011 - echo b1 != 9 - END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) - - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR x = b1 > b2 - END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) - - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR x = b1 < b2 - END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) - - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR x = b1 - b2 - END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) - - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR x = b1 / b2 - END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) - - let lines =<< trim END - VAR b1 = 0z0011 - VAR b2 = 0z1100 - VAR x = b1 * b2 - END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) -endfunc - -func Test_blob_index_assign() - let lines =<< trim END - VAR b = 0z00 - LET b[1] = 0x11 - LET b[2] = 0x22 - call assert_equal(0z001122, b) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - VAR b = 0z00 - LET b[2] = 0x33 - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0z00 - LET b[-2] = 0x33 - END - call CheckLegacyAndVim9Failure(lines, 'E979:') -endfunc - -func Test_blob_for_loop() - let lines =<< trim END - VAR blob = 0z00010203 - VAR i = 0 - for byte in blob - call assert_equal(i, byte) - LET i += 1 - endfor - call assert_equal(4, i) - - LET blob = 0z00 - call remove(blob, 0) - call assert_equal(0, len(blob)) - for byte in blob - call assert_report('loop over empty blob') - endfor - - LET blob = 0z0001020304 - LET i = 0 - for byte in blob - call assert_equal(i, byte) - if i == 1 - call remove(blob, 0) - elseif i == 3 - call remove(blob, 3) - endif - LET i += 1 - endfor - call assert_equal(5, i) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -func Test_blob_concatenate() - let lines =<< trim END - VAR b = 0z0011 - LET b += 0z2233 - call assert_equal(0z00112233, b) - - LET b = 0zDEAD + 0zBEEF - call assert_equal(0zDEADBEEF, b) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - VAR b = 0z0011 - LET b += "a" - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) - - let lines =<< trim END - VAR b = 0z0011 - LET b += 88 - END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) -endfunc - -func Test_blob_add() - let lines =<< trim END - VAR b = 0z0011 - call add(b, 0x22) - call assert_equal(0z001122, b) - END - call CheckLegacyAndVim9Success(lines) - - " Only works in legacy script - let b = 0z0011 - call add(b, '51') - call assert_equal(0z001133, b) - call assert_equal(1, add(v:_null_blob, 0x22)) - - let lines =<< trim END - VAR b = 0z0011 - call add(b, [9]) - END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E745:']) - - let lines =<< trim END - VAR b = 0z0011 - call add("", 0x01) - END - call CheckLegacyAndVim9Failure(lines, 'E897:') - - let lines =<< trim END - add(v:_null_blob, 0x22) - END - call CheckDefExecAndScriptFailure(lines, 'E1131:') -endfunc - -func Test_blob_empty() - call assert_false(empty(0z001122)) - call assert_true(empty(0z)) - call assert_true(empty(v:_null_blob)) -endfunc - -" Test removing items in blob -func Test_blob_func_remove() - let lines =<< trim END - #" Test removing 1 element - VAR b = 0zDEADBEEF - call assert_equal(0xDE, remove(b, 0)) - call assert_equal(0zADBEEF, b) - - LET b = 0zDEADBEEF - call assert_equal(0xEF, remove(b, -1)) - call assert_equal(0zDEADBE, b) - - LET b = 0zDEADBEEF - call assert_equal(0xAD, remove(b, 1)) - call assert_equal(0zDEBEEF, b) - - #" Test removing range of element(s) - LET b = 0zDEADBEEF - call assert_equal(0zBE, remove(b, 2, 2)) - call assert_equal(0zDEADEF, b) - - LET b = 0zDEADBEEF - call assert_equal(0zADBE, remove(b, 1, 2)) - call assert_equal(0zDEEF, b) - END - call CheckLegacyAndVim9Success(lines) - - " Test invalid cases - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(b, 5) - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(b, 1, 5) - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(b, 3, 2) - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(1, 0) - END - call CheckLegacyAndVim9Failure(lines, 'E896:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(b, b) - END - call CheckLegacyAndVim9Failure(lines, 'E974:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(b, 1, []) - END - call CheckLegacyAndVim9Failure(lines, 'E745:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call remove(v:_null_blob, 1, 2) - END - call CheckLegacyAndVim9Failure(lines, 'E979:') - - let lines =<< trim END - let b = 0zDEADBEEF - lockvar b - call remove(b, 0) - unlockvar b - END - call CheckScriptFailure(lines, 'E741:') - - " can only check at script level, not in a :def function - let lines =<< trim END - vim9script - var b = 0zDEADBEEF - lockvar b - remove(b, 0) - END - call CheckScriptFailure(lines, 'E741:') -endfunc - -func Test_blob_read_write() - let lines =<< trim END - VAR b = 0zDEADBEEF - call writefile(b, 'Xblob') - VAR br = readfile('Xblob', 'B') - call assert_equal(b, br) - VAR br2 = readblob('Xblob') - call assert_equal(b, br2) - VAR br3 = readblob('Xblob', 1) - call assert_equal(b[1 :], br3) - VAR br4 = readblob('Xblob', 1, 2) - call assert_equal(b[1 : 2], br4) - VAR br5 = readblob('Xblob', -3) - call assert_equal(b[-3 :], br5) - VAR br6 = readblob('Xblob', -3, 2) - call assert_equal(b[-3 : -2], br6) - - #" reading past end of file, empty result - VAR br1e = readblob('Xblob', 10000) - call assert_equal(0z, br1e) - - #" reading too much, result is truncated - VAR blong = readblob('Xblob', -1000) - call assert_equal(b, blong) - LET blong = readblob('Xblob', -10, 8) - call assert_equal(b, blong) - LET blong = readblob('Xblob', 0, 10) - call assert_equal(b, blong) - - call delete('Xblob') - END - call CheckLegacyAndVim9Success(lines) - - if filereadable('/dev/random') - let b = readblob('/dev/random', 0, 10) - call assert_equal(10, len(b)) - endif - - call assert_fails("call readblob('notexist')", 'E484:') - " TODO: How do we test for the E485 error? - - " This was crashing when calling readfile() with a directory. - call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') -endfunc - -" filter() item in blob -func Test_blob_filter() - let lines =<< trim END - call assert_equal(v:_null_blob, filter(v:_null_blob, '0')) - call assert_equal(0z, filter(0zDEADBEEF, '0')) - call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE')) - call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE')) - call assert_equal(0zDEADBE, filter(0zDEADBEEF, 'v:val != 0xEF')) - call assert_equal(0zDEADBEEF, filter(0zDEADBEEF, '1')) - call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) - call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -" map() item in blob -func Test_blob_map() - let lines =<< trim END - call assert_equal(0zDFAEBFF0, map(0zDEADBEEF, 'v:val + 1')) - call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) - call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - call map(0z00, '[9]') - END - call CheckLegacyAndVim9Failure(lines, 'E978:') -endfunc - -func Test_blob_index() - let lines =<< trim END - call assert_equal(2, index(0zDEADBEEF, 0xBE)) - call assert_equal(-1, index(0zDEADBEEF, 0)) - call assert_equal(2, index(0z11111111, 0x11, 2)) - call assert_equal(3, 0z11110111->index(0x11, 2)) - call assert_equal(2, index(0z11111111, 0x11, -2)) - call assert_equal(3, index(0z11110111, 0x11, -2)) - call assert_equal(0, index(0z11110111, 0x11, -10)) - call assert_equal(-1, index(v:_null_blob, 1)) - END - call CheckLegacyAndVim9Success(lines) - - let lines =<< trim END - echo index(0z11110111, 0x11, []) - END - call CheckLegacyAndVim9Failure(lines, 'E745:') - - let lines =<< trim END - call index("asdf", 0) - END - call CheckLegacyAndVim9Failure(lines, 'E897:') -endfunc - -func Test_blob_insert() - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, 0x33) - call assert_equal(0z33DEADBEEF, b) - - LET b = 0zDEADBEEF - call insert(b, 0x33, 2) - call assert_equal(0zDEAD33BEEF, b) - END - call CheckLegacyAndVim9Success(lines) - - " only works in legacy script - call assert_equal(0, insert(v:_null_blob, 0x33)) - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, -1) - END - call CheckLegacyAndVim9Failure(lines, 'E475:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, 257) - END - call CheckLegacyAndVim9Failure(lines, 'E475:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, 0, [9]) - END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E745:']) - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, 0, -20) - END - call CheckLegacyAndVim9Failure(lines, 'E475:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, 0, 20) - END - call CheckLegacyAndVim9Failure(lines, 'E475:') - - let lines =<< trim END - VAR b = 0zDEADBEEF - call insert(b, []) - END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E745:']) - - let lines =<< trim END - insert(v:_null_blob, 0x33) - END - call CheckDefExecAndScriptFailure(lines, 'E1131:') - - let lines =<< trim END - let b = 0zDEADBEEF - lockvar b - call insert(b, 3) - unlockvar b - END - call CheckScriptFailure(lines, 'E741:') - - let lines =<< trim END - vim9script - var b = 0zDEADBEEF - lockvar b - insert(b, 3) - END - call CheckScriptFailure(lines, 'E741:') -endfunc - -func Test_blob_reverse() - let lines =<< trim END - call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) - call assert_equal(0zBEADDE, reverse(0zDEADBE)) - call assert_equal(0zADDE, reverse(0zDEAD)) - call assert_equal(0zDE, reverse(0zDE)) - call assert_equal(0z, reverse(v:_null_blob)) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -func Test_blob_json_encode() - let lines =<< trim END - #" call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) - call assert_equal('[222, 173, 190, 239]', json_encode(0zDEADBEEF)) - call assert_equal('[]', json_encode(0z)) - END - call CheckLegacyAndVim9Success(lines) -endfunc - -func Test_blob_lock() - let lines =<< trim END - let b = 0z112233 - lockvar b - unlockvar b - let b = 0z44 - END - call CheckScriptSuccess(lines) - - let lines =<< trim END - vim9script - var b = 0z112233 - lockvar b - unlockvar b - b = 0z44 - END - call CheckScriptSuccess(lines) - - let lines =<< trim END - let b = 0z112233 - lockvar b - let b = 0z44 - END - call CheckScriptFailure(lines, 'E741:') - - let lines =<< trim END - vim9script - var b = 0z112233 - lockvar b - b = 0z44 - END - call CheckScriptFailure(lines, 'E741:') -endfunc - -func Test_blob_sort() - if has('float') - call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') - endif - call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') -endfunc - -" Tests for the blob2list() function -func Test_blob2list() - call assert_fails('let v = blob2list(10)', 'E1238: Blob required for argument 1') - eval 0zFFFF->blob2list()->assert_equal([255, 255]) - let tests = [[0z0102, [1, 2]], - \ [0z00, [0]], - \ [0z, []], - \ [0z00000000, [0, 0, 0, 0]], - \ [0zAABB.CCDD, [170, 187, 204, 221]]] - for t in tests - call assert_equal(t[0]->blob2list(), t[1]) - endfor - exe 'let v = 0z' .. repeat('000102030405060708090A0B0C0D0E0F', 64) - call assert_equal(1024, blob2list(v)->len()) - call assert_equal([4, 8, 15], [v[100], v[1000], v[1023]]) - call assert_equal([], blob2list(v:_null_blob)) -endfunc - -" Tests for the list2blob() function -func Test_list2blob() - call assert_fails('let b = list2blob(0z10)', 'E1211: List required for argument 1') - let tests = [[[1, 2], 0z0102], - \ [[0], 0z00], - \ [[], 0z], - \ [[0, 0, 0, 0], 0z00000000], - \ [[255, 255], 0zFFFF], - \ [[170, 187, 204, 221], 0zAABB.CCDD], - \ ] - for t in tests - call assert_equal(t[1], t[0]->list2blob()) - endfor - call assert_fails('let b = list2blob([1, []])', 'E745:') - call assert_fails('let b = list2blob([-1])', 'E1239:') - call assert_fails('let b = list2blob([256])', 'E1239:') - let b = range(16)->repeat(64)->list2blob() - call assert_equal(1024, b->len()) - call assert_equal([4, 8, 15], [b[100], b[1000], b[1023]]) - call assert_equal(0z, list2blob(v:_null_list)) -endfunc - -" The following used to cause an out-of-bounds memory access -func Test_blob2string() - let v = '0z' .. repeat('01010101.', 444) - let v ..= '01' - exe 'let b = ' .. v - call assert_equal(v, string(b)) -endfunc - -func Test_blob_repeat() - call assert_equal(0z, repeat(0z00, 0)) - call assert_equal(0z00, repeat(0z00, 1)) - call assert_equal(0z0000, repeat(0z00, 2)) - call assert_equal(0z00000000, repeat(0z0000, 2)) - - call assert_equal(0z, repeat(0z12, 0)) - call assert_equal(0z, repeat(0z1234, 0)) - call assert_equal(0z1234, repeat(0z1234, 1)) - call assert_equal(0z12341234, repeat(0z1234, 2)) -endfunc - -" Test for blob allocation failure -func Test_blob_alloc_failure() - CheckFunction test_alloc_fail - " blob variable - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let v = 0z10', 'E342:') - - " blob slice - let v = 0z1020 - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let x = v[0:0]', 'E342:') - call assert_equal(0z1020, x) - - " blob remove() - let v = 0z10203040 - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let x = remove(v, 1, 2)', 'E342:') - call assert_equal(0, x) - - " list2blob() - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let a = list2blob([1, 2, 4])', 'E342:') - call assert_equal(0, a) - - " mapnew() - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let x = mapnew(0z1234, {_, v -> 1})', 'E342:') - call assert_equal(0, x) - - " copy() - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let x = copy(v)', 'E342:') - call assert_equal(0z, x) - - " readblob() - call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) - call assert_fails('let x = readblob("test_blob.vim")', 'E342:') - call assert_equal(0, x) -endfunc - -" Test for the indexof() function -func Test_indexof() - let b = 0zdeadbeef - call assert_equal(0, indexof(b, {i, v -> v == 0xde})) - call assert_equal(3, indexof(b, {i, v -> v == 0xef})) - call assert_equal(-1, indexof(b, {i, v -> v == 0x1})) - call assert_equal(1, indexof(b, "v:val == 0xad")) - call assert_equal(-1, indexof(b, "v:val == 0xff")) - call assert_equal(-1, indexof(b, {_, v -> "v == 0xad"})) - - call assert_equal(-1, indexof(0z, "v:val == 0x0")) - call assert_equal(-1, indexof(v:_null_blob, "v:val == 0xde")) - call assert_equal(-1, indexof(b, v:_null_string)) - " Nvim doesn't have null functions - " call assert_equal(-1, indexof(b, test_null_function())) - - let b = 0z01020102 - call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0})) - call assert_equal(2, indexof(b, "v:val == 0x01", #{startidx: -2})) - call assert_equal(-1, indexof(b, "v:val == 0x01", #{startidx: 5})) - call assert_equal(0, indexof(b, "v:val == 0x01", #{startidx: -5})) - call assert_equal(0, indexof(b, "v:val == 0x01", v:_null_dict)) - - " failure cases - call assert_fails('let i = indexof(b, "val == 0xde")', 'E121:') - call assert_fails('let i = indexof(b, {})', 'E1256:') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim deleted file mode 100644 index 7b56b1554f..0000000000 --- a/src/nvim/testdir/test_blockedit.vim +++ /dev/null @@ -1,132 +0,0 @@ -" Test for block inserting -" - -func Test_blockinsert_indent() - new - filetype plugin indent on - setlocal sw=2 et ft=vim - call setline(1, ['let a=[', ' ''eins'',', ' ''zwei'',', ' ''drei'']']) - call cursor(2, 3) - exe "norm! \2jI\\ \" - call assert_equal(['let a=[', ' \ ''eins'',', ' \ ''zwei'',', ' \ ''drei'']'], - \ getline(1,'$')) - " reset to sane state - filetype off - bwipe! -endfunc - -func Test_blockinsert_autoindent() - new - let lines =<< trim END - var d = { - a: () => 0, - b: () => 0, - c: () => 0, - } - END - call setline(1, lines) - filetype plugin indent on - setlocal sw=2 et ft=vim - setlocal indentkeys+=: - exe "norm! 2Gf)\2jA: asdf\" - let expected =<< trim END - var d = { - a: (): asdf => 0, - b: (): asdf => 0, - c: (): asdf => 0, - } - END - call assert_equal(expected, getline(1, 5)) - - " insert on the next column should do exactly the same - :%dele - call setline(1, lines) - exe "norm! 2Gf)l\2jI: asdf\" - call assert_equal(expected, getline(1, 5)) - - :%dele - call setline(1, lines) - setlocal sw=8 noet - exe "norm! 2Gf)\2jA: asdf\" - let expected =<< trim END - var d = { - a: (): asdf => 0, - b: (): asdf => 0, - c: (): asdf => 0, - } - END - call assert_equal(expected, getline(1, 5)) - - " insert on the next column should do exactly the same - :%dele - call setline(1, lines) - exe "norm! 2Gf)l\2jI: asdf\" - call assert_equal(expected, getline(1, 5)) - - filetype off - bwipe! -endfunc - -func Test_blockinsert_delete() - new - let _bs = &bs - set bs=2 - call setline(1, ['case Arg is ', ' when Name_Async,', ' when Name_Num_Gangs,', 'end if;']) - exe "norm! ggjVj\$o$A\\" - "call feedkeys("Vj\$o$A\\", 'ti') - call assert_equal(["case Arg is ", " when Name_Async", " when Name_Num_Gangs,", "end if;"], - \ getline(1,'$')) - " reset to sane state - let &bs = _bs - bwipe! -endfunc - -func Test_blockappend_eol_cursor() - new - " Test 1 Move 1 char left - call setline(1, ['aaa', 'bbb', 'ccc']) - exe "norm! gg$\2jA\x\" - call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) - " Test 2 Move 2 chars left - sil %d - call setline(1, ['aaa', 'bbb', 'ccc']) - exe "norm! gg$\2jA\\x\" - call assert_equal(['axaa', 'bxbb', 'cxcc'], getline(1, '$')) - " Test 3 Move 3 chars left (outside of the visual selection) - sil %d - call setline(1, ['aaa', 'bbb', 'ccc']) - exe "norm! ggl$\2jA\\\x\" - call assert_equal(['xaaa', 'bbb', 'ccc'], getline(1, '$')) - bw! -endfunc - -func Test_blockappend_eol_cursor2() - new - " Test 1 Move 1 char left - call setline(1, ['aaaaa', 'bbb', 'ccccc']) - exe "norm! gg\$2jA\x\" - call assert_equal(['aaaaxa', 'bbbx', 'ccccxc'], getline(1, '$')) - " Test 2 Move 2 chars left - sil %d - call setline(1, ['aaaaa', 'bbb', 'ccccc']) - exe "norm! gg\$2jA\\x\" - call assert_equal(['aaaxaa', 'bbbx', 'cccxcc'], getline(1, '$')) - " Test 3 Move 3 chars left (to the beginning of the visual selection) - sil %d - call setline(1, ['aaaaa', 'bbb', 'ccccc']) - exe "norm! gg\$2jA\\\x\" - call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$')) - " Test 4 Move 3 chars left (outside of the visual selection) - sil %d - call setline(1, ['aaaaa', 'bbb', 'ccccc']) - exe "norm! ggl\$2jA\\\x\" - call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$')) - " Test 5 Move 4 chars left (outside of the visual selection) - sil %d - call setline(1, ['aaaaa', 'bbb', 'ccccc']) - exe "norm! ggl\$2jA\\\\x\" - call assert_equal(['axaaaa', 'bxbb', 'cxcccc'], getline(1, '$')) - bw! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim deleted file mode 100644 index 0d1753182e..0000000000 --- a/src/nvim/testdir/test_breakindent.vim +++ /dev/null @@ -1,1096 +0,0 @@ -" Test for breakindent -" -" Note: if you get strange failures when adding new tests, it might be that -" while the test is run, the breakindent caching gets in its way. -" It helps to change the tabstop setting and force a redraw (e.g. see -" Test_breakindent08()) -source check.vim -CheckOption breakindent - -source view_util.vim -source screendump.vim - -func SetUp() - let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" -endfunc - -func s:screen_lines(lnum, width) abort - return ScreenLines([a:lnum, a:lnum + 2], a:width) -endfunc - -func s:screen_lines2(lnums, lnume, width) abort - return ScreenLines([a:lnums, a:lnume], a:width) -endfunc - -func s:compare_lines(expect, actual) - call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) -endfunc - -func s:test_windows(...) - call NewWindow(10, 20) - setl ts=4 sw=4 sts=4 breakindent - put =s:input - exe get(a:000, 0, '') -endfunc - -func s:close_windows(...) - call CloseWindow() - exe get(a:000, 0, '') -endfunc - -func Test_breakindent01() - " simple breakindent test - call s:test_windows('setl briopt=min:0') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrst", - \ " GHIJ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent01_vartabs() - " like 01 but with vartabs feature - if !has("vartabs") - return - endif - call s:test_windows('setl briopt=min:0 vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrst", - \ " GHIJ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent02() - " simple breakindent test with showbreak set - set sbr=>> - call s:test_windows('setl briopt=min:0 sbr=') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " >>qr", - \ " >>EF", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr=') -endfunc - -func Test_breakindent02_vartabs() - if !has("vartabs") - return - endif - " simple breakindent test with showbreak set - call s:test_windows('setl briopt=min:0 sbr=>> vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " >>qr", - \ " >>EF", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent03() - " simple breakindent test with showbreak set and briopt including sbr - call s:test_windows('setl briopt=sbr,min:0 sbr=++') - let lines = s:screen_lines(line('.'),8) - let expect=[ -\ " abcd", -\ "++ qrst", -\ "++ GHIJ", -\ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr=') -endfunc - -func Test_breakindent03_vartabs() - " simple breakindent test with showbreak set and briopt including sbr - if !has("vartabs") - return - endif - call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ "++ qrst", - \ "++ GHIJ", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent04() - " breakindent set with min width 18 - set sbr=<<< - call s:test_windows('setl sbr=NONE briopt=min:18') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrstuv", - \ " IJKLMN", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr=') - set sbr= -endfunc - -func Test_breakindent04_vartabs() - " breakindent set with min width 18 - if !has("vartabs") - return - endif - call s:test_windows('setl sbr= briopt=min:18 vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrstuv", - \ " IJKLMN", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent05() - " breakindent set and shift by 2 - call s:test_windows('setl briopt=shift:2,min:0') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qr", - \ " EF", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent05_vartabs() - " breakindent set and shift by 2 - if !has("vartabs") - return - endif - call s:test_windows('setl briopt=shift:2,min:0 vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qr", - \ " EF", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent06() - " breakindent set and shift by -1 - call s:test_windows('setl briopt=shift:-1,min:0') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrstu", - \ " HIJKL", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent06_vartabs() - " breakindent set and shift by -1 - if !has("vartabs") - return - endif - call s:test_windows('setl briopt=shift:-1,min:0 vts=4') - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ " abcd", - \ " qrstu", - \ " HIJKL", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent07() - " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ "? m", - \ "? x", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr= cpo-=n') -endfunc - -func Test_breakindent07_vartabs() - if !has("vartabs") - return - endif - " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ "? m", - \ "? x", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr= cpo-=n vts&') -endfunc - -func Test_breakindent07a() - " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ " ? m", - \ " ? x", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr=') -endfunc - -func Test_breakindent07a_vartabs() - if !has("vartabs") - return - endif - " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ " ? m", - \ " ? x", - \ ] - call s:compare_lines(expect, lines) - " clean up - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent08() - " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4') - " make sure, cache is invalidated! - set ts=8 - redraw! - set ts=4 - redraw! - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ "# opq", - \ "# BCD", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= cpo-=n') -endfunc - -func Test_breakindent08_vartabs() - if !has("vartabs") - return - endif - " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4') - " make sure, cache is invalidated! - set ts=8 - redraw! - set ts=4 - redraw! - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ "# opq", - \ "# BCD", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= cpo-=n vts&') -endfunc - -func Test_breakindent08a() - " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ " # opq", - \ " # BCD", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr=') -endfunc - -func Test_breakindent08a_vartabs() - if !has("vartabs") - return - endif - " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ " # opq", - \ " # BCD", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent09() - " breakindent set and shift by 1, Number and list set sbr=# - call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ " #op", - \ " #AB", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr=') -endfunc - -func Test_breakindent09_vartabs() - if !has("vartabs") - return - endif - " breakindent set and shift by 1, Number and list set sbr=# - call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4') - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ^Iabcd", - \ " #op", - \ " #AB", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent10() - " breakindent set, Number set sbr=~ - call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') - " make sure, cache is invalidated! - set ts=8 - redraw! - set ts=4 - redraw! - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ "~ mn", - \ "~ yz", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= cpo-=n') -endfunc - -func Test_breakindent10_vartabs() - if !has("vartabs") - return - endif - " breakindent set, Number set sbr=~ - call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4') - " make sure, cache is invalidated! - set ts=8 - redraw! - set ts=4 - redraw! - let lines = s:screen_lines(line('.'),10) - let expect = [ - \ " 2 ab", - \ "~ mn", - \ "~ yz", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set sbr= cpo-=n vts&') -endfunc - -func Test_breakindent11() - " test strdisplaywidth() - call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') - let text = getline(2) - let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times - call assert_equal(width, strdisplaywidth(text)) - call s:close_windows('set sbr=') - call assert_equal(4, strdisplaywidth("\t", 4)) -endfunc - -func Test_breakindent11_vartabs() - if !has("vartabs") - return - endif - " test strdisplaywidth() - call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4') - let text = getline(2) - let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times - call assert_equal(width, text->strdisplaywidth()) - call s:close_windows('set sbr= vts&') -endfunc - -func Test_breakindent12() - " test breakindent with long indent - let s:input="\t\t\t\t\t{" - call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-') - let lines = s:screen_lines(2,16) - let expect = [ - \ " 2 >--->--->--->", - \ " ---{ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set nuw=4 listchars=') -endfunc - -func Test_breakindent12_vartabs() - if !has("vartabs") - return - endif - " test breakindent with long indent - let s:input = "\t\t\t\t\t{" - call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4') - let lines = s:screen_lines(2,16) - let expect = [ - \ " 2 >--->--->--->", - \ " ---{ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set nuw=4 listchars= vts&') -endfunc - -func Test_breakindent13() - let s:input = "" - call s:test_windows('setl breakindent briopt=min:10 ts=8') - vert resize 20 - call setline(1, [" a\tb\tc\td\te", " z y x w v"]) - 1 - norm! fbgj"ayl - 2 - norm! fygj"byl - call assert_equal('d', @a) - call assert_equal('w', @b) - call s:close_windows() -endfunc - -func Test_breakindent13_vartabs() - if !has("vartabs") - return - endif - let s:input = "" - call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8') - vert resize 20 - call setline(1, [" a\tb\tc\td\te", " z y x w v"]) - 1 - norm! fbgj"ayl - 2 - norm! fygj"byl - call assert_equal('d', @a) - call assert_equal('w', @b) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent14() - let s:input = "" - call s:test_windows('setl breakindent briopt= ts=8') - vert resize 30 - norm! 3a1234567890 - norm! a abcde - exec "norm! 0\tex" - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ "e ", - \ "~ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent14_vartabs() - if !has("vartabs") - return - endif - let s:input = "" - call s:test_windows('setl breakindent briopt= ts=8 vts=8') - vert resize 30 - norm! 3a1234567890 - norm! a abcde - exec "norm! 0\tex" - let lines = s:screen_lines(line('.'),8) - let expect = [ - \ "e ", - \ "~ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent15() - let s:input = "" - call s:test_windows('setl breakindent briopt= ts=8 sw=8') - vert resize 30 - norm! 4a1234567890 - exe "normal! >>\3f0x" - let lines = s:screen_lines(line('.'),20) - let expect = [ - \ " 1234567890 ", - \ "~ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent15_vartabs() - if !has("vartabs") - return - endif - let s:input = "" - call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8') - vert resize 30 - norm! 4a1234567890 - exe "normal! >>\3f0x" - let lines = s:screen_lines(line('.'),20) - let expect = [ - \ " 1234567890 ", - \ "~ ", - \ "~ ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent16() - " Check that overlong lines are indented correctly. - let s:input = "" - call s:test_windows('setl breakindent briopt=min:0 ts=4') - call setline(1, "\t".repeat("1234567890", 10)) - resize 6 - norm! 1gg$ - redraw! - let lines = s:screen_lines(1,10) - let expect = [ - \ " 789012", - \ " 345678", - \ " 901234", - \ ] - call s:compare_lines(expect, lines) - let lines = s:screen_lines(4,10) - let expect = [ - \ " 567890", - \ " 123456", - \ " 7890 ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows() -endfunc - -func Test_breakindent16_vartabs() - if !has("vartabs") - return - endif - " Check that overlong lines are indented correctly. - let s:input = "" - call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4') - call setline(1, "\t".repeat("1234567890", 10)) - resize 6 - norm! 1gg$ - redraw! - let lines = s:screen_lines(1,10) - let expect = [ - \ " 789012", - \ " 345678", - \ " 901234", - \ ] - call s:compare_lines(expect, lines) - let lines = s:screen_lines(4,10) - let expect = [ - \ " 567890", - \ " 123456", - \ " 7890 ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set vts&') -endfunc - -func Test_breakindent17_vartabs() - if !has("vartabs") - return - endif - let s:input = "" - call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++') - call setline(1, "\t" . repeat('a', 63)) - vert resize 30 - norm! 1gg$ - redraw! - let lines = s:screen_lines(1, 30) - let expect = [ - \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", - \ " +++aaaaaaaaaaaaaaaaaaaaaaa", - \ " +++aaaaaaaaaaaaaa ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set breakindent& list& listchars& showbreak&') -endfunc - -func Test_breakindent18_vartabs() - if !has("vartabs") - return - endif - let s:input = "" - call s:test_windows('setl breakindent list listchars=tab:<->') - call setline(1, "\t" . repeat('a', 63)) - vert resize 30 - norm! 1gg$ - redraw! - let lines = s:screen_lines(1, 30) - let expect = [ - \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaa ", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set breakindent& list& listchars&') -endfunc - -func Test_breakindent19_sbr_nextpage() - let s:input = "" - call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>') - call setline(1, repeat('a', 200)) - norm! 1gg - redraw! - let lines = s:screen_lines(1, 20) - let expect = [ - \ "aaaaaaaaaaaaaaaaaaaa", - \ "> aaaaaaaaaaaaaaaaaa", - \ "> aaaaaaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - " Scroll down one screen line - setl scrolloff=5 - norm! 5gj - let lines = s:screen_lines(1, 20) - let expect = [ - \ "aaaaaaaaaaaaaaaaaaaa", - \ "> aaaaaaaaaaaaaaaaaa", - \ "> aaaaaaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - redraw! - " moving the cursor doesn't change the text offset - norm! l - redraw! - let lines = s:screen_lines(1, 20) - call s:compare_lines(expect, lines) - - setl breakindent briopt=min:18 sbr=> - norm! 5gj - let lines = s:screen_lines(1, 20) - let expect = [ - \ ">aaaaaaaaaaaaaaaaaaa", - \ ">aaaaaaaaaaaaaaaaaaa", - \ ">aaaaaaaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - call s:close_windows('set breakindent& briopt& sbr&') -endfunc - -func Test_breakindent20_cpo_n_nextpage() - let s:input = "" - call s:test_windows('setl breakindent briopt=min:14 cpo+=n number') - call setline(1, repeat('a', 200)) - norm! 1gg - redraw! - let lines = s:screen_lines(1, 20) - let expect = [ - \ " 1 aaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - " Scroll down one screen line - setl scrolloff=5 - norm! 5gj - redraw! - let lines = s:screen_lines(1, 20) - let expect = [ - \ "--1 aaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - - setl briopt+=shift:2 - norm! 1gg - let lines = s:screen_lines(1, 20) - let expect = [ - \ " 1 aaaaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - " Scroll down one screen line - norm! 5gj - let lines = s:screen_lines(1, 20) - let expect = [ - \ "--1 aaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaa", - \ " aaaaaaaaaaaaaa", - \ ] - call s:compare_lines(expect, lines) - - call s:close_windows('set breakindent& briopt& cpo& number&') -endfunc - -func Test_breakindent20_list() - call s:test_windows('setl breakindent breakindentopt= linebreak') - " default: - call setline(1, [' 1. Congress shall make no law', - \ ' 2.) Congress shall make no law', - \ ' 3.] Congress shall make no law']) - norm! 1gg - redraw! - let lines = s:screen_lines2(1, 6, 20) - let expect = [ - \ " 1. Congress ", - \ "shall make no law ", - \ " 2.) Congress ", - \ "shall make no law ", - \ " 3.] Congress ", - \ "shall make no law ", - \ ] - call s:compare_lines(expect, lines) - " set minimum indent - setl briopt=min:5 - redraw! - let lines = s:screen_lines2(1, 6, 20) - let expect = [ - \ " 1. Congress ", - \ " shall make no law ", - \ " 2.) Congress ", - \ " shall make no law ", - \ " 3.] Congress ", - \ " shall make no law ", - \ ] - call s:compare_lines(expect, lines) - " set additional handing indent - setl briopt+=list:4 - redraw! - let expect = [ - \ " 1. Congress ", - \ " shall make no ", - \ " law ", - \ " 2.) Congress ", - \ " shall make no ", - \ " law ", - \ " 3.] Congress ", - \ " shall make no ", - \ " law ", - \ ] - let lines = s:screen_lines2(1, 9, 20) - call s:compare_lines(expect, lines) - - " reset linebreak option - " Note: it indents by one additional - " space, because of the leading space. - setl linebreak&vim list listchars=eol:$,space:_ - redraw! - let expect = [ - \ "__1.__Congress_shall", - \ " _make_no_law$ ", - \ "__2.)_Congress_shall", - \ " _make_no_law$ ", - \ "__3.]_Congress_shall", - \ " _make_no_law$ ", - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - - " check formatlistpat indent - setl briopt=min:5,list:-1 - setl linebreak list&vim listchars&vim - let &l:flp = '^\s*\d\+\.\?[\]:)}\t ]\s*' - redraw! - let expect = [ - \ " 1. Congress ", - \ " shall make no ", - \ " law ", - \ " 2.) Congress ", - \ " shall make no ", - \ " law ", - \ " 3.] Congress ", - \ " shall make no ", - \ " law ", - \ ] - let lines = s:screen_lines2(1, 9, 20) - call s:compare_lines(expect, lines) - " check formatlistpat indent with different list levels - let &l:flp = '^\s*\*\+\s\+' - %delete _ - call setline(1, ['* Congress shall make no law', - \ '*** Congress shall make no law', - \ '**** Congress shall make no law']) - norm! 1gg - redraw! - let expect = [ - \ "* Congress shall ", - \ " make no law ", - \ "*** Congress shall ", - \ " make no law ", - \ "**** Congress shall ", - \ " make no law ", - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - - " check formatlistpat indent with different list level - " showbreak and sbr - setl briopt=min:5,sbr,list:-1 - setl showbreak=> - redraw! - let expect = [ - \ "* Congress shall ", - \ "> make no law ", - \ "*** Congress shall ", - \ "> make no law ", - \ "**** Congress shall ", - \ "> make no law ", - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - - " check formatlistpat indent with different list level - " showbreak sbr and shift - setl briopt=min:5,sbr,list:-1,shift:2 - setl showbreak=> - redraw! - let expect = [ - \ "* Congress shall ", - \ "> make no law ", - \ "*** Congress shall ", - \ "> make no law ", - \ "**** Congress shall ", - \ "> make no law ", - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - - " check breakindent works if breakindentopt=list:-1 - " for a non list content - %delete _ - call setline(1, [' Congress shall make no law', - \ ' Congress shall make no law', - \ ' Congress shall make no law']) - norm! 1gg - setl briopt=min:5,list:-1 - setl showbreak= - redraw! - let expect = [ - \ " Congress shall ", - \ " make no law ", - \ " Congress shall ", - \ " make no law ", - \ " Congress shall ", - \ " make no law ", - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - - call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&') -endfunc - -" The following used to crash Vim. This is fixed by 8.2.3391. -" This is a regression introduced by 8.2.2903. -func Test_window_resize_with_linebreak() - new - 53vnew - setl linebreak - setl showbreak=>> - setl breakindent - setl breakindentopt=shift:4 - call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a") - redraw! - call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14)) - vertical resize 52 - redraw! - call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14)) - set linebreak& showbreak& breakindent& breakindentopt& - %bw! -endfunc - -func Test_cursor_position_with_showbreak() - CheckScreendump - - let lines =<< trim END - vim9script - &signcolumn = 'yes' - &showbreak = '+ ' - var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff') - repeat('x', &columns - leftcol - 1)->setline(1) - 'second line'->setline(2) - END - call writefile(lines, 'XscriptShowbreak') - let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6}) - - call term_sendkeys(buf, "AX") - call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {}) - - call StopVimInTerminal(buf) - call delete('XscriptShowbreak') -endfunc - -func Test_no_spurious_match() - let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50)) - call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls') - let @/ = '\%>3v[y]' - redraw! - call searchcount().total->assert_equal(1) - - " cleanup - set hls&vim - bwipeout! -endfunc - -func Test_no_extra_indent() - call s:test_windows('setl breakindent breakindentopt=list:-1,min:10') - %d - let &l:formatlistpat='^\s*\d\+\.\s\+' - let text = 'word ' - let len = text->strcharlen() - let line1 = text->repeat((winwidth(0) / len) * 2) - let line2 = repeat(' ', 2) .. '1. ' .. line1 - call setline(1, [line2]) - redraw! - " 1) matches formatlist pattern, so indent - let expect = [ - \ " 1. word word word ", - \ " word word word ", - \ " word word ", - \ "~ ", - \ ] - let lines = s:screen_lines2(1, 4, 20) - call s:compare_lines(expect, lines) - " 2) change formatlist pattern - " -> indent adjusted - let &l:formatlistpat='^\s*\d\+\.' - let expect = [ - \ " 1. word word word ", - \ " word word word ", - \ " word word ", - \ "~ ", - \ ] - let lines = s:screen_lines2(1, 4, 20) - " 3) no local formatlist pattern, - " so use global one -> indent - let g_flp = &g:flp - let &g:formatlistpat='^\s*\d\+\.\s\+' - let &l:formatlistpat='' - let expect = [ - \ " 1. word word word ", - \ " word word word ", - \ " word word ", - \ "~ ", - \ ] - let lines = s:screen_lines2(1, 4, 20) - call s:compare_lines(expect, lines) - let &g:flp = g_flp - let &l:formatlistpat='^\s*\d\+\.' - " 4) add something in front, no additional indent - norm! gg0 - exe ":norm! 5iword \" - redraw! - let expect = [ - \ "word word word word ", - \ "word 1. word word ", - \ "word word word word ", - \ "word word ", - \ "~ ", - \ ] - let lines = s:screen_lines2(1, 5, 20) - call s:compare_lines(expect, lines) - bwipeout! -endfunc - -func Test_breakindent_column() - call s:test_windows('setl breakindent breakindentopt=column:10') - redraw! - " 1) default: does not indent, too wide :( - let expect = [ - \ " ", - \ " abcdefghijklmnop", - \ "qrstuvwxyzABCDEFGHIJ", - \ "KLMNOP " - \ ] - let lines = s:screen_lines2(1, 4, 20) - call s:compare_lines(expect, lines) - " 2) lower min value, so that breakindent works - setl breakindentopt+=min:5 - redraw! - let expect = [ - \ " ", - \ " abcdefghijklmnop", - \ " qrstuvwxyz", - \ " ABCDEFGHIJ", - \ " KLMNOP " - \ ] - let lines = s:screen_lines2(1, 5, 20) - " 3) set shift option -> no influence - setl breakindentopt+=shift:5 - redraw! - let expect = [ - \ " ", - \ " abcdefghijklmnop", - \ " qrstuvwxyz", - \ " ABCDEFGHIJ", - \ " KLMNOP " - \ ] - let lines = s:screen_lines2(1, 5, 20) - call s:compare_lines(expect, lines) - " 4) add showbreak value - setl showbreak=++ - redraw! - let expect = [ - \ " ", - \ " abcdefghijklmnop", - \ " ++qrstuvwx", - \ " ++yzABCDEF", - \ " ++GHIJKLMN", - \ " ++OP " - \ ] - let lines = s:screen_lines2(1, 6, 20) - call s:compare_lines(expect, lines) - bwipeout! -endfunc - -func Test_linebreak_list() - " This was setting wlv.c_extra to NUL while wlv.p_extra is NULL - filetype plugin on - syntax enable - edit! $VIMRUNTIME/doc/index.txt - /v_P - - setlocal list - setlocal listchars=tab:>- - setlocal linebreak - setlocal nowrap - setlocal filetype=help - redraw! - - bwipe! -endfunc - - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim deleted file mode 100644 index 98eba83f73..0000000000 --- a/src/nvim/testdir/test_buffer.vim +++ /dev/null @@ -1,525 +0,0 @@ -" Tests for Vim buffer - -source check.vim - -" Test for the :bunload command with an offset -func Test_bunload_with_offset() - %bwipe! - call writefile(['B1'], 'b1') - call writefile(['B2'], 'b2') - call writefile(['B3'], 'b3') - call writefile(['B4'], 'b4') - - " Load four buffers. Unload the second and third buffers and then - " execute .+3bunload to unload the last buffer. - edit b1 - new b2 - new b3 - new b4 - - bunload b2 - bunload b3 - exe bufwinnr('b1') . 'wincmd w' - .+3bunload - call assert_equal(0, getbufinfo('b4')[0].loaded) - call assert_equal('b1', - \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) - - " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload - " and check whether the second buffer is unloaded. - ball - bunload b3 - bunload b4 - exe bufwinnr('b1') . 'wincmd w' - .+3bunload - call assert_equal(0, getbufinfo('b2')[0].loaded) - call assert_equal('b1', - \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) - - " Load four buffers. Unload the second and third buffers and from the last - " buffer execute .-3bunload to unload the first buffer. - ball - bunload b2 - bunload b3 - exe bufwinnr('b4') . 'wincmd w' - .-3bunload - call assert_equal(0, getbufinfo('b1')[0].loaded) - call assert_equal('b4', - \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) - - " Load four buffers. Unload the first and second buffers. Execute .-3bunload - " from the last buffer and check whether the third buffer is unloaded. - ball - bunload b1 - bunload b2 - exe bufwinnr('b4') . 'wincmd w' - .-3bunload - call assert_equal(0, getbufinfo('b3')[0].loaded) - call assert_equal('b4', - \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) - - %bwipe! - call delete('b1') - call delete('b2') - call delete('b3') - call delete('b4') - - call assert_fails('1,4bunload', 'E16:') - call assert_fails(',100bunload', 'E16:') - - call assert_fails('$bunload', 'E90:') -endfunc - -" Test for :buffer, :bnext, :bprevious, :brewind, :blast and :bmodified -" commands -func Test_buflist_browse() - %bwipe! - call assert_fails('buffer 1000', 'E86:') - - call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1') - call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2') - call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3') - edit Xfile1 - let b1 = bufnr() - edit Xfile2 - let b2 = bufnr() - edit +/baz4 Xfile3 - let b3 = bufnr() - - call assert_fails('buffer ' .. b1 .. ' abc', 'E488:') - call assert_equal(b3, bufnr()) - call assert_equal(4, line('.')) - exe 'buffer +/bar2 ' .. b2 - call assert_equal(b2, bufnr()) - call assert_equal(2, line('.')) - exe 'buffer +/bar1' - call assert_equal(b2, bufnr()) - call assert_equal(1, line('.')) - - brewind + - call assert_equal(b1, bufnr()) - call assert_equal(4, line('.')) - - blast +/baz2 - call assert_equal(b3, bufnr()) - call assert_equal(2, line('.')) - - bprevious +/bar4 - call assert_equal(b2, bufnr()) - call assert_equal(4, line('.')) - - bnext +/baz3 - call assert_equal(b3, bufnr()) - call assert_equal(3, line('.')) - - call assert_fails('bmodified', 'E84:') - call setbufvar(b2, '&modified', 1) - exe 'bmodified +/bar3' - call assert_equal(b2, bufnr()) - call assert_equal(3, line('.')) - - " With no listed buffers in the list, :bnext and :bprev should fail - %bwipe! - set nobuflisted - call assert_fails('bnext', 'E85:') - call assert_fails('bprev', 'E85:') - set buflisted - - call assert_fails('sandbox bnext', 'E48:') - - call delete('Xfile1') - call delete('Xfile2') - call delete('Xfile3') - %bwipe! -endfunc - -" Test for :bdelete -func Test_bdelete_cmd() - %bwipe! - call assert_fails('bdelete 5', 'E516:') - call assert_fails('1,1bdelete 1 2', 'E488:') - call assert_fails('bdelete \)', 'E55:') - - " Deleting a unlisted and unloaded buffer - edit Xfile1 - let bnr = bufnr() - set nobuflisted - enew - call assert_fails('bdelete ' .. bnr, 'E516:') - - " Deleting more than one buffer - new Xbuf1 - new Xbuf2 - exe 'bdel ' .. bufnr('Xbuf2') .. ' ' .. bufnr('Xbuf1') - call assert_equal(1, winnr('$')) - call assert_equal(0, getbufinfo('Xbuf1')[0].loaded) - call assert_equal(0, getbufinfo('Xbuf2')[0].loaded) - - " Deleting more than one buffer and an invalid buffer - new Xbuf1 - new Xbuf2 - let cmd = "exe 'bdel ' .. bufnr('Xbuf2') .. ' xxx ' .. bufnr('Xbuf1')" - call assert_fails(cmd, 'E94:') - call assert_equal(2, winnr('$')) - call assert_equal(1, getbufinfo('Xbuf1')[0].loaded) - call assert_equal(0, getbufinfo('Xbuf2')[0].loaded) - - %bwipe! -endfunc - -func Test_buffer_error() - new foo1 - new foo2 - - call assert_fails('buffer foo', 'E93:') - call assert_fails('buffer bar', 'E94:') - call assert_fails('buffer 0', 'E939:') - - %bwipe -endfunc - -" Test for the status messages displayed when unloading, deleting or wiping -" out buffers -func Test_buffer_statusmsg() - CheckEnglish - set report=1 - new Xbuf1 - new Xbuf2 - let bnr = bufnr() - exe "normal 2\" - call assert_match('buf ' .. bnr .. ':', v:statusmsg) - bunload Xbuf1 Xbuf2 - call assert_equal('2 buffers unloaded', v:statusmsg) - bdel Xbuf1 Xbuf2 - call assert_equal('2 buffers deleted', v:statusmsg) - bwipe Xbuf1 Xbuf2 - call assert_equal('2 buffers wiped out', v:statusmsg) - set report& -endfunc - -" Test for quitting the 'swapfile exists' dialog with the split buffer -" command. -func Test_buffer_sbuf_cleanup() - call writefile([], 'Xfile') - " first open the file in a buffer - new Xfile - let bnr = bufnr() - close - " create the swap file - call writefile([], '.Xfile.swp') - " Remove the catch-all that runtest.vim adds - au! SwapExists - augroup BufTest - au! - autocmd SwapExists Xfile let v:swapchoice='q' - augroup END - exe 'sbuf ' . bnr - call assert_equal(1, winnr('$')) - call assert_equal(0, getbufinfo('Xfile')[0].loaded) - - " test for :sball - sball - call assert_equal(1, winnr('$')) - call assert_equal(0, getbufinfo('Xfile')[0].loaded) - - %bw! - set shortmess+=F - let v:statusmsg = '' - edit Xfile - call assert_equal('', v:statusmsg) - call assert_equal(1, winnr('$')) - call assert_equal(0, getbufinfo('Xfile')[0].loaded) - set shortmess& - - call delete('Xfile') - call delete('.Xfile.swp') - augroup BufTest - au! - augroup END - augroup! BufTest -endfunc - -" Test for deleting a modified buffer with :confirm -func Test_bdel_with_confirm() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/buffer_spec.lua' - CheckUnix - CheckNotGui - CheckFeature dialog_con - new - call setline(1, 'test') - call assert_fails('bdel', 'E89:') - call feedkeys('c', 'L') - confirm bdel - call assert_equal(2, winnr('$')) - call assert_equal(1, &modified) - call feedkeys('n', 'L') - confirm bdel - call assert_equal(1, winnr('$')) -endfunc - -" Test for editing another buffer from a modified buffer with :confirm -func Test_goto_buf_with_confirm() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/buffer_spec.lua' - CheckUnix - CheckNotGui - CheckFeature dialog_con - new Xfile - enew - call setline(1, 'test') - call assert_fails('b Xfile', 'E37:') - call feedkeys('c', 'L') - call assert_fails('confirm b Xfile', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) - call feedkeys('y', 'L') - call assert_fails('confirm b Xfile', ['', 'E37:']) - call assert_equal(1, &modified) - call assert_equal('', @%) - call feedkeys('n', 'L') - confirm b Xfile - call assert_equal('Xfile', @%) - close! -endfunc - -" Test for splitting buffer with 'switchbuf' -func Test_buffer_switchbuf() - new Xfile - wincmd w - set switchbuf=useopen - sbuf Xfile - call assert_equal(1, winnr()) - call assert_equal(2, winnr('$')) - set switchbuf=usetab - tabnew - sbuf Xfile - call assert_equal(1, tabpagenr()) - call assert_equal(2, tabpagenr('$')) - set switchbuf& - %bw -endfunc - -" Test for BufAdd autocommand wiping out the buffer -func Test_bufadd_autocmd_bwipe() - %bw! - augroup BufAdd_Wipe - au! - autocmd BufAdd Xfile %bw! - augroup END - edit Xfile - call assert_equal('', @%) - call assert_equal(0, bufexists('Xfile')) - augroup BufAdd_Wipe - au! - augroup END - augroup! BufAdd_Wipe -endfunc - -" Test for trying to load a buffer with text locked -" e in the command line is used to lock the text -func Test_load_buf_with_text_locked() - new Xfile1 - edit Xfile2 - let cmd = ":\eexecute(\"normal \\")\\" - call assert_fails("call feedkeys(cmd, 'xt')", 'E565:') - %bw! -endfunc - -" Test for using CTRL-^ to edit the alternative file keeping the cursor -" position with 'nostartofline'. Also test using the 'buf' command. -func Test_buffer_edit_altfile() - call writefile(repeat(['one two'], 50), 'Xfile1') - call writefile(repeat(['five six'], 50), 'Xfile2') - set nosol - edit Xfile1 - call cursor(25, 5) - edit Xfile2 - call cursor(30, 4) - exe "normal \" - call assert_equal([0, 25, 5, 0], getpos('.')) - exe "normal \" - call assert_equal([0, 30, 4, 0], getpos('.')) - buf Xfile1 - call assert_equal([0, 25, 5, 0], getpos('.')) - buf Xfile2 - call assert_equal([0, 30, 4, 0], getpos('.')) - set sol& - call delete('Xfile1') - call delete('Xfile2') -endfunc - -" Test for running the :sball command with a maximum window count and a -" modified buffer -func Test_sball_with_count() - %bw! - edit Xfile1 - call setline(1, ['abc']) - new Xfile2 - new Xfile3 - new Xfile4 - 2sball - call assert_equal(bufnr('Xfile4'), winbufnr(1)) - call assert_equal(bufnr('Xfile1'), winbufnr(2)) - call assert_equal(0, getbufinfo('Xfile2')[0].loaded) - call assert_equal(0, getbufinfo('Xfile3')[0].loaded) - %bw! -endfunc - -func Test_badd_options() - new SomeNewBuffer - setlocal numberwidth=3 - wincmd p - badd +1 SomeNewBuffer - new SomeNewBuffer - call assert_equal(3, &numberwidth) - close - close - bwipe! SomeNewBuffer -endfunc - -func Test_balt() - new SomeNewBuffer - balt +3 OtherBuffer - e # - call assert_equal('OtherBuffer', bufname()) -endfunc - -" Test for buffer match URL(scheme) check -" scheme is alpha and inner hyphen only. -func Test_buffer_scheme() - CheckMSWindows - - set noshellslash - %bwipe! - let bufnames = [ - \ #{id: 'ssb0', name: 'test://xyz/foo/ssb0' , match: 1}, - \ #{id: 'ssb1', name: 'test+abc://xyz/foo/ssb1', match: 0}, - \ #{id: 'ssb2', name: 'test_abc://xyz/foo/ssb2', match: 0}, - \ #{id: 'ssb3', name: 'test-abc://xyz/foo/ssb3', match: 1}, - \ #{id: 'ssb4', name: '-test://xyz/foo/ssb4' , match: 0}, - \ #{id: 'ssb5', name: 'test-://xyz/foo/ssb5' , match: 0}, - \] - for buf in bufnames - new `=buf.name` - if buf.match - call assert_equal(buf.name, getbufinfo(buf.id)[0].name) - else - " slashes will have become backslashes - call assert_notequal(buf.name, getbufinfo(buf.id)[0].name) - endif - bwipe - endfor - - set shellslash& -endfunc - -" this was using a NULL pointer after failing to use the pattern -func Test_buf_pattern_invalid() - vsplit 0000000 - silent! buf [0--]\&\zs*\zs*e - bwipe! - - vsplit 00000000000000000000000000 - silent! buf [0--]\&\zs*\zs*e - bwipe! - - " similar case with different code path - split 0 - edit ÿ - silent! buf [0--]\&\zs*\zs*0 - bwipe! -endfunc - -" Test for the 'maxmem' and 'maxmemtot' options -func Test_buffer_maxmem() - " use 1KB per buffer and 2KB for all the buffers - " set maxmem=1 maxmemtot=2 - new - let v:errmsg = '' - " try opening some files - edit test_arglist.vim - call assert_equal('test_arglist.vim', bufname()) - edit test_eval_stuff.vim - call assert_equal('test_eval_stuff.vim', bufname()) - b test_arglist.vim - call assert_equal('test_arglist.vim', bufname()) - b test_eval_stuff.vim - call assert_equal('test_eval_stuff.vim', bufname()) - close - call assert_equal('', v:errmsg) - " set maxmem& maxmemtot& -endfunc - -" Test for buffer allocation failure -func Test_buflist_alloc_failure() - CheckFunction test_alloc_fail - %bw! - - edit Xfile1 - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('edit Xfile2', 'E342:') - - " test for bufadd() - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('call bufadd("Xbuffer")', 'E342:') - - " test for setting the arglist - edit Xfile2 - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('next Xfile3', 'E342:') - - " test for setting the alternate buffer name when writing a file - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('write Xother', 'E342:') - call delete('Xother') - - " test for creating a buffer using bufnr() - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails("call bufnr('Xnewbuf', v:true)", 'E342:') - - " test for renaming buffer using :file - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('file Xnewfile', 'E342:') - - " test for creating a buffer for a popup window - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('call popup_create("mypop", {})', 'E342:') - - if has('terminal') - " test for creating a buffer for a terminal window - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('call term_start(&shell)', 'E342:') - %bw! - endif - - " test for loading a new buffer after wiping out all the buffers - edit Xfile4 - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('%bw!', 'E342:') - - " test for :checktime loading the buffer - call writefile(['one'], 'Xfile5') - if has('unix') - edit Xfile5 - " sleep for some time to make sure the timestamp is different - sleep 200m - call writefile(['two'], 'Xfile5') - set autoread - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('checktime', 'E342:') - set autoread& - bw! - endif - - " test for :vimgrep loading a dummy buffer - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('vimgrep two Xfile5', 'E342:') - call delete('Xfile5') - - " test for quickfix command loading a buffer - call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) - call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim deleted file mode 100644 index 0468025f55..0000000000 --- a/src/nvim/testdir/test_bufline.vim +++ /dev/null @@ -1,296 +0,0 @@ -" Tests for setbufline(), getbufline(), appendbufline(), deletebufline() - -source shared.vim -source screendump.vim -source check.vim - -func Test_setbufline_getbufline() - " similar to Test_set_get_bufline() - new - let b = bufnr('%') - hide - call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) - call assert_equal(['foo'], getbufline(b, 1)) - call assert_equal('foo', getbufoneline(b, 1)) - call assert_equal(['bar'], getbufline(b, '$')) - call assert_equal('bar', getbufoneline(b, '$')) - call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) - exe "bd!" b - call assert_equal([], getbufline(b, 1, 2)) - - split Xtest - call setline(1, ['a', 'b', 'c']) - let b = bufnr('%') - wincmd w - - call assert_equal(1, setbufline(b, 5, 'x')) - call assert_equal(1, setbufline(b, 5, ['x'])) - call assert_equal(1, setbufline(b, 5, [])) - call assert_equal(1, setbufline(b, 5, v:_null_list)) - - call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1)) - call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) - call assert_equal(1, []->setbufline(bufnr('$') + 1, 1)) - call assert_equal(1, v:_null_list->setbufline(bufnr('$') + 1, 1)) - - call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) - - call assert_equal(0, setbufline(b, 4, ['d', 'e'])) - call assert_equal(['c'], b->getbufline(3)) - call assert_equal('c', b->getbufoneline(3)) - call assert_equal(['d'], getbufline(b, 4)) - call assert_equal('d', getbufoneline(b, 4)) - call assert_equal(['e'], getbufline(b, 5)) - call assert_equal('e', getbufoneline(b, 5)) - call assert_equal([], getbufline(b, 6)) - call assert_equal([], getbufline(b, 2, 1)) - - if has('job') - call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()]) - call assert_equal(["function('eval')", - \ "{'key': 123}", - \ "no process"], - \ getbufline(b, 2, 4)) - endif - exe "bwipe! " . b -endfunc - -func Test_setbufline_getbufline_fold() - split Xtest - setlocal foldmethod=expr foldexpr=0 - let b = bufnr('%') - new - call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) - call assert_equal(['foo'], getbufline(b, 1)) - call assert_equal(['bar'], getbufline(b, 2)) - call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) - exe "bwipe!" b - bwipe! -endfunc - -func Test_setbufline_getbufline_fold_tab() - split Xtest - setlocal foldmethod=expr foldexpr=0 - let b = bufnr('%') - tab new - call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) - call assert_equal(['foo'], getbufline(b, 1)) - call assert_equal(['bar'], getbufline(b, 2)) - call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) - exe "bwipe!" b - bwipe! -endfunc - -func Test_setline_startup() - let cmd = GetVimCommand('Xscript') - if cmd == '' - return - endif - call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript') - call system(cmd) - call assert_equal(['Hello'], readfile('Xtest')) - - call delete('Xscript') - call delete('Xtest') -endfunc - -func Test_appendbufline() - new - let b = bufnr('%') - hide - - new - call setline(1, ['line1', 'line2', 'line3']) - normal! 2gggg - call assert_equal(2, line("''")) - - call assert_equal(0, appendbufline(b, 0, ['foo', 'bar'])) - call assert_equal(['foo'], getbufline(b, 1)) - call assert_equal(['bar'], getbufline(b, 2)) - call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) - call assert_equal(0, appendbufline(b, 0, 'baz')) - call assert_equal(['baz', 'foo', 'bar'], getbufline(b, 1, 3)) - - " appendbufline() in a hidden buffer shouldn't move marks in current window. - call assert_equal(2, line("''")) - bwipe! - - exe "bd!" b - call assert_equal([], getbufline(b, 1, 3)) - - split Xtest - call setline(1, ['a', 'b', 'c']) - let b = bufnr('%') - wincmd w - - call assert_equal(1, appendbufline(b, -1, 'x')) - call assert_equal(1, appendbufline(b, -1, ['x'])) - call assert_equal(1, appendbufline(b, -1, [])) - call assert_equal(1, appendbufline(b, -1, v:_null_list)) - - call assert_equal(1, appendbufline(b, 4, 'x')) - call assert_equal(1, appendbufline(b, 4, ['x'])) - call assert_equal(1, appendbufline(b, 4, [])) - call assert_equal(1, appendbufline(b, 4, v:_null_list)) - - call assert_equal(1, appendbufline(1234, 1, 'x')) - call assert_equal(1, appendbufline(1234, 1, ['x'])) - call assert_equal(1, appendbufline(1234, 1, [])) - call assert_equal(1, appendbufline(1234, 1, v:_null_list)) - - call assert_equal(0, appendbufline(b, 1, [])) - call assert_equal(0, appendbufline(b, 1, v:_null_list)) - call assert_equal(1, appendbufline(b, 3, [])) - call assert_equal(1, appendbufline(b, 3, v:_null_list)) - - call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) - - call assert_equal(0, appendbufline(b, 3, ['d', 'e'])) - call assert_equal(['c'], getbufline(b, 3)) - call assert_equal(['d'], getbufline(b, 4)) - call assert_equal(['e'], getbufline(b, 5)) - call assert_equal([], getbufline(b, 6)) - exe "bwipe! " . b -endfunc - -func Test_deletebufline() - new - let b = bufnr('%') - call setline(1, ['aaa', 'bbb', 'ccc']) - hide - - new - call setline(1, ['line1', 'line2', 'line3']) - normal! 2gggg - call assert_equal(2, line("''")) - - call assert_equal(0, deletebufline(b, 2)) - call assert_equal(['aaa', 'ccc'], getbufline(b, 1, 2)) - call assert_equal(0, deletebufline(b, 2, 8)) - call assert_equal(['aaa'], getbufline(b, 1, 2)) - - " deletebufline() in a hidden buffer shouldn't move marks in current window. - call assert_equal(2, line("''")) - bwipe! - - exe "bd!" b - call assert_equal(1, b->deletebufline(1)) - - call assert_equal(1, deletebufline(-1, 1)) - - split Xtest - call setline(1, ['a', 'b', 'c']) - call cursor(line('$'), 1) - let b = bufnr('%') - wincmd w - call assert_equal(1, deletebufline(b, 4)) - call assert_equal(0, deletebufline(b, 1)) - call assert_equal(['b', 'c'], getbufline(b, 1, 2)) - exe "bwipe! " . b - - edit XbufOne - let one = bufnr() - call setline(1, ['a', 'b', 'c']) - setlocal nomodifiable - split XbufTwo - let two = bufnr() - call assert_fails('call deletebufline(one, 1)', 'E21:') - call assert_equal(two, bufnr()) - bwipe! XbufTwo - bwipe! XbufOne -endfunc - -func Test_appendbufline_redraw() - CheckScreendump - - let lines =<< trim END - new foo - let winnr = 'foo'->bufwinnr() - let buf = bufnr('foo') - wincmd p - call appendbufline(buf, '$', range(1,200)) - exe winnr .. 'wincmd w' - norm! G - wincmd p - call deletebufline(buf, 1, '$') - call appendbufline(buf, '$', 'Hello Vim world...') - END - call writefile(lines, 'XscriptMatchCommon') - let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10}) - call term_wait(buf) - call VerifyScreenDump(buf, 'Test_appendbufline_1', {}) - - call StopVimInTerminal(buf) - call delete('XscriptMatchCommon') -endfunc - -func Test_setbufline_select_mode() - new - call setline(1, ['foo', 'bar']) - call feedkeys("j^v2l\", 'nx') - - let bufnr = bufadd('Xdummy') - call bufload(bufnr) - call setbufline(bufnr, 1, ['abc']) - - call feedkeys("x", 'nx') - call assert_equal(['foo', 'x'], getline(1, 2)) - - exe "bwipe! " .. bufnr - bwipe! -endfunc - -func Test_deletebufline_select_mode() - new - call setline(1, ['foo', 'bar']) - call feedkeys("j^v2l\", 'nx') - - let bufnr = bufadd('Xdummy') - call bufload(bufnr) - call setbufline(bufnr, 1, ['abc', 'def']) - call deletebufline(bufnr, 1) - - call feedkeys("x", 'nx') - call assert_equal(['foo', 'x'], getline(1, 2)) - - exe "bwipe! " .. bufnr - bwipe! -endfunc - -func Test_setbufline_startup_nofile() - let before =<< trim [CODE] - set shortmess+=F - file Xresult - set buftype=nofile - call setbufline('', 1, 'success') - [CODE] - let after =<< trim [CODE] - set buftype= - write - quit - [CODE] - - if !RunVim(before, after, '--clean') - return - endif - call assert_equal(['success'], readfile('Xresult')) - call delete('Xresult') -endfunc - -" Test that setbufline(), appendbufline() and deletebufline() should fail and -" return 1 when "textlock" is active. -func Test_change_bufline_with_textlock() - new - inoremap setbufline('', 1, '') - call assert_fails("normal a\", 'E565:') - call assert_equal('1', getline(1)) - inoremap appendbufline('', 1, '') - call assert_fails("normal a\", 'E565:') - call assert_equal('11', getline(1)) - inoremap deletebufline('', 1) - call assert_fails("normal a\", 'E565:') - call assert_equal('111', getline(1)) - bwipe! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim deleted file mode 100644 index 326aefb731..0000000000 --- a/src/nvim/testdir/test_bufwintabinfo.vim +++ /dev/null @@ -1,187 +0,0 @@ -" Tests for the getbufinfo(), getwininfo() and gettabinfo() functions - -function Test_getbufwintabinfo() - edit Xtestfile1 - edit Xtestfile2 - let buflist = getbufinfo() - call assert_equal(2, len(buflist)) - call assert_match('Xtestfile1', buflist[0].name) - call assert_match('Xtestfile2', getbufinfo('Xtestfile2')[0].name) - call assert_equal([], getbufinfo(2016)) - edit Xtestfile1 - hide edit Xtestfile2 - hide enew - call assert_equal(3, len(getbufinfo({'bufloaded':1}))) - - set tabstop&vim - let b:editor = 'vim' - let l = getbufinfo('%') - call assert_equal(bufnr('%'), l[0].bufnr) - call assert_equal('vim', l[0].variables.editor) - call assert_notequal(-1, index(l[0].windows, '%'->bufwinid())) - - let l = '%'->getbufinfo() - call assert_equal(bufnr('%'), l[0].bufnr) - - " Test for getbufinfo() with 'bufmodified' - call assert_equal(0, len(getbufinfo({'bufmodified' : 1}))) - call setbufline('Xtestfile1', 1, ["Line1"]) - let l = getbufinfo({'bufmodified' : 1}) - call assert_equal(1, len(l)) - call assert_equal(bufnr('Xtestfile1'), l[0].bufnr) - - if has('signs') - call append(0, ['Linux', 'Windows', 'Mac']) - sign define Mark text=>> texthl=Search - exe "sign place 2 line=3 name=Mark buffer=" . bufnr('%') - let l = getbufinfo('%') - call assert_equal(2, l[0].signs[0].id) - call assert_equal(3, l[0].signs[0].lnum) - call assert_equal('Mark', l[0].signs[0].name) - sign unplace * - sign undefine Mark - enew! - endif - - only - let w1_id = win_getid() - setl foldcolumn=3 - new - let w2_id = win_getid() - tabnew | let w3_id = win_getid() - new | let w4_id = win_getid() - vert new | let w5_id = win_getid() - eval 'green'->setwinvar(0, 'signal') - tabfirst - let winlist = getwininfo() - call assert_equal(5, len(winlist)) - call assert_equal(winwidth(1), winlist[0].width) - call assert_equal(1, winlist[0].wincol) - " tabline adds one row in terminal, not in GUI - let tablineheight = winlist[0].winrow == 2 ? 1 : 0 - call assert_equal(tablineheight + 1, winlist[0].winrow) - - call assert_equal(winbufnr(2), winlist[1].bufnr) - call assert_equal(winheight(2), winlist[1].height) - call assert_equal(1, winlist[1].wincol) - call assert_equal(3, winlist[1].textoff) " foldcolumn - call assert_equal(tablineheight + winheight(1) + 2, winlist[1].winrow) - - call assert_equal(1, winlist[2].winnr) - call assert_equal(tablineheight + 1, winlist[2].winrow) - call assert_equal(1, winlist[2].wincol) - - call assert_equal(winlist[2].width + 2, winlist[3].wincol) - call assert_equal(1, winlist[4].wincol) - - call assert_equal(1, winlist[0].tabnr) - call assert_equal(1, winlist[1].tabnr) - call assert_equal(2, winlist[2].tabnr) - call assert_equal(2, winlist[3].tabnr) - call assert_equal(2, winlist[4].tabnr) - - call assert_equal('green', winlist[2].variables.signal) - call assert_equal(w4_id, winlist[3].winid) - let winfo = w5_id->getwininfo()[0] - call assert_equal(2, winfo.tabnr) - call assert_equal([], getwininfo(3)) - - call settabvar(1, 'space', 'build') - let tablist = gettabinfo() - call assert_equal(2, len(tablist)) - call assert_equal(3, len(tablist[1].windows)) - call assert_equal(2, tablist[1].tabnr) - call assert_equal('build', tablist[0].variables.space) - call assert_equal(w2_id, tablist[0].windows[0]) - call assert_equal([], 3->gettabinfo()) - - tabonly | only - - lexpr '' - lopen - copen - let winlist = getwininfo() - call assert_false(winlist[0].quickfix) - call assert_false(winlist[0].loclist) - call assert_true(winlist[1].quickfix) - call assert_true(winlist[1].loclist) - call assert_true(winlist[2].quickfix) - call assert_false(winlist[2].loclist) - wincmd t | only -endfunction - -function Test_get_buf_options() - let opts = bufnr()->getbufvar('&') - call assert_equal(v:t_dict, type(opts)) - call assert_equal(8, opts.tabstop) -endfunc - -function Test_get_win_options() - if has('folding') - set foldlevel=999 - endif - set list - let opts = getwinvar(1, '&') - call assert_equal(v:t_dict, type(opts)) - call assert_equal(0, opts.linebreak) - call assert_equal(1, opts.list) - if has('folding') - call assert_equal(999, opts.foldlevel) - endif - if has('signs') - call assert_equal('auto', opts.signcolumn) - endif - - let opts = gettabwinvar(1, 1, '&') - call assert_equal(v:t_dict, type(opts)) - call assert_equal(0, opts.linebreak) - call assert_equal(1, opts.list) - if has('signs') - call assert_equal('auto', opts.signcolumn) - endif - set list& - if has('folding') - set foldlevel=0 - endif -endfunc - -function Test_getbufinfo_lastused() - new Xfoo - let info = getbufinfo('Xfoo')[0] - call assert_equal(has_key(info, 'lastused'), 1) - call assert_equal(type(info.lastused), type(0)) -endfunc - -func Test_getbufinfo_lines() - new Xfoo - call setline(1, ['a', 'bc', 'd']) - let bn = bufnr('%') - hide - call assert_equal(3, getbufinfo(bn)[0]["linecount"]) - edit Xfoo - bw! -endfunc - -func Test_getwininfo_au() - enew - call setline(1, range(1, 16)) - - let g:info = #{} - augroup T1 - au! - au WinEnter * let g:info = getwininfo(win_getid())[0] - augroup END - - 4split - " Check that calling getwininfo() from WinEnter returns fresh values for - " topline and botline. - call assert_equal(1, g:info.topline) - call assert_equal(4, g:info.botline) - close - - unlet g:info - augroup! T1 - bwipe! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_cd.vim b/src/nvim/testdir/test_cd.vim deleted file mode 100644 index 2b37f2c7c0..0000000000 --- a/src/nvim/testdir/test_cd.vim +++ /dev/null @@ -1,256 +0,0 @@ -" Test for :cd and chdir() - -source shared.vim -source check.vim - -func Test_cd_large_path() - " This used to crash with a heap write overflow. - call assert_fails('cd ' . repeat('x', 5000), 'E344:') -endfunc - -func Test_cd_up_and_down() - let path = getcwd() - cd .. - call assert_notequal(path, getcwd()) - exe 'cd ' .. fnameescape(path) - call assert_equal(path, getcwd()) -endfunc - -func Test_cd_no_arg() - if has('unix') - " Test that cd without argument goes to $HOME directory on Unix systems. - let path = getcwd() - cd - call assert_equal($HOME, getcwd()) - call assert_notequal(path, getcwd()) - exe 'cd ' .. fnameescape(path) - call assert_equal(path, getcwd()) - else - " Test that cd without argument echoes cwd on non-Unix systems. - call assert_match(getcwd(), execute('cd')) - endif -endfunc - -func Test_cd_minus() - " Test the :cd - goes back to the previous directory. - let path = getcwd() - cd .. - let path_dotdot = getcwd() - call assert_notequal(path, path_dotdot) - cd - - call assert_equal(path, getcwd()) - cd - - call assert_equal(path_dotdot, getcwd()) - cd - - call assert_equal(path, getcwd()) - - " Test for :cd - after a failed :cd - call assert_fails('cd /nonexistent', 'E344:') - call assert_equal(path, getcwd()) - cd - - call assert_equal(path_dotdot, getcwd()) - cd - - - " Test for :cd - without a previous directory - let lines =<< trim [SCRIPT] - call assert_fails('cd -', 'E186:') - call assert_fails('call chdir("-")', 'E186:') - call writefile(v:errors, 'Xresult') - qall! - [SCRIPT] - call writefile(lines, 'Xscript') - if RunVim([], [], '--clean -S Xscript') - call assert_equal([], readfile('Xresult')) - endif - call delete('Xscript') - call delete('Xresult') -endfunc - -" Test for chdir() -func Test_chdir_func() - let topdir = getcwd() - call mkdir('Xdir/y/z', 'p') - - " Create a few tabpages and windows with different directories - new - cd Xdir - tabnew - tcd y - below new - below new - lcd z - - tabfirst - call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd'))) - call chdir('..') - call assert_equal('y', fnamemodify(getcwd(1, 2), ':t')) - call assert_equal('z', fnamemodify(3->getcwd(2), ':t')) - tabnext | wincmd t - call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd'))) - eval '..'->chdir() - call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) - call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) - call assert_equal('z', fnamemodify(getcwd(3, 2), ':t')) - call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) - 3wincmd w - call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd'))) - call chdir('..') - call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) - call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) - call assert_equal('y', fnamemodify(getcwd(3, 2), ':t')) - call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) - - " Error case - call assert_fails("call chdir('dir-abcd')", 'E344:') - silent! let d = chdir("dir_abcd") - call assert_equal("", d) - " Should not crash - call chdir(d) - - only | tabonly - call chdir(topdir) - call delete('Xdir', 'rf') -endfunc - -" Test for changing to the previous directory '-' -func Test_prev_dir() - let topdir = getcwd() - call mkdir('Xdir/a/b/c', 'p') - - " Create a few tabpages and windows with different directories - new | only - tabnew | new - tabnew - tabfirst - cd Xdir - tabnext | wincmd t - tcd a - wincmd w - lcd b - tabnext - tcd a/b/c - - " Change to the previous directory twice in all the windows. - tabfirst - cd - | cd - - tabnext | wincmd t - tcd - | tcd - - wincmd w - lcd - | lcd - - tabnext - tcd - | tcd - - - " Check the directory of all the windows - tabfirst - call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) - tabnext | wincmd t - call assert_equal('a', fnamemodify(getcwd(), ':t')) - wincmd w - call assert_equal('b', fnamemodify(getcwd(), ':t')) - tabnext - call assert_equal('c', fnamemodify(getcwd(), ':t')) - - " Change to the previous directory using chdir() - tabfirst - call chdir("-") | call chdir("-") - tabnext | wincmd t - call chdir("-") | call chdir("-") - wincmd w - call chdir("-") | call chdir("-") - tabnext - call chdir("-") | call chdir("-") - - " Check the directory of all the windows - tabfirst - call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) - tabnext | wincmd t - call assert_equal('a', fnamemodify(getcwd(), ':t')) - wincmd w - call assert_equal('b', fnamemodify(getcwd(), ':t')) - tabnext - call assert_equal('c', fnamemodify(getcwd(), ':t')) - - only | tabonly - call chdir(topdir) - call delete('Xdir', 'rf') -endfunc - -func Test_lcd_split() - let curdir = getcwd() - lcd .. - split - lcd - - call assert_equal(curdir, getcwd()) - quit! -endfunc - -func Test_cd_from_non_existing_dir() - CheckNotMSWindows - - let saveddir = getcwd() - call mkdir('Xdeleted_dir') - cd Xdeleted_dir - call delete(saveddir .. '/Xdeleted_dir', 'd') - - " Expect E187 as the current directory was deleted. - call assert_fails('pwd', 'E187:') - call assert_equal('', getcwd()) - cd - - call assert_equal(saveddir, getcwd()) -endfunc - -func Test_cd_completion() - call mkdir('XComplDir1', 'p') - call mkdir('XComplDir2', 'p') - call writefile([], 'XComplFile') - - for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir'] - call feedkeys(':' .. cmd .. " XCompl\\\"\", 'tx') - call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:) - endfor - - call delete('XComplDir1', 'd') - call delete('XComplDir2', 'd') - call delete('XComplFile') -endfunc - -func Test_cd_unknown_dir() - call mkdir('Xa') - cd Xa - call writefile(['text'], 'Xb.txt') - edit Xa/Xb.txt - let first_buf = bufnr() - cd .. - edit - call assert_equal(first_buf, bufnr()) - edit Xa/Xb.txt - call assert_notequal(first_buf, bufnr()) - - bwipe! - exe "bwipe! " .. first_buf - call delete('Xa', 'rf') -endfunc - -func Test_getcwd_actual_dir() - CheckFunction test_autochdir - CheckOption autochdir - - let startdir = getcwd() - call mkdir('Xactual') - call test_autochdir() - set autochdir - edit Xactual/file.txt - call assert_match('testdir.Xactual$', getcwd()) - lcd .. - call assert_match('testdir$', getcwd()) - edit - call assert_match('testdir.Xactual$', getcwd()) - call assert_match('testdir$', getcwd(win_getid())) - - set noautochdir - bwipe! - call chdir(startdir) - call delete('Xactual', 'rf') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_cdo.vim b/src/nvim/testdir/test_cdo.vim deleted file mode 100644 index dbed7df4ac..0000000000 --- a/src/nvim/testdir/test_cdo.vim +++ /dev/null @@ -1,216 +0,0 @@ -" Tests for the :cdo, :cfdo, :ldo and :lfdo commands - -source check.vim -CheckFeature quickfix - -" Create the files used by the tests -func SetUp() - call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1') - call writefile(["Line1", "Line2", "Line3"], 'Xtestfile2') - call writefile(["Line1", "Line2", "Line3"], 'Xtestfile3') -endfunc - -" Remove the files used by the tests -func TearDown() - call delete('Xtestfile1') - call delete('Xtestfile2') - call delete('Xtestfile3') -endfunc - -" Returns the current line in ' L C' format -func GetRuler() - return expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' -endfunc - -" Tests for the :cdo and :ldo commands -func XdoTests(cchar) - enew - - " Shortcuts for calling the cdo and ldo commands - let Xdo = a:cchar . 'do' - let Xgetexpr = a:cchar . 'getexpr' - let Xprev = a:cchar. 'prev' - let XdoCmd = Xdo . ' call add(l, GetRuler())' - - " Try with an empty list - let l = [] - exe XdoCmd - call assert_equal([], l) - - " Populate the list and then try - exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:3:1:Line3']" - - let l = [] - exe XdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l) - - " Run command only on selected error lines - let l = [] - enew - exe "2,3" . XdoCmd - call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l) - - " Boundary condition tests - let l = [] - enew - exe "1,1" . XdoCmd - call assert_equal(['Xtestfile1 1L 3C'], l) - - let l = [] - enew - exe "3" . XdoCmd - call assert_equal(['Xtestfile3 3L 1C'], l) - - " Range test commands - let l = [] - enew - exe "%" . XdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l) - - let l = [] - enew - exe "1,$" . XdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l) - - let l = [] - enew - exe Xprev - exe "." . XdoCmd - call assert_equal(['Xtestfile2 2L 2C'], l) - - let l = [] - enew - exe "+" . XdoCmd - call assert_equal(['Xtestfile3 3L 1C'], l) - - " Invalid error lines test - let l = [] - enew - exe "silent! 27" . XdoCmd - exe "silent! 4,5" . XdoCmd - call assert_equal([], l) - - " Run commands from an unsaved buffer - let v:errmsg='' - let l = [] - enew - setlocal modified - exe "silent! 2,2" . XdoCmd - if v:errmsg !~# 'No write since last change' - call add(v:errors, 'Unsaved file change test failed') - endif - - " If the executed command fails, then the operation should be aborted - enew! - let subst_count = 0 - exe "silent!" . Xdo . " s/Line/xLine/ | let subst_count += 1" - if subst_count != 1 || getline('.') != 'xLine1' - call add(v:errors, 'Abort command on error test failed') - endif - - let l = [] - exe "2,2" . Xdo . "! call add(l, GetRuler())" - call assert_equal(['Xtestfile2 2L 2C'], l) - - " List with no valid error entries - let l = [] - edit! +2 Xtestfile1 - exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']" - exe XdoCmd - call assert_equal([], l) - exe "silent! 2" . XdoCmd - call assert_equal([], l) - let v:errmsg='' - exe "%" . XdoCmd - exe "1,$" . XdoCmd - exe "." . XdoCmd - call assert_equal('', v:errmsg) - - " List with only one valid entry - let l = [] - exe Xgetexpr . " ['Xtestfile3:3:1:Line3']" - exe XdoCmd - call assert_equal(['Xtestfile3 3L 1C'], l) - -endfunc - -" Tests for the :cfdo and :lfdo commands -func XfdoTests(cchar) - enew - - " Shortcuts for calling the cfdo and lfdo commands - let Xfdo = a:cchar . 'fdo' - let Xgetexpr = a:cchar . 'getexpr' - let XfdoCmd = Xfdo . ' call add(l, GetRuler())' - let Xpfile = a:cchar. 'pfile' - - " Clear the quickfix/location list - exe Xgetexpr . " []" - - " Try with an empty list - let l = [] - exe XfdoCmd - call assert_equal([], l) - - " Populate the list and then try - exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 'Xtestfile1:2:1:Line2', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:2:3:Line2', 'Xtestfile3:3:1:Line3']" - - let l = [] - exe XfdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l) - - " Run command only on selected error lines - let l = [] - exe "2,3" . XfdoCmd - call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l) - - " Boundary condition tests - let l = [] - exe "3" . XfdoCmd - call assert_equal(['Xtestfile3 2L 3C'], l) - - " Range test commands - let l = [] - exe "%" . XfdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l) - - let l = [] - exe "1,$" . XfdoCmd - call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l) - - let l = [] - exe Xpfile - exe "." . XfdoCmd - call assert_equal(['Xtestfile2 2L 2C'], l) - - " List with only one valid entry - let l = [] - exe Xgetexpr . " ['Xtestfile2:2:5:Line2']" - exe XfdoCmd - call assert_equal(['Xtestfile2 2L 5C'], l) - -endfunc - -" Tests for cdo and cfdo -func Test_cdo() - call XdoTests('c') - call XfdoTests('c') -endfunc - -" Tests for ldo and lfdo -func Test_ldo() - call XdoTests('l') - call XfdoTests('l') -endfunc - -" Test for making 'shm' doesn't interfere with the output. -func Test_cdo_print() - enew | only! - cgetexpr ["Xtestfile1:1:Line1", "Xtestfile2:1:Line1", "Xtestfile3:1:Line1"] - cdo print - call assert_equal('Line1', Screenline(&lines)) - call assert_equal('Line1', Screenline(&lines - 3)) - call assert_equal('Line1', Screenline(&lines - 6)) -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_changedtick.vim b/src/nvim/testdir/test_changedtick.vim deleted file mode 100644 index c789cdc1bc..0000000000 --- a/src/nvim/testdir/test_changedtick.vim +++ /dev/null @@ -1,95 +0,0 @@ -" Tests for b:changedtick - -func Test_changedtick_increments() - new - " New buffer has an empty line, tick starts at 2. - let expected = 2 - call assert_equal(expected, b:changedtick) - call assert_equal(expected, b:['changedtick']) - call setline(1, 'hello') - let expected += 1 - call assert_equal(expected, b:changedtick) - call assert_equal(expected, b:['changedtick']) - undo - " Somehow undo counts as two changes. - let expected += 2 - call assert_equal(expected, b:changedtick) - call assert_equal(expected, b:['changedtick']) - bwipe! -endfunc - -func Test_changedtick_dict_entry() - let d = b: - call assert_equal(b:changedtick, d['changedtick']) -endfunc - -func Test_changedtick_bdel() - new - let bnr = bufnr('%') - let v = b:changedtick - bdel - " Delete counts as a change too. - call assert_equal(v + 1, getbufvar(bnr, 'changedtick')) -endfunc - -func Test_changedtick_islocked() - call assert_equal(0, islocked('b:changedtick')) - let d = b: - call assert_equal(0, islocked('d.changedtick')) -endfunc - -func Test_changedtick_fixed() - call assert_fails('let b:changedtick = 4', 'E46:') - call assert_fails('let b:["changedtick"] = 4', 'E46:') - - call assert_fails('lockvar b:changedtick', 'E940:') - call assert_fails('lockvar b:["changedtick"]', 'E46:') - call assert_fails('unlockvar b:changedtick', 'E940:') - call assert_fails('unlockvar b:["changedtick"]', 'E46:') - call assert_fails('unlet b:changedtick', 'E795:') - call assert_fails('unlet b:["changedtick"]', 'E46:') - - let d = b: - call assert_fails('lockvar d["changedtick"]', 'E46:') - call assert_fails('unlockvar d["changedtick"]', 'E46:') - call assert_fails('unlet d["changedtick"]', 'E46:') - -endfunc - -func Test_changedtick_not_incremented_with_write() - new - let fname = "XChangeTick" - exe 'w ' .. fname - - " :write when the buffer is not changed does not increment changedtick - let expected = b:changedtick - w - call assert_equal(expected, b:changedtick) - - " :write when the buffer IS changed DOES increment changedtick - let expected = b:changedtick + 1 - setlocal modified - w - call assert_equal(expected, b:changedtick) - - " Two ticks: change + write - let expected = b:changedtick + 2 - call setline(1, 'hello') - w - call assert_equal(expected, b:changedtick) - - " Two ticks: start insert + write - let expected = b:changedtick + 2 - normal! o - w - call assert_equal(expected, b:changedtick) - - " Three ticks: start insert + change + write - let expected = b:changedtick + 3 - normal! ochanged - w - call assert_equal(expected, b:changedtick) - - bwipe - call delete(fname) -endfunc diff --git a/src/nvim/testdir/test_changelist.vim b/src/nvim/testdir/test_changelist.vim deleted file mode 100644 index 3bb22a89b8..0000000000 --- a/src/nvim/testdir/test_changelist.vim +++ /dev/null @@ -1,107 +0,0 @@ -" Tests for the changelist functionality - -" When splitting a window the changelist position is wrong. -" Test the changelist position after splitting a window. -" Test for the bug fixed by 7.4.386 -func Test_changelist() - let save_ul = &ul - enew! - call append('$', ['1', '2']) - exe "normal i\u" - exe "normal Gkylpa\u" - set ul=100 - exe "normal Gylpa\u" - set ul=100 - normal gg - vsplit - normal g; - call assert_equal([3, 2], [line('.'), col('.')]) - normal g; - call assert_equal([2, 2], [line('.'), col('.')]) - call assert_fails('normal g;', 'E662:') - new - call assert_fails('normal g;', 'E664:') - %bwipe! - let &ul = save_ul -endfunc - -" Moving a split should not change its changelist index. -func Test_changelist_index_move_split() - exe "norm! iabc\u\ndef\u\nghi" - vsplit - normal 99g; - call assert_equal(0, getchangelist('%')[1]) - wincmd L - call assert_equal(0, getchangelist('%')[1]) -endfunc - -" Tests for the getchangelist() function -func Test_changelist_index() - edit Xfile1.txt - exe "normal iabc\u\ndef\u\nghi" - call assert_equal(3, getchangelist('%')[1]) - " Move one step back in the changelist. - normal 2g; - - hide edit Xfile2.txt - exe "normal iabcd\u\ndefg\u\nghij" - call assert_equal(3, getchangelist('%')[1]) - " Move to the beginning of the changelist. - normal 99g; - - " Check the changelist indices. - call assert_equal(0, getchangelist('%')[1]) - call assert_equal(1, getchangelist('#')[1]) - - bwipe! - call delete('Xfile1.txt') - call delete('Xfile2.txt') -endfunc - -func Test_getchangelist() - bwipe! - enew - call assert_equal([], 10->getchangelist()) - call assert_equal([[], 0], getchangelist()) - - call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt') - call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt') - - edit Xfile1.txt - let buf_1 = bufnr() - exe "normal 1Goline\u1.1" - exe "normal 3Goline\u2.1" - exe "normal 5Goline\u3.1" - normal g; - call assert_equal([[ - \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, - \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, - \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2], - \ getchangelist('%')) - - hide edit Xfile2.txt - let buf_2 = bufnr() - exe "normal 1GOline\u1.0" - exe "normal 2Goline\u2.0" - call assert_equal([[ - \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, - \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], - \ getchangelist('%')) - hide enew - - call assert_equal([[ - \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, - \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, - \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2], - \ getchangelist(buf_1)) - call assert_equal([[ - \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, - \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], - \ getchangelist(buf_2)) - - bwipe! - call delete('Xfile1.txt') - call delete('Xfile2.txt') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_charsearch.vim b/src/nvim/testdir/test_charsearch.vim deleted file mode 100644 index f8f3e958ca..0000000000 --- a/src/nvim/testdir/test_charsearch.vim +++ /dev/null @@ -1,99 +0,0 @@ -" Test for character search commands - t, T, f, F, ; and , - -func Test_charsearch() - enew! - call append(0, ['Xabcdefghijkemnopqretuvwxyz', - \ 'Yabcdefghijkemnopqretuvwxyz', - \ 'Zabcdefghijkemnokqretkvwxyz']) - " check that "fe" and ";" work - 1 - normal! ylfep;;p,,p - call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1)) - " check that save/restore works - 2 - normal! ylfep - let csave = getcharsearch() - normal! fip - call setcharsearch(csave) - normal! ;p;p - call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2)) - - " check that setcharsearch() changes the settings. - 3 - normal! ylfep - eval {'char': 'k'}->setcharsearch() - normal! ;p - call setcharsearch({'forward': 0}) - normal! $;p - call setcharsearch({'until': 1}) - set cpo-=; - normal! ;;p - call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) - - " check that repeating a search before and after a line fails - normal 3Gfv - call assert_beeps('normal ;') - call assert_beeps('normal ,') - - " clear the character search - call setcharsearch({'char' : ''}) - call assert_equal('', getcharsearch().char) - - call assert_fails("call setcharsearch([])", 'E715:') - enew! -endfunc - -" Test for character search in virtual edit mode with -func Test_csearch_virtualedit() - new - set virtualedit=all - call setline(1, "a\tb") - normal! tb - call assert_equal([0, 1, 2, 6], getpos('.')) - set virtualedit& - bw! -endfunc - -" Test for character search failure in latin1 encoding -func Test_charsearch_latin1() - new - let save_enc = &encoding - " set encoding=latin1 - call setline(1, 'abcdefghijk') - call assert_beeps('normal fz') - call assert_beeps('normal tx') - call assert_beeps('normal $Fz') - call assert_beeps('normal $Tx') - let &encoding = save_enc - bw! -endfunc - -" Test for using character search to find a multibyte character with composing -" characters. -func Test_charsearch_composing_char() - new - call setline(1, "one two thq\u0328\u0301r\u0328\u0301ree") - call feedkeys("fr\u0328\u0301", 'xt') - call assert_equal([0, 1, 16, 0, 12], getcurpos()) - - " use character search with a multi-byte character followed by a - " non-composing character - call setline(1, "abc deȉf ghi") - call feedkeys("ggcf\u0209\u0210", 'xt') - call assert_equal("\u0210f ghi", getline(1)) - bw! -endfunc - -" Test for character search with 'hkmap' -func Test_charsearch_hkmap() - throw "Skipped: Nvim does not support 'hkmap'" - new - set hkmap - call setline(1, "ùðáâ÷ëòéïçìêöî") - call feedkeys("fë", 'xt') - call assert_equal([0, 1, 11, 0, 6], getcurpos()) - set hkmap& - bw! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_charsearch_utf8.vim b/src/nvim/testdir/test_charsearch_utf8.vim deleted file mode 100644 index 82a807ac5b..0000000000 --- a/src/nvim/testdir/test_charsearch_utf8.vim +++ /dev/null @@ -1,19 +0,0 @@ -" Tests for related f{char} and t{char} using utf-8. - -" Test for t,f,F,T movement commands -func Test_search_cmds() - new! - call setline(1, "・最初から最後まで最強のVimは最高") - 1 - normal! f最 - call assert_equal([0, 1, 4, 0], getpos('.')) - normal! ; - call assert_equal([0, 1, 16, 0], getpos('.')) - normal! 2; - call assert_equal([0, 1, 43, 0], getpos('.')) - normal! , - call assert_equal([0, 1, 28, 0], getpos('.')) - bw! -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_checkpath.vim b/src/nvim/testdir/test_checkpath.vim deleted file mode 100644 index f6a3bbce08..0000000000 --- a/src/nvim/testdir/test_checkpath.vim +++ /dev/null @@ -1,121 +0,0 @@ -" Tests for the :checkpath command - -" Test for 'include' without \zs or \ze -func Test_checkpath1() - call mkdir("Xdir1/dir2", "p") - call writefile(['#include "bar.a"'], 'Xdir1/dir2/foo.a') - call writefile(['#include "baz.a"'], 'Xdir1/dir2/bar.a') - call writefile(['#include "foo.a"'], 'Xdir1/dir2/baz.a') - call writefile(['#include '], 'Xbase.a') - - edit Xbase.a - set path=Xdir1/dir2 - let res = split(execute("checkpath!"), "\n") - call assert_equal([ - \ '--- Included files in path ---', - \ 'Xdir1/dir2/foo.a', - \ 'Xdir1/dir2/foo.a -->', - \ ' Xdir1/dir2/bar.a', - \ ' Xdir1/dir2/bar.a -->', - \ ' Xdir1/dir2/baz.a', - \ ' Xdir1/dir2/baz.a -->', - \ ' "foo.a" (Already listed)'], res) - - enew - call delete("./Xbase.a") - call delete("Xdir1", "rf") - set path& -endfunc - -func DotsToSlashes() - return substitute(v:fname, '\.', '/', 'g') . '.b' -endfunc - -" Test for 'include' with \zs and \ze -func Test_checkpath2() - call mkdir("Xdir1/dir2", "p") - call writefile(['%inc /bar/'], 'Xdir1/dir2/foo.b') - call writefile(['%inc /baz/'], 'Xdir1/dir2/bar.b') - call writefile(['%inc /foo/'], 'Xdir1/dir2/baz.b') - call writefile(['%inc /foo/'], 'Xbase.b') - - let &include='^\s*%inc\s*/\zs[^/]\+\ze' - let &includeexpr='DotsToSlashes()' - - edit Xbase.b - set path=Xdir1/dir2 - let res = split(execute("checkpath!"), "\n") - call assert_equal([ - \ '--- Included files in path ---', - \ 'Xdir1/dir2/foo.b', - \ 'Xdir1/dir2/foo.b -->', - \ ' Xdir1/dir2/bar.b', - \ ' Xdir1/dir2/bar.b -->', - \ ' Xdir1/dir2/baz.b', - \ ' Xdir1/dir2/baz.b -->', - \ ' foo (Already listed)'], res) - - enew - call delete("./Xbase.b") - call delete("Xdir1", "rf") - set path& - set include& - set includeexpr& -endfunc - -func StripNewlineChar() - if v:fname =~ '\n$' - return v:fname[:-2] - endif - return v:fname -endfunc - -" Test for 'include' with \zs and no \ze -func Test_checkpath3() - call mkdir("Xdir1/dir2", "p") - call writefile(['%inc bar.c'], 'Xdir1/dir2/foo.c') - call writefile(['%inc baz.c'], 'Xdir1/dir2/bar.c') - call writefile(['%inc foo.c'], 'Xdir1/dir2/baz.c') - call writefile(['%inc foo.c'], 'Xdir1/dir2/FALSE.c') - call writefile(['%inc FALSE.c foo.c'], 'Xbase.c') - - let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze' - let &includeexpr='StripNewlineChar()' - - edit Xbase.c - set path=Xdir1/dir2 - let res = split(execute("checkpath!"), "\n") - call assert_equal([ - \ '--- Included files in path ---', - \ 'Xdir1/dir2/foo.c', - \ 'Xdir1/dir2/foo.c -->', - \ ' Xdir1/dir2/bar.c', - \ ' Xdir1/dir2/bar.c -->', - \ ' Xdir1/dir2/baz.c', - \ ' Xdir1/dir2/baz.c -->', - \ ' foo.c (Already listed)'], res) - - enew - call delete("./Xbase.c") - call delete("Xdir1", "rf") - set path& - set include& - set includeexpr& -endfunc - -" Test for invalid regex in 'include' and 'define' options -func Test_checkpath_errors() - let save_include = &include - set include=\\%( - call assert_fails('checkpath', 'E53:') - let &include = save_include - - let save_define = &define - set define=\\%( - call assert_fails('dsearch abc', 'E53:') - let &define = save_define - - call assert_fails('psearch \%(', 'E53:') -endfunc - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim deleted file mode 100644 index ccc8168c09..0000000000 --- a/src/nvim/testdir/test_cindent.vim +++ /dev/null @@ -1,5428 +0,0 @@ -" Test for cinoptions and cindent -" - -func Test_cino_hash() - " Test that curbuf->b_ind_hash_comment is correctly reset - new - setlocal cindent cinoptions=#1 - setlocal cinoptions= - call setline(1, ["#include "]) - call cursor(1, 1) - norm! o#include - "call feedkeys("o#include\", 't') - call assert_equal(["#include ", "#include"], getline(1,2)) - bwipe! -endfunc - -func Test_cino_extern_c() - " Test for cino-E - - let without_ind =<< trim [CODE] - #ifdef __cplusplus - extern "C" { - #endif - int func_a(void); - #ifdef __cplusplus - } - #endif - [CODE] - - let with_ind =<< trim [CODE] - #ifdef __cplusplus - extern "C" { - #endif - int func_a(void); - #ifdef __cplusplus - } - #endif - [CODE] - new - setlocal cindent cinoptions=E0 - call setline(1, without_ind) - call feedkeys("gg=G", 'tx') - call assert_equal(with_ind, getline(1, '$')) - - setlocal cinoptions=E-s - call setline(1, with_ind) - call feedkeys("gg=G", 'tx') - call assert_equal(without_ind, getline(1, '$')) - - setlocal cinoptions=Es - let tests = [ - \ ['recognized', ['extern "C" {'], "\t\t;"], - \ ['recognized', ['extern "C++" {'], "\t\t;"], - \ ['recognized', ['extern /* com */ "C"{'], "\t\t;"], - \ ['recognized', ['extern"C"{'], "\t\t;"], - \ ['recognized', ['extern "C"', '{'], "\t\t;"], - \ ['not recognized', ['extern {'], "\t;"], - \ ['not recognized', ['extern /*"C"*/{'], "\t;"], - \ ['not recognized', ['extern "C" //{'], ";"], - \ ['not recognized', ['extern "C" /*{*/'], ";"], - \ ] - - for pair in tests - let lines = pair[1] - call setline(1, lines) - call feedkeys(len(lines) . "Go;", 'tx') - call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"') - endfor - - bwipe! -endfunc - -func Test_cindent_rawstring() - new - setl cindent - call feedkeys("i" . - \ "int main() {\" . - \ "R\"(\" . - \ ")\";\" . - \ "statement;\", "x") - call assert_equal("\tstatement;", getline(line('.'))) - bw! -endfunc - -func Test_cindent_expr() - new - func! MyIndentFunction() - return v:lnum == 1 ? shiftwidth() : 0 - endfunc - setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction() - let testinput =<< trim [CODE] - var_a = something() - b = something() - [CODE] - call setline(1, testinput) - call cursor(1, 1) - call feedkeys("^\j$A;\", 'tnix') - let expected =<< [CODE] - var_a = something(); -b = something(); -[CODE] - call assert_equal(expected, getline(1, '$')) - - %d - let testinput =<< [CODE] - var_a = something() - b = something() -[CODE] - call setline(1, testinput) - call cursor(1, 1) - call feedkeys("^\j$A;\", 'tnix') - let expected =<< [CODE] - var_a = something(); - b = something() -[CODE] - call assert_equal(expected, getline(1, '$')) - bw! -endfunc - -func Test_cindent_func() - new - setlocal cindent - call setline(1, ['int main(void)', '{', 'return 0;', '}']) - call assert_equal(-1, cindent(0)) - call assert_equal(&sw, 3->cindent()) - call assert_equal(-1, cindent(line('$')+1)) - bwipe! -endfunc - -func Test_cindent_1() - new - setl cindent ts=4 sw=4 - setl cino& sts& - - let code =<< trim [CODE] - /* start of AUTO matically checked vim: set ts=4 : */ - { - if (test) - cmd1; - cmd2; - } - - { - if (test) - cmd1; - else - cmd2; - } - - { - if (test) - { - cmd1; - cmd2; - } - } - - { - if (test) - { - cmd1; - else - } - } - - { - while (this) - if (test) - cmd1; - cmd2; - } - - { - while (this) - if (test) - cmd1; - else - cmd2; - } - - { - if (test) - { - cmd; - } - - if (test) - cmd; - } - - { - if (test) { - cmd; - } - - if (test) cmd; - } - - { - cmd1; - for (blah) - while (this) - if (test) - cmd2; - cmd3; - } - - { - cmd1; - for (blah) - while (this) - if (test) - cmd2; - cmd3; - - if (test) - { - cmd1; - cmd2; - cmd3; - } - } - - - /* Test for 'cindent' do/while mixed with if/else: */ - - { - do - if (asdf) - asdfasd; - while (cond); - - do - if (asdf) - while (asdf) - asdf; - while (asdf); - } - - /* Test for 'cindent' with two ) on a continuation line */ - { - if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d - aal;sdkjf ( ;asldfkja;sldfk - al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) - line up here; - } - - - /* C++ tests: */ - - // foo() these three lines should remain in column 0 - // { - // } - - /* Test for continuation and unterminated lines: */ - { - i = 99 + 14325 + - 21345 + - 21345 + - 21345 + ( 21345 + - 21345) + - 2345 + - 1234; - c = 1; - } - - /* - testje for indent with empty line - - here */ - - { - if (testing && - not a joke || - line up here) - hay; - if (testing && - (not a joke || testing - )line up here) - hay; - if (testing && - (not a joke || testing - line up here)) - hay; - } - - - { - switch (c) - { - case xx: - do - if (asdf) - do - asdfasdf; - while (asdf); - else - asdfasdf; - while (cond); - case yy: - case xx: - case zz: - testing; - } - } - - { - if (cond) { - foo; - } - else - { - bar; - } - } - - { - if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf - alsdkfj (asldk;fj - awith cino=(0 ;lf this one goes to below the paren with == - ;laksjfd ;lsakdjf ;alskdf asd) - asdfasdf;))) - asdfasdf; - } - - int - func(a, b) - int a; - int c; - { - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3) - ) - } - - { - while (asd) - { - if (asdf) - if (test) - if (that) - { - if (asdf) - do - cdasd; - while (as - df); - } - else - if (asdf) - asdf; - else - asdf; - asdf; - } - } - - { - s = "/*"; b = ';' - s = "/*"; b = ';'; - a = b; - } - - { - switch (a) - { - case a: - switch (t) - { - case 1: - cmd; - break; - case 2: - cmd; - break; - } - cmd; - break; - case b: - { - int i; - cmd; - } - break; - case c: { - int i; - cmd; - } - case d: if (cond && - test) { /* this line doesn't work right */ - int i; - cmd; - } - break; - } - } - - { - if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && - (bp_to->b_p_initialized || - (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) - return; - label : - asdf = asdf ? - asdf : asdf; - asdf = asdf ? - asdf: asdf; - } - - /* Special Comments : This function has the added complexity (compared */ - /* : to addtolist) of having to check for a detail */ - /* : texture and add that to the list first. */ - - char *(array[100]) = { - "testje", - "foo", - "bar", - } - - enum soppie - { - yes = 0, - no, - maybe - }; - - typedef enum soppie - { - yes = 0, - no, - maybe - }; - - static enum - { - yes = 0, - no, - maybe - } soppie; - - public static enum - { - yes = 0, - no, - maybe - } soppie; - - static private enum - { - yes = 0, - no, - maybe - } soppie; - - { - int a, - b; - } - - { - struct Type - { - int i; - char *str; - } var[] = - { - 0, "zero", - 1, "one", - 2, "two", - 3, "three" - }; - - float matrix[3][3] = - { - { - 0, - 1, - 2 - }, - { - 3, - 4, - 5 - }, - { - 6, - 7, - 8 - } - }; - } - - { - /* blah ( blah */ - /* where does this go? */ - - /* blah ( blah */ - cmd; - - func(arg1, - /* comment */ - arg2); - a; - { - b; - { - c; /* Hey, NOW it indents?! */ - } - } - - { - func(arg1, - arg2, - arg3); - /* Hey, what am I doing here? Is this coz of the ","? */ - } - } - - main () - { - if (cond) - { - a = b; - } - if (cond) { - a = c; - } - if (cond) - a = d; - return; - } - - { - case 2: if (asdf && - asdfasdf) - aasdf; - a = 9; - case 3: if (asdf) - aasdf; - a = 9; - case 4: x = 1; - y = 2; - - label: if (asdf) - here; - - label: if (asdf && - asdfasdf) - { - } - - label: if (asdf && - asdfasdf) { - there; - } - - label: if (asdf && - asdfasdf) - there; - } - - { - /* - hello with ":set comments= cino=c5" - */ - - /* - hello with ":set comments= cino=" - */ - } - - - { - if (a < b) { - a = a + 1; - } else - a = a + 2; - - if (a) - do { - testing; - } while (asdfasdf); - a = b + 1; - asdfasdf - } - - { - for ( int i = 0; - i < 10; i++ ) - { - } - i = 0; - } - - class bob - { - int foo() {return 1;} - int bar; - } - - main() - { - while(1) - if (foo) - { - bar; - } - else { - asdf; - } - misplacedline; - } - - { - if (clipboard.state == SELECT_DONE - && ((row == clipboard.start.lnum - && col >= clipboard.start.col) - || row > clipboard.start.lnum)) - } - - { - if (1) {i += 4;} - where_am_i; - return 0; - } - - { - { - } // sdf(asdf - if (asdf) - asd; - } - - { - label1: - label2: - } - - { - int fooRet = foo(pBar1, false /*fKB*/, - true /*fPTB*/, 3 /*nT*/, false /*fDF*/); - f() { - for ( i = 0; - i < m; - /* c */ i++ ) { - a = b; - } - } - } - - { - f1(/*comment*/); - f2(); - } - - { - do { - if (foo) { - } else - ; - } while (foo); - foo(); // was wrong - } - - int x; // no extra indent because of the ; - void func() - { - } - - char *tab[] = {"aaa", - "};", /* }; */ NULL} - int indented; - {} - - char *a[] = {"aaa", "bbb", - "ccc", NULL}; - // here - - char *tab[] = {"aaa", - "xx", /* xx */}; /* asdf */ - int not_indented; - - { - do { - switch (bla) - { - case 1: if (foo) - bar; - } - } while (boo); - wrong; - } - - int foo, - bar; - int foo; - - #if defined(foo) \ - && defined(bar) - char * xx = "asdf\ - foo\ - bor"; - int x; - - char *foo = "asdf\ - asdf\ - asdf", - *bar; - - void f() - { - #if defined(foo) \ - && defined(bar) - char *foo = "asdf\ - asdf\ - asdf", - *bar; - { - int i; - char *foo = "asdf\ - asdf\ - asdf", - *bar; - } - #endif - } - #endif - - int y; // comment - // comment - - // comment - - { - Constructor(int a, - int b ) : BaseClass(a) - { - } - } - - void foo() - { - char one, - two; - struct bla piet, - jan; - enum foo kees, - jannie; - static unsigned sdf, - krap; - unsigned int piet, - jan; - int - kees, - jan; - } - - { - t(int f, - int d); // ) - d(); - } - - Constructor::Constructor(int a, - int b - ) : - BaseClass(a, - b, - c), - mMember(b), - { - } - - Constructor::Constructor(int a, - int b ) : - BaseClass(a) - { - } - - Constructor::Constructor(int a, - int b ) /*x*/ : /*x*/ BaseClass(a), - member(b) - { - } - - A::A(int a, int b) - : aa(a), - bb(b), - cc(c) - { - } - - class CAbc : - public BaseClass1, - protected BaseClass2 - { - int Test() { return FALSE; } - int Test1() { return TRUE; } - - CAbc(int a, int b ) : - BaseClass(a) - { - switch(xxx) - { - case abc: - asdf(); - break; - - case 999: - baer(); - break; - } - } - - public: // <-- this was incorrectly indented before!! - void testfall(); - protected: - void testfall(); - }; - - class CAbc : public BaseClass1, - protected BaseClass2 - { - }; - - static struct - { - int a; - int b; - } variable[COUNT] = - { - { - 123, - 456 - }, - { - 123, - 456 - } - }; - - static struct - { - int a; - int b; - } variable[COUNT] = - { - { 123, 456 }, - { 123, 456 } - }; - - void asdf() /* ind_maxparen may cause trouble here */ - { - if ((0 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1)) break; - } - - foo() - { - a = cond ? foo() : asdf - + asdf; - - a = cond ? - foo() : asdf - + asdf; - } - - int main(void) - { - if (a) - if (b) - 2; - else 3; - next_line_of_code(); - } - - barry() - { - Foo::Foo (int one, - int two) - : something(4) - {} - } - - barry() - { - Foo::Foo (int one, int two) - : something(4) - {} - } - - Constructor::Constructor(int a, - int b - ) : - BaseClass(a, - b, - c), - mMember(b) - { - } - int main () - { - if (lala) - do - ++(*lolo); - while (lili - && lele); - lulu; - } - - int main () - { - switch (c) - { - case 'c': if (cond) - { - } - } - } - - main() - { - (void) MyFancyFuasdfadsfnction( - argument); - } - - main() - { - char foo[] = "/*"; - /* as - df */ - hello - } - - /* valid namespaces with normal indent */ - namespace - { - { - 111111111111; - } - } - namespace /* test */ - { - 11111111111111111; - } - namespace // test - { - 111111111111111111; - } - namespace - { - 111111111111111111; - } - namespace test - { - 111111111111111111; - } - namespace{ - 111111111111111111; - } - namespace test{ - 111111111111111111; - } - namespace { - 111111111111111111; - } - namespace test { - 111111111111111111; - namespace test2 { - 22222222222222222; - } - } - inline namespace { - 111111111111111111; - } - inline /* test */ namespace { - 111111111111111111; - } - inline/* test */namespace { - 111111111111111111; - } - - /* invalid namespaces use block indent */ - namespace test test2 { - 111111111111111111111; - } - namespace11111111111 { - 111111111111; - } - namespace() { - 1111111111111; - } - namespace() - { - 111111111111111111; - } - namespace test test2 - { - 1111111111111111111; - } - namespace111111111 - { - 111111111111111111; - } - inlinenamespace { - 111111111111111111; - } - - void getstring() { - /* Raw strings */ - const char* s = R"( - test { - # comment - field: 123 - } - )"; - } - - void getstring() { - const char* s = R"foo( - test { - # comment - field: 123 - } - )foo"; - } - - { - int a[4] = { - [0] = 0, - [1] = 1, - [2] = 2, - [3] = 3, - }; - } - - { - a = b[2] - + 3; - } - - { - if (1) - /* aaaaa - * bbbbb - */ - a = 1; - } - - void func() - { - switch (foo) - { - case (bar): - if (baz()) - quux(); - break; - case (shmoo): - if (!bar) - { - } - case (foo1): - switch (bar) - { - case baz: - baz_f(); - break; - } - break; - default: - baz(); - baz(); - break; - } - } - - /* end of AUTO */ - [CODE] - - call append(0, code) - normal gg - call search('start of AUTO') - exe "normal =/end of AUTO\" - - let expected =<< trim [CODE] - /* start of AUTO matically checked vim: set ts=4 : */ - { - if (test) - cmd1; - cmd2; - } - - { - if (test) - cmd1; - else - cmd2; - } - - { - if (test) - { - cmd1; - cmd2; - } - } - - { - if (test) - { - cmd1; - else - } - } - - { - while (this) - if (test) - cmd1; - cmd2; - } - - { - while (this) - if (test) - cmd1; - else - cmd2; - } - - { - if (test) - { - cmd; - } - - if (test) - cmd; - } - - { - if (test) { - cmd; - } - - if (test) cmd; - } - - { - cmd1; - for (blah) - while (this) - if (test) - cmd2; - cmd3; - } - - { - cmd1; - for (blah) - while (this) - if (test) - cmd2; - cmd3; - - if (test) - { - cmd1; - cmd2; - cmd3; - } - } - - - /* Test for 'cindent' do/while mixed with if/else: */ - - { - do - if (asdf) - asdfasd; - while (cond); - - do - if (asdf) - while (asdf) - asdf; - while (asdf); - } - - /* Test for 'cindent' with two ) on a continuation line */ - { - if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d - aal;sdkjf ( ;asldfkja;sldfk - al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) - line up here; - } - - - /* C++ tests: */ - - // foo() these three lines should remain in column 0 - // { - // } - - /* Test for continuation and unterminated lines: */ - { - i = 99 + 14325 + - 21345 + - 21345 + - 21345 + ( 21345 + - 21345) + - 2345 + - 1234; - c = 1; - } - - /* - testje for indent with empty line - - here */ - - { - if (testing && - not a joke || - line up here) - hay; - if (testing && - (not a joke || testing - )line up here) - hay; - if (testing && - (not a joke || testing - line up here)) - hay; - } - - - { - switch (c) - { - case xx: - do - if (asdf) - do - asdfasdf; - while (asdf); - else - asdfasdf; - while (cond); - case yy: - case xx: - case zz: - testing; - } - } - - { - if (cond) { - foo; - } - else - { - bar; - } - } - - { - if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf - alsdkfj (asldk;fj - awith cino=(0 ;lf this one goes to below the paren with == - ;laksjfd ;lsakdjf ;alskdf asd) - asdfasdf;))) - asdfasdf; - } - - int - func(a, b) - int a; - int c; - { - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3) - ) - } - - { - while (asd) - { - if (asdf) - if (test) - if (that) - { - if (asdf) - do - cdasd; - while (as - df); - } - else - if (asdf) - asdf; - else - asdf; - asdf; - } - } - - { - s = "/*"; b = ';' - s = "/*"; b = ';'; - a = b; - } - - { - switch (a) - { - case a: - switch (t) - { - case 1: - cmd; - break; - case 2: - cmd; - break; - } - cmd; - break; - case b: - { - int i; - cmd; - } - break; - case c: { - int i; - cmd; - } - case d: if (cond && - test) { /* this line doesn't work right */ - int i; - cmd; - } - break; - } - } - - { - if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && - (bp_to->b_p_initialized || - (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) - return; - label : - asdf = asdf ? - asdf : asdf; - asdf = asdf ? - asdf: asdf; - } - - /* Special Comments : This function has the added complexity (compared */ - /* : to addtolist) of having to check for a detail */ - /* : texture and add that to the list first. */ - - char *(array[100]) = { - "testje", - "foo", - "bar", - } - - enum soppie - { - yes = 0, - no, - maybe - }; - - typedef enum soppie - { - yes = 0, - no, - maybe - }; - - static enum - { - yes = 0, - no, - maybe - } soppie; - - public static enum - { - yes = 0, - no, - maybe - } soppie; - - static private enum - { - yes = 0, - no, - maybe - } soppie; - - { - int a, - b; - } - - { - struct Type - { - int i; - char *str; - } var[] = - { - 0, "zero", - 1, "one", - 2, "two", - 3, "three" - }; - - float matrix[3][3] = - { - { - 0, - 1, - 2 - }, - { - 3, - 4, - 5 - }, - { - 6, - 7, - 8 - } - }; - } - - { - /* blah ( blah */ - /* where does this go? */ - - /* blah ( blah */ - cmd; - - func(arg1, - /* comment */ - arg2); - a; - { - b; - { - c; /* Hey, NOW it indents?! */ - } - } - - { - func(arg1, - arg2, - arg3); - /* Hey, what am I doing here? Is this coz of the ","? */ - } - } - - main () - { - if (cond) - { - a = b; - } - if (cond) { - a = c; - } - if (cond) - a = d; - return; - } - - { - case 2: if (asdf && - asdfasdf) - aasdf; - a = 9; - case 3: if (asdf) - aasdf; - a = 9; - case 4: x = 1; - y = 2; - - label: if (asdf) - here; - - label: if (asdf && - asdfasdf) - { - } - - label: if (asdf && - asdfasdf) { - there; - } - - label: if (asdf && - asdfasdf) - there; - } - - { - /* - hello with ":set comments= cino=c5" - */ - - /* - hello with ":set comments= cino=" - */ - } - - - { - if (a < b) { - a = a + 1; - } else - a = a + 2; - - if (a) - do { - testing; - } while (asdfasdf); - a = b + 1; - asdfasdf - } - - { - for ( int i = 0; - i < 10; i++ ) - { - } - i = 0; - } - - class bob - { - int foo() {return 1;} - int bar; - } - - main() - { - while(1) - if (foo) - { - bar; - } - else { - asdf; - } - misplacedline; - } - - { - if (clipboard.state == SELECT_DONE - && ((row == clipboard.start.lnum - && col >= clipboard.start.col) - || row > clipboard.start.lnum)) - } - - { - if (1) {i += 4;} - where_am_i; - return 0; - } - - { - { - } // sdf(asdf - if (asdf) - asd; - } - - { - label1: - label2: - } - - { - int fooRet = foo(pBar1, false /*fKB*/, - true /*fPTB*/, 3 /*nT*/, false /*fDF*/); - f() { - for ( i = 0; - i < m; - /* c */ i++ ) { - a = b; - } - } - } - - { - f1(/*comment*/); - f2(); - } - - { - do { - if (foo) { - } else - ; - } while (foo); - foo(); // was wrong - } - - int x; // no extra indent because of the ; - void func() - { - } - - char *tab[] = {"aaa", - "};", /* }; */ NULL} - int indented; - {} - - char *a[] = {"aaa", "bbb", - "ccc", NULL}; - // here - - char *tab[] = {"aaa", - "xx", /* xx */}; /* asdf */ - int not_indented; - - { - do { - switch (bla) - { - case 1: if (foo) - bar; - } - } while (boo); - wrong; - } - - int foo, - bar; - int foo; - - #if defined(foo) \ - && defined(bar) - char * xx = "asdf\ - foo\ - bor"; - int x; - - char *foo = "asdf\ - asdf\ - asdf", - *bar; - - void f() - { - #if defined(foo) \ - && defined(bar) - char *foo = "asdf\ - asdf\ - asdf", - *bar; - { - int i; - char *foo = "asdf\ - asdf\ - asdf", - *bar; - } - #endif - } - #endif - - int y; // comment - // comment - - // comment - - { - Constructor(int a, - int b ) : BaseClass(a) - { - } - } - - void foo() - { - char one, - two; - struct bla piet, - jan; - enum foo kees, - jannie; - static unsigned sdf, - krap; - unsigned int piet, - jan; - int - kees, - jan; - } - - { - t(int f, - int d); // ) - d(); - } - - Constructor::Constructor(int a, - int b - ) : - BaseClass(a, - b, - c), - mMember(b), - { - } - - Constructor::Constructor(int a, - int b ) : - BaseClass(a) - { - } - - Constructor::Constructor(int a, - int b ) /*x*/ : /*x*/ BaseClass(a), - member(b) - { - } - - A::A(int a, int b) - : aa(a), - bb(b), - cc(c) - { - } - - class CAbc : - public BaseClass1, - protected BaseClass2 - { - int Test() { return FALSE; } - int Test1() { return TRUE; } - - CAbc(int a, int b ) : - BaseClass(a) - { - switch(xxx) - { - case abc: - asdf(); - break; - - case 999: - baer(); - break; - } - } - - public: // <-- this was incorrectly indented before!! - void testfall(); - protected: - void testfall(); - }; - - class CAbc : public BaseClass1, - protected BaseClass2 - { - }; - - static struct - { - int a; - int b; - } variable[COUNT] = - { - { - 123, - 456 - }, - { - 123, - 456 - } - }; - - static struct - { - int a; - int b; - } variable[COUNT] = - { - { 123, 456 }, - { 123, 456 } - }; - - void asdf() /* ind_maxparen may cause trouble here */ - { - if ((0 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1 - && 1)) break; - } - - foo() - { - a = cond ? foo() : asdf - + asdf; - - a = cond ? - foo() : asdf - + asdf; - } - - int main(void) - { - if (a) - if (b) - 2; - else 3; - next_line_of_code(); - } - - barry() - { - Foo::Foo (int one, - int two) - : something(4) - {} - } - - barry() - { - Foo::Foo (int one, int two) - : something(4) - {} - } - - Constructor::Constructor(int a, - int b - ) : - BaseClass(a, - b, - c), - mMember(b) - { - } - int main () - { - if (lala) - do - ++(*lolo); - while (lili - && lele); - lulu; - } - - int main () - { - switch (c) - { - case 'c': if (cond) - { - } - } - } - - main() - { - (void) MyFancyFuasdfadsfnction( - argument); - } - - main() - { - char foo[] = "/*"; - /* as - df */ - hello - } - - /* valid namespaces with normal indent */ - namespace - { - { - 111111111111; - } - } - namespace /* test */ - { - 11111111111111111; - } - namespace // test - { - 111111111111111111; - } - namespace - { - 111111111111111111; - } - namespace test - { - 111111111111111111; - } - namespace{ - 111111111111111111; - } - namespace test{ - 111111111111111111; - } - namespace { - 111111111111111111; - } - namespace test { - 111111111111111111; - namespace test2 { - 22222222222222222; - } - } - inline namespace { - 111111111111111111; - } - inline /* test */ namespace { - 111111111111111111; - } - inline/* test */namespace { - 111111111111111111; - } - - /* invalid namespaces use block indent */ - namespace test test2 { - 111111111111111111111; - } - namespace11111111111 { - 111111111111; - } - namespace() { - 1111111111111; - } - namespace() - { - 111111111111111111; - } - namespace test test2 - { - 1111111111111111111; - } - namespace111111111 - { - 111111111111111111; - } - inlinenamespace { - 111111111111111111; - } - - void getstring() { - /* Raw strings */ - const char* s = R"( - test { - # comment - field: 123 - } - )"; - } - - void getstring() { - const char* s = R"foo( - test { - # comment - field: 123 - } - )foo"; - } - - { - int a[4] = { - [0] = 0, - [1] = 1, - [2] = 2, - [3] = 3, - }; - } - - { - a = b[2] - + 3; - } - - { - if (1) - /* aaaaa - * bbbbb - */ - a = 1; - } - - void func() - { - switch (foo) - { - case (bar): - if (baz()) - quux(); - break; - case (shmoo): - if (!bar) - { - } - case (foo1): - switch (bar) - { - case baz: - baz_f(); - break; - } - break; - default: - baz(); - baz(); - break; - } - } - - /* end of AUTO */ - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_2() - new - setl cindent ts=4 sw=4 - setl tw=0 noai fo=croq - let &wm = &columns - 20 - - let code =<< trim [CODE] - { - - /* this is - * a real serious important big - * comment - */ - /* insert " about life, the universe, and the rest" after "serious" */ - } - [CODE] - - call append(0, code) - normal gg - call search('serious', 'e') - normal a about life, the universe, and the rest - - let expected =<< trim [CODE] - { - - /* this is - * a real serious - * about life, the - * universe, and the - * rest important big - * comment - */ - /* insert " about life, the universe, and the rest" after "serious" */ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - set wm& - enew! | close -endfunc - -func Test_cindent_3() - new - setl nocindent ts=4 sw=4 - - let code =<< trim [CODE] - { - /* - * Testing for comments, without 'cin' set - */ - - /* - * what happens here? - */ - - /* - the end of the comment, try inserting a line below */ - - /* how about - this one */ - } - [CODE] - - call append(0, code) - normal gg - call search('comments') - normal joabout life - call search('happens') - normal jothere - call search('below') - normal oline - call search('this') - normal Ohello - - let expected =<< trim [CODE] - { - /* - * Testing for comments, without 'cin' set - */ - about life - - /* - * what happens here? - */ - there - - /* - the end of the comment, try inserting a line below */ - line - - /* how about - hello - this one */ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_4() - new - setl cindent ts=4 sw=4 - - let code =<< trim [CODE] - { - var = this + that + vec[0] * vec[0] - + vec[1] * vec[1] - + vec2[2] * vec[2]; - } - [CODE] - - call append(0, code) - normal gg - call search('vec2') - normal == - - let expected =<< trim [CODE] - { - var = this + that + vec[0] * vec[0] - + vec[1] * vec[1] - + vec2[2] * vec[2]; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_5() - new - setl cindent ts=4 sw=4 - setl cino=}4 - - let code =<< trim [CODE] - { - asdf asdflkajds f; - if (tes & ting) { - asdf asdf asdf ; - asdfa sdf asdf; - } - testing1; - if (tes & ting) - { - asdf asdf asdf ; - asdfa sdf asdf; - } - testing2; - } - [CODE] - - call append(0, code) - normal gg - call search('testing1') - exe "normal k2==/testing2\" - normal k2== - - let expected =<< trim [CODE] - { - asdf asdflkajds f; - if (tes & ting) { - asdf asdf asdf ; - asdfa sdf asdf; - } - testing1; - if (tes & ting) - { - asdf asdf asdf ; - asdfa sdf asdf; - } - testing2; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_6() - new - setl cindent ts=4 sw=4 - setl cino=(0,)20 - - let code =<< trim [CODE] - main ( int first_par, /* - * Comment for - * first par - */ - int second_par /* - * Comment for - * second par - */ - ) - { - func( first_par, /* - * Comment for - * first par - */ - second_par /* - * Comment for - * second par - */ - ); - - } - [CODE] - - call append(0, code) - normal gg - call search('main') - normal =][ - - let expected =<< trim [CODE] - main ( int first_par, /* - * Comment for - * first par - */ - int second_par /* - * Comment for - * second par - */ - ) - { - func( first_par, /* - * Comment for - * first par - */ - second_par /* - * Comment for - * second par - */ - ); - - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_7() - new - setl cindent ts=4 sw=4 - setl cino=es,n0s - - let code =<< trim [CODE] - main(void) - { - /* Make sure that cino=X0s is not parsed like cino=Xs. */ - if (cond) - foo(); - else - { - bar(); - } - } - [CODE] - - call append(0, code) - normal gg - call search('main') - normal =][ - - let expected =<< trim [CODE] - main(void) - { - /* Make sure that cino=X0s is not parsed like cino=Xs. */ - if (cond) - foo(); - else - { - bar(); - } - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_8() - new - setl cindent ts=4 sw=4 - setl cino= - - let code =<< trim [CODE] - - { - do - { - if () - { - if () - asdf; - else - asdf; - } - } while (); - cmd; /* this should go under the } */ - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - - { - do - { - if () - { - if () - asdf; - else - asdf; - } - } while (); - cmd; /* this should go under the } */ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_9() - new - setl cindent ts=4 sw=4 - - let code =<< trim [CODE] - - void f() - { - if ( k() ) { - l(); - - } else { /* Start (two words) end */ - m(); - } - - n(); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - - void f() - { - if ( k() ) { - l(); - - } else { /* Start (two words) end */ - m(); - } - - n(); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_10() - new - setl cindent ts=4 sw=4 - setl cino={s,e-s - - let code =<< trim [CODE] - - void f() - { - if ( k() ) - { - l(); - } else { /* Start (two words) end */ - m(); - } - n(); /* should be under the if () */ - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - - void f() - { - if ( k() ) - { - l(); - } else { /* Start (two words) end */ - m(); - } - n(); /* should be under the if () */ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_11() - new - setl cindent ts=4 sw=4 - setl cino={s,fs - - let code =<< trim [CODE] - void bar(void) - { - static array[2][2] = - { - { 1, 2 }, - { 3, 4 }, - } - - while (a) - { - foo(&a); - } - - { - int a; - { - a = a + 1; - } - } - b = a; - } - - void func(void) - { - a = 1; - { - b = 2; - } - c = 3; - d = 4; - } - /* foo */ - [CODE] - - call append(0, code) - normal gg - exe "normal ]]=/ foo\" - - let expected =<< trim [CODE] - void bar(void) - { - static array[2][2] = - { - { 1, 2 }, - { 3, 4 }, - } - - while (a) - { - foo(&a); - } - - { - int a; - { - a = a + 1; - } - } - b = a; - } - - void func(void) - { - a = 1; - { - b = 2; - } - c = 3; - d = 4; - } - /* foo */ - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_12() - new - setl cindent ts=4 sw=4 - setl cino= - - let code =<< trim [CODE] - a() - { - do { - a = a + - a; - } while ( a ); /* add text under this line */ - if ( a ) - a; - } - [CODE] - - call append(0, code) - normal gg - call search('while') - normal ohere - - let expected =<< trim [CODE] - a() - { - do { - a = a + - a; - } while ( a ); /* add text under this line */ - here - if ( a ) - a; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_13() - new - setl cindent ts=4 sw=4 - setl cino= com= - - let code =<< trim [CODE] - a() - { - label1: - /* hmm */ - // comment - } - [CODE] - - call append(0, code) - normal gg - call search('comment') - exe "normal olabel2: b();\rlabel3 /* post */:\r/* pre */ label4:\r" . - \ "f(/*com*/);\rif (/*com*/)\rcmd();" - - let expected =<< trim [CODE] - a() - { - label1: - /* hmm */ - // comment - label2: b(); - label3 /* post */: - /* pre */ label4: - f(/*com*/); - if (/*com*/) - cmd(); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_14() - new - setl cindent ts=4 sw=4 - setl comments& comments^=s:/*,m:**,ex:*/ - - let code =<< trim [CODE] - /* - * A simple comment - */ - - /* - ** A different comment - */ - [CODE] - - call append(0, code) - normal gg - call search('simple') - normal =5j - - let expected =<< trim [CODE] - /* - * A simple comment - */ - - /* - ** A different comment - */ - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_15() - new - setl cindent ts=4 sw=4 - setl cino=c0 - setl comments& comments-=s1:/* comments^=s0:/* - - let code =<< trim [CODE] - void f() - { - - /********* - A comment. - *********/ - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - - /********* - A comment. - *********/ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_16() - new - setl cindent ts=4 sw=4 - setl cino=c0,C1 - setl comments& comments-=s1:/* comments^=s0:/* - - let code =<< trim [CODE] - void f() - { - - /********* - A comment. - *********/ - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - - /********* - A comment. - *********/ - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_17() - new - setl cindent ts=4 sw=4 - setl cino= - - let code =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_18() - new - setl cindent ts=4 sw=4 - setl cino=(s - - let code =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_19() - new - setl cindent ts=4 sw=4 - set cino=(s,U1 - - let code =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - c = c1 && - ( - c2 || - c3 - ) && c4; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_20() - new - setl cindent ts=4 sw=4 - setl cino=(0 - - let code =<< trim [CODE] - void f() - { - if ( c1 - && ( c2 - || c3)) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - if ( c1 - && ( c2 - || c3)) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_21() - new - setl cindent ts=4 sw=4 - setl cino=(0,w1 - - let code =<< trim [CODE] - void f() - { - if ( c1 - && ( c2 - || c3)) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - if ( c1 - && ( c2 - || c3)) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_22() - new - setl cindent ts=4 sw=4 - setl cino=(s - - let code =<< trim [CODE] - void f() - { - c = c1 && ( - c2 || - c3 - ) && c4; - if ( - c1 && c2 - ) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - c = c1 && ( - c2 || - c3 - ) && c4; - if ( - c1 && c2 - ) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_23() - new - setl cindent ts=4 sw=4 - setl cino=(s,m1 - - let code =<< trim [CODE] - void f() - { - c = c1 && ( - c2 || - c3 - ) && c4; - if ( - c1 && c2 - ) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - c = c1 && ( - c2 || - c3 - ) && c4; - if ( - c1 && c2 - ) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_24() - new - setl cindent ts=4 sw=4 - setl cino=b1 - - let code =<< trim [CODE] - void f() - { - switch (x) - { - case 1: - a = b; - break; - default: - a = 0; - break; - } - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - switch (x) - { - case 1: - a = b; - break; - default: - a = 0; - break; - } - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_25() - new - setl cindent ts=4 sw=4 - setl cino=(0,W5 - - let code =<< trim [CODE] - void f() - { - invokeme( - argu, - ment); - invokeme( - argu, - ment - ); - invokeme(argu, - ment - ); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - invokeme( - argu, - ment); - invokeme( - argu, - ment - ); - invokeme(argu, - ment - ); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_26() - new - setl cindent ts=4 sw=4 - setl cino=/6 - - let code =<< trim [CODE] - void f() - { - statement; - // comment 1 - // comment 2 - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void f() - { - statement; - // comment 1 - // comment 2 - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_27() - new - setl cindent ts=4 sw=4 - setl cino= - - let code =<< trim [CODE] - void f() - { - statement; - // comment 1 - // comment 2 - } - [CODE] - - call append(0, code) - normal gg - exe "normal ]]/comment 1/+1\==" - - let expected =<< trim [CODE] - void f() - { - statement; - // comment 1 - // comment 2 - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_28() - new - setl cindent ts=4 sw=4 - setl cino=g0 - - let code =<< trim [CODE] - class CAbc - { - int Test() { return FALSE; } - - public: // comment - void testfall(); - protected: - void testfall(); - }; - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - class CAbc - { - int Test() { return FALSE; } - - public: // comment - void testfall(); - protected: - void testfall(); - }; - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_29() - new - setl cindent ts=4 sw=4 - setl cino=(0,gs,hs - - let code =<< trim [CODE] - class Foo : public Bar - { - public: - virtual void method1(void) = 0; - virtual void method2(int arg1, - int arg2, - int arg3) = 0; - }; - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - class Foo : public Bar - { - public: - virtual void method1(void) = 0; - virtual void method2(int arg1, - int arg2, - int arg3) = 0; - }; - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_30() - new - setl cindent ts=4 sw=4 - setl cino=+20 - - let code =<< [CODE] - void -foo() -{ - if (a) - { - } else - asdf; -} -[CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< [CODE] - void -foo() -{ - if (a) - { - } else - asdf; -} - -[CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_31() - new - setl cindent ts=4 sw=4 - setl cino=(0,W2s - - let code =<< trim [CODE] - - { - averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( - asdasdf, - func(asdf, - asdfadsf), - asdfasdf - ); - - /* those are ugly, but consequent */ - - func()->asd(asdasdf, - averylongfunctionname( - abc, - dec)->averylongfunctionname( - asdfadsf, - asdfasdf, - asdfasdf, - ), - func(asdfadf, - asdfasdf - ), - asdasdf - ); - - averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( - abc, - dec)->asdfasdfasdf( - asdfadsf, - asdfasdf, - asdfasdf, - ), - func(asdfadf, - asdfasdf), - asdasdf - ); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - - { - averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( - asdasdf, - func(asdf, - asdfadsf), - asdfasdf - ); - - /* those are ugly, but consequent */ - - func()->asd(asdasdf, - averylongfunctionname( - abc, - dec)->averylongfunctionname( - asdfadsf, - asdfasdf, - asdfasdf, - ), - func(asdfadf, - asdfasdf - ), - asdasdf - ); - - averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( - abc, - dec)->asdfasdfasdf( - asdfadsf, - asdfasdf, - asdfasdf, - ), - func(asdfadf, - asdfasdf), - asdasdf - ); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_32() - new - setl cindent ts=4 sw=4 - setl cino=M1 - - let code =<< trim [CODE] - int main () - { - if (cond1 && - cond2 - ) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - int main () - { - if (cond1 && - cond2 - ) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_33() - new - setl cindent ts=4 sw=4 - setl cino=(0,ts - - let code =<< trim [CODE] - void func(int a - #if defined(FOO) - , int b - , int c - #endif - ) - { - } - [CODE] - - call append(0, code) - normal gg - normal 2j=][ - - let expected =<< trim [CODE] - void func(int a - #if defined(FOO) - , int b - , int c - #endif - ) - { - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_34() - new - setl cindent ts=4 sw=4 - setl cino=(0 - - let code =<< trim [CODE] - - void - func(int a - #if defined(FOO) - , int b - , int c - #endif - ) - { - } - [CODE] - - call append(0, code) - normal gg - normal =][ - - let expected =<< trim [CODE] - - void - func(int a - #if defined(FOO) - , int b - , int c - #endif - ) - { - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_35() - new - setl cindent ts=4 sw=4 - setl cino& - - let code =<< trim [CODE] - void func(void) - { - if(x==y) - if(y==z) - foo=1; - else { bar=1; - baz=2; - } - printf("Foo!\n"); - } - - void func1(void) - { - char* tab[] = {"foo", "bar", - "baz", "quux", - "this line used", "to be indented incorrectly"}; - foo(); - } - - void func2(void) - { - int tab[] = - {1, 2, - 3, 4, - 5, 6}; - - printf("This line used to be indented incorrectly.\n"); - } - - int foo[] - #ifdef BAR - - = { 1, 2, 3, - 4, 5, 6 } - - #endif - ; - int baz; - - void func3(void) - { - int tab[] = { - 1, 2, - 3, 4, - 5, 6}; - - printf("Don't you dare indent this line incorrectly!\n"); - } - - void - func4(a, b, - c) - int a; - int b; - int c; - { - } - - void - func5( - int a, - int b) - { - } - - void - func6( - int a) - { - } - [CODE] - - call append(0, code) - normal gg - normal ]]=7][ - - let expected =<< trim [CODE] - void func(void) - { - if(x==y) - if(y==z) - foo=1; - else { bar=1; - baz=2; - } - printf("Foo!\n"); - } - - void func1(void) - { - char* tab[] = {"foo", "bar", - "baz", "quux", - "this line used", "to be indented incorrectly"}; - foo(); - } - - void func2(void) - { - int tab[] = - {1, 2, - 3, 4, - 5, 6}; - - printf("This line used to be indented incorrectly.\n"); - } - - int foo[] - #ifdef BAR - - = { 1, 2, 3, - 4, 5, 6 } - - #endif - ; - int baz; - - void func3(void) - { - int tab[] = { - 1, 2, - 3, 4, - 5, 6}; - - printf("Don't you dare indent this line incorrectly!\n"); - } - - void - func4(a, b, - c) - int a; - int b; - int c; - { - } - - void - func5( - int a, - int b) - { - } - - void - func6( - int a) - { - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_36() - new - setl cindent ts=4 sw=4 - setl cino& - setl cino+=l1 - - let code =<< trim [CODE] - void func(void) - { - int tab[] = - { - 1, 2, 3, - 4, 5, 6}; - - printf("Indent this line correctly!\n"); - - switch (foo) - { - case bar: - printf("bar"); - break; - case baz: { - printf("baz"); - break; - } - case quux: - printf("But don't break the indentation of this instruction\n"); - break; - } - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - int tab[] = - { - 1, 2, 3, - 4, 5, 6}; - - printf("Indent this line correctly!\n"); - - switch (foo) - { - case bar: - printf("bar"); - break; - case baz: { - printf("baz"); - break; - } - case quux: - printf("But don't break the indentation of this instruction\n"); - break; - } - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_37() - new - setl cindent ts=4 sw=4 - setl cino& - - let code =<< trim [CODE] - void func(void) - { - cout << "a" - << "b" - << ") :" - << "c"; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - cout << "a" - << "b" - << ") :" - << "c"; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_38() - new - setl cindent ts=4 sw=4 - setl com=s1:/*,m:*,ex:*/ - - let code =<< trim [CODE] - void func(void) - { - /* - * This is a comment. - */ - } - [CODE] - - call append(0, code) - normal gg - normal ]]3jofoo(); - - let expected =<< trim [CODE] - void func(void) - { - /* - * This is a comment. - */ - foo(); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_39() - new - setl cindent ts=4 sw=4 - setl cino& - - let code =<< trim [CODE] - void func(void) - { - for (int i = 0; i < 10; ++i) - if (i & 1) { - foo(1); - } else - foo(0); - baz(); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - for (int i = 0; i < 10; ++i) - if (i & 1) { - foo(1); - } else - foo(0); - baz(); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_40() - new - setl cindent ts=4 sw=4 - setl cino=k2s,(0 - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_41() - new - setl cindent ts=4 sw=4 - setl cino=k2s,(s - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_42() - new - setl cindent ts=4 sw=4 - setl cino=k2s,(s,U1 - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - c = c1 && - ( - c2 || - c3 - ) && c4; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - c = c1 && - ( - c2 || - c3 - ) && c4; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_43() - new - setl cindent ts=4 sw=4 - setl cino=k2s,(0,W4 - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - if ( c1 - && ( c2 - || c3)) - foo; - - a_long_line( - argument, - argument); - a_short_line(argument, - argument); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - if ( c1 - && ( c2 - || c3)) - foo; - - a_long_line( - argument, - argument); - a_short_line(argument, - argument); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_44() - new - setl cindent ts=4 sw=4 - setl cino=k2s,u2 - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_45() - new - setl cindent ts=4 sw=4 - setl cino=k2s,(0,w1 - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - if (c123456789 - && (c22345 - || c3)) - printf("foo\n"); - - if ( c1 - && ( c2 - || c3)) - foo; - func( c1 - && ( c2 - || c3)) - foo; - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_46() - new - setl cindent ts=4 sw=4 - setl cino=k2,(s - - let code =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - } - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - void func(void) - { - if (condition1 - && condition2) - action(); - function(argument1 - && argument2); - - if (c1 && (c2 || - c3)) - foo; - if (c1 && - (c2 || c3)) - { - } - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_47() - new - setl cindent ts=4 sw=4 - setl cino=N-s - - let code =<< trim [CODE] - NAMESPACESTART - /* valid namespaces with normal indent */ - namespace - { - { - 111111111111; - } - } - namespace /* test */ - { - 11111111111111111; - } - namespace // test - { - 111111111111111111; - } - namespace - { - 111111111111111111; - } - namespace test - { - 111111111111111111; - } - namespace test::cpp17 - { - 111111111111111111; - } - namespace ::incorrectcpp17 - { - 111111111111111111; - } - namespace test::incorrectcpp17:: - { - 111111111111111111; - } - namespace test:incorrectcpp17 - { - 111111111111111111; - } - namespace test:::incorrectcpp17 - { - 111111111111111111; - } - namespace{ - 111111111111111111; - } - namespace test{ - 111111111111111111; - } - namespace { - 111111111111111111; - } - namespace test { - 111111111111111111; - namespace test2 { - 22222222222222222; - } - } - inline namespace { - 111111111111111111; - } - inline /* test */ namespace { - 111111111111111111; - } - inline/* test */namespace { - 111111111111111111; - } - - /* invalid namespaces use block indent */ - namespace test test2 { - 111111111111111111111; - } - namespace11111111111 { - 111111111111; - } - namespace() { - 1111111111111; - } - namespace() - { - 111111111111111111; - } - namespace test test2 - { - 1111111111111111111; - } - namespace111111111 - { - 111111111111111111; - } - inlinenamespace { - 111111111111111111; - } - NAMESPACEEND - [CODE] - - call append(0, code) - normal gg - call search('^NAMESPACESTART') - exe "normal =/^NAMESPACEEND\n" - - let expected =<< trim [CODE] - NAMESPACESTART - /* valid namespaces with normal indent */ - namespace - { - { - 111111111111; - } - } - namespace /* test */ - { - 11111111111111111; - } - namespace // test - { - 111111111111111111; - } - namespace - { - 111111111111111111; - } - namespace test - { - 111111111111111111; - } - namespace test::cpp17 - { - 111111111111111111; - } - namespace ::incorrectcpp17 - { - 111111111111111111; - } - namespace test::incorrectcpp17:: - { - 111111111111111111; - } - namespace test:incorrectcpp17 - { - 111111111111111111; - } - namespace test:::incorrectcpp17 - { - 111111111111111111; - } - namespace{ - 111111111111111111; - } - namespace test{ - 111111111111111111; - } - namespace { - 111111111111111111; - } - namespace test { - 111111111111111111; - namespace test2 { - 22222222222222222; - } - } - inline namespace { - 111111111111111111; - } - inline /* test */ namespace { - 111111111111111111; - } - inline/* test */namespace { - 111111111111111111; - } - - /* invalid namespaces use block indent */ - namespace test test2 { - 111111111111111111111; - } - namespace11111111111 { - 111111111111; - } - namespace() { - 1111111111111; - } - namespace() - { - 111111111111111111; - } - namespace test test2 - { - 1111111111111111111; - } - namespace111111111 - { - 111111111111111111; - } - inlinenamespace { - 111111111111111111; - } - NAMESPACEEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_48() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - var bar = { - foo: { - that: this, - some: ok, - }, - "bar":{ - a : 2, - b: "123abc", - x: 4, - "y": 5 - } - } - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - var bar = { - foo: { - that: this, - some: ok, - }, - "bar":{ - a : 2, - b: "123abc", - x: 4, - "y": 5 - } - } - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_49() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - var foo = [ - 1, - 2, - 3 - ]; - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - var foo = [ - 1, - 2, - 3 - ]; - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_50() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - function bar() { - var foo = [ - 1, - 2, - 3 - ]; - } - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - function bar() { - var foo = [ - 1, - 2, - 3 - ]; - } - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_51() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - (function($){ - - if (cond && - cond) { - stmt; - } - window.something.left = - (width - 50 + offset) + "px"; - var class_name='myclass'; - - function private_method() { - } - - var public_method={ - method: function(options,args){ - private_method(); - } - } - - function init(options) { - - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - - $.fn[class_name]=function() { - - var _arguments=arguments; - return this.each(function(){ - - var options=$(this).data(class_name+'_public'); - if (!options) { - init.apply(this,_arguments); - - } else { - var method=public_method[_arguments[0]]; - - if (typeof(method)!='function') { - console.log(class_name+' has no method "'+_arguments[0]+'"'); - return false; - } - _arguments[0]=options; - method.apply(this,_arguments); - } - }); - } - - })(jQuery); - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - (function($){ - - if (cond && - cond) { - stmt; - } - window.something.left = - (width - 50 + offset) + "px"; - var class_name='myclass'; - - function private_method() { - } - - var public_method={ - method: function(options,args){ - private_method(); - } - } - - function init(options) { - - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - - $.fn[class_name]=function() { - - var _arguments=arguments; - return this.each(function(){ - - var options=$(this).data(class_name+'_public'); - if (!options) { - init.apply(this,_arguments); - - } else { - var method=public_method[_arguments[0]]; - - if (typeof(method)!='function') { - console.log(class_name+' has no method "'+_arguments[0]+'"'); - return false; - } - _arguments[0]=options; - method.apply(this,_arguments); - } - }); - } - - })(jQuery); - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_52() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - function init(options) { - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - function init(options) { - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_53() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1 - - let code =<< trim [CODE] - JSSTART - (function($){ - function init(options) { - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - })(jQuery); - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - (function($){ - function init(options) { - $(this).data(class_name+'_public',$.extend({},{ - foo: 'bar', - bar: 2, - foobar: [ - 1, - 2, - 3 - ], - callback: function(){ - return true; - } - }, options||{})); - } - })(jQuery); - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_54() - new - setl cindent ts=4 sw=4 - setl cino=j1,J1,+2 - - let code =<< trim [CODE] - JSSTART - // Results of JavaScript indent - // 1 - (function(){ - var a = [ - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 2 - (function(){ - var a = [ - 0 + - 5 * - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 3 - (function(){ - var a = [ - 0 + - // comment 1 - 5 * - /* comment 2 */ - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 4 - { - var a = [ - 0, - 1 - ]; - var b; - var c; - } - - // 5 - { - var a = [ - [ - 0 - ], - 2, - 3 - ]; - } - - // 6 - { - var a = [ - [ - 0, - 1 - ], - 2, - 3 - ]; - } - - // 7 - { - var a = [ - // [ - 0, - // 1 - // ], - 2, - 3 - ]; - } - - // 8 - var x = [ - (function(){ - var a, - b, - c, - d, - e, - f, - g, - h, - i; - }) - ]; - - // 9 - var a = [ - 0 + - 5 * - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - - // 10 - var a, - b, - c, - d, - e, - f, - g, - h, - i; - JSEND - [CODE] - - call append(0, code) - normal gg - call search('^JSSTART') - exe "normal =/^JSEND\n" - - let expected =<< trim [CODE] - JSSTART - // Results of JavaScript indent - // 1 - (function(){ - var a = [ - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 2 - (function(){ - var a = [ - 0 + - 5 * - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 3 - (function(){ - var a = [ - 0 + - // comment 1 - 5 * - /* comment 2 */ - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - }()) - - // 4 - { - var a = [ - 0, - 1 - ]; - var b; - var c; - } - - // 5 - { - var a = [ - [ - 0 - ], - 2, - 3 - ]; - } - - // 6 - { - var a = [ - [ - 0, - 1 - ], - 2, - 3 - ]; - } - - // 7 - { - var a = [ - // [ - 0, - // 1 - // ], - 2, - 3 - ]; - } - - // 8 - var x = [ - (function(){ - var a, - b, - c, - d, - e, - f, - g, - h, - i; - }) - ]; - - // 9 - var a = [ - 0 + - 5 * - 9 * - 'a', - 'b', - 0 + - 5 * - 9 * - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i' - ]; - - // 10 - var a, - b, - c, - d, - e, - f, - g, - h, - i; - JSEND - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_55() - new - setl cindent ts=4 sw=4 - setl cino& - - let code =<< trim [CODE] - /* start of define */ - { - } - #define AAA \ - BBB\ - CCC - - #define CNT \ - 1 + \ - 2 + \ - 4 - /* end of define */ - [CODE] - - call append(0, code) - normal gg - call search('start of define') - exe "normal =/end of define\n" - - let expected =<< trim [CODE] - /* start of define */ - { - } - #define AAA \ - BBB\ - CCC - - #define CNT \ - 1 + \ - 2 + \ - 4 - /* end of define */ - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_56() - new - setl cindent ts=4 sw=4 - setl cino& - - let code =<< trim [CODE] - { - a = second/*bug*/*line; - } - [CODE] - - call append(0, code) - normal gg - call search('a = second') - normal ox - - let expected =<< trim [CODE] - { - a = second/*bug*/*line; - x - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -" this was going beyond the end of the line. -func Test_cindent_case() - new - call setline(1, 'case x: // x') - set cindent - norm! f:a: - call assert_equal('case x:: // x', getline(1)) - set cindent& - bwipe! -endfunc - -" Test for changing multiple lines (using c) with cindent -func Test_cindent_change_multline() - new - setlocal cindent - call setline(1, ['if (a)', '{', ' i = 1;', '}']) - normal! jc3jm = 2; - call assert_equal("\tm = 2;", getline(2)) - close! -endfunc - -" This was reading past the end of the line -func Test_cindent_check_funcdecl() - new - sil norm o0('\0=L - bwipe! -endfunc - -func Test_cindent_scopedecls() - new - setl cindent ts=4 sw=4 - setl cino=g0 - setl cinsd+=public\ slots,signals - - let code =<< trim [CODE] - class Foo - { - public: - virtual void foo() = 0; - public slots: - void onBar(); - signals: - void baz(); - private: - int x; - }; - [CODE] - - call append(0, code) - normal gg - normal ]]=][ - - let expected =<< trim [CODE] - class Foo - { - public: - virtual void foo() = 0; - public slots: - void onBar(); - signals: - void baz(); - private: - int x; - }; - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_cindent_pragma() - new - setl cindent ts=4 sw=4 - setl cino=Ps - - let code =<< trim [CODE] - { - #pragma omp parallel - { - #pragma omp task - foo(); - # pragma omp taskwait - } - } - [CODE] - - call append(0, code) - normal gg - normal =G - - let expected =<< trim [CODE] - { - #pragma omp parallel - { - #pragma omp task - foo(); - # pragma omp taskwait - } - } - - [CODE] - - call assert_equal(expected, getline(1, '$')) - enew! | close -endfunc - -func Test_backslash_at_end_of_line() - new - exe "norm v>O'\\\-" - exe "norm \=" - bwipe! -endfunc - -func Test_find_brace_backwards() - " this was looking beyond the end of the line - new - norm R/* - norm o0{ - norm o// - norm V{= - call assert_equal(['/*', ' 0{', '//'], getline(1, 3)) - bwipe! -endfunc - - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_cjk_linebreak.vim b/src/nvim/testdir/test_cjk_linebreak.vim deleted file mode 100644 index dfaa8fa1af..0000000000 --- a/src/nvim/testdir/test_cjk_linebreak.vim +++ /dev/null @@ -1,97 +0,0 @@ -scriptencoding utf-8 - -func Run_cjk_linebreak_after(rigorous) - set textwidth=12 - for punct in [ - \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡', - \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》', - \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':', - \ ';', '?', ']', '}'] - call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。') - normal gqq - if a:rigorous - call assert_equal('这是一个测', getline(1)) - else - call assert_equal('这是一个测试' .. punct, getline(1)) - endif - %d_ - endfor -endfunc - -func Test_cjk_linebreak_after() - set formatoptions=croqn2mB1j - call Run_cjk_linebreak_after(0) -endfunc - -func Test_cjk_linebreak_after_rigorous() - set formatoptions=croqn2mB1j] - call Run_cjk_linebreak_after(1) -endfunc - -func Run_cjk_linebreak_before() - set textwidth=12 - for punct in [ - \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔', - \ '〖', '〘', '〚', '(', '[', '{'] - call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。') - normal gqq - call assert_equal('这是个测试', getline(1)) - %d_ - endfor -endfunc - -func Test_cjk_linebreak_before() - set formatoptions=croqn2mB1j - call Run_cjk_linebreak_before() -endfunc - -func Test_cjk_linebreak_before_rigorous() - set formatoptions=croqn2mB1j] - call Run_cjk_linebreak_before() -endfunc - -func Run_cjk_linebreak_nobetween(rigorous) - " …… must not start a line - call setline('.', '这是个测试……试试 CJK 行禁则补丁。') - set textwidth=12 ambiwidth=double - normal gqq - if a:rigorous - call assert_equal('这是个测', getline(1)) - else - call assert_equal('这是个测试……', getline(1)) - endif - %d_ - - call setline('.', '这是一个测试……试试 CJK 行禁则补丁。') - set textwidth=12 ambiwidth=double - normal gqq - call assert_equal('这是一个测', getline(1)) - %d_ - - " but —— can - call setline('.', '这是个测试——试试 CJK 行禁则补丁。') - set textwidth=12 ambiwidth=double - normal gqq - call assert_equal('这是个测试', getline(1)) -endfunc - -func Test_cjk_linebreak_nobetween() - set formatoptions=croqn2mB1j - call Run_cjk_linebreak_nobetween(0) -endfunc - -func Test_cjk_linebreak_nobetween_rigorous() - set formatoptions=croqn2mB1j] - call Run_cjk_linebreak_nobetween(1) -endfunc - -func Test_cjk_linebreak_join_punct() - for punct in ['——', '〗', ',', '。', '……'] - call setline(1, '文本文本' .. punct) - call setline(2, 'English') - set formatoptions=croqn2mB1j - normal ggJ - call assert_equal('文本文本' .. punct.'English', getline(1)) - %d_ - endfor -endfunc diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim deleted file mode 100644 index d8b29f6c42..0000000000 --- a/src/nvim/testdir/test_clientserver.vim +++ /dev/null @@ -1,195 +0,0 @@ -" Tests for the +clientserver feature. - -source check.vim -CheckFeature job - -if !has('clientserver') - call assert_fails('call remote_startserver("local")', 'E942:') -endif - -CheckFeature clientserver - -source shared.vim - -func Check_X11_Connection() - if has('x11') - CheckEnv DISPLAY - try - call remote_send('xxx', '') - catch - if v:exception =~ 'E240:' - throw 'Skipped: no connection to the X server' - endif - " ignore other errors - endtry - endif -endfunc - -func Test_client_server() - let cmd = GetVimCommand() - if cmd == '' - return - endif - call Check_X11_Connection() - - let name = 'XVIMTEST' - let cmd .= ' --servername ' . name - let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) - call WaitForAssert({-> assert_equal("run", job_status(job))}) - - " Takes a short while for the server to be active. - " When using valgrind it takes much longer. - call WaitForAssert({-> assert_match(name, serverlist())}) - - if !has('win32') - if RunVim([], [], '--serverlist >Xtest_serverlist') - let lines = readfile('Xtest_serverlist') - call assert_true(index(lines, 'XVIMTEST') >= 0) - endif - call delete('Xtest_serverlist') - endif - - eval name->remote_foreground() - - call remote_send(name, ":let testvar = 'yes'\") - call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"') - call assert_equal('yes', remote_expr(name, "testvar", "", 2)) - call assert_fails("let x=remote_expr(name, '2+x')", 'E449:') - call assert_fails("let x=remote_expr('[], '2+2')", 'E116:') - - if has('unix') && has('gui') && !has('gui_running') - " Running in a terminal and the GUI is available: Tell the server to open - " the GUI and check that the remote command still works. - " Need to wait for the GUI to start up, otherwise the send hangs in trying - " to send to the terminal window. - if has('gui_motif') - " For this GUI ignore the 'failed to create input context' error. - call remote_send(name, ":call test_ignore_error('E285') | gui -f\") - else - call remote_send(name, ":gui -f\") - endif - " Wait for the server to be up and answering requests. - " When using valgrind this can be very, very slow. - sleep 1 - call WaitForAssert({-> assert_match('\d', name->remote_expr("v:version", "", 1))}, 10000) - - call remote_send(name, ":let testvar = 'maybe'\") - call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))}) - endif - - call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\")', 'E241') - - call writefile(['one'], 'Xclientfile') - let cmd = GetVimProg() .. ' --servername ' .. name .. ' --remote Xclientfile' - call system(cmd) - call WaitForAssert({-> assert_equal('Xclientfile', remote_expr(name, "bufname()", "", 2))}) - call WaitForAssert({-> assert_equal('one', remote_expr(name, "getline(1)", "", 2))}) - call writefile(['one', 'two'], 'Xclientfile') - call system(cmd) - call WaitForAssert({-> assert_equal('two', remote_expr(name, "getline(2)", "", 2))}) - call delete('Xclientfile') - - " Expression evaluated locally. - if v:servername == '' - eval 'MYSELF'->remote_startserver() - " May get MYSELF1 when running the test again. - call assert_match('MYSELF', v:servername) - call assert_fails("call remote_startserver('MYSELF')", 'E941:') - endif - let g:testvar = 'myself' - call assert_equal('myself', remote_expr(v:servername, 'testvar')) - call remote_send(v:servername, ":let g:testvar2 = 75\") - call feedkeys('', 'x') - call assert_equal(75, g:testvar2) - call assert_fails('let v = remote_expr(v:servername, "/2")', ['E15:.*/2']) - - call remote_send(name, ":call server2client(expand(''), 'got it')\", 'g:myserverid') - call assert_equal('got it', g:myserverid->remote_read(2)) - - call remote_send(name, ":eval expand('')->server2client('another')\", 'g:myserverid') - let peek_result = 'nothing' - let r = g:myserverid->remote_peek('peek_result') - " unpredictable whether the result is already available. - if r > 0 - call assert_equal('another', peek_result) - elseif r == 0 - call assert_equal('nothing', peek_result) - else - call assert_report('remote_peek() failed') - endif - let g:peek_result = 'empty' - call WaitFor('remote_peek(g:myserverid, "g:peek_result") > 0') - call assert_equal('another', g:peek_result) - call assert_equal('another', remote_read(g:myserverid, 2)) - - if !has('gui_running') - " In GUI vim, the following tests display a dialog box - - let cmd = GetVimProg() .. ' --servername ' .. name - - " Run a separate instance to send a command to the server - call remote_expr(name, 'execute("only")') - call system(cmd .. ' --remote-send ":new Xfile"') - call assert_equal('2', remote_expr(name, 'winnr("$")')) - call assert_equal('Xfile', remote_expr(name, 'winbufnr(1)->bufname()')) - call remote_expr(name, 'execute("only")') - - " Invoke a remote-expr. On MS-Windows, the returned value has a carriage - " return. - let l = system(cmd .. ' --remote-expr "2 + 2"') - call assert_equal(['4'], split(l, "\n")) - - " Edit multiple files using --remote - call system(cmd .. ' --remote Xfile1 Xfile2 Xfile3') - call assert_match(".*Xfile1\n.*Xfile2\n.*Xfile3\n", remote_expr(name, 'argv()')) - eval name->remote_send(":%bw!\") - - " Edit files in separate tab pages - call system(cmd .. ' --remote-tab Xfile1 Xfile2 Xfile3') - call WaitForAssert({-> assert_equal('3', remote_expr(name, 'tabpagenr("$")'))}) - call assert_match('.*\remote_send(":%bw!\") - - " Edit a file using --remote-wait - eval name->remote_send(":source $VIMRUNTIME/plugin/rrhelper.vim\") - call system(cmd .. ' --remote-wait +enew Xfile1') - call assert_match('.*\remote_send(":%bw!\") - - " Edit files using --remote-tab-wait - call system(cmd .. ' --remote-tabwait +tabonly\|enew Xfile1 Xfile2') - call assert_equal('1', remote_expr(name, 'tabpagenr("$")')) - eval name->remote_send(":%bw!\") - - " Error cases - if v:lang == "C" || v:lang =~ '^[Ee]n' - let l = split(system(cmd .. ' --remote +pwd'), "\n") - call assert_equal("Argument missing after: \"+pwd\"", l[1]) - endif - let l = system(cmd .. ' --remote-expr "abcd"') - call assert_match('^E449: ', l) - endif - - eval name->remote_send(":%bw!\") - eval name->remote_send(":qa!\") - try - call WaitForAssert({-> assert_equal("dead", job_status(job))}) - finally - if job_status(job) != 'dead' - call assert_report('Server did not exit') - call job_stop(job, 'kill') - endif - endtry - - call assert_fails('call remote_startserver([])', 'E730:') - call assert_fails("let x = remote_peek([])", 'E730:') - call assert_fails("let x = remote_read('vim10')", - \ has('unix') ? ['E573:.*vim10'] : 'E277:') - call assert_fails("call server2client('abc', 'xyz')", - \ has('unix') ? ['E573:.*abc'] : 'E258:') -endfunc - -" Uncomment this line to get a debugging log -" call ch_logfile('channellog', 'w') - -" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_close_count.vim b/src/nvim/testdir/test_close_count.vim deleted file mode 100644 index 1f9adba32d..0000000000 --- a/src/nvim/testdir/test_close_count.vim +++ /dev/null @@ -1,174 +0,0 @@ - -" Tests for :[count]close! command -func Test_close_count() - enew! | only - - let wids = [win_getid()] - for i in range(5) - new - call add(wids, win_getid()) - endfor - - 4wincmd w - close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids) - - 1close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids) - - $close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1]], ids) - - 1wincmd w - 2close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[1]], ids) - - 1wincmd w - new - call add(wids, win_getid()) - new - call add(wids, win_getid()) - 2wincmd w - -1close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[6], wids[4], wids[1]], ids) - - 2wincmd w - +1close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[6], wids[4]], ids) - - only! -endfunc - -" Tests for :[count]hide command -func Test_hide_count() - enew! | only - - let wids = [win_getid()] - for i in range(5) - new - call add(wids, win_getid()) - endfor - - 4wincmd w - .hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids) - - 1hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids) - - $hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1]], ids) - - 1wincmd w - 2hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[1]], ids) - - 1wincmd w - new - call add(wids, win_getid()) - new - call add(wids, win_getid()) - 3wincmd w - -hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[7], wids[4], wids[1]], ids) - - 2wincmd w - +hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[7], wids[4]], ids) - - only! -endfunc - -" Tests for :[count]close! command with 'hidden' -func Test_hidden_close_count() - enew! | only - - let wids = [win_getid()] - for i in range(5) - new - call add(wids, win_getid()) - endfor - - set hidden - - $ hide - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[4], wids[3], wids[2], wids[1]], ids) - - $-1 close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[4], wids[3], wids[1]], ids) - - 1wincmd w - .+close! - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[3], wids[1]], ids) - - set nohidden - only! -endfunc - -" Tests for 'CTRL-W c' command to close windows. -func Test_winclose_command() - enew! | only - - let wids = [win_getid()] - for i in range(5) - new - call add(wids, win_getid()) - endfor - - set hidden - - 4wincmd w - exe "normal \c" - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids) - - exe "normal 1\c" - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids) - - exe "normal 9\c" - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[3], wids[1]], ids) - - 1wincmd w - exe "normal 2\c" - let ids = [] - windo call add(ids, win_getid()) - call assert_equal([wids[4], wids[1]], ids) - - set nohidden - only! -endfunc diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim deleted file mode 100644 index 1dceb43e5d..0000000000 --- a/src/nvim/testdir/test_cmdline.vim +++ /dev/null @@ -1,3586 +0,0 @@ -" Tests for editing the command line. - -source check.vim -source screendump.vim -source view_util.vim -source shared.vim - -func SetUp() - func SaveLastScreenLine() - let g:Sline = Screenline(&lines - 1) - return '' - endfunc - cnoremap SaveLastScreenLine() -endfunc - -func TearDown() - delfunc SaveLastScreenLine - cunmap -endfunc - -func Test_complete_tab() - call writefile(['testfile'], 'Xtestfile') - call feedkeys(":e Xtest\t\r", "tx") - call assert_equal('testfile', getline(1)) - - " Pressing after '%' completes the current file, also on MS-Windows - call feedkeys(":e %\t\r", "tx") - call assert_equal('e Xtestfile', @:) - call delete('Xtestfile') -endfunc - -func Test_complete_list() - " We can't see the output, but at least we check the code runs properly. - call feedkeys(":e test\\r", "tx") - call assert_equal('test', expand('%:t')) - - " If a command doesn't support completion, then CTRL-D should be literally - " used. - call feedkeys(":chistory \\\"\", 'xt') - call assert_equal("\"chistory \", @:) - - " Test for displaying the tail of the completion matches - set wildmode=longest,full - call mkdir('Xtest') - call writefile([], 'Xtest/a.c') - call writefile([], 'Xtest/a.h') - let g:Sline = '' - call feedkeys(":e Xtest/\\\\"\", 'xt') - call assert_equal('a.c a.h', g:Sline) - call assert_equal('"e Xtest/', @:) - if has('win32') - " Test for 'completeslash' - set completeslash=backslash - call feedkeys(":e Xtest\\\"\", 'xt') - call assert_equal('"e Xtest\', @:) - call feedkeys(":e Xtest/\\\"\", 'xt') - call assert_equal('"e Xtest\a.', @:) - set completeslash=slash - call feedkeys(":e Xtest\\\"\", 'xt') - call assert_equal('"e Xtest/', @:) - call feedkeys(":e Xtest\\\\\"\", 'xt') - call assert_equal('"e Xtest/a.', @:) - set completeslash& - endif - - " Test for displaying the tail with wildcards - let g:Sline = '' - call feedkeys(":e Xtes?/\\\\"\", 'xt') - call assert_equal('Xtest/a.c Xtest/a.h', g:Sline) - call assert_equal('"e Xtes?/', @:) - let g:Sline = '' - call feedkeys(":e Xtes*/\\\\"\", 'xt') - call assert_equal('Xtest/a.c Xtest/a.h', g:Sline) - call assert_equal('"e Xtes*/', @:) - let g:Sline = '' - call feedkeys(":e Xtes[/\\\\"\", 'xt') - call assert_equal(':e Xtes[/', g:Sline) - call assert_equal('"e Xtes[/', @:) - - call delete('Xtest', 'rf') - set wildmode& -endfunc - -func Test_complete_wildmenu() - call mkdir('Xdir1/Xdir2', 'p') - call writefile(['testfile1'], 'Xdir1/Xtestfile1') - call writefile(['testfile2'], 'Xdir1/Xtestfile2') - call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3') - call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4') - set wildmenu - - " Pressing completes, and moves to next files when pressing again. - call feedkeys(":e Xdir1/\\\", 'tx') - call assert_equal('testfile1', getline(1)) - call feedkeys(":e Xdir1/\\\\", 'tx') - call assert_equal('testfile2', getline(1)) - - " is like but begin with the last match and then go to - " previous. - call feedkeys(":e Xdir1/Xtest\\", 'tx') - call assert_equal('testfile2', getline(1)) - call feedkeys(":e Xdir1/Xtest\\\", 'tx') - call assert_equal('testfile1', getline(1)) - - " / to move to previous/next file. - call feedkeys(":e Xdir1/\\\", 'tx') - call assert_equal('testfile1', getline(1)) - call feedkeys(":e Xdir1/\\\\", 'tx') - call assert_equal('testfile2', getline(1)) - call feedkeys(":e Xdir1/\\\\\", 'tx') - call assert_equal('testfile1', getline(1)) - - " / to go up/down directories. - call feedkeys(":e Xdir1/\\\", 'tx') - call assert_equal('testfile3', getline(1)) - call feedkeys(":e Xdir1/\\\\\", 'tx') - call assert_equal('testfile1', getline(1)) - - " this fails in some Unix GUIs, not sure why - if !has('unix') || !has('gui_running') - " / mappings to go up/down directories when 'wildcharm' is - " different than 'wildchar'. - set wildcharm= - cnoremap - cnoremap - call feedkeys(":e Xdir1/\\\", 'tx') - call assert_equal('testfile3', getline(1)) - call feedkeys(":e Xdir1/\\\\", 'tx') - call assert_equal('testfile1', getline(1)) - set wildcharm=0 - cunmap - cunmap - endif - - " Test for canceling the wild menu by adding a character - redrawstatus - call feedkeys(":e Xdir1/\x\\"\", 'xt') - call assert_equal('"e Xdir1/Xdir2/x', @:) - - " Completion using a relative path - cd Xdir1/Xdir2 - call feedkeys(":e ../\\\\\\"\", 'tx') - call assert_equal('"e Xtestfile3 Xtestfile4', @:) - cd - - - " test for wildmenumode() - cnoremap wildmenumode() - call feedkeys(":cd Xdir\\\\"\", 'tx') - call assert_equal('"cd Xdir1/0', @:) - call feedkeys(":e Xdir1/\\\\"\", 'tx') - call assert_equal('"e Xdir1/Xdir2/1', @:) - cunmap - - " Test for canceling the wild menu by pressing or . - " After this pressing or should not change the selection. - call feedkeys(":sign \\\\\\\"\", 'tx') - call assert_equal('"sign define', @:) - call histadd('cmd', 'TestWildMenu') - call feedkeys(":sign \\\\\\\"\", 'tx') - call assert_equal('"TestWildMenu', @:) - - " cleanup - %bwipe - call delete('Xdir1', 'rf') - set nowildmenu -endfunc - -func Test_wildmenu_screendump() - CheckScreendump - - let lines =<< trim [SCRIPT] - set wildmenu hlsearch - [SCRIPT] - call writefile(lines, 'XTest_wildmenu') - - let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) - call term_sendkeys(buf, ":vim\") - call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) - - call term_sendkeys(buf, "\") - call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) - - call term_sendkeys(buf, "\") - call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) - - call term_sendkeys(buf, "\") - call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) - call term_sendkeys(buf, "\") - - " clean up - call StopVimInTerminal(buf) - call delete('XTest_wildmenu') -endfunc - -func Test_redraw_in_autocmd() - CheckScreendump - - let lines =<< trim END - set cmdheight=2 - autocmd CmdlineChanged * redraw - END - call writefile(lines, 'XTest_redraw', 'D') - - let buf = RunVimInTerminal('-S XTest_redraw', {'rows': 8}) - call term_sendkeys(buf, ":for i in range(3)\") - call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_1', {}) - - call term_sendkeys(buf, "let i =") - call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_2', {}) - - " clean up - call term_sendkeys(buf, "\") - call StopVimInTerminal(buf) -endfunc - -func Test_redrawstatus_in_autocmd() - CheckScreendump - - let lines =<< trim END - set laststatus=2 - set statusline=%=:%{getcmdline()} - autocmd CmdlineChanged * redrawstatus - END - call writefile(lines, 'XTest_redrawstatus', 'D') - - let buf = RunVimInTerminal('-S XTest_redrawstatus', {'rows': 8}) - " :redrawstatus is postponed if messages have scrolled - call term_sendkeys(buf, ":echo \"one\\ntwo\\nthree\\nfour\"\") - call term_sendkeys(buf, ":foobar") - call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {}) - " it is not postponed if messages have not scrolled - call term_sendkeys(buf, "\:for in in range(3)") - call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_2', {}) - " with cmdheight=1 messages have scrolled when typing :endfor - call term_sendkeys(buf, "\:endfor") - call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_3', {}) - call term_sendkeys(buf, "\:set cmdheight=2\") - " with cmdheight=2 messages haven't scrolled when typing :for or :endfor - call term_sendkeys(buf, ":for in in range(3)") - call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_4', {}) - call term_sendkeys(buf, "\:endfor") - call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_5', {}) - - " clean up - call term_sendkeys(buf, "\") - call StopVimInTerminal(buf) -endfunc - -func Test_changing_cmdheight() - CheckScreendump - - let lines =<< trim END - set cmdheight=1 laststatus=2 - func EchoTwo() - set laststatus=2 - set cmdheight=5 - echo 'foo' - echo 'bar' - set cmdheight=1 - endfunc - END - call writefile(lines, 'XTest_cmdheight', 'D') - - let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8}) - call term_sendkeys(buf, ":resize -3\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {}) - - " using the space available doesn't change the status line - call term_sendkeys(buf, ":set cmdheight+=3\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {}) - - " using more space moves the status line up - call term_sendkeys(buf, ":set cmdheight+=1\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {}) - - " reducing cmdheight moves status line down - call term_sendkeys(buf, ":set cmdheight-=2\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {}) - - " reducing window size and then setting cmdheight - call term_sendkeys(buf, ":resize -1\") - call term_sendkeys(buf, ":set cmdheight=1\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_5', {}) - - " setting 'cmdheight' works after outputting two messages - call term_sendkeys(buf, ":call EchoTwo()\") - call VerifyScreenDump(buf, 'Test_changing_cmdheight_6', {}) - - " clean up - call StopVimInTerminal(buf) -endfunc - -func Test_cmdheight_tabline() - CheckScreendump - - let buf = RunVimInTerminal('-c "set ls=2" -c "set stal=2" -c "set cmdheight=1"', {'rows': 6}) - call VerifyScreenDump(buf, 'Test_cmdheight_tabline_1', {}) - - " clean up - call StopVimInTerminal(buf) -endfunc - -func Test_map_completion() - call feedkeys(":map \\"\", 'xt') - call assert_equal('"map ', getreg(':')) - call feedkeys(":map