diff options
235 files changed, 5383 insertions, 4689 deletions
diff --git a/.travis.yml b/.travis.yml index 3fd93d31b2..f47b71ced1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ env: - CMAKE_FLAGS="-DTRAVIS_CI_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX - -DBUSTED_OUTPUT_TYPE=gtest + -DBUSTED_OUTPUT_TYPE=nvim -DDEPS_PREFIX=$DEPS_BUILD_DIR/usr -DMIN_LOG_LEVEL=2" - DEPS_CMAKE_FLAGS="-DDEPS_DOWNLOAD_DIR:PATH=$DEPS_DOWNLOAD_DIR" @@ -43,11 +43,6 @@ env: # If this file exists, we know that the cache contains compiled # dependencies and we can use it. - CACHE_MARKER="$HOME/.cache/nvim-deps/.travis_cache_marker" - # Test success marker. If this file exists, we know that all tests - # were successful. Required because we only want to update the cache - # if the tests were successful, but don't have this information - # available in before_cache (which is run before after_success). - - SUCCESS_MARKER="$BUILD_DIR/.tests_successful" # default target name for functional tests - FUNCTIONALTEST=functionaltest - CI_TARGET=tests diff --git a/CMakeLists.txt b/CMakeLists.txt index e818c4372a..82560b61c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,6 @@ else() endif() add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) -add_definitions(-DHAVE_CONFIG_H) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") diff --git a/appveyor.yml b/appveyor.yml index 091e86583a..8027aee166 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ build_script: - call ci\build.bat cache: - C:\msys64\var\cache\pacman\pkg -> ci\build.bat -- .deps -> third-party/CMakeLists.txt +- .deps -> third-party/** artifacts: - path: build/Neovim.zip - path: build/bin/nvim.exe diff --git a/busted/outputHandlers/nvim.lua b/busted/outputHandlers/nvim.lua new file mode 100644 index 0000000000..b612ead070 --- /dev/null +++ b/busted/outputHandlers/nvim.lua @@ -0,0 +1,305 @@ +local s = require 'say' +local pretty = require 'pl.pretty' +local term = require 'term' + +local colors + +local isWindows = package.config:sub(1,1) == '\\' + +if isWindows then + colors = setmetatable({}, {__index = function() return function(s) return s end end}) +else + colors = require 'term.colors' +end + +return function(options) + local busted = require 'busted' + local handler = require 'busted.outputHandlers.base'() + + local c = { + succ = function(s) return colors.bright(colors.green(s)) end, + skip = function(s) return colors.bright(colors.yellow(s)) end, + fail = function(s) return colors.bright(colors.magenta(s)) end, + errr = function(s) return colors.bright(colors.red(s)) end, + test = tostring, + file = colors.cyan, + time = colors.dim, + note = colors.yellow, + sect = function(s) return colors.green(colors.dim(s)) end, + nmbr = colors.bright, + } + + local repeatSuiteString = '\nRepeating all tests (run %d of %d) . . .\n\n' + local randomizeString = c.note('Note: Randomizing test order with a seed of %d.\n') + local globalSetup = c.sect('[----------]') .. ' Global test environment setup.\n' + local fileStartString = c.sect('[----------]') .. ' Running tests from ' .. c.file('%s') .. '\n' + local runString = c.sect('[ RUN ]') .. ' ' .. c.test('%s') .. ': ' + local successString = c.succ('OK') .. '\n' + local skippedString = c.skip('SKIP') .. '\n' + local failureString = c.fail('FAIL') .. '\n' + local errorString = c.errr('ERR') .. '\n' + local fileEndString = c.sect('[----------]') .. ' '.. c.nmbr('%d') .. ' %s from ' .. c.file('%s') .. ' ' .. c.time('(%.2f ms total)') .. '\n\n' + local globalTeardown = c.sect('[----------]') .. ' Global test environment teardown.\n' + local suiteEndString = c.sect('[==========]') .. ' ' .. c.nmbr('%d') .. ' %s from ' .. c.nmbr('%d') .. ' test %s ran. ' .. c.time('(%.2f ms total)') .. '\n' + local successStatus = c.succ('[ PASSED ]') .. ' ' .. c.nmbr('%d') .. ' %s.\n' + local timeString = c.time('%.2f ms') + + local summaryStrings = { + skipped = { + header = c.skip('[ SKIPPED ]') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n', + test = c.skip('[ SKIPPED ]') .. ' %s\n', + footer = ' ' .. c.nmbr('%d') .. ' SKIPPED %s\n', + }, + + failure = { + header = c.fail('[ FAILED ]') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n', + test = c.fail('[ FAILED ]') .. ' %s\n', + footer = ' ' .. c.nmbr('%d') .. ' FAILED %s\n', + }, + + error = { + header = c.errr('[ ERROR ]') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n', + test = c.errr('[ ERROR ]') .. ' %s\n', + footer = ' ' .. c.nmbr('%d') .. ' %s\n', + }, + } + + c = nil + + local fileCount = 0 + local fileTestCount = 0 + local testCount = 0 + local successCount = 0 + local skippedCount = 0 + local failureCount = 0 + local errorCount = 0 + + local pendingDescription = function(pending) + local name = pending.name + local string = '' + + if type(pending.message) == 'string' then + string = string .. pending.message .. '\n' + elseif pending.message ~= nil then + string = string .. pretty.write(pending.message) .. '\n' + end + + return string + end + + local failureDescription = function(failure) + local string = failure.randomseed and ('Random seed: ' .. failure.randomseed .. '\n') or '' + if type(failure.message) == 'string' then + string = string .. failure.message + elseif failure.message == nil then + string = string .. 'Nil error' + else + string = string .. pretty.write(failure.message) + end + + string = string .. '\n' + + if options.verbose and failure.trace and failure.trace.traceback then + string = string .. failure.trace.traceback .. '\n' + end + + return string + end + + local getFileLine = function(element) + local fileline = '' + if element.trace or element.trace.short_src then + fileline = colors.cyan(element.trace.short_src) .. ' @ ' .. + colors.cyan(element.trace.currentline) .. ': ' + end + return fileline + end + + local getTestList = function(status, count, list, getDescription) + local string = '' + local header = summaryStrings[status].header + if count > 0 and header then + local tests = (count == 1 and 'test' or 'tests') + local errors = (count == 1 and 'error' or 'errors') + string = header:format(count, status == 'error' and errors or tests) + + local testString = summaryStrings[status].test + if testString then + for _, t in ipairs(list) do + local fullname = getFileLine(t.element) .. colors.bright(t.name) + string = string .. testString:format(fullname) + string = string .. getDescription(t) + end + end + end + return string + end + + local getSummary = function(status, count) + local string = '' + local footer = summaryStrings[status].footer + if count > 0 and footer then + local tests = (count == 1 and 'TEST' or 'TESTS') + local errors = (count == 1 and 'ERROR' or 'ERRORS') + string = footer:format(count, status == 'error' and errors or tests) + end + return string + end + + local getSummaryString = function() + local tests = (successCount == 1 and 'test' or 'tests') + local string = successStatus:format(successCount, tests) + + string = string .. getTestList('skipped', skippedCount, handler.pendings, pendingDescription) + string = string .. getTestList('failure', failureCount, handler.failures, failureDescription) + string = string .. getTestList('error', errorCount, handler.errors, failureDescription) + + string = string .. ((skippedCount + failureCount + errorCount) > 0 and '\n' or '') + string = string .. getSummary('skipped', skippedCount) + string = string .. getSummary('failure', failureCount) + string = string .. getSummary('error', errorCount) + + return string + end + + handler.suiteReset = function() + fileCount = 0 + fileTestCount = 0 + testCount = 0 + successCount = 0 + skippedCount = 0 + failureCount = 0 + errorCount = 0 + + return nil, true + end + + handler.suiteStart = function(suite, count, total, randomseed) + if total > 1 then + io.write(repeatSuiteString:format(count, total)) + end + if randomseed then + io.write(randomizeString:format(randomseed)) + end + io.write(globalSetup) + io.flush() + + return nil, true + end + + local function getElapsedTime(tbl) + if tbl.duration then + return tbl.duration * 1000 + else + return tonumber('nan') + end + end + + handler.suiteEnd = function(suite, count, total) + local elapsedTime_ms = getElapsedTime(suite) + local tests = (testCount == 1 and 'test' or 'tests') + local files = (fileCount == 1 and 'file' or 'files') + io.write(globalTeardown) + io.write(suiteEndString:format(testCount, tests, fileCount, files, elapsedTime_ms)) + io.write(getSummaryString()) + io.flush() + + return nil, true + end + + handler.fileStart = function(file) + fileTestCount = 0 + io.write(fileStartString:format(file.name)) + io.flush() + return nil, true + end + + handler.fileEnd = function(file) + local elapsedTime_ms = getElapsedTime(file) + local tests = (fileTestCount == 1 and 'test' or 'tests') + fileCount = fileCount + 1 + io.write(fileEndString:format(fileTestCount, tests, file.name, elapsedTime_ms)) + io.flush() + return nil, true + end + + handler.testStart = function(element, parent) + io.write(runString:format(handler.getFullName(element))) + io.flush() + + return nil, true + end + + handler.testEnd = function(element, parent, status, debug) + local elapsedTime_ms = getElapsedTime(element) + local string + + fileTestCount = fileTestCount + 1 + testCount = testCount + 1 + if status == 'success' then + successCount = successCount + 1 + string = successString + elseif status == 'pending' then + skippedCount = skippedCount + 1 + string = skippedString + elseif status == 'failure' then + failureCount = failureCount + 1 + string = nil + elseif status == 'error' then + errorCount = errorCount + 1 + string = nil + end + + if string ~= nil then + if elapsedTime_ms == elapsedTime_ms then + string = timeString:format(elapsedTime_ms) .. ' ' .. string + end + io.write(string) + io.flush() + end + + return nil, true + end + + handler.testFailure = function(element, parent, message, debug) + io.write(failureString) + io.flush() + + io.write(failureDescription(handler.failures[#handler.failures])) + io.flush() + return nil, true + end + + handler.testError = function(element, parent, message, debug) + io.write(errorString) + io.flush() + + io.write(failureDescription(handler.errors[#handler.errors])) + io.flush() + return nil, true + end + + handler.error = function(element, parent, message, debug) + if element.descriptor ~= 'it' then + io.write(failureDescription(handler.errors[#handler.errors])) + io.flush() + errorCount = errorCount + 1 + end + + return nil, true + end + + busted.subscribe({ 'suite', 'reset' }, handler.suiteReset) + busted.subscribe({ 'suite', 'start' }, handler.suiteStart) + busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) + busted.subscribe({ 'file', 'start' }, handler.fileStart) + busted.subscribe({ 'file', 'end' }, handler.fileEnd) + busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'failure', 'it' }, handler.testFailure) + busted.subscribe({ 'error', 'it' }, handler.testError) + busted.subscribe({ 'failure' }, handler.error) + busted.subscribe({ 'error' }, handler.error) + + return handler +end diff --git a/ci/before_cache.sh b/ci/before_cache.sh index dd1fcf2bf7..3d7cc0ec5a 100755 --- a/ci/before_cache.sh +++ b/ci/before_cache.sh @@ -3,12 +3,15 @@ set -e set -o pipefail +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${CI_DIR}/common/suite.sh" + # Don't cache pip's log and selfcheck. rm -rf "${HOME}/.cache/pip/log" rm -f "${HOME}/.cache/pip/selfcheck.json" # Update the third-party dependency cache only if the build was successful. -if [[ -f "${SUCCESS_MARKER}" ]]; then +if ended_successfully; then rm -rf "${HOME}/.cache/nvim-deps" mv "${DEPS_BUILD_DIR}" "${HOME}/.cache/nvim-deps" touch "${CACHE_MARKER}" diff --git a/ci/build.bat b/ci/build.bat index 87a171b994..9071c0864e 100644 --- a/ci/build.bat +++ b/ci/build.bat @@ -38,7 +38,7 @@ cd .. :: Build Neovim mkdir build cd build -cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUSTED_OUTPUT_TYPE=gtest -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error +cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUSTED_OUTPUT_TYPE=nvim -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error mingw32-make VERBOSE=1 || goto :error bin\nvim --version || goto :error diff --git a/ci/common/suite.sh b/ci/common/suite.sh index 46207754fa..568d5d5bee 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -2,11 +2,18 @@ NL="$(printf '\nE')" NL="${NL%E}" -FAILED=0 - FAIL_SUMMARY="" +# 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" + enter_suite() { + FAILED=0 + rm -f "${END_MARKER}" local suite_name="$1" export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE}/$suite_name" } @@ -19,17 +26,16 @@ exit_suite() { export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE%/*}" if test "x$1" != "x--continue" ; then exit $FAILED + else + local saved_failed=$FAILED + FAILED=0 + return $saved_failed fi } fail() { - local allow_failure= - if test "x$1" = "x--allow-failure" ; then - shift - allow_failure=A - fi local test_name="$1" - local fail_char="$allow_failure$2" + local fail_char="$2" local message="$3" : ${fail_char:=F} @@ -37,10 +43,9 @@ fail() { local full_msg="$fail_char $NVIM_TEST_CURRENT_SUITE|$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" + echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" - if test "x$allow_failure" = "x" ; then - FAILED=1 - fi + FAILED=1 } run_test() { @@ -55,6 +60,12 @@ run_test() { } run_test_wd() { + local hang_ok= + if test "x$1" = "x--allow-hang" ; then + hang_ok=1 + shift + fi + local timeout="$1" test $# -gt 0 && shift @@ -77,14 +88,13 @@ run_test_wd() { while test $restarts -gt 0 ; do : > "${status_file}" ( - FAILED=0 - if ! ( - set -o pipefail - eval "$cmd" 2>&1 | tee -a "$output_file" - ) ; then - fail "${test_name}" "$@" + set -o pipefail + ret=0 + if ! eval "$cmd" 2>&1 | tee -a "$output_file" ; then + ret=1 fi - echo "$FAILED" > "$status_file" + echo "$ret" > "$status_file" + exit $ret ) & local pid=$! while test "$(stat -c "%s" "$status_file")" -eq 0 ; do @@ -101,7 +111,9 @@ run_test_wd() { # status file not updated, assuming hang kill -KILL $pid if test $restarts -eq 0 ; then - fail "${test_name}" E "Test hang up" + if test "x$hang_ok" = "x" ; then + fail "${test_name}" E "Test hang up" + fi else echo "Test ${test_name} hang up, restarting" eval "$restart_cmd" @@ -116,6 +128,20 @@ run_test_wd() { done } -succeeded() { - return $FAILED +ended_successfully() { + if [[ -f "${FAIL_SUMMARY_FILE}" ]]; then + echo 'Test failed, complete summary:' + cat "${FAIL_SUMMARY_FILE}" + return 1 + fi + if ! [[ -f "${END_MARKER}" ]] ; then + echo 'ended_successfully called before end marker was touched' + return 1 + fi + return 0 +} + +end_tests() { + touch "${END_MARKER}" + ended_successfully } diff --git a/ci/common/test.sh b/ci/common/test.sh index 4936992cfd..d911d9bc18 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -1,4 +1,5 @@ source "${CI_DIR}/common/build.sh" +source "${CI_DIR}/common/suite.sh" print_core() { local app="$1" @@ -40,10 +41,9 @@ check_core_dumps() { print_core "$app" "$core" fi done - if test "$app" = quiet ; then - return 0 + if test "$app" != quiet ; then + fail 'cores' E 'Core dumps found' fi - exit 1 } check_logs() { @@ -62,8 +62,7 @@ check_logs() { err=1 done if [[ -n "${err}" ]]; then - echo "Runtime errors detected." - exit 1 + fail 'logs' E 'Runtime errors detected.' fi } @@ -75,50 +74,53 @@ asan_check() { check_logs "${1}" "*san.*" } -run_unittests() { +run_unittests() {( + enter_suite unittests ulimit -c unlimited if ! build_make unittest ; then - check_core_dumps "$(which luajit)" - exit 1 + fail 'unittests' F 'Unit tests failed' fi check_core_dumps "$(which luajit)" -} + exit_suite +)} -run_functionaltests() { +run_functionaltests() {( + enter_suite functionaltests ulimit -c unlimited if ! build_make ${FUNCTIONALTEST}; then - asan_check "${LOG_DIR}" - valgrind_check "${LOG_DIR}" - check_core_dumps - exit 1 + fail 'functionaltests' F 'Functional tests failed' fi asan_check "${LOG_DIR}" valgrind_check "${LOG_DIR}" check_core_dumps -} + exit_suite +)} -run_oldtests() { +run_oldtests() {( + enter_suite oldtests ulimit -c unlimited if ! make -C "${TRAVIS_BUILD_DIR}/src/nvim/testdir"; then reset - asan_check "${LOG_DIR}" - valgrind_check "${LOG_DIR}" - check_core_dumps - exit 1 + fail 'oldtests' F 'Legacy tests failed' fi asan_check "${LOG_DIR}" valgrind_check "${LOG_DIR}" check_core_dumps -} + exit_suite +)} -install_nvim() { - build_make install +install_nvim() {( + enter_suite 'install_nvim' + if ! build_make install ; then + fail 'install' E 'make install failed' + exit_suite + fi "${INSTALL_PREFIX}/bin/nvim" --version "${INSTALL_PREFIX}/bin/nvim" -u NONE -e -c ':help' -c ':qall' || { echo "Running ':help' in the installed nvim failed." echo "Maybe the helptags have not been generated properly." - exit 1 + fail 'help' F 'Failed running :help' } local genvimsynf=syntax/vim/generated.vim @@ -127,24 +129,22 @@ install_nvim() { cd runtime ; git ls-files | grep -e '.vim$' -e '.ps$' -e '.dict$' -e '.py$' -e '.tutor$' ) ; do if ! test -e "${INSTALL_PREFIX}/share/nvim/runtime/$file" ; then - echo "It appears that $file is not installed." - exit 1 + fail 'runtime-install' F "It appears that $file is not installed." fi done # Check that generated syntax file has function names, #5060. local gpat='syn keyword vimFuncName .*eval' if ! grep -q "$gpat" "${INSTALL_PREFIX}/share/nvim/runtime/$genvimsynf"; then - echo "It appears that $genvimsynf does not contain $gpat." - exit 1 + fail 'funcnames' F "It appears that $genvimsynf does not contain $gpat." fi for file in $( cd runtime ; git ls-files | grep -e '.awk$' -e '.sh$' -e '.bat$' ) ; do if ! test -x "${INSTALL_PREFIX}/share/nvim/runtime/$file" ; then - echo "It appears that $file is not installed or is not executable." - exit 1 + fail 'not-exe' F "It appears that $file is not installed or is not executable." fi done -} + exit_suite +)} diff --git a/ci/run_lint.sh b/ci/run_lint.sh index 39a90102e7..5639b4c3db 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -20,9 +20,10 @@ csi_clean() { run_test 'top_make clint-full' clint run_test 'top_make testlint' testlint CLICOLOR_FORCE=1 run_test_wd \ - 5s \ + --allow-hang \ + 10s \ 'top_make check-single-includes' \ 'csi_clean' \ single-includes -exit_suite +end_tests diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 92cb5a9fd8..4abc9eea9f 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -27,8 +27,4 @@ run_test run_oldtests run_test install_nvim -if succeeded ; then - touch "${SUCCESS_MARKER}" -fi - -exit_suite +end_tests diff --git a/cmake/InstallClintErrors.cmake b/cmake/InstallClintErrors.cmake new file mode 100644 index 0000000000..bd5ca07828 --- /dev/null +++ b/cmake/InstallClintErrors.cmake @@ -0,0 +1,2 @@ +file(GLOB_RECURSE JSON_FILES *.json) +file(COPY ${JSON_FILES} DESTINATION "${TARGET}") diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 5b85377a31..5540c993f6 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2292,7 +2292,7 @@ tabpagebuflist([{arg}]) List list of buffer numbers in tab page tabpagenr([{arg}]) Number number of current or last tab page tabpagewinnr({tabarg}[, {arg}]) Number number of current window in tab page -taglist({expr}) List list of tags matching {expr} +taglist({expr}[, {filename}]) List list of tags matching {expr} tagfiles() List tags files used tan({expr}) Float tangent of {expr} tanh({expr}) Float hyperbolic tangent of {expr} @@ -4945,8 +4945,8 @@ json_decode({expr}) *json_decode()* json_encode({expr}) *json_encode()* Convert {expr} into a JSON string. Accepts - |msgpack-special-dict| as the input. Will not convert |Funcref|s, - mappings with non-string keys (can be created as + |msgpack-special-dict| as the input. Will not convert + |Funcref|s, mappings with non-string keys (can be created as |msgpack-special-dict|), values with self-referencing containers, strings which contain non-UTF-8 characters, pseudo-UTF-8 strings which contain codepoints reserved for @@ -7431,8 +7431,13 @@ tagfiles() Returns a |List| with the file names used to search for tags for the current buffer. This is the 'tags' option expanded. -taglist({expr}) *taglist()* +taglist({expr}[, {filename}]) *taglist()* Returns a list of tags matching the regular expression {expr}. + + If {filename} is passed it is used to prioritize the results + in the same way that |:tselect| does. See |tag-priority|. + {filename} should be the full path of the file. + Each list item is a dictionary with at least the following entries: name Name of the tag. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d212e029aa..c30a88f48d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5151,8 +5151,8 @@ A jump table for the options with a short description can be found at |Q_op|. saved. When not included, the value of 'history' is used. *shada-c* c Dummy option, kept for compatibility reasons. Has no actual - effect. Current encoding state is described in - |shada-encoding|. + effect: ShaDa always uses UTF-8 and 'encoding' value is fixed + to UTF-8 as well. *shada-f* f Whether file marks need to be stored. If zero, file marks ('0 to '9, 'A to 'Z) are not stored. When not present or when diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index daf6ad9ca2..2d1dd22222 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1097,23 +1097,6 @@ SHADA FILE NAME *shada-file-name* default and the name given with 'shada' or "-i" (unless it's NONE). -CHARACTER ENCODING *shada-encoding* - -The text in the ShaDa file is UTF-8-encoded. Normally you will always work -with the same 'encoding' value, and this works just fine. However, if you -read the ShaDa file with value for 'encoding' different from utf-8 and -'encoding' used when writing ShaDa file, some of the text (non-ASCII -characters) may be invalid as Neovim always attempts to convert the text in -the ShaDa file from the UTF-8 to the current 'encoding' value. Filenames are -never converted, affected elements are: - -- history strings; -- variable values; -- register values; -- last used search and substitute patterns; -- last used substitute replacement string. - - MANUALLY READING AND WRITING *shada-read-write* Two commands can be used to read and write the ShaDa file manually. This @@ -1221,8 +1204,11 @@ exactly four MessagePack objects: 3. Third goes the length of the fourth entry. Unsigned integer as well, used for fast skipping without parsing. 4. Fourth is actual entry data. All currently used ShaDa entries use - containers to hold data: either map or array. Exact format depends on the - entry type: + containers to hold data: either map or array. All string values in those + containers are either binary (applies to filenames) or UTF-8, yet parser + needs to expect that invalid bytes may be present in a UTF-8 string. + + Exact format depends on the entry type: Entry type (name) Entry data ~ 1 (Header) Map containing data that describes the generator diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index e87f0d68aa..cec9a09141 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -42,7 +42,10 @@ set(LINT_SUPPRESS_URL "${LINT_SUPPRESS_URL_BASE}/errors.json") set(LINT_PRG ${PROJECT_SOURCE_DIR}/src/clint.py) set(DOWNLOAD_SCRIPT ${PROJECT_SOURCE_DIR}/cmake/Download.cmake) set(LINT_SUPPRESSES_ROOT ${PROJECT_BINARY_DIR}/errors) -set(LINT_SUPPRESSES_URL "https://raw.githubusercontent.com/neovim/doc/gh-pages/reports/clint/errors.tar.gz") +set(LINT_SUPPRESSES_URL "${LINT_SUPPRESS_URL_BASE}/errors.tar.gz") +set(LINT_SUPPRESSES_ARCHIVE ${LINT_SUPPRESSES_ROOT}/errors.tar.gz) +set(LINT_SUPPRESSES_TOUCH_FILE "${TOUCHES_DIR}/unpacked-clint-errors-archive") +set(LINT_SUPPRESSES_INSTALL_SCRIPT "${PROJECT_SOURCE_DIR}/cmake/InstallClintErrors.cmake") file(GLOB UNICODE_FILES ${UNICODE_DIR}/*.txt) file(GLOB API_HEADERS api/*.h) @@ -55,6 +58,8 @@ include_directories(${GENERATED_INCLUDES_DIR}) file(MAKE_DIRECTORY ${TOUCHES_DIR}) file(MAKE_DIRECTORY ${GENERATED_DIR}) file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}) +file(MAKE_DIRECTORY ${LINT_SUPPRESSES_ROOT}) +file(MAKE_DIRECTORY ${LINT_SUPPRESSES_ROOT}/src) file(GLOB NVIM_SOURCES *.c) file(GLOB NVIM_HEADERS *.h) @@ -495,26 +500,10 @@ function(get_test_target prefix sfile relative_path_var target_var) endfunction() set(NO_SINGLE_CHECK_HEADERS - cursor_shape.h - digraph.h - ex_cmds.h - ex_getln.h - file_search.h - fold.h getchar.h - hardcopy.h - if_cscope.h if_cscope_defs.h - mark.h - mbyte.h - memfile_defs.h - memline.h - memline_defs.h - menu.h misc2.h - move.h msgpack_rpc/server.h - ops.h option.h os/shell.h os_unix.h @@ -573,6 +562,21 @@ function(add_download output url allow_failure) ) endfunction() +add_download(${LINT_SUPPRESSES_ARCHIVE} ${LINT_SUPPRESSES_URL} off) + +add_custom_command( + OUTPUT ${LINT_SUPPRESSES_TOUCH_FILE} + WORKING_DIRECTORY ${LINT_SUPPRESSES_ROOT}/src + COMMAND ${CMAKE_COMMAND} -E tar xfz ${LINT_SUPPRESSES_ARCHIVE} + COMMAND + ${CMAKE_COMMAND} + -DTARGET=${LINT_SUPPRESSES_ROOT} + -P ${LINT_SUPPRESSES_INSTALL_SCRIPT} + COMMAND ${CMAKE_COMMAND} -E touch ${LINT_SUPPRESSES_TOUCH_FILE} + DEPENDS + ${LINT_SUPPRESSES_ARCHIVE} ${LINT_SUPPRESSES_INSTALL_SCRIPT} +) + add_download(${LINT_SUPPRESS_FILE} ${LINT_SUPPRESS_URL} off) set(LINT_NVIM_REL_SOURCES) @@ -581,14 +585,13 @@ foreach(sfile ${LINT_NVIM_SOURCES}) set(suppress_file ${LINT_SUPPRESSES_ROOT}/${suffix}.json) set(suppress_url "${LINT_SUPPRESS_URL_BASE}/${suffix}.json") set(rsfile src/nvim/${r}) - add_download(${suppress_file} ${suppress_url} on) set(touch_file "${TOUCHES_DIR}/ran-clint-${suffix}") add_custom_command( OUTPUT ${touch_file} COMMAND ${LINT_PRG} --suppress-errors=${suppress_file} ${rsfile} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${CMAKE_COMMAND} -E touch ${touch_file} - DEPENDS ${LINT_PRG} ${sfile} ${suppress_file} + DEPENDS ${LINT_PRG} ${sfile} ${LINT_SUPPRESSES_TOUCH_FILE} ) list(APPEND LINT_TARGETS ${touch_file}) list(APPEND LINT_NVIM_REL_SOURCES ${rsfile}) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 99d3e2dd88..645139f696 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -212,8 +212,8 @@ int buf_init_chartab(buf_T *buf, int global) // work properly when 'encoding' is "latin1" and the locale is // "C". if (!do_isalpha - || vim_islower(c) - || vim_isupper(c) + || mb_islower(c) + || mb_isupper(c) || (p_altkeymap && (F_isalpha(c) || F_isdigit(c)))) { if (i == 0) { // (re)set ID flag @@ -417,11 +417,11 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen) while (STR_CHAR(i) != NUL) { int c = utf_ptr2char(STR_PTR(i)); int olen = utf_ptr2len(STR_PTR(i)); - int lc = utf_tolower(c); + int lc = mb_tolower(c); // Only replace the character when it is not an invalid // sequence (ASCII character or more than one byte) and - // utf_tolower() doesn't return the original character. + // mb_tolower() doesn't return the original character. if (((c < 0x80) || (olen > 1)) && (c != lc)) { int nlen = utf_char2len(lc); @@ -1506,67 +1506,6 @@ char_u* skiptohex(char_u *q) return p; } -// Vim's own character class functions. These exist because many library -// islower()/toupper() etc. do not work properly: they crash when used with -// invalid values or can't handle latin1 when the locale is C. -// Speed is most important here. - -/// Check that the character is lower-case -/// -/// @param c character to check -bool vim_islower(int c) - FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT -{ - if (c <= '@') { - return false; - } - - if (c >= 0x80) { - return utf_islower(c); - } - return islower(c); -} - -/// Check that the character is upper-case -/// -/// @param c character to check -bool vim_isupper(int c) - FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT -{ - if (c <= '@') { - return false; - } - - if (c >= 0x80) { - return utf_isupper(c); - } - return isupper(c); -} - -int vim_toupper(int c) -{ - if (c <= '@') { - return c; - } - - if (c >= 0x80) { - return utf_toupper(c); - } - return TOUPPER_LOC(c); -} - -int vim_tolower(int c) -{ - if (c <= '@') { - return c; - } - - if (c >= 0x80) { - return utf_tolower(c); - } - return TOLOWER_LOC(c); -} - /// Skip over text until ' ' or '\t' or NUL /// /// @param[in] p Text to skip over. diff --git a/src/nvim/cursor_shape.h b/src/nvim/cursor_shape.h index 0006ede31d..7cf65cba3c 100644 --- a/src/nvim/cursor_shape.h +++ b/src/nvim/cursor_shape.h @@ -1,6 +1,9 @@ #ifndef NVIM_CURSOR_SHAPE_H #define NVIM_CURSOR_SHAPE_H +#include "nvim/types.h" +#include "nvim/api/private/defs.h" + /// struct to store values from 'guicursor' and 'mouseshape' /// Indexes in shape_table[] typedef enum { diff --git a/src/nvim/digraph.h b/src/nvim/digraph.h index b623969e08..1b73ccaf3f 100644 --- a/src/nvim/digraph.h +++ b/src/nvim/digraph.h @@ -1,6 +1,9 @@ #ifndef NVIM_DIGRAPH_H #define NVIM_DIGRAPH_H +#include "nvim/types.h" +#include "nvim/ex_cmds_defs.h" + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "digraph.h.generated.h" #endif diff --git a/src/nvim/edit.c b/src/nvim/edit.c index b35504908e..fe00027dec 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2037,12 +2037,12 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int } else { c = *(p++); } - if (vim_islower(c)) { + if (mb_islower(c)) { has_lower = true; - if (vim_isupper(wca[i])) { + if (mb_isupper(wca[i])) { // Rule 1 is satisfied. for (i = actual_compl_length; i < actual_len; i++) { - wca[i] = vim_tolower(wca[i]); + wca[i] = mb_tolower(wca[i]); } break; } @@ -2062,14 +2062,14 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int } else { c = *(p++); } - if (was_letter && vim_isupper(c) && vim_islower(wca[i])) { + if (was_letter && mb_isupper(c) && mb_islower(wca[i])) { // Rule 2 is satisfied. for (i = actual_compl_length; i < actual_len; i++) { - wca[i] = vim_toupper(wca[i]); + wca[i] = mb_toupper(wca[i]); } break; } - was_letter = vim_islower(c) || vim_isupper(c); + was_letter = mb_islower(c) || mb_isupper(c); } } @@ -2082,10 +2082,10 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int } else { c = *(p++); } - if (vim_islower(c)) { - wca[i] = vim_tolower(wca[i]); - } else if (vim_isupper(c)) { - wca[i] = vim_toupper(wca[i]); + if (mb_islower(c)) { + wca[i] = mb_tolower(wca[i]); + } else if (mb_isupper(c)) { + wca[i] = mb_toupper(wca[i]); } } } @@ -2302,9 +2302,10 @@ static void ins_compl_longest_match(compl_T *match) c1 = *p; c2 = *s; } - if (match->cp_icase ? (vim_tolower(c1) != vim_tolower(c2)) - : (c1 != c2)) + if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2)) + : (c1 != c2)) { break; + } if (has_mbyte) { mb_ptr_adv(p); mb_ptr_adv(s); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2002554b0b..75cd100061 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8729,10 +8729,10 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr) } fold_count = foldedCount(curwin, lnum, &foldinfo); if (fold_count > 0) { - text = get_foldtext(curwin, lnum, lnum + fold_count - 1, - &foldinfo, buf); - if (text == buf) + text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf); + if (text == buf) { text = vim_strsave(text); + } rettv->vval.v_string = text; } } @@ -16451,7 +16451,12 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - (void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern); + const char *fname = NULL; + if (argvars[1].v_type != VAR_UNKNOWN) { + fname = tv_get_string(&argvars[1]); + } + (void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern, + (char_u *)fname); } /* @@ -16801,30 +16806,9 @@ void timer_teardown(void) */ static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - char_u *p = (char_u *)xstrdup(tv_get_string(&argvars[0])); rettv->v_type = VAR_STRING; - rettv->vval.v_string = p; - - while (*p != NUL) { - int l; - - if (enc_utf8) { - int c, lc; - - c = utf_ptr2char(p); - lc = utf_tolower(c); - l = utf_ptr2len(p); - /* TODO: reallocate string when byte count changes. */ - if (utf_char2len(lc) == l) - utf_char2bytes(lc, p); - p += l; - } else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) - p += l; /* skip multi-byte character */ - else { - *p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */ - ++p; - } - } + rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), + false); } /* @@ -16833,7 +16817,8 @@ static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_toupper(typval_T *argvars, typval_T *rettv, FunPtr fptr) { rettv->v_type = VAR_STRING; - rettv->vval.v_string = (char_u *)strup_save(tv_get_string(&argvars[0])); + rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), + true); } /* diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9db90ce05d..d6a5b2adc2 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -301,7 +301,7 @@ return { tabpagenr={args={0, 1}}, tabpagewinnr={args={1, 2}}, tagfiles={}, - taglist={args=1}, + taglist={args={1, 2}}, tan={args=1, func="float_op_wrapper", data="&tan"}, tanh={args=1, func="float_op_wrapper", data="&tanh"}, tempname={}, diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 939d75608c..86fa2c7ad5 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -295,8 +295,6 @@ typval_T decode_string(const char *const s, const size_t len, /// Parse JSON double-quoted string /// -/// @param[in] conv Defines conversion necessary to convert UTF-8 string to -/// &encoding. /// @param[in] buf Buffer being converted. /// @param[in] buf_len Length of the buffer. /// @param[in,out] pp Pointer to the start of the string. Must point to '"'. @@ -313,8 +311,7 @@ typval_T decode_string(const char *const s, const size_t len, /// value when decoder is restarted, otherwise unused. /// /// @return OK in case of success, FAIL in case of error. -static inline int parse_json_string(vimconv_T *const conv, - const char *const buf, const size_t buf_len, +static inline int parse_json_string(const char *const buf, const size_t buf_len, const char **const pp, ValuesStack *const stack, ContainerStack *const container_stack, @@ -489,20 +486,6 @@ static inline int parse_json_string(vimconv_T *const conv, } PUT_FST_IN_PAIR(fst_in_pair, str_end); #undef PUT_FST_IN_PAIR - if (conv->vc_type != CONV_NONE) { - size_t str_len = (size_t) (str_end - str); - char *const new_str = (char *) string_convert(conv, (char_u *) str, - &str_len); - if (new_str == NULL) { - emsgf(_("E474: Failed to convert string \"%.*s\" from UTF-8"), - (int) str_len, str); - xfree(str); - goto parse_json_string_fail; - } - xfree(str); - str = new_str; - str_end = new_str + str_len; - } *str_end = NUL; typval_T obj = decode_string( str, (size_t)(str_end - str), hasnul ? kTrue : kFalse, false, true); @@ -683,9 +666,6 @@ int json_decode_string(const char *const buf, const size_t buf_len, EMSG(_("E474: Attempt to decode a blank string")); return FAIL; } - vimconv_T conv = { .vc_type = CONV_NONE }; - convert_setup(&conv, (char_u *) "utf-8", p_enc); - conv.vc_fail = true; int ret = OK; ValuesStack stack = KV_INITIAL_VALUE; ContainerStack container_stack = KV_INITIAL_VALUE; @@ -831,7 +811,7 @@ json_decode_string_cycle_start: break; } case '"': { - if (parse_json_string(&conv, buf, buf_len, &p, &stack, &container_stack, + if (parse_json_string(buf, buf_len, &p, &stack, &container_stack, &next_map_special, &didcomma, &didcolon) == FAIL) { // Error message was already given diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 26f9aaa27d..d74913a481 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -11,7 +11,7 @@ #include <math.h> #include "nvim/eval/encode.h" -#include "nvim/buffer_defs.h" // vimconv_T +#include "nvim/buffer_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/garray.h" @@ -29,10 +29,6 @@ #define utf_ptr2char(b) utf_ptr2char((char_u *)b) #define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b)) #define utf_char2len(b) ((size_t)utf_char2len(b)) -#define string_convert(a, b, c) \ - ((char *)string_convert((vimconv_T *)a, (char_u *)b, c)) -#define convert_setup(vcp, from, to) \ - (convert_setup(vcp, (char_u *)from, (char_u *)to)) const char *const encode_special_var_names[] = { [kSpecialVarNull] = "null", @@ -537,17 +533,6 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, } \ } while (0) -/// Last used p_enc value -/// -/// Generic pointer: it is not used as a string, only pointer comparisons are -/// performed. Must not be freed. -static const void *last_p_enc = NULL; - -/// Conversion setup for converting from last_p_enc to UTF-8 -static vimconv_T p_enc_conv = { - .vc_type = CONV_NONE, -}; - /// Escape sequences used in JSON static const char escapes[][3] = { [BS] = "\\b", @@ -579,33 +564,15 @@ static inline int convert_to_json_string(garray_T *const gap, } else { size_t utf_len = len; char *tofree = NULL; - if (last_p_enc != (const void *) p_enc) { - p_enc_conv.vc_type = CONV_NONE; - convert_setup(&p_enc_conv, p_enc, "utf-8"); - p_enc_conv.vc_fail = true; - last_p_enc = p_enc; - } - if (p_enc_conv.vc_type != CONV_NONE) { - tofree = string_convert(&p_enc_conv, buf, &utf_len); - if (tofree == NULL) { - emsgf(_("E474: Failed to convert string \"%.*s\" to UTF-8"), - utf_len, utf_buf); - return FAIL; - } - utf_buf = tofree; - } size_t str_len = 0; - // Encode character as \u0000 if - // 1. It is an ASCII control character (0x0 .. 0x1F, 0x7F). - // 2. &encoding is not UTF-8 and code point is above 0x7F. - // 3. &encoding is UTF-8 and code point is not printable according to - // utf_printable(). - // This is done to make it possible to :echo values when &encoding is not - // UTF-8. -#define ENCODE_RAW(p_enc_conv, ch) \ - (ch >= 0x20 && (p_enc_conv.vc_type == CONV_NONE \ - ? utf_printable(ch) \ - : ch < 0x7F)) + // Encode character as \uNNNN if + // 1. It is an ASCII control character (0x0 .. 0x1F; 0x7F not + // utf_printable and thus not checked specially). + // 2. Code point is not printable according to utf_printable(). + // This is done to make resulting values displayable on screen also not from + // Neovim. +#define ENCODE_RAW(ch) \ + (ch >= 0x20 && utf_printable(ch)) for (size_t i = 0; i < utf_len;) { const int ch = utf_ptr2char(utf_buf + i); const size_t shift = (ch == 0? 1: utf_ptr2len(utf_buf + i)); @@ -636,7 +603,7 @@ static inline int convert_to_json_string(garray_T *const gap, utf_len - (i - shift), utf_buf + i - shift); xfree(tofree); return FAIL; - } else if (ENCODE_RAW(p_enc_conv, ch)) { + } else if (ENCODE_RAW(ch)) { str_len += shift; } else { str_len += ((sizeof("\\u1234") - 1) @@ -666,7 +633,7 @@ static inline int convert_to_json_string(garray_T *const gap, break; } default: { - if (ENCODE_RAW(p_enc_conv, ch)) { + if (ENCODE_RAW(ch)) { ga_concat_len(gap, utf_buf + i, shift); } else if (ch < SURROGATE_FIRST_CHAR) { ga_concat_len(gap, ((const char[]) { diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h index 65bbd8a99e..b564cde56c 100644 --- a/src/nvim/ex_cmds.h +++ b/src/nvim/ex_cmds.h @@ -6,6 +6,8 @@ #include "nvim/os/time.h" #include "nvim/pos.h" #include "nvim/eval/typval.h" +#include "nvim/buffer_defs.h" +#include "nvim/ex_cmds_defs.h" // flags for do_ecmd() #define ECMD_HIDE 0x01 // don't free the current buffer diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6d23ba9913..aab99e50d3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1231,7 +1231,7 @@ static int command_line_handle_key(CommandLineState *s) // command line has no uppercase characters, convert // the character to lowercase if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff)) { - s->c = vim_tolower(s->c); + s->c = mb_tolower(s->c); } if (s->c != NUL) { @@ -3018,7 +3018,7 @@ ExpandOne ( || xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_BUFFERS)) { - if (vim_tolower(c0) != vim_tolower(ci)) { + if (mb_tolower(c0) != mb_tolower(ci)) { break; } } else if (c0 != ci) { diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 5a1ca5213a..051564fbe1 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -3,6 +3,9 @@ #include "nvim/eval/typval.h" #include "nvim/ex_cmds.h" +#include "nvim/ex_cmds_defs.h" +#include "nvim/os/time.h" +#include "nvim/regexp_defs.h" /* Values for nextwild() and ExpandOne(). See ExpandOne() for meaning. */ #define WILD_FREE 1 diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 9592235905..db745bdd15 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1057,7 +1057,7 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) c1 = PTR2CHAR(s1 + i); c2 = PTR2CHAR(s2 + j); - if ((p_fic ? vim_tolower(c1) != vim_tolower(c2) : c1 != c2) + if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) { return false; } diff --git a/src/nvim/file_search.h b/src/nvim/file_search.h index 833a1a05ff..b128029123 100644 --- a/src/nvim/file_search.h +++ b/src/nvim/file_search.h @@ -1,6 +1,11 @@ #ifndef NVIM_FILE_SEARCH_H #define NVIM_FILE_SEARCH_H +#include <stdlib.h> // for size_t + +#include "nvim/types.h" // for char_u +#include "nvim/globals.h" // for CdScope + /* Flags for find_file_*() functions. */ #define FINDFILE_FILE 0 /* only files */ #define FINDFILE_DIR 1 /* only directories */ diff --git a/src/nvim/fold.h b/src/nvim/fold.h index 2ff10c0e91..f35b328fb1 100644 --- a/src/nvim/fold.h +++ b/src/nvim/fold.h @@ -1,7 +1,12 @@ #ifndef NVIM_FOLD_H #define NVIM_FOLD_H +#include <stdio.h> + #include "nvim/pos.h" +#include "nvim/garray.h" +#include "nvim/types.h" +#include "nvim/buffer_defs.h" /* * Info used to pass info about a fold from the fold-detection code to the diff --git a/src/nvim/hardcopy.h b/src/nvim/hardcopy.h index 4ead8dd5d4..a70b20e6f5 100644 --- a/src/nvim/hardcopy.h +++ b/src/nvim/hardcopy.h @@ -2,6 +2,10 @@ #define NVIM_HARDCOPY_H #include <stdint.h> +#include <stdlib.h> // for size_t + +#include "nvim/types.h" // for char_u +#include "nvim/ex_cmds_defs.h" // for exarg_T /* * Structure to hold printing color and font attributes. diff --git a/src/nvim/iconv.h b/src/nvim/iconv.h index bf29b15247..d7234090c4 100644 --- a/src/nvim/iconv.h +++ b/src/nvim/iconv.h @@ -10,9 +10,7 @@ // USE_ICONV, or to put the USE_ICONV definition in config.h.in directly. As // it stands, globals.h needs to be included alongside iconv.h. -#ifdef HAVE_CONFIG_H -# include "auto/config.h" -#endif +#include "auto/config.h" // Use iconv() when it's available, either by linking to the library at // compile time or by loading it at runtime. diff --git a/src/nvim/if_cscope.h b/src/nvim/if_cscope.h index 351d9caef6..e20462576a 100644 --- a/src/nvim/if_cscope.h +++ b/src/nvim/if_cscope.h @@ -1,6 +1,9 @@ #ifndef NVIM_IF_CSCOPE_H #define NVIM_IF_CSCOPE_H +#include "nvim/types.h" // for char_u and expand_T +#include "nvim/ex_cmds_defs.h" // for exarg_T + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "if_cscope.h.generated.h" #endif diff --git a/src/nvim/macros.h b/src/nvim/macros.h index a8df6322cf..22fd48de9d 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -62,7 +62,7 @@ * toupper() and tolower() that use the current locale. * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the * range 0 - 255. toupper()/tolower() on some systems can't handle others. - * Note: It is often better to use vim_tolower() and vim_toupper(), because many + * Note: It is often better to use mb_tolower() and mb_toupper(), because many * toupper() and tolower() implementations only work for ASCII. */ #define TOUPPER_LOC toupper diff --git a/src/nvim/mark.h b/src/nvim/mark.h index efba9708db..c22a102926 100644 --- a/src/nvim/mark.h +++ b/src/nvim/mark.h @@ -8,6 +8,7 @@ #include "nvim/memory.h" #include "nvim/pos.h" #include "nvim/os/time.h" +#include "nvim/ex_cmds_defs.h" // for exarg_T /// Set fmark using given value #define SET_FMARK(fmarkp_, mark_, fnum_) \ diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 460528b85f..b18459a2b5 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1174,11 +1174,14 @@ int utf_fold(int a) return utf_convert(a, foldCase, ARRAY_SIZE(foldCase)); } -/* - * Return the upper-case equivalent of "a", which is a UCS-4 character. Use - * simple case folding. - */ -int utf_toupper(int a) +// Vim's own character class functions. These exist because many library +// islower()/toupper() etc. do not work properly: they crash when used with +// invalid values or can't handle latin1 when the locale is C. +// Speed is most important here. + +/// Return the upper-case equivalent of "a", which is a UCS-4 character. Use +/// simple case folding. +int mb_toupper(int a) { /* If 'casemap' contains "keepascii" use ASCII style toupper(). */ if (a < 128 && (cmp_flags & CMP_KEEPASCII)) @@ -1198,17 +1201,15 @@ int utf_toupper(int a) return utf_convert(a, toUpper, ARRAY_SIZE(toUpper)); } -bool utf_islower(int a) +bool mb_islower(int a) { - /* German sharp s is lower case but has no upper case equivalent. */ - return (utf_toupper(a) != a) || a == 0xdf; + // German sharp s is lower case but has no upper case equivalent. + return (mb_toupper(a) != a) || a == 0xdf; } -/* - * Return the lower-case equivalent of "a", which is a UCS-4 character. Use - * simple case folding. - */ -int utf_tolower(int a) +/// Return the lower-case equivalent of "a", which is a UCS-4 character. Use +/// simple case folding. +int mb_tolower(int a) { /* If 'casemap' contains "keepascii" use ASCII style tolower(). */ if (a < 128 && (cmp_flags & CMP_KEEPASCII)) @@ -1228,9 +1229,9 @@ int utf_tolower(int a) return utf_convert(a, toLower, ARRAY_SIZE(toLower)); } -bool utf_isupper(int a) +bool mb_isupper(int a) { - return utf_tolower(a) != a; + return mb_tolower(a) != a; } static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index 3565202466..ad9e38004c 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -7,6 +7,7 @@ #include "nvim/iconv.h" #include "nvim/func_attr.h" #include "nvim/os/os_defs.h" // For WCHAR, indirect +#include "nvim/types.h" // for char_u /* * Return byte length of character that starts with byte "b". diff --git a/src/nvim/memfile_defs.h b/src/nvim/memfile_defs.h index cc71e1a7ff..b3c2f3564c 100644 --- a/src/nvim/memfile_defs.h +++ b/src/nvim/memfile_defs.h @@ -3,8 +3,10 @@ #include <stdint.h> #include <stdbool.h> +#include <stdlib.h> #include "nvim/types.h" +#include "nvim/pos.h" /// A block number. /// diff --git a/src/nvim/memline.h b/src/nvim/memline.h index f84e86fea0..a239c6a031 100644 --- a/src/nvim/memline.h +++ b/src/nvim/memline.h @@ -2,6 +2,8 @@ #define NVIM_MEMLINE_H #include "nvim/types.h" +#include "nvim/pos.h" // for pos_T, linenr_T, colnr_T +#include "nvim/buffer_defs.h" // for buf_T #ifdef INCLUDE_GENERATED_DECLARATIONS # include "memline.h.generated.h" diff --git a/src/nvim/menu.h b/src/nvim/menu.h index 3266c511b4..a84b7d812e 100644 --- a/src/nvim/menu.h +++ b/src/nvim/menu.h @@ -1,6 +1,11 @@ #ifndef NVIM_MENU_H #define NVIM_MENU_H +#include <stdbool.h> // for bool + +#include "nvim/types.h" // for char_u and expand_T +#include "nvim/ex_cmds_defs.h" // for exarg_T + /* Indices into vimmenu_T->strings[] and vimmenu_T->noremap[] for each mode */ #define MENU_INDEX_INVALID -1 #define MENU_INDEX_NORMAL 0 diff --git a/src/nvim/message.c b/src/nvim/message.c index 1d3609291a..3e4a1e10b6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2730,8 +2730,8 @@ do_dialog ( break; } - /* Make the character lowercase, as chars in "hotkeys" are. */ - c = vim_tolower(c); + // Make the character lowercase, as chars in "hotkeys" are. + c = mb_tolower(c); retval = 1; for (i = 0; hotkeys[i]; ++i) { if (has_mbyte) { @@ -2777,7 +2777,7 @@ copy_char ( if (has_mbyte) { if (lowercase) { - c = vim_tolower((*mb_ptr2char)(from)); + c = mb_tolower((*mb_ptr2char)(from)); return (*mb_char2bytes)(c, to); } else { len = (*mb_ptr2len)(from); diff --git a/src/nvim/move.h b/src/nvim/move.h index 3f3bf70929..00fbcc580f 100644 --- a/src/nvim/move.h +++ b/src/nvim/move.h @@ -2,6 +2,8 @@ #define NVIM_MOVE_H #include <stdbool.h> +#include "nvim/buffer_defs.h" +#include "nvim/pos.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "move.h.generated.h" diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 68ef27222c..f11d6b69b2 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1956,16 +1956,18 @@ int swapchar(int op_type, pos_T *pos) if (enc_dbcs != 0 && c >= 0x100) /* No lower/uppercase letter */ return FALSE; nc = c; - if (vim_islower(c)) { - if (op_type == OP_ROT13) + if (mb_islower(c)) { + if (op_type == OP_ROT13) { nc = ROT13(c, 'a'); - else if (op_type != OP_LOWER) - nc = vim_toupper(c); - } else if (vim_isupper(c)) { - if (op_type == OP_ROT13) + } else if (op_type != OP_LOWER) { + nc = mb_toupper(c); + } + } else if (mb_isupper(c)) { + if (op_type == OP_ROT13) { nc = ROT13(c, 'A'); - else if (op_type != OP_UPPER) - nc = vim_tolower(c); + } else if (op_type != OP_UPPER) { + nc = mb_tolower(c); + } } if (nc != c) { if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) { @@ -3327,10 +3329,11 @@ void ex_display(exarg_T *eap) get_clipboard(name, &yb, true); - if (name == vim_tolower(redir_reg) - || (redir_reg == '"' && yb == y_previous)) - continue; /* do not list register being written to, the - * pointer can be freed */ + if (name == mb_tolower(redir_reg) + || (redir_reg == '"' && yb == y_previous)) { + continue; // do not list register being written to, the + // pointer can be freed + } if (yb->y_array != NULL) { msg_putchar('\n'); diff --git a/src/nvim/ops.h b/src/nvim/ops.h index 13d0142343..a8867e02ea 100644 --- a/src/nvim/ops.h +++ b/src/nvim/ops.h @@ -8,6 +8,8 @@ #include "nvim/types.h" #include "nvim/eval/typval.h" #include "nvim/os/time.h" +#include "nvim/normal.h" // for MotionType and oparg_T +#include "nvim/ex_cmds_defs.h" // for exarg_T typedef int (*Indenter)(void); diff --git a/src/nvim/path.c b/src/nvim/path.c index 6bf42ed2fa..205fc2ed62 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1853,7 +1853,7 @@ int pathcmp(const char *p, const char *q, int maxlen) break; } - if ((p_fic ? vim_toupper(c1) != vim_toupper(c2) : c1 != c2) + if ((p_fic ? mb_toupper(c1) != mb_toupper(c2) : c1 != c2) #ifdef BACKSLASH_IN_FILENAME /* consider '/' and '\\' to be equal */ && !((c1 == '/' && c2 == '\\') @@ -1864,8 +1864,8 @@ int pathcmp(const char *p, const char *q, int maxlen) return -1; if (vim_ispathsep(c2)) return 1; - return p_fic ? vim_toupper(c1) - vim_toupper(c2) - : c1 - c2; /* no match */ + return p_fic ? mb_toupper(c1) - mb_toupper(c2) + : c1 - c2; // no match } i += MB_PTR2LEN((char_u *)p + i); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 9baa53d2a2..4b5e17b00b 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2350,7 +2350,7 @@ collection: break; case CLASS_LOWER: for (cu = 1; cu <= 255; cu++) { - if (vim_islower(cu) && cu != 170 && cu != 186) { + if (mb_islower(cu) && cu != 170 && cu != 186) { regmbc(cu); } } @@ -2376,7 +2376,7 @@ collection: break; case CLASS_UPPER: for (cu = 1; cu <= 255; cu++) { - if (vim_isupper(cu)) { + if (mb_isupper(cu)) { regmbc(cu); } } @@ -3474,7 +3474,7 @@ static long bt_regexec_both(char_u *line, || (ireg_ic && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) || (c < 255 && prog->regstart < 255 - && vim_tolower(prog->regstart) == vim_tolower(c))))) { + && mb_tolower(prog->regstart) == mb_tolower(c))))) { retval = regtry(prog, col); } else { retval = 0; @@ -4155,7 +4155,7 @@ regmatch ( if (*opnd != *reginput && (!ireg_ic || (!enc_utf8 - && vim_tolower(*opnd) != vim_tolower(*reginput)))) { + && mb_tolower(*opnd) != mb_tolower(*reginput)))) { status = RA_NOMATCH; } else if (*opnd == NUL) { // match empty string always works; happens when "~" is @@ -4573,12 +4573,14 @@ regmatch ( if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); if (ireg_ic) { - if (vim_isupper(rst.nextb)) - rst.nextb_ic = vim_tolower(rst.nextb); - else - rst.nextb_ic = vim_toupper(rst.nextb); - } else + if (mb_isupper(rst.nextb)) { + rst.nextb_ic = mb_tolower(rst.nextb); + } else { + rst.nextb_ic = mb_toupper(rst.nextb); + } + } else { rst.nextb_ic = rst.nextb; + } } else { rst.nextb = NUL; rst.nextb_ic = NUL; @@ -5339,8 +5341,8 @@ do_class: * would have been used for it. It does handle single-byte * characters, such as latin1. */ if (ireg_ic) { - cu = vim_toupper(*opnd); - cl = vim_tolower(*opnd); + cu = mb_toupper(*opnd); + cl = mb_tolower(*opnd); while (count < maxcount && (*scan == cu || *scan == cl)) { count++; scan++; @@ -6312,14 +6314,15 @@ static char_u *cstrchr(char_u *s, int c) /* tolower() and toupper() can be slow, comparing twice should be a lot * faster (esp. when using MS Visual C++!). * For UTF-8 need to use folded case. */ - if (enc_utf8 && c > 0x80) + if (c > 0x80) { cc = utf_fold(c); - else if (vim_isupper(c)) - cc = vim_tolower(c); - else if (vim_islower(c)) - cc = vim_toupper(c); - else + } else if (mb_isupper(c)) { + cc = mb_tolower(c); + } else if (mb_islower(c)) { + cc = mb_toupper(c); + } else { return vim_strchr(s, c); + } if (has_mbyte) { for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) { @@ -6348,28 +6351,28 @@ static char_u *cstrchr(char_u *s, int c) static fptr_T do_upper(int *d, int c) { - *d = vim_toupper(c); + *d = mb_toupper(c); return (fptr_T)NULL; } static fptr_T do_Upper(int *d, int c) { - *d = vim_toupper(c); + *d = mb_toupper(c); return (fptr_T)do_Upper; } static fptr_T do_lower(int *d, int c) { - *d = vim_tolower(c); + *d = mb_tolower(c); return (fptr_T)NULL; } static fptr_T do_Lower(int *d, int c) { - *d = vim_tolower(c); + *d = mb_tolower(c); return (fptr_T)do_Lower; } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 5b49ab38f0..caf26fdd35 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4373,7 +4373,7 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_LOWER: - if (vim_islower(c) && c != 170 && c != 186) { + if (mb_islower(c) && c != 170 && c != 186) { return OK; } break; @@ -4391,8 +4391,9 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_UPPER: - if (vim_isupper(c)) + if (mb_isupper(c)) { return OK; + } break; case NFA_CLASS_XDIGIT: if (ascii_isxdigit(c)) @@ -4892,7 +4893,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) int c2_len = PTR2LEN(s2); int c2 = PTR2CHAR(s2); - if ((c1 != c2 && (!ireg_ic || vim_tolower(c1) != vim_tolower(c2))) + if ((c1 != c2 && (!ireg_ic || mb_tolower(c1) != mb_tolower(c2))) || c1_len != c2_len) { match = false; break; @@ -5585,22 +5586,24 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, break; } if (ireg_ic) { - int curc_low = vim_tolower(curc); - int done = FALSE; + int curc_low = mb_tolower(curc); + int done = false; - for (; c1 <= c2; ++c1) - if (vim_tolower(c1) == curc_low) { + for (; c1 <= c2; c1++) { + if (mb_tolower(c1) == curc_low) { result = result_if_matched; done = TRUE; break; } - if (done) + } + if (done) { break; + } } } else if (state->c < 0 ? check_char_class(state->c, curc) : (curc == state->c - || (ireg_ic && vim_tolower(curc) - == vim_tolower(state->c)))) { + || (ireg_ic && mb_tolower(curc) + == mb_tolower(state->c)))) { result = result_if_matched; break; } @@ -6003,8 +6006,9 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, #endif result = (c == curc); - if (!result && ireg_ic) - result = vim_tolower(c) == vim_tolower(curc); + if (!result && ireg_ic) { + result = mb_tolower(c) == mb_tolower(curc); + } // If ireg_icombine is not set only skip over the character // itself. When it is set skip over composing characters. @@ -6152,8 +6156,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, // Checking if the required start character matches is // cheaper than adding a state that won't match. c = PTR2CHAR(reginput + clen); - if (c != prog->regstart && (!ireg_ic || vim_tolower(c) - != vim_tolower(prog->regstart))) { + if (c != prog->regstart && (!ireg_ic || mb_tolower(c) + != mb_tolower(prog->regstart))) { #ifdef REGEXP_DEBUG fprintf(log_fd, " Skipping start state, regstart does not match\n"); diff --git a/src/nvim/search.c b/src/nvim/search.c index c5c92b41c5..91a558045f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -335,23 +335,26 @@ int pat_has_uppercase(char_u *pat) while (*p != NUL) { int l; - if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { - if (enc_utf8 && utf_isupper(utf_ptr2char(p))) - return TRUE; + if ((l = mb_ptr2len(p)) > 1) { + if (mb_isupper(utf_ptr2char(p))) { + return true; + } p += l; } else if (*p == '\\') { - if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */ + if (p[1] == '_' && p[2] != NUL) { // skip "\_X" p += 3; - else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */ + } else if (p[1] == '%' && p[2] != NUL) { // skip "\%X" p += 3; - else if (p[1] != NUL) /* skip "\X" */ + } else if (p[1] != NUL) { // skip "\X" p += 2; - else + } else { p += 1; - } else if (vim_isupper(*p)) - return TRUE; - else - ++p; + } + } else if (mb_isupper(*p)) { + return true; + } else { + p++; + } } return FALSE; } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index c7b95958e0..8c5d6dff65 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -73,15 +73,10 @@ KHASH_SET_INIT_STR(strset) (vim_rename((char_u *)a, (char_u *)b)) #define mb_strnicmp(a, b, c) \ (mb_strnicmp((char_u *)a, (char_u *)b, c)) -#define has_non_ascii(a) (has_non_ascii((char_u *)a)) -#define string_convert(a, b, c) \ - ((char *)string_convert((vimconv_T *)a, (char_u *)b, c)) #define path_shorten_fname_if_possible(b) \ ((char *)path_shorten_fname_if_possible((char_u *)b)) #define buflist_new(ffname, sfname, ...) \ (buflist_new((char_u *)ffname, (char_u *)sfname, __VA_ARGS__)) -#define convert_setup(vcp, from, to) \ - (convert_setup(vcp, (char_u *)from, (char_u *)to)) #define os_isdir(f) (os_isdir((char_u *) f)) #define regtilde(s, m) ((char *) regtilde((char_u *) s, m)) #define path_tail_with_sep(f) ((char *) path_tail_with_sep((char_u *)f)) @@ -413,8 +408,6 @@ typedef struct sd_read_def { const char *error; ///< Error message in case of error. uintmax_t fpos; ///< Current position (amount of bytes read since ///< reader structure initialization). May overflow. - vimconv_T sd_conv; ///< Structure used for converting encodings of some - ///< items. } ShaDaReadDef; struct sd_write_def; @@ -435,8 +428,6 @@ typedef struct sd_write_def { ShaDaWriteCloser close; ///< Close function. void *cookie; ///< Data describing object written to. const char *error; ///< Error message in case of error. - vimconv_T sd_conv; ///< Structure used for converting encodings of some - ///< items. } ShaDaWriteDef; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -803,7 +794,7 @@ static int open_shada_file_for_reading(const char *const fname, return error; } - convert_setup(&sd_reader->sd_conv, "utf-8", p_enc); + assert(STRCMP(p_enc, "utf-8") == 0); return 0; } @@ -1899,127 +1890,24 @@ shada_pack_entry_error: } #undef PACK_STRING -/// Write single ShaDa entry, converting it if needed +/// Write single ShaDa entry and free it afterwards /// -/// @warning Frees entry after packing. +/// Will not free if entry could not be freed. /// /// @param[in] packer Packer used to write entry. -/// @param[in] sd_conv Conversion definitions. -/// @param[in] entry Entry written. If entry.can_free_entry is false then -/// it assumes that entry was not converted, otherwise it -/// is assumed that entry was already converted. +/// @param[in] entry Entry written. /// @param[in] max_kbyte Maximum size of an item in KiB. Zero means no /// restrictions. -static ShaDaWriteResult shada_pack_encoded_entry(msgpack_packer *const packer, - const vimconv_T *const sd_conv, - PossiblyFreedShadaEntry entry, - const size_t max_kbyte) - FUNC_ATTR_NONNULL_ALL +static inline ShaDaWriteResult shada_pack_pfreed_entry( + msgpack_packer *const packer, PossiblyFreedShadaEntry entry, + const size_t max_kbyte) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE { ShaDaWriteResult ret = kSDWriteSuccessfull; + ret = shada_pack_entry(packer, entry.data, max_kbyte); if (entry.can_free_entry) { - ret = shada_pack_entry(packer, entry.data, max_kbyte); shada_free_shada_entry(&entry.data); - return ret; - } -#define RUN_WITH_CONVERTED_STRING(cstr, code) \ - do { \ - bool did_convert = false; \ - if (sd_conv->vc_type != CONV_NONE && has_non_ascii((cstr))) { \ - char *const converted_string = string_convert(sd_conv, (cstr), NULL); \ - if (converted_string != NULL) { \ - (cstr) = converted_string; \ - did_convert = true; \ - } \ - } \ - code \ - if (did_convert) { \ - xfree((cstr)); \ - } \ - } while (0) - switch (entry.data.type) { - case kSDItemUnknown: - case kSDItemMissing: { - assert(false); - } - case kSDItemSearchPattern: { - RUN_WITH_CONVERTED_STRING(entry.data.data.search_pattern.pat, { - ret = shada_pack_entry(packer, entry.data, max_kbyte); - }); - break; - } - case kSDItemHistoryEntry: { - RUN_WITH_CONVERTED_STRING(entry.data.data.history_item.string, { - ret = shada_pack_entry(packer, entry.data, max_kbyte); - }); - break; - } - case kSDItemSubString: { - RUN_WITH_CONVERTED_STRING(entry.data.data.sub_string.sub, { - ret = shada_pack_entry(packer, entry.data, max_kbyte); - }); - break; - } - case kSDItemVariable: { - if (sd_conv->vc_type != CONV_NONE) { - typval_T tgttv; - var_item_copy(sd_conv, &entry.data.data.global_var.value, &tgttv, - true, 0); - tv_clear(&entry.data.data.global_var.value); - entry.data.data.global_var.value = tgttv; - } - ret = shada_pack_entry(packer, entry.data, max_kbyte); - break; - } - case kSDItemRegister: { - bool did_convert = false; - if (sd_conv->vc_type != CONV_NONE) { - size_t first_non_ascii = 0; - for (size_t i = 0; i < entry.data.data.reg.contents_size; i++) { - if (has_non_ascii(entry.data.data.reg.contents[i])) { - first_non_ascii = i; - did_convert = true; - break; - } - } - if (did_convert) { - entry.data.data.reg.contents = - xmemdup(entry.data.data.reg.contents, - (entry.data.data.reg.contents_size - * sizeof(entry.data.data.reg.contents[0]))); - for (size_t i = 0; i < entry.data.data.reg.contents_size; i++) { - if (i >= first_non_ascii) { - entry.data.data.reg.contents[i] = get_converted_string( - sd_conv, - entry.data.data.reg.contents[i], - strlen(entry.data.data.reg.contents[i])); - } else { - entry.data.data.reg.contents[i] = - xstrdup(entry.data.data.reg.contents[i]); - } - } - } - } - ret = shada_pack_entry(packer, entry.data, max_kbyte); - if (did_convert) { - for (size_t i = 0; i < entry.data.data.reg.contents_size; i++) { - xfree(entry.data.data.reg.contents[i]); - } - xfree(entry.data.data.reg.contents); - } - break; - } - case kSDItemHeader: - case kSDItemGlobalMark: - case kSDItemJump: - case kSDItemBufferList: - case kSDItemLocalMark: - case kSDItemChange: { - ret = shada_pack_entry(packer, entry.data, max_kbyte); - break; - } } -#undef RUN_WITH_CONVERTED_STRING return ret; } @@ -2556,11 +2444,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, break; } typval_T tgttv; - if (sd_writer->sd_conv.vc_type != CONV_NONE) { - var_item_copy(&sd_writer->sd_conv, &vartv, &tgttv, true, 0); - } else { - tv_copy(&vartv, &tgttv); - } + tv_copy(&vartv, &tgttv); ShaDaWriteResult spe_ret; if ((spe_ret = shada_pack_entry(packer, (ShadaEntry) { .type = kSDItemVariable, @@ -2811,9 +2695,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, do { \ for (size_t i_ = 0; i_ < ARRAY_SIZE(wms_array); i_++) { \ if (wms_array[i_].data.type != kSDItemMissing) { \ - if (shada_pack_encoded_entry(packer, &sd_writer->sd_conv, \ - wms_array[i_], \ - max_kbyte) == kSDWriteFailed) { \ + if (shada_pack_pfreed_entry(packer, wms_array[i_], max_kbyte) \ + == kSDWriteFailed) { \ ret = kSDWriteFailed; \ goto shada_write_exit; \ } \ @@ -2823,8 +2706,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, PACK_WMS_ARRAY(wms->global_marks); PACK_WMS_ARRAY(wms->registers); for (size_t i = 0; i < wms->jumps_size; i++) { - if (shada_pack_encoded_entry(packer, &sd_writer->sd_conv, wms->jumps[i], - max_kbyte) == kSDWriteFailed) { + if (shada_pack_pfreed_entry(packer, wms->jumps[i], max_kbyte) + == kSDWriteFailed) { ret = kSDWriteFailed; goto shada_write_exit; } @@ -2832,8 +2715,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, #define PACK_WMS_ENTRY(wms_entry) \ do { \ if (wms_entry.data.type != kSDItemMissing) { \ - if (shada_pack_encoded_entry(packer, &sd_writer->sd_conv, wms_entry, \ - max_kbyte) == kSDWriteFailed) { \ + if (shada_pack_pfreed_entry(packer, wms_entry, max_kbyte) \ + == kSDWriteFailed) { \ ret = kSDWriteFailed; \ goto shada_write_exit; \ } \ @@ -2860,9 +2743,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, for (size_t i = 0; i < file_markss_to_dump; i++) { PACK_WMS_ARRAY(all_file_markss[i]->marks); for (size_t j = 0; j < all_file_markss[i]->changes_size; j++) { - if (shada_pack_encoded_entry(packer, &sd_writer->sd_conv, - all_file_markss[i]->changes[j], - max_kbyte) == kSDWriteFailed) { + if (shada_pack_pfreed_entry(packer, all_file_markss[i]->changes[j], + max_kbyte) == kSDWriteFailed) { ret = kSDWriteFailed; goto shada_write_exit; } @@ -2886,8 +2768,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, if (dump_one_history[i]) { hms_insert_whole_neovim_history(&wms->hms[i]); HMS_ITER(&wms->hms[i], cur_entry, { - if (shada_pack_encoded_entry( - packer, &sd_writer->sd_conv, (PossiblyFreedShadaEntry) { + if (shada_pack_pfreed_entry( + packer, (PossiblyFreedShadaEntry) { .data = cur_entry->data, .can_free_entry = cur_entry->can_free_entry, }, max_kbyte) == kSDWriteFailed) { @@ -3038,8 +2920,6 @@ shada_write_file_nomerge: {} verbose_leave(); } - convert_setup(&sd_writer.sd_conv, p_enc, "utf-8"); - const ShaDaWriteResult sw_ret = shada_write(&sd_writer, (nomerge ? NULL : &sd_reader)); @@ -3327,29 +3207,6 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, return kSDReadStatusSuccess; } -/// Convert or copy and return a string -/// -/// @param[in] sd_conv Conversion definition. -/// @param[in] str String to convert. -/// @param[in] len String length. -/// -/// @return [allocated] converted string or copy of the original string. -static inline char *get_converted_string(const vimconv_T *const sd_conv, - const char *const str, - const size_t len) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT -{ - if (!has_non_ascii_len(str, len)) { - return xmemdupz(str, len); - } - size_t new_len = len; - char *const new_str = string_convert(sd_conv, str, &new_len); - if (new_str == NULL) { - return xmemdupz(str, len); - } - return new_str; -} - #define READERR(entry_name, error_desc) \ RERR "Error while reading ShaDa file: " \ entry_name " entry at position %" PRIu64 " " \ @@ -3427,10 +3284,7 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv, sizeof(*unpacked.data.via.map.ptr)); \ ad_ga.ga_len++; \ } -#define CONVERTED(str, len) ( \ - sd_reader->sd_conv.vc_type != CONV_NONE \ - ? get_converted_string(&sd_reader->sd_conv, (str), (len)) \ - : xmemdupz((str), (len))) +#define CONVERTED(str, len) (xmemdupz((str), (len))) #define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size) #define SET_ADDITIONAL_DATA(tgt, name) \ do { \ @@ -3803,30 +3657,14 @@ shada_read_next_item_start: (char) unpacked.data.via.array.ptr[2].via.u64; } size_t strsize; - if (sd_reader->sd_conv.vc_type == CONV_NONE - || !has_non_ascii_len(unpacked.data.via.array.ptr[1].via.bin.ptr, - unpacked.data.via.array.ptr[1].via.bin.size)) { -shada_read_next_item_hist_no_conv: - strsize = ( - unpacked.data.via.array.ptr[1].via.bin.size - + 1 // Zero byte - + 1); // Separator character - entry->data.history_item.string = xmalloc(strsize); - memcpy(entry->data.history_item.string, - unpacked.data.via.array.ptr[1].via.bin.ptr, - unpacked.data.via.array.ptr[1].via.bin.size); - } else { - size_t len = unpacked.data.via.array.ptr[1].via.bin.size; - char *const converted = string_convert( - &sd_reader->sd_conv, unpacked.data.via.array.ptr[1].via.bin.ptr, - &len); - if (converted != NULL) { - strsize = len + 2; - entry->data.history_item.string = xrealloc(converted, strsize); - } else { - goto shada_read_next_item_hist_no_conv; - } - } + strsize = ( + unpacked.data.via.array.ptr[1].via.bin.size + + 1 // Zero byte + + 1); // Separator character + entry->data.history_item.string = xmalloc(strsize); + memcpy(entry->data.history_item.string, + unpacked.data.via.array.ptr[1].via.bin.ptr, + unpacked.data.via.array.ptr[1].via.bin.size); entry->data.history_item.string[strsize - 2] = 0; entry->data.history_item.string[strsize - 1] = entry->data.history_item.sep; @@ -3859,16 +3697,6 @@ shada_read_next_item_hist_no_conv: "be converted to the VimL value")), initial_fpos); goto shada_read_next_item_error; } - if (sd_reader->sd_conv.vc_type != CONV_NONE) { - typval_T tgttv; - var_item_copy(&sd_reader->sd_conv, - &entry->data.global_var.value, - &tgttv, - true, - 0); - tv_clear(&entry->data.global_var.value); - entry->data.global_var.value = tgttv; - } SET_ADDITIONAL_ELEMENTS(unpacked.data.via.array, 2, entry->data.global_var.additional_elements, "variable"); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d4f49bffb2..18febda1d8 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2526,8 +2526,7 @@ void clear_spell_chartab(spelltab_T *sp) } } -// Init the chartab used for spelling. Only depends on 'encoding'. -// Called once while starting up and when 'encoding' changes. +// Init the chartab used for spelling. Called once while starting up. // The default is to use isalpha(), but the spell file should define the word // characters to make it possible that 'encoding' differs from the current // locale. For utf-8 we don't use isalpha() but our own functions. @@ -2537,36 +2536,17 @@ void init_spell_chartab(void) did_set_spelltab = false; clear_spell_chartab(&spelltab); - if (enc_dbcs) { - // DBCS: assume double-wide characters are word characters. - for (i = 128; i <= 255; ++i) - if (MB_BYTE2LEN(i) == 2) - spelltab.st_isw[i] = true; - } else if (enc_utf8) { - for (i = 128; i < 256; ++i) { - int f = utf_fold(i); - int u = utf_toupper(i); - - spelltab.st_isu[i] = utf_isupper(i); - spelltab.st_isw[i] = spelltab.st_isu[i] || utf_islower(i); - // The folded/upper-cased value is different between latin1 and - // utf8 for 0xb5, causing E763 for no good reason. Use the latin1 - // value for utf-8 to avoid this. - spelltab.st_fold[i] = (f < 256) ? f : i; - spelltab.st_upper[i] = (u < 256) ? u : i; - } - } else { - // Rough guess: use locale-dependent library functions. - for (i = 128; i < 256; ++i) { - if (vim_isupper(i)) { - spelltab.st_isw[i] = true; - spelltab.st_isu[i] = true; - spelltab.st_fold[i] = vim_tolower(i); - } else if (vim_islower(i)) { - spelltab.st_isw[i] = true; - spelltab.st_upper[i] = vim_toupper(i); - } - } + for (i = 128; i < 256; i++) { + int f = utf_fold(i); + int u = mb_toupper(i); + + spelltab.st_isu[i] = mb_isupper(i); + spelltab.st_isw[i] = spelltab.st_isu[i] || mb_islower(i); + // The folded/upper-cased value is different between latin1 and + // utf8 for 0xb5, causing E763 for no good reason. Use the latin1 + // value for utf-8 to avoid this. + spelltab.st_fold[i] = (f < 256) ? f : i; + spelltab.st_upper[i] = (u < 256) ? u : i; } } diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h index c54a7f5390..ddd54c724e 100644 --- a/src/nvim/spell_defs.h +++ b/src/nvim/spell_defs.h @@ -265,11 +265,11 @@ typedef struct trystate_S { : (c) < \ 256 ? (int)spelltab.st_fold[c] : (int)towlower(c)) -#define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \ +#define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? mb_toupper(c) \ : (c) < \ 256 ? (int)spelltab.st_upper[c] : (int)towupper(c)) -#define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \ +#define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? mb_isupper(c) \ : (c) < 256 ? spelltab.st_isu[c] : iswupper(c)) // First language that is loaded, start of the linked list of loaded diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 4d7ff558ad..1da71dc4f9 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -223,7 +223,9 @@ // few bytes as possible, see offset2bytes()) #include <stdio.h> +#include <stdint.h> #include <wctype.h> +#include <strings.h> #include "nvim/vim.h" #include "nvim/spell_defs.h" @@ -266,7 +268,7 @@ #define SAL_REM_ACCENTS 4 #define VIMSPELLMAGIC "VIMspell" // string at start of Vim spell file -#define VIMSPELLMAGICL 8 +#define VIMSPELLMAGICL (sizeof(VIMSPELLMAGIC) - 1) #define VIMSPELLVERSION 50 // Section IDs. Only renumber them when VIMSPELLVERSION changes! @@ -493,6 +495,64 @@ typedef struct spellinfo_S { # include "spellfile.c.generated.h" #endif +/// Read n bytes from fd to buf, returning on errors +/// +/// @param[out] buf Buffer to read to, must be at least n bytes long. +/// @param[in] n Amount of bytes to read. +/// @param fd FILE* to read from. +/// @param exit_code Code to run before returning. +/// +/// @return Allows to proceed if everything is OK, returns SP_TRUNCERROR if +/// there are not enough bytes, returns SP_OTHERERROR if reading failed. +#define SPELL_READ_BYTES(buf, n, fd, exit_code) \ + do { \ + const size_t n__SPRB = (n); \ + FILE *const fd__SPRB = (fd); \ + char *const buf__SPRB = (buf); \ + const size_t read_bytes__SPRB = fread(buf__SPRB, 1, n__SPRB, fd__SPRB); \ + if (read_bytes__SPRB != n__SPRB) { \ + exit_code; \ + return feof(fd__SPRB) ? SP_TRUNCERROR : SP_OTHERERROR; \ + } \ + } while (0) + +/// Like #SPELL_READ_BYTES, but also error out if NUL byte was read +/// +/// @return Allows to proceed if everything is OK, returns SP_TRUNCERROR if +/// there are not enough bytes, returns SP_OTHERERROR if reading failed, +/// returns SP_FORMERROR if read out a NUL byte. +#define SPELL_READ_NONNUL_BYTES(buf, n, fd, exit_code) \ + do { \ + const size_t n__SPRNB = (n); \ + FILE *const fd__SPRNB = (fd); \ + char *const buf__SPRNB = (buf); \ + SPELL_READ_BYTES(buf__SPRNB, n__SPRNB, fd__SPRNB, exit_code); \ + if (memchr(buf__SPRNB, NUL, (size_t)n__SPRNB)) { \ + exit_code; \ + return SP_FORMERROR; \ + } \ + } while (0) + +/// Check that spell file starts with a magic string +/// +/// Does not check for version of the file. +/// +/// @param fd File to check. +/// +/// @return 0 in case of success, SP_TRUNCERROR if file contains not enough +/// bytes, SP_FORMERROR if it does not match magic string and +/// SP_OTHERERROR if reading file failed. +static inline int spell_check_magic_string(FILE *const fd) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE +{ + char buf[VIMSPELLMAGICL]; + SPELL_READ_BYTES(buf, VIMSPELLMAGICL, fd, ;); + if (memcmp(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0) { + return SP_FORMERROR; + } + return 0; +} + // Load one spell file and store the info into a slang_T. // // This is invoked in three ways: @@ -513,9 +573,7 @@ spell_load_file ( ) { FILE *fd; - char_u buf[VIMSPELLMAGICL]; char_u *p; - int i; int n; int len; char_u *save_sourcing_name = sourcing_name; @@ -557,11 +615,20 @@ spell_load_file ( sourcing_lnum = 0; // <HEADER>: <fileID> - for (i = 0; i < VIMSPELLMAGICL; ++i) - buf[i] = getc(fd); // <fileID> - if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0) { - EMSG(_("E757: This does not look like a spell file")); - goto endFAIL; + const int scms_ret = spell_check_magic_string(fd); + switch (scms_ret) { + case SP_FORMERROR: + case SP_TRUNCERROR: { + emsgf(_("E757: This does not look like a spell file")); + goto endFAIL; + } + case SP_OTHERERROR: { + emsgf(_("E5042: Failed to read spell file %s: %s"), + fname, strerror(ferror(fd))); + } + case 0: { + break; + } } c = getc(fd); // <versionnr> if (c < VIMSPELLVERSION) { @@ -934,12 +1001,10 @@ static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp) // Return SP_*ERROR flags. static int read_region_section(FILE *fd, slang_T *lp, int len) { - int i; - - if (len > 16) + if (len > 16) { return SP_FORMERROR; - for (i = 0; i < len; ++i) - lp->sl_regions[i] = getc(fd); // <regionname> + } + SPELL_READ_NONNUL_BYTES((char *)lp->sl_regions, (size_t)len, fd, ;); lp->sl_regions[len] = NUL; return 0; } @@ -982,35 +1047,30 @@ static int read_charflags_section(FILE *fd) // Return SP_*ERROR flags. static int read_prefcond_section(FILE *fd, slang_T *lp) { - int cnt; - int i; - int n; - char_u *p; - char_u buf[MAXWLEN + 1]; - // <prefcondcnt> <prefcond> ... - cnt = get2c(fd); // <prefcondcnt> - if (cnt <= 0) + const int cnt = get2c(fd); // <prefcondcnt> + if (cnt <= 0) { return SP_FORMERROR; + } lp->sl_prefprog = xcalloc(cnt, sizeof(regprog_T *)); lp->sl_prefixcnt = cnt; - for (i = 0; i < cnt; ++i) { + for (int i = 0; i < cnt; i++) { // <prefcond> : <condlen> <condstr> - n = getc(fd); // <condlen> - if (n < 0 || n >= MAXWLEN) + const int n = getc(fd); // <condlen> + if (n < 0 || n >= MAXWLEN) { return SP_FORMERROR; + } // When <condlen> is zero we have an empty condition. Otherwise // compile the regexp program used to check for the condition. if (n > 0) { - buf[0] = '^'; // always match at one position only - p = buf + 1; - while (n-- > 0) - *p++ = getc(fd); // <condstr> - *p = NUL; - lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC + RE_STRING); + char buf[MAXWLEN + 1]; + buf[0] = '^'; // always match at one position only + SPELL_READ_NONNUL_BYTES(buf + 1, (size_t)n, fd, ;); + buf[n + 1] = NUL; + lp->sl_prefprog[i] = vim_regcomp((char_u *)buf, RE_MAGIC | RE_STRING); } } return 0; @@ -1063,7 +1123,6 @@ static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first) // Return SP_*ERROR flags. static int read_sal_section(FILE *fd, slang_T *slang) { - int i; int cnt; garray_T *gap; salitem_T *smp; @@ -1073,13 +1132,16 @@ static int read_sal_section(FILE *fd, slang_T *slang) slang->sl_sofo = false; - i = getc(fd); // <salflags> - if (i & SAL_F0LLOWUP) + const int flags = getc(fd); // <salflags> + if (flags & SAL_F0LLOWUP) { slang->sl_followup = true; - if (i & SAL_COLLAPSE) + } + if (flags & SAL_COLLAPSE) { slang->sl_collapse = true; - if (i & SAL_REM_ACCENTS) + } + if (flags & SAL_REM_ACCENTS) { slang->sl_rem_accents = true; + } cnt = get2c(fd); // <salcount> if (cnt < 0) @@ -1099,7 +1161,8 @@ static int read_sal_section(FILE *fd, slang_T *slang) smp->sm_lead = p; // Read up to the first special char into sm_lead. - for (i = 0; i < ccnt; ++i) { + int i = 0; + for (; i < ccnt; ++i) { c = getc(fd); // <salfrom> if (vim_strchr((char_u *)"0123456789(-<^$", c) != NULL) break; @@ -1125,11 +1188,17 @@ static int read_sal_section(FILE *fd, slang_T *slang) // Any following chars go in sm_rules. smp->sm_rules = p; - if (i < ccnt) + if (i < ccnt) { // store the char we got while checking for end of sm_lead *p++ = c; - for (++i; i < ccnt; ++i) - *p++ = getc(fd); // <salfrom> + } + i++; + if (i < ccnt) { + SPELL_READ_NONNUL_BYTES( // <salfrom> + (char *)p, (size_t)(ccnt - i), fd, xfree(smp->sm_lead)); + p += (ccnt - i); + i = ccnt; + } *p++ = NUL; // <saltolen> <salto> @@ -1569,9 +1638,14 @@ spell_read_tree ( // The tree size was computed when writing the file, so that we can // allocate it as one long block. <nodecount> - int len = get4c(fd); - if (len < 0) + long len = get4c(fd); + if (len < 0) { return SP_TRUNCERROR; + } + if ((size_t)len >= SIZE_MAX / sizeof(int)) { + // Invalid length, multiply with sizeof(int) would overflow. + return SP_FORMERROR; + } if (len > 0) { // Allocate the byte array. bp = xmalloc(len); diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 5dcffe00e0..87e066d80a 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -291,14 +291,15 @@ void vim_strup(char_u *p) } } -/// Make given string all upper-case +/// Make given string all upper-case or all lower-case /// -/// Handels multi-byte characters as good as possible. +/// Handles multi-byte characters as good as possible. /// /// @param[in] orig Input string. +/// @param[in] upper If true make uppercase, otherwise lowercase /// /// @return [allocated] upper-cased string. -char *strup_save(const char *const orig) +char *strcase_save(const char *const orig, bool upper) FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL { char *res = xstrdup(orig); @@ -307,33 +308,25 @@ char *strup_save(const char *const orig) while (*p != NUL) { int l; - if (enc_utf8) { - int c = utf_ptr2char((const char_u *)p); - int uc = utf_toupper(c); - - // Reallocate string when byte count changes. This is rare, - // thus it's OK to do another malloc()/free(). - l = utf_ptr2len((const char_u *)p); - int newl = utf_char2len(uc); - if (newl != l) { - // TODO(philix): use xrealloc() in strup_save() - char *s = xmalloc(STRLEN(res) + (size_t)(1 + newl - l)); - memcpy(s, res, (size_t)(p - res)); - STRCPY(s + (p - res) + newl, p + l); - p = s + (p - res); - xfree(res); - res = s; - } - - utf_char2bytes(uc, (char_u *)p); - p += newl; - } else if (has_mbyte && (l = (*mb_ptr2len)((const char_u *)p)) > 1) { - p += l; // Skip multi-byte character. - } else { - // note that toupper() can be a macro - *p = (char)(uint8_t)TOUPPER_LOC(*p); - p++; + int c = utf_ptr2char((const char_u *)p); + int uc = upper ? mb_toupper(c) : mb_tolower(c); + + // Reallocate string when byte count changes. This is rare, + // thus it's OK to do another malloc()/free(). + l = utf_ptr2len((const char_u *)p); + int newl = utf_char2len(uc); + if (newl != l) { + // TODO(philix): use xrealloc() in strup_save() + char *s = xmalloc(STRLEN(res) + (size_t)(1 + newl - l)); + memcpy(s, res, (size_t)(p - res)); + STRCPY(s + (p - res) + newl, p + l); + p = s + (p - res); + xfree(res); + res = s; } + + utf_char2bytes(uc, (char_u *)p); + p += newl; } return res; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e36b00d770..1ed65ec52a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4246,83 +4246,81 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) if (rest != NULL) { syn_id = syn_check_group(arg, (int)(group_name_end - arg)); - if (syn_id != 0) - /* allocate a buffer, for removing backslashes in the keyword */ + if (syn_id != 0) { + // Allocate a buffer, for removing backslashes in the keyword. keyword_copy = xmalloc(STRLEN(rest) + 1); - syn_opt_arg.flags = 0; - syn_opt_arg.keyword = TRUE; - syn_opt_arg.sync_idx = NULL; - syn_opt_arg.has_cont_list = FALSE; - syn_opt_arg.cont_in_list = NULL; - syn_opt_arg.next_list = NULL; - - /* - * The options given apply to ALL keywords, so all options must be - * found before keywords can be created. - * 1: collect the options and copy the keywords to keyword_copy. - */ - cnt = 0; - p = keyword_copy; - for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) { - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); - if (rest == NULL || ends_excmd(*rest)) - break; - /* Copy the keyword, removing backslashes, and add a NUL. */ - while (*rest != NUL && !ascii_iswhite(*rest)) { - if (*rest == '\\' && rest[1] != NUL) - ++rest; - *p++ = *rest++; - } - *p++ = NUL; - ++cnt; } + if (keyword_copy != NULL) { + syn_opt_arg.flags = 0; + syn_opt_arg.keyword = true; + syn_opt_arg.sync_idx = NULL; + syn_opt_arg.has_cont_list = false; + syn_opt_arg.cont_in_list = NULL; + syn_opt_arg.next_list = NULL; + + // The options given apply to ALL keywords, so all options must be + // found before keywords can be created. + // 1: collect the options and copy the keywords to keyword_copy. + cnt = 0; + p = keyword_copy; + for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) { + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + if (rest == NULL || ends_excmd(*rest)) { + break; + } + // Copy the keyword, removing backslashes, and add a NUL. + while (*rest != NUL && !ascii_iswhite(*rest)) { + if (*rest == '\\' && rest[1] != NUL) { + rest++; + } + *p++ = *rest++; + } + *p++ = NUL; + cnt++; + } - if (!eap->skip) { - /* Adjust flags for use of ":syn include". */ - syn_incl_toplevel(syn_id, &syn_opt_arg.flags); + if (!eap->skip) { + // Adjust flags for use of ":syn include". + syn_incl_toplevel(syn_id, &syn_opt_arg.flags); - /* - * 2: Add an entry for each keyword. - */ - for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) { - for (p = vim_strchr(kw, '[');; ) { - if (p != NULL) - *p = NUL; - add_keyword(kw, syn_id, syn_opt_arg.flags, - syn_opt_arg.cont_in_list, - syn_opt_arg.next_list, conceal_char); - if (p == NULL) - break; - if (p[1] == NUL) { - EMSG2(_("E789: Missing ']': %s"), kw); - goto error; - } - if (p[1] == ']') { - if (p[2] != NUL) { - EMSG3(_("E890: trailing char after ']': %s]%s"), - kw, &p[2]); + // 2: Add an entry for each keyword. + for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) { + for (p = vim_strchr(kw, '[');; ) { + if (p != NULL) { + *p = NUL; + } + add_keyword(kw, syn_id, syn_opt_arg.flags, + syn_opt_arg.cont_in_list, + syn_opt_arg.next_list, conceal_char); + if (p == NULL) { + break; + } + if (p[1] == NUL) { + emsgf(_("E789: Missing ']': %s"), kw); goto error; } - kw = p + 1; - break; // skip over the "]" - } - if (has_mbyte) { - int l = (*mb_ptr2len)(p + 1); + if (p[1] == ']') { + if (p[2] != NUL) { + emsgf(_("E890: trailing char after ']': %s]%s"), + kw, &p[2]); + goto error; + } + kw = p + 1; + break; // skip over the "]" + } + const int l = (*mb_ptr2len)(p + 1); memmove(p, p + 1, l); p += l; - } else { - p[0] = p[1]; - ++p; } } } - } error: - xfree(keyword_copy); - xfree(syn_opt_arg.cont_in_list); - xfree(syn_opt_arg.next_list); + xfree(keyword_copy); + xfree(syn_opt_arg.cont_in_list); + xfree(syn_opt_arg.next_list); + } } if (rest != NULL) diff --git a/src/nvim/tag.c b/src/nvim/tag.c index b812dd2ffd..f01b8b8ab1 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1847,14 +1847,14 @@ parse_line: } } } else { -#define TAG_SEP 0x01 +#define TAG_SEP 0x02 size_t tag_fname_len = STRLEN(tag_fname); // Save the tag in a buffer. - // Use 0x01 to separate fields (Can't use NUL, because the + // Use 0x02 to separate fields (Can't use NUL, because the // hash key is terminated by NUL). - // Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf> - // other tag: <mtt><tag_fname><NUL><NUL><lbuf> - // without Emacs tags: <mtt><tag_fname><NUL><lbuf> + // Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL> + // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> + // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> // Here <mtt> is the "mtt" value plus 1 to avoid NUL. len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3; mfp = xmalloc(sizeof(char_u) + len + 1); @@ -2797,11 +2797,9 @@ add_tag_field ( return retval; } -/* - * Add the tags matching the specified pattern to the list "list" - * as a dictionary - */ -int get_tags(list_T *list, char_u *pat) +/// Add the tags matching the specified pattern "pat" to the list "list" +/// as a dictionary. Use "buf_fname" for priority, unless NULL. +int get_tags(list_T *list, char_u *pat, char_u *buf_fname) { int num_matches, i, ret; char_u **matches, *p; @@ -2811,7 +2809,7 @@ int get_tags(list_T *list, char_u *pat) bool is_static; ret = find_tags(pat, &num_matches, &matches, - TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL); + TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname); if (ret == OK && num_matches > 0) { for (i = 0; i < num_matches; ++i) { int parse_result = parse_match(matches[i], &tp); diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index baf49b7ff7..99d9835996 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -26,6 +26,7 @@ source test_tabline.vim " source test_tabpage.vim source test_tagcase.vim source test_tagjump.vim +source test_taglist.vim source test_true_false.vim source test_unlet.vim source test_utf8.vim diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 81cb6314ce..3c258299c1 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -29,3 +29,147 @@ func Test_setbufvar_options() bwipe! endfunc +func Test_tolower() + call assert_equal("", tolower("")) + + " Test with all printable ASCII characters. + call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~', + \ tolower(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')) + + if !has('multi_byte') + return + endif + + " Test with a few uppercase diacritics. + call assert_equal("aàáâãäåāăąǎǟǡả", tolower("AÀÁÂÃÄÅĀĂĄǍǞǠẢ")) + call assert_equal("bḃḇ", tolower("BḂḆ")) + call assert_equal("cçćĉċč", tolower("CÇĆĈĊČ")) + call assert_equal("dďđḋḏḑ", tolower("DĎĐḊḎḐ")) + call assert_equal("eèéêëēĕėęěẻẽ", tolower("EÈÉÊËĒĔĖĘĚẺẼ")) + call assert_equal("fḟ ", tolower("FḞ ")) + call assert_equal("gĝğġģǥǧǵḡ", tolower("GĜĞĠĢǤǦǴḠ")) + call assert_equal("hĥħḣḧḩ", tolower("HĤĦḢḦḨ")) + call assert_equal("iìíîïĩīĭįiǐỉ", tolower("IÌÍÎÏĨĪĬĮİǏỈ")) + call assert_equal("jĵ", tolower("JĴ")) + call assert_equal("kķǩḱḵ", tolower("KĶǨḰḴ")) + call assert_equal("lĺļľŀłḻ", tolower("LĹĻĽĿŁḺ")) + call assert_equal("mḿṁ", tolower("MḾṀ")) + call assert_equal("nñńņňṅṉ", tolower("NÑŃŅŇṄṈ")) + call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ")) + call assert_equal("pṕṗ", tolower("PṔṖ")) + call assert_equal("q", tolower("Q")) + call assert_equal("rŕŗřṙṟ", tolower("RŔŖŘṘṞ")) + call assert_equal("sśŝşšṡ", tolower("SŚŜŞŠṠ")) + call assert_equal("tţťŧṫṯ", tolower("TŢŤŦṪṮ")) + call assert_equal("uùúûüũūŭůűųưǔủ", tolower("UÙÚÛÜŨŪŬŮŰŲƯǓỦ")) + call assert_equal("vṽ", tolower("VṼ")) + call assert_equal("wŵẁẃẅẇ", tolower("WŴẀẂẄẆ")) + call assert_equal("xẋẍ", tolower("XẊẌ")) + call assert_equal("yýŷÿẏỳỷỹ", tolower("YÝŶŸẎỲỶỸ")) + call assert_equal("zźżžƶẑẕ", tolower("ZŹŻŽƵẐẔ")) + + " Test with a few lowercase diacritics, which should remain unchanged. + call assert_equal("aàáâãäåāăąǎǟǡả", tolower("aàáâãäåāăąǎǟǡả")) + call assert_equal("bḃḇ", tolower("bḃḇ")) + call assert_equal("cçćĉċč", tolower("cçćĉċč")) + call assert_equal("dďđḋḏḑ", tolower("dďđḋḏḑ")) + call assert_equal("eèéêëēĕėęěẻẽ", tolower("eèéêëēĕėęěẻẽ")) + call assert_equal("fḟ", tolower("fḟ")) + call assert_equal("gĝğġģǥǧǵḡ", tolower("gĝğġģǥǧǵḡ")) + call assert_equal("hĥħḣḧḩẖ", tolower("hĥħḣḧḩẖ")) + call assert_equal("iìíîïĩīĭįǐỉ", tolower("iìíîïĩīĭįǐỉ")) + call assert_equal("jĵǰ", tolower("jĵǰ")) + call assert_equal("kķǩḱḵ", tolower("kķǩḱḵ")) + call assert_equal("lĺļľŀłḻ", tolower("lĺļľŀłḻ")) + call assert_equal("mḿṁ ", tolower("mḿṁ ")) + call assert_equal("nñńņňʼnṅṉ", tolower("nñńņňʼnṅṉ")) + call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("oòóôõöøōŏőơǒǫǭỏ")) + call assert_equal("pṕṗ", tolower("pṕṗ")) + call assert_equal("q", tolower("q")) + call assert_equal("rŕŗřṙṟ", tolower("rŕŗřṙṟ")) + call assert_equal("sśŝşšṡ", tolower("sśŝşšṡ")) + call assert_equal("tţťŧṫṯẗ", tolower("tţťŧṫṯẗ")) + call assert_equal("uùúûüũūŭůűųưǔủ", tolower("uùúûüũūŭůűųưǔủ")) + call assert_equal("vṽ", tolower("vṽ")) + call assert_equal("wŵẁẃẅẇẘ", tolower("wŵẁẃẅẇẘ")) + call assert_equal("ẋẍ", tolower("ẋẍ")) + call assert_equal("yýÿŷẏẙỳỷỹ", tolower("yýÿŷẏẙỳỷỹ")) + call assert_equal("zźżžƶẑẕ", tolower("zźżžƶẑẕ")) + + " According to https://twitter.com/jifa/status/625776454479970304 + " Ⱥ (U+023A) and Ⱦ (U+023E) are the *only* code points to increase + " in length (2 to 3 bytes) when lowercased. So let's test them. + call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ")) +endfunc + +func Test_toupper() + call assert_equal("", toupper("")) + + " Test with all printable ASCII characters. + call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~', + \ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')) + + if !has('multi_byte') + return + endif + + " Test with a few lowercase diacritics. + call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả")) + call assert_equal("BḂḆ", toupper("bḃḇ")) + call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč")) + call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ")) + call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("eèéêëēĕėęěẻẽ")) + call assert_equal("FḞ", toupper("fḟ")) + call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("gĝğġģǥǧǵḡ")) + call assert_equal("HĤĦḢḦḨẖ", toupper("hĥħḣḧḩẖ")) + call assert_equal("IÌÍÎÏĨĪĬĮǏỈ", toupper("iìíîïĩīĭįǐỉ")) + call assert_equal("JĴǰ", toupper("jĵǰ")) + call assert_equal("KĶǨḰḴ", toupper("kķǩḱḵ")) + call assert_equal("LĹĻĽĿŁḺ", toupper("lĺļľŀłḻ")) + call assert_equal("MḾṀ ", toupper("mḿṁ ")) + call assert_equal("NÑŃŅŇʼnṄṈ", toupper("nñńņňʼnṅṉ")) + call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("oòóôõöøōŏőơǒǫǭỏ")) + call assert_equal("PṔṖ", toupper("pṕṗ")) + call assert_equal("Q", toupper("q")) + call assert_equal("RŔŖŘṘṞ", toupper("rŕŗřṙṟ")) + call assert_equal("SŚŜŞŠṠ", toupper("sśŝşšṡ")) + call assert_equal("TŢŤŦṪṮẗ", toupper("tţťŧṫṯẗ")) + call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("uùúûüũūŭůűųưǔủ")) + call assert_equal("VṼ", toupper("vṽ")) + call assert_equal("WŴẀẂẄẆẘ", toupper("wŵẁẃẅẇẘ")) + call assert_equal("ẊẌ", toupper("ẋẍ")) + call assert_equal("YÝŸŶẎẙỲỶỸ", toupper("yýÿŷẏẙỳỷỹ")) + call assert_equal("ZŹŻŽƵẐẔ", toupper("zźżžƶẑẕ")) + + " Test that uppercase diacritics, which should remain unchanged. + call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("AÀÁÂÃÄÅĀĂĄǍǞǠẢ")) + call assert_equal("BḂḆ", toupper("BḂḆ")) + call assert_equal("CÇĆĈĊČ", toupper("CÇĆĈĊČ")) + call assert_equal("DĎĐḊḎḐ", toupper("DĎĐḊḎḐ")) + call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("EÈÉÊËĒĔĖĘĚẺẼ")) + call assert_equal("FḞ ", toupper("FḞ ")) + call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("GĜĞĠĢǤǦǴḠ")) + call assert_equal("HĤĦḢḦḨ", toupper("HĤĦḢḦḨ")) + call assert_equal("IÌÍÎÏĨĪĬĮİǏỈ", toupper("IÌÍÎÏĨĪĬĮİǏỈ")) + call assert_equal("JĴ", toupper("JĴ")) + call assert_equal("KĶǨḰḴ", toupper("KĶǨḰḴ")) + call assert_equal("LĹĻĽĿŁḺ", toupper("LĹĻĽĿŁḺ")) + call assert_equal("MḾṀ", toupper("MḾṀ")) + call assert_equal("NÑŃŅŇṄṈ", toupper("NÑŃŅŇṄṈ")) + call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ")) + call assert_equal("PṔṖ", toupper("PṔṖ")) + call assert_equal("Q", toupper("Q")) + call assert_equal("RŔŖŘṘṞ", toupper("RŔŖŘṘṞ")) + call assert_equal("SŚŜŞŠṠ", toupper("SŚŜŞŠṠ")) + call assert_equal("TŢŤŦṪṮ", toupper("TŢŤŦṪṮ")) + call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("UÙÚÛÜŨŪŬŮŰŲƯǓỦ")) + call assert_equal("VṼ", toupper("VṼ")) + call assert_equal("WŴẀẂẄẆ", toupper("WŴẀẂẄẆ")) + call assert_equal("XẊẌ", toupper("XẊẌ")) + call assert_equal("YÝŶŸẎỲỶỸ", toupper("YÝŶŸẎỲỶỸ")) + call assert_equal("ZŹŻŽƵẐẔ", toupper("ZŹŻŽƵẐẔ")) + + call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ")) +endfunc + + diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index a22dca35cc..c529971528 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -1606,6 +1606,40 @@ fun! Test_normal30_changecase() norm! V~ call assert_equal('THIS IS A simple test: äüöss', getline('.')) + " Turkish ASCII turns to multi-byte. On Mac the Turkish locale is available + " but toupper()/tolower() don't do the right thing. + if !has('mac') && !has('osx') + try + lang tr_TR.UTF-8 + set casemap= + call setline(1, 'iI') + 1normal gUU + call assert_equal("\u0130I", getline(1)) + call assert_equal("\u0130I", toupper("iI")) + + call setline(1, 'iI') + 1normal guu + call assert_equal("i\u0131", getline(1)) + call assert_equal("i\u0131", tolower("iI")) + + set casemap& + call setline(1, 'iI') + 1normal gUU + call assert_equal("II", getline(1)) + call assert_equal("II", toupper("iI")) + + call setline(1, 'iI') + 1normal guu + call assert_equal("ii", getline(1)) + call assert_equal("ii", tolower("iI")) + + lang en_US.UTF-8 + catch /E197:/ + " can't use Turkish locale + throw 'Skipped: Turkish locale not available' + endtry + endif + " clean up bw! endfunc diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim new file mode 100644 index 0000000000..2d1557ebd9 --- /dev/null +++ b/src/nvim/testdir/test_taglist.vim @@ -0,0 +1,58 @@ +" test 'taglist' function + +func Test_taglist() + call writefile([ + \ "FFoo\tXfoo\t1", + \ "FBar\tXfoo\t2", + \ "BFoo\tXbar\t1", + \ "BBar\tXbar\t2" + \ ], 'Xtags') + set tags=Xtags + split Xtext + + call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name})) + call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name})) + call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name})) + call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name})) + + call delete('Xtags') + bwipe +endfunc + +func Test_taglist_native_etags() + if !has('emacs_tags') + return + endif + call writefile([ + \ "\x0c", + \ "src/os_unix.c,13491", + \ "set_signals(\x7f1335,32699", + \ "reset_signals(\x7f1407,34136", + \ ], 'Xtags') + + set tags=Xtags + + call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']], + \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]})) + + call delete('Xtags') +endfunc + +func Test_taglist_ctags_etags() + if !has('emacs_tags') + return + endif + call writefile([ + \ "\x0c", + \ "src/os_unix.c,13491", + \ "set_signals(void)\x7fset_signals\x011335,32699", + \ "reset_signals(void)\x7freset_signals\x011407,34136", + \ ], 'Xtags') + + set tags=Xtags + + call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']], + \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]})) + + call delete('Xtags') +endfunc diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 4d4e8d9bb9..571ad7204f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -76,6 +76,7 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <fcntl.h> @@ -966,12 +967,12 @@ static u_entry_T *unserialize_uep(bufinfo_T * bi, bool *error, uep->ue_lcount = undo_read_4c(bi); uep->ue_size = undo_read_4c(bi); - char_u **array; + char_u **array = NULL; if (uep->ue_size > 0) { - array = xmalloc(sizeof(char_u *) * (size_t)uep->ue_size); - memset(array, 0, sizeof(char_u *) * (size_t)uep->ue_size); - } else { - array = NULL; + if ((size_t)uep->ue_size < SIZE_MAX / sizeof(char_u *)) { + array = xmalloc(sizeof(char_u *) * (size_t)uep->ue_size); + memset(array, 0, sizeof(char_u *) * (size_t)uep->ue_size); + } } uep->ue_array = array; @@ -1400,7 +1401,9 @@ void u_read_undo(char *name, char_u *hash, char_u *orig_name) // sequence numbers of the headers. // When there are no headers uhp_table is NULL. if (num_head > 0) { - uhp_table = xmalloc((size_t)num_head * sizeof(u_header_T *)); + if ((size_t)num_head < SIZE_MAX / sizeof(*uhp_table)) { + uhp_table = xmalloc((size_t)num_head * sizeof(*uhp_table)); + } } long num_read_uhps = 0; diff --git a/src/nvim/vim.h b/src/nvim/vim.h index cc0587fb88..172e62b039 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -11,20 +11,16 @@ #define RUNTIME_DIRNAME "runtime" /* end */ -/* ============ the header file puzzle (ca. 50-100 pieces) ========= */ - -#ifdef HAVE_CONFIG_H /* GNU autoconf (or something else) was here */ -# include "auto/config.h" -# define HAVE_PATHDEF +#include "auto/config.h" +#define HAVE_PATHDEF /* * Check if configure correctly managed to find sizeof(int). If this failed, * it becomes zero. This is likely a problem of not being able to run the * test program. Other items from configure may also be wrong then! */ -# if (SIZEOF_INT == 0) -Error: configure did not run properly.Check auto/config.log. -# endif +#if (SIZEOF_INT == 0) +# error Configure did not run properly. #endif #include "nvim/os/os_defs.h" /* bring lots of system header files */ @@ -46,11 +42,6 @@ enum { NUMBUFLEN = 65 }; #include "nvim/keymap.h" #include "nvim/macros.h" - - - -/* ================ end of the header file puzzle =============== */ - #include "nvim/gettext.h" /* special attribute addition: Put message in history */ diff --git a/test/config/paths.lua.in b/test/config/paths.lua.in index 8dd4de75db..7fe5d8ad80 100644 --- a/test/config/paths.lua.in +++ b/test/config/paths.lua.in @@ -5,7 +5,8 @@ for p in ("${TEST_INCLUDE_DIRS}" .. ";"):gmatch("[^;]+") do table.insert(module.include_paths, p) end -module.test_include_path = "${CMAKE_BINARY_DIR}/test/includes/post" +module.test_build_dir = "${CMAKE_BINARY_DIR}" +module.test_include_path = module.test_build_dir .. "/test/includes/post" module.test_libnvim_path = "${TEST_LIBNVIM_PATH}" module.test_source_path = "${CMAKE_SOURCE_DIR}" module.test_lua_prg = "${LUA_PRG}" diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 552e3a8564..c3002618b0 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -5,7 +5,7 @@ local curbufmeths, ok = helpers.curbufmeths, helpers.ok local funcs = helpers.funcs local request = helpers.request local exc_exec = helpers.exc_exec -local execute = helpers.execute +local feed_command = helpers.feed_command local insert = helpers.insert local NIL = helpers.NIL local meth_pcall = helpers.meth_pcall @@ -246,7 +246,7 @@ describe('api/buf', function() end) it("set_line on alternate buffer does not access invalid line (E315)", function() - execute('set hidden') + feed_command('set hidden') insert('Initial file') command('enew') insert([[ @@ -257,7 +257,7 @@ describe('api/buf', function() The Other Buffer]]) - execute('$') + feed_command('$') local retval = exc_exec("call nvim_buf_set_lines(1, 0, 1, v:false, ['test'])") eq(0, retval) end) diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 78639d7ed7..9d7cfb9b78 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, eval, execute, nvim, next_message = - helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.nvim, +local eq, clear, eval, command, nvim, next_message = + helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.nvim, helpers.next_message local meths = helpers.meths @@ -16,8 +16,8 @@ describe('notify', function() it('sends the notification/args to the corresponding channel', function() eval('rpcnotify('..channel..', "test-event", 1, 2, 3)') eq({'notification', 'test-event', {1, 2, 3}}, next_message()) - execute('au FileType lua call rpcnotify('..channel..', "lua!")') - execute('set filetype=lua') + command('au FileType lua call rpcnotify('..channel..', "lua!")') + command('set filetype=lua') eq({'notification', 'lua!', {}}, next_message()) end) end) diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 76a335a8f4..658077b112 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -1,6 +1,8 @@ -- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate -- `rpcrequest` calls we need the client event loop to be running. local helpers = require('test.functional.helpers')(after_each) +local Paths = require('test.config.paths') + local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs @@ -200,7 +202,7 @@ describe('server -> client', function() \ 'rpc': v:true \ } ]]) - local lua_prog = arg[-1] + local lua_prog = Paths.test_lua_prg meths.set_var("args", {lua_prog, 'test/functional/api/rpc_fixture.lua'}) jobid = eval("jobstart(g:args, g:job_opts)") neq(0, 'jobid') diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index c38bd75c69..8ee9462a8d 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -1,9 +1,13 @@ local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command local eq = helpers.eq local eval = helpers.eval +local clear = helpers.clear +local meths = helpers.meths +local expect = helpers.expect +local command = helpers.command +local exc_exec = helpers.exc_exec +local curbufmeths = helpers.curbufmeths describe('autocmds:', function() before_each(clear) @@ -33,4 +37,22 @@ describe('autocmds:', function() it('v:vim_did_enter is 1 after VimEnter', function() eq(1, eval('v:vim_did_enter')) end) + + describe('BufLeave autocommand', function() + it('can wipe out the buffer created by :edit which triggered autocmd', + function() + meths.set_option('hidden', true) + curbufmeths.set_lines(0, 1, false, { + 'start of test file xx', + 'end of test file xx'}) + + command('autocmd BufLeave * bwipeout yy') + eq('Vim(edit):E143: Autocommands unexpectedly deleted new buffer yy', + exc_exec('edit yy')) + + expect([[ + start of test file xx + end of test file xx]]) + end) + end) end) diff --git a/test/functional/autocmd/bufenter_spec.lua b/test/functional/autocmd/bufenter_spec.lua index ccbcdf5c5e..fef9838050 100644 --- a/test/functional/autocmd/bufenter_spec.lua +++ b/test/functional/autocmd/bufenter_spec.lua @@ -4,7 +4,6 @@ local clear = helpers.clear local command = helpers.command local eq = helpers.eq local eval = helpers.eval -local execute = helpers.execute local request = helpers.request local source = helpers.source @@ -28,7 +27,7 @@ describe('autocmd BufEnter', function() endtry endfunction ]]) - execute("call Test()") + command("call Test()") eq(1, eval("exists('g:dir_bufenter')")) -- Did BufEnter for the directory. eq(2, eval("bufnr('%')")) -- Switched to the dir buffer. end) diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua index bd5f1912c5..486a3346b1 100644 --- a/test/functional/autocmd/textyankpost_spec.lua +++ b/test/functional/autocmd/textyankpost_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq -local feed, execute, expect, command = helpers.feed, helpers.execute, helpers.expect, helpers.command +local feed, command, expect = helpers.feed, helpers.command, helpers.expect local curbufmeths, funcs, neq = helpers.curbufmeths, helpers.funcs, helpers.neq describe('TextYankPost', function() @@ -8,11 +8,11 @@ describe('TextYankPost', function() clear() -- emulate the clipboard so system clipboard isn't affected - execute('let &rtp = "test/functional/fixtures,".&rtp') + command('let &rtp = "test/functional/fixtures,".&rtp') - execute('let g:count = 0') - execute('autocmd TextYankPost * let g:event = copy(v:event)') - execute('autocmd TextYankPost * let g:count += 1') + command('let g:count = 0') + command('autocmd TextYankPost * let g:event = copy(v:event)') + command('autocmd TextYankPost * let g:count += 1') curbufmeths.set_lines(0, -1, true, { 'foo\0bar', @@ -61,27 +61,27 @@ describe('TextYankPost', function() regtype = 'V' }, eval('g:event')) - execute('set debug=msg') + command('set debug=msg') -- the regcontents should not be changed without copy. local status, err = pcall(command,'call extend(g:event.regcontents, ["more text"])') eq(status,false) neq(nil, string.find(err, ':E742:')) -- can't mutate keys inside the autocommand - execute('autocmd! TextYankPost * let v:event.regcontents = 0') + command('autocmd! TextYankPost * let v:event.regcontents = 0') status, err = pcall(command,'normal yy') eq(status,false) neq(nil, string.find(err, ':E46:')) -- can't add keys inside the autocommand - execute('autocmd! TextYankPost * let v:event.mykey = 0') + command('autocmd! TextYankPost * let v:event.mykey = 0') status, err = pcall(command,'normal yy') eq(status,false) neq(nil, string.find(err, ':E742:')) end) it('is not invoked recursively', function() - execute('autocmd TextYankPost * normal "+yy') + command('autocmd TextYankPost * normal "+yy') feed('yy') eq({ operator = 'y', @@ -134,7 +134,7 @@ describe('TextYankPost', function() feed('"_yy') eq(0, eval('g:count')) - execute('delete _') + command('delete _') eq(0, eval('g:count')) end) @@ -155,7 +155,7 @@ describe('TextYankPost', function() regtype = 'V' }, eval('g:event')) - execute("set clipboard=unnamed") + command("set clipboard=unnamed") -- regname still shows the name the user requested feed('yy') @@ -176,7 +176,7 @@ describe('TextYankPost', function() end) it('works with Ex commands', function() - execute('1delete +') + command('1delete +') eq({ operator = 'd', regcontents = { 'foo\nbar' }, @@ -185,7 +185,7 @@ describe('TextYankPost', function() }, eval('g:event')) eq(1, eval('g:count')) - execute('yank') + command('yank') eq({ operator = 'y', regcontents = { 'baz text' }, @@ -194,7 +194,7 @@ describe('TextYankPost', function() }, eval('g:event')) eq(2, eval('g:count')) - execute('normal yw') + command('normal yw') eq({ operator = 'y', regcontents = { 'baz ' }, @@ -203,7 +203,7 @@ describe('TextYankPost', function() }, eval('g:event')) eq(3, eval('g:count')) - execute('normal! dd') + command('normal! dd') eq({ operator = 'd', regcontents = { 'baz text' }, diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua index d969d4a487..eb2eeee0da 100644 --- a/test/functional/clipboard/clipboard_provider_spec.lua +++ b/test/functional/clipboard/clipboard_provider_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval +local feed_command, expect, eq, eval = helpers.feed_command, helpers.expect, helpers.eq, helpers.eval local function basic_register_test(noblock) insert("some words") @@ -95,7 +95,7 @@ describe('clipboard usage', function() before_each(function() reset() - execute('call getreg("*")') -- force load of provider + feed_command('call getreg("*")') -- force load of provider end) it('has independent "* and unnamed registers per default', function() @@ -140,8 +140,8 @@ describe('clipboard usage', function() end) it('support autodectection of regtype', function() - execute("let g:test_clip['*'] = ['linewise stuff','']") - execute("let g:test_clip['+'] = ['charwise','stuff']") + feed_command("let g:test_clip['*'] = ['linewise stuff','']") + feed_command("let g:test_clip['+'] = ['charwise','stuff']") eq("V", eval("getregtype('*')")) eq("v", eval("getregtype('+')")) insert("just some text") @@ -156,7 +156,7 @@ describe('clipboard usage', function() insert([[ much text]]) - execute("let g:test_clip['*'] = [['very','block'],'b']") + feed_command("let g:test_clip['*'] = [['very','block'],'b']") feed('gg"*P') expect([[ very much @@ -170,15 +170,15 @@ describe('clipboard usage', function() end) it('supports setreg', function() - execute('call setreg("*", "setted\\ntext", "c")') - execute('call setreg("+", "explicitly\\nlines", "l")') + feed_command('call setreg("*", "setted\\ntext", "c")') + feed_command('call setreg("+", "explicitly\\nlines", "l")') feed('"+P"*p') expect([[ esetted textxplicitly lines ]]) - execute('call setreg("+", "blocky\\nindeed", "b")') + feed_command('call setreg("+", "blocky\\nindeed", "b")') feed('"+p') expect([[ esblockyetted @@ -188,13 +188,13 @@ describe('clipboard usage', function() end) it('supports let @+ (issue #1427)', function() - execute("let @+ = 'some'") - execute("let @* = ' other stuff'") + feed_command("let @+ = 'some'") + feed_command("let @* = ' other stuff'") eq({{'some'}, 'v'}, eval("g:test_clip['+']")) eq({{' other stuff'}, 'v'}, eval("g:test_clip['*']")) feed('"+p"*p') expect('some other stuff') - execute("let @+ .= ' more'") + feed_command("let @+ .= ' more'") feed('dd"+p') expect('some more') end) @@ -202,7 +202,7 @@ describe('clipboard usage', function() it('pastes unnamed register if the provider fails', function() insert('the text') feed('yy') - execute("let g:cliperror = 1") + feed_command("let g:cliperror = 1") feed('"*p') expect([[ the text @@ -214,7 +214,7 @@ describe('clipboard usage', function() -- the basic behavior of unnamed register should be the same -- even when handled by clipboard provider before_each(function() - execute('set clipboard=unnamed') + feed_command('set clipboard=unnamed') end) it('works', function() @@ -222,7 +222,7 @@ describe('clipboard usage', function() end) it('works with pure text clipboard', function() - execute("let g:cliplossy = 1") + feed_command("let g:cliplossy = 1") -- expect failure for block mode basic_register_test(true) end) @@ -237,7 +237,7 @@ describe('clipboard usage', function() -- "+ shouldn't have changed eq({''}, eval("g:test_clip['+']")) - execute("let g:test_clip['*'] = ['linewise stuff','']") + feed_command("let g:test_clip['*'] = ['linewise stuff','']") feed('p') expect([[ words @@ -247,7 +247,7 @@ describe('clipboard usage', function() it('does not clobber "0 when pasting', function() insert('a line') feed('yy') - execute("let g:test_clip['*'] = ['b line','']") + feed_command("let g:test_clip['*'] = ['b line','']") feed('"0pp"0p') expect([[ a line @@ -258,20 +258,20 @@ describe('clipboard usage', function() it('supports v:register and getreg() without parameters', function() eq('*', eval('v:register')) - execute("let g:test_clip['*'] = [['some block',''], 'b']") + feed_command("let g:test_clip['*'] = [['some block',''], 'b']") eq('some block', eval('getreg()')) eq('\02210', eval('getregtype()')) end) it('yanks visual selection when pasting', function() insert("indeed visual") - execute("let g:test_clip['*'] = [['clipboard'], 'c']") + feed_command("let g:test_clip['*'] = [['clipboard'], 'c']") feed("viwp") eq({{'visual'}, 'v'}, eval("g:test_clip['*']")) expect("indeed clipboard") -- explicit "* should do the same - execute("let g:test_clip['*'] = [['star'], 'c']") + feed_command("let g:test_clip['*'] = [['star'], 'c']") feed('viw"*p') eq({{'clipboard'}, 'v'}, eval("g:test_clip['*']")) expect("indeed star") @@ -280,7 +280,7 @@ describe('clipboard usage', function() it('unamed operations work even if the provider fails', function() insert('the text') feed('yy') - execute("let g:cliperror = 1") + feed_command("let g:cliperror = 1") feed('p') expect([[ the text @@ -294,11 +294,11 @@ describe('clipboard usage', function() match text ]]) - execute('g/match/d') + feed_command('g/match/d') eq('match\n', eval('getreg("*")')) feed('u') eval('setreg("*", "---")') - execute('g/test/') + feed_command('g/test/') feed('<esc>') eq('---', eval('getreg("*")')) end) @@ -307,7 +307,7 @@ describe('clipboard usage', function() describe('with clipboard=unnamedplus', function() before_each(function() - execute('set clipboard=unnamedplus') + feed_command('set clipboard=unnamedplus') end) it('links the "+ and unnamed registers', function() @@ -320,13 +320,13 @@ describe('clipboard usage', function() -- "* shouldn't have changed eq({''}, eval("g:test_clip['*']")) - execute("let g:test_clip['+'] = ['three']") + feed_command("let g:test_clip['+'] = ['three']") feed('p') expect('twothree') end) it('and unnamed, yanks to both', function() - execute('set clipboard=unnamedplus,unnamed') + feed_command('set clipboard=unnamedplus,unnamed') insert([[ really unnamed text]]) @@ -340,8 +340,8 @@ describe('clipboard usage', function() -- unnamedplus takes predecence when pasting eq('+', eval('v:register')) - execute("let g:test_clip['+'] = ['the plus','']") - execute("let g:test_clip['*'] = ['the star','']") + feed_command("let g:test_clip['+'] = ['the plus','']") + feed_command("let g:test_clip['*'] = ['the star','']") feed("p") expect([[ text @@ -356,11 +356,11 @@ describe('clipboard usage', function() match text ]]) - execute('g/match/d') + feed_command('g/match/d') eq('match\n', eval('getreg("+")')) feed('u') eval('setreg("+", "---")') - execute('g/test/') + feed_command('g/test/') feed('<esc>') eq('---', eval('getreg("+")')) end) @@ -375,13 +375,13 @@ describe('clipboard usage', function() it('supports :put', function() insert("a line") - execute("let g:test_clip['*'] = ['some text']") - execute("let g:test_clip['+'] = ['more', 'text', '']") - execute(":put *") + feed_command("let g:test_clip['*'] = ['some text']") + feed_command("let g:test_clip['+'] = ['more', 'text', '']") + feed_command(":put *") expect([[ a line some text]]) - execute(":put +") + feed_command(":put +") expect([[ a line some text @@ -392,9 +392,9 @@ describe('clipboard usage', function() it('supports "+ and "* in registers', function() local screen = Screen.new(60, 10) screen:attach() - execute("let g:test_clip['*'] = ['some', 'star data','']") - execute("let g:test_clip['+'] = ['such', 'plus', 'stuff']") - execute("registers") + feed_command("let g:test_clip['*'] = ['some', 'star data','']") + feed_command("let g:test_clip['+'] = ['such', 'plus', 'stuff']") + feed_command("registers") screen:expect([[ ~ | ~ | @@ -418,17 +418,17 @@ describe('clipboard usage', function() insert('s/s/t/') feed('gg"*y$:<c-r>*<cr>') expect('t/s/t/') - execute("let g:test_clip['*'] = ['s/s/u']") + feed_command("let g:test_clip['*'] = ['s/s/u']") feed(':<c-r>*<cr>') expect('t/u/t/') end) it('supports :redir @*>', function() - execute("let g:test_clip['*'] = ['stuff']") - execute('redir @*>') + feed_command("let g:test_clip['*'] = ['stuff']") + feed_command('redir @*>') -- it is made empty eq({{''}, 'v'}, eval("g:test_clip['*']")) - execute('let g:test = doesnotexist') + feed_command('let g:test = doesnotexist') feed('<cr>') eq({{ '', @@ -436,7 +436,7 @@ describe('clipboard usage', function() 'E121: Undefined variable: doesnotexist', 'E15: Invalid expression: doesnotexist', }, 'v'}, eval("g:test_clip['*']")) - execute(':echo "Howdy!"') + feed_command(':echo "Howdy!"') eq({{ '', '', @@ -448,7 +448,7 @@ describe('clipboard usage', function() end) it('handles middleclick correctly', function() - execute('set mouse=a') + feed_command('set mouse=a') local screen = Screen.new(30, 5) screen:attach() @@ -471,7 +471,7 @@ describe('clipboard usage', function() the a target]]) -- on error, fall back to unnamed register - execute("let g:cliperror = 1") + feed_command("let g:cliperror = 1") feed('<MiddleMouse><6,1>') expect([[ the source diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 9ee91f2fe9..b98169b067 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, eq, eval, exc_exec, execute, feed, insert, neq, next_msg, nvim, +local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim, nvim_dir, ok, source, write_file, mkdir, rmdir = helpers.clear, - helpers.eq, helpers.eval, helpers.exc_exec, helpers.execute, helpers.feed, + helpers.eq, helpers.eval, helpers.exc_exec, helpers.feed_command, helpers.feed, helpers.insert, helpers.neq, helpers.next_message, helpers.nvim, helpers.nvim_dir, helpers.ok, helpers.source, helpers.write_file, helpers.mkdir, helpers.rmdir @@ -94,7 +94,7 @@ describe('jobs', function() it('returns 0 when it fails to start', function() eq("", eval("v:errmsg")) - execute("let g:test_jobid = jobstart([])") + feed_command("let g:test_jobid = jobstart([])") eq(0, eval("g:test_jobid")) eq("E474:", string.match(eval("v:errmsg"), "E%d*:")) end) @@ -470,7 +470,7 @@ describe('jobs', function() end) it('will return -2 when interrupted', function() - execute('call rpcnotify(g:channel, "ready") | '.. + feed_command('call rpcnotify(g:channel, "ready") | '.. 'call rpcnotify(g:channel, "wait", '.. 'jobwait([jobstart("sleep 10; exit 55")]))') eq({'notification', 'ready', {}}, next_msg()) @@ -514,7 +514,7 @@ describe('jobs', function() \ ]) endfunction ]]) - execute('call Run()') + feed_command('call Run()') local r for i = 10, 1, -1 do r = next_msg() @@ -668,7 +668,7 @@ describe("pty process teardown", function() it("does not prevent/delay exit. #4798 #4900", function() if helpers.pending_win32(pending) then return end -- Use a nested nvim (in :term) to test without --headless. - execute(":terminal '"..helpers.nvim_prog + feed_command(":terminal '"..helpers.nvim_prog -- Use :term again in the _nested_ nvim to get a PTY process. -- Use `sleep` to simulate a long-running child of the PTY. .."' +terminal +'!(sleep 300 &)' +qa") diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index 21dd228145..7f6f53d226 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local lfs = require('lfs') -local neq, eq, execute = helpers.neq, helpers.eq, helpers.execute +local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear, curbufmeths = helpers.clear, helpers.curbufmeths local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval local insert = helpers.insert @@ -10,17 +10,17 @@ describe('api functions', function() before_each(clear) it("work", function() - execute("call nvim_command('let g:test = 1')") + command("call nvim_command('let g:test = 1')") eq(1, eval("nvim_get_var('test')")) local buf = eval("nvim_get_current_buf()") - execute("call nvim_buf_set_lines("..buf..", 0, -1, v:true, ['aa', 'bb'])") + command("call nvim_buf_set_lines("..buf..", 0, -1, v:true, ['aa', 'bb'])") expect([[ aa bb]]) - execute("call nvim_win_set_cursor(0, [1, 1])") - execute("call nvim_input('ax<esc>')") + command("call nvim_win_set_cursor(0, [1, 1])") + command("call nvim_input('ax<esc>')") expect([[ aax bb]]) @@ -57,7 +57,7 @@ describe('api functions', function() eq(bnr, bhnd) eq(wid, whnd) - execute("new") -- creates new buffer and new window + command("new") -- creates new buffer and new window local bnr2 = eval("bufnr('')") local bhnd2 = eval("nvim_get_current_buf()") local wid2 = eval("win_getid()") @@ -69,7 +69,7 @@ describe('api functions', function() -- 0 is synonymous to the current buffer eq(bnr2, eval("nvim_buf_get_number(0)")) - execute("bn") -- show old buffer in new window + command("bn") -- show old buffer in new window eq(bnr, eval("nvim_get_current_buf()")) eq(bnr, eval("bufnr('')")) eq(bnr, eval("nvim_buf_get_number(0)")) @@ -81,7 +81,7 @@ describe('api functions', function() curbufmeths.set_lines(0, -1, true, {"aa\0", "b\0b"}) eq({'aa\n', 'b\nb'}, eval("nvim_buf_get_lines(0, 0, -1, 1)")) - execute('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])') + command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])') eq({'aa\0', 'xx', '\0yy'}, curbufmeths.get_lines(0, -1, 1)) end) @@ -124,9 +124,9 @@ describe('api functions', function() [5] = {bold = true, foreground = Screen.colors.Blue}, }) - execute("set ft=vim") - execute("let &rtp='build/runtime/,'.&rtp") - execute("syntax on") + command("set ft=vim") + command("let &rtp='build/runtime/,'.&rtp") + command("syntax on") insert([[ call bufnr('%') call nvim_input('typing...') diff --git a/test/functional/eval/glob_spec.lua b/test/functional/eval/glob_spec.lua index 599b3dcdc3..b8807ecfcc 100644 --- a/test/functional/eval/glob_spec.lua +++ b/test/functional/eval/glob_spec.lua @@ -1,13 +1,13 @@ local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) -local clear, execute, eval, eq = helpers.clear, helpers.execute, helpers.eval, helpers.eq +local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq before_each(function() clear() lfs.mkdir('test-glob') -- Long path might cause "Press ENTER" prompt; use :silent to avoid it. - execute('silent cd test-glob') + command('silent cd test-glob') end) after_each(function() diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index fc0a19bdfa..4d34cde849 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -4,16 +4,17 @@ local funcs = helpers.funcs local meths = helpers.meths local eq = helpers.eq local eval = helpers.eval -local execute = helpers.execute +local command = helpers.command local exc_exec = helpers.exc_exec local redir_exec = helpers.redir_exec local NIL = helpers.NIL +local source = helpers.source describe('json_decode() function', function() local restart = function(...) clear(...) - execute('language C') - execute([[ + source([[ + language C function Eq(exp, act) let act = a:act let exp = a:exp @@ -45,8 +46,6 @@ describe('json_decode() function', function() endif return 1 endfunction - ]]) - execute([[ function EvalEq(exp, act_expr) let act = eval(a:act_expr) if Eq(a:exp, act) @@ -441,7 +440,7 @@ describe('json_decode() function', function() local sp_decode_eq = function(expected, json) meths.set_var('__json', json) speq(expected, 'json_decode(g:__json)') - execute('unlet! g:__json') + command('unlet! g:__json') end it('parses strings with NUL properly', function() @@ -527,7 +526,7 @@ end) describe('json_encode() function', function() before_each(function() clear() - execute('language C') + command('language C') end) it('dumps strings', function() @@ -576,94 +575,94 @@ describe('json_encode() function', function() it('cannot dump generic mapping with generic mapping keys and values', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('let todumpv1 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('let todumpv2 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('call add(todump._VAL, [todumpv1, todumpv2])') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('let todumpv1 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('let todumpv2 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('call add(todump._VAL, [todumpv1, todumpv2])') eq('Vim(call):E474: Invalid key in special dictionary', exc_exec('call json_encode(todump)')) end) it('cannot dump generic mapping with ext key', function() - execute('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('Vim(call):E474: Invalid key in special dictionary', exc_exec('call json_encode(todump)')) end) it('cannot dump generic mapping with array key', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('Vim(call):E474: Invalid key in special dictionary', exc_exec('call json_encode(todump)')) end) it('cannot dump generic mapping with UINT64_MAX key', function() - execute('let todump = {"_TYPE": v:msgpack_types.integer}') - execute('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.integer}') + command('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('Vim(call):E474: Invalid key in special dictionary', exc_exec('call json_encode(todump)')) end) it('cannot dump generic mapping with floating-point key', function() - execute('let todump = {"_TYPE": v:msgpack_types.float, "_VAL": 0.125}') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.float, "_VAL": 0.125}') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('Vim(call):E474: Invalid key in special dictionary', exc_exec('call json_encode(todump)')) end) it('can dump generic mapping with STR special key and NUL', function() - execute('let todump = {"_TYPE": v:msgpack_types.string, "_VAL": ["\\n"]}') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.string, "_VAL": ["\\n"]}') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('{"\\u0000": 1}', eval('json_encode(todump)')) end) it('can dump generic mapping with BIN special key and NUL', function() - execute('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n"]}') - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') + command('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n"]}') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}') eq('{"\\u0000": 1}', eval('json_encode(todump)')) end) it('can dump STR special mapping with NUL and NL', function() - execute('let todump = {"_TYPE": v:msgpack_types.string, "_VAL": ["\\n", ""]}') + command('let todump = {"_TYPE": v:msgpack_types.string, "_VAL": ["\\n", ""]}') eq('"\\u0000\\n"', eval('json_encode(todump)')) end) it('can dump BIN special mapping with NUL and NL', function() - execute('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n", ""]}') + command('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n", ""]}') eq('"\\u0000\\n"', eval('json_encode(todump)')) end) it('cannot dump special ext mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') + command('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') eq('Vim(call):E474: Unable to convert EXT string to JSON', exc_exec('call json_encode(todump)')) end) it('can dump special array mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') eq('[5, [""]]', eval('json_encode(todump)')) end) it('can dump special UINT64_MAX mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.integer}') - execute('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') + command('let todump = {"_TYPE": v:msgpack_types.integer}') + command('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') eq('18446744073709551615', eval('json_encode(todump)')) end) it('can dump special INT64_MIN mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.integer}') - execute('let todump._VAL = [-1, 2, 0, 0]') + command('let todump = {"_TYPE": v:msgpack_types.integer}') + command('let todump._VAL = [-1, 2, 0, 0]') eq('-9223372036854775808', eval('json_encode(todump)')) end) it('can dump special BOOLEAN true mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 1}') + command('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 1}') eq('true', eval('json_encode(todump)')) end) it('can dump special BOOLEAN false mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 0}') + command('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 0}') eq('false', eval('json_encode(todump)')) end) it('can dump special NIL mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.nil, "_VAL": 0}') + command('let todump = {"_TYPE": v:msgpack_types.nil, "_VAL": 0}') eq('null', eval('json_encode(todump)')) end) @@ -673,7 +672,7 @@ describe('json_encode() function', function() end) it('fails to dump a partial', function() - execute('function T() dict\nendfunction') + command('function T() dict\nendfunction') eq('Vim(call):E474: Error while dumping encode_tv2json() argument, itself: attempt to dump function reference', exc_exec('call json_encode(function("T", [1, 2], {}))')) end) @@ -684,56 +683,56 @@ describe('json_encode() function', function() end) it('fails to dump a recursive list', function() - execute('let todump = [[[]]]') - execute('call add(todump[0][0], todump)') + command('let todump = [[[]]]') + command('call add(todump[0][0], todump)') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode(todump)')) end) it('fails to dump a recursive dict', function() - execute('let todump = {"d": {"d": {}}}') - execute('call extend(todump.d.d, {"d": todump})') + command('let todump = {"d": {"d": {}}}') + command('call extend(todump.d.d, {"d": todump})') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode([todump])')) end) it('can dump dict with two same dicts inside', function() - execute('let inter = {}') - execute('let todump = {"a": inter, "b": inter}') + command('let inter = {}') + command('let todump = {"a": inter, "b": inter}') eq('{"a": {}, "b": {}}', eval('json_encode(todump)')) end) it('can dump list with two same lists inside', function() - execute('let inter = []') - execute('let todump = [inter, inter]') + command('let inter = []') + command('let todump = [inter, inter]') eq('[[], []]', eval('json_encode(todump)')) end) it('fails to dump a recursive list in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') - execute('call add(todump._VAL, todump)') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') + command('call add(todump._VAL, todump)') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode(todump)')) end) it('fails to dump a recursive (val) map in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('call add(todump._VAL, ["", todump])') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('call add(todump._VAL, ["", todump])') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode([todump])')) end) it('fails to dump a recursive (val) map in a special dict, _VAL reference', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [["", []]]}') - execute('call add(todump._VAL[0][1], todump._VAL)') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [["", []]]}') + command('call add(todump._VAL[0][1], todump._VAL)') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode(todump)')) end) it('fails to dump a recursive (val) special list in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') - execute('call add(todump._VAL, ["", todump._VAL])') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') + command('call add(todump._VAL, ["", todump._VAL])') eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call json_encode(todump)')) end) diff --git a/test/functional/eval/modeline_spec.lua b/test/functional/eval/modeline_spec.lua index 0be7210a76..c5bb798f4a 100644 --- a/test/functional/eval/modeline_spec.lua +++ b/test/functional/eval/modeline_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, execute, write_file = helpers.clear, helpers.execute, helpers.write_file +local clear, command, write_file = helpers.clear, helpers.command, helpers.write_file local eq, eval = helpers.eq, helpers.eval describe("modeline", function() @@ -12,7 +12,7 @@ describe("modeline", function() it('does not crash with a large version number', function() write_file(tempfile, 'vim100000000000000000000000') - execute('e! ' .. tempfile) + command('e! ' .. tempfile) eq(2, eval('1+1')) -- Still alive? end) diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua index 44c01d2226..c5520deb73 100644 --- a/test/functional/eval/msgpack_functions_spec.lua +++ b/test/functional/eval/msgpack_functions_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local funcs = helpers.funcs local eval, eq = helpers.eval, helpers.eq -local execute = helpers.execute +local command = helpers.command local nvim = helpers.nvim local exc_exec = helpers.exc_exec @@ -331,9 +331,9 @@ describe('msgpack*() functions', function() obj_test('are able to dump and restore floating-point value', {0.125}) it('can restore and dump UINT64_MAX', function() - execute('let dumped = ["\\xCF" . repeat("\\xFF", 8)]') - execute('let parsed = msgpackparse(dumped)') - execute('let dumped2 = msgpackdump(parsed)') + command('let dumped = ["\\xCF" . repeat("\\xFF", 8)]') + command('let parsed = msgpackparse(dumped)') + command('let dumped2 = msgpackdump(parsed)') eq(1, eval('type(parsed[0]) == type(0) ' .. '|| parsed[0]._TYPE is v:msgpack_types.integer')) if eval('type(parsed[0]) == type(0)') == 1 then @@ -345,9 +345,9 @@ describe('msgpack*() functions', function() end) it('can restore and dump INT64_MIN', function() - execute('let dumped = ["\\xD3\\x80" . repeat("\\n", 7)]') - execute('let parsed = msgpackparse(dumped)') - execute('let dumped2 = msgpackdump(parsed)') + command('let dumped = ["\\xD3\\x80" . repeat("\\n", 7)]') + command('let parsed = msgpackparse(dumped)') + command('let dumped2 = msgpackdump(parsed)') eq(1, eval('type(parsed[0]) == type(0) ' .. '|| parsed[0]._TYPE is v:msgpack_types.integer')) if eval('type(parsed[0]) == type(0)') == 1 then @@ -359,33 +359,33 @@ describe('msgpack*() functions', function() end) it('can restore and dump BIN string with zero byte', function() - execute('let dumped = ["\\xC4\\x01\\n"]') - execute('let parsed = msgpackparse(dumped)') - execute('let dumped2 = msgpackdump(parsed)') + command('let dumped = ["\\xC4\\x01\\n"]') + command('let parsed = msgpackparse(dumped)') + command('let dumped2 = msgpackdump(parsed)') eq({{_TYPE={}, _VAL={'\n'}}}, eval('parsed')) eq(1, eval('parsed[0]._TYPE is v:msgpack_types.binary')) eq(1, eval('dumped ==# dumped2')) end) it('can restore and dump STR string with zero byte', function() - execute('let dumped = ["\\xA1\\n"]') - execute('let parsed = msgpackparse(dumped)') - execute('let dumped2 = msgpackdump(parsed)') + command('let dumped = ["\\xA1\\n"]') + command('let parsed = msgpackparse(dumped)') + command('let dumped2 = msgpackdump(parsed)') eq({{_TYPE={}, _VAL={'\n'}}}, eval('parsed')) eq(1, eval('parsed[0]._TYPE is v:msgpack_types.string')) eq(1, eval('dumped ==# dumped2')) end) it('can restore and dump BIN string with NL', function() - execute('let dumped = ["\\xC4\\x01", ""]') - execute('let parsed = msgpackparse(dumped)') - execute('let dumped2 = msgpackdump(parsed)') + command('let dumped = ["\\xC4\\x01", ""]') + command('let parsed = msgpackparse(dumped)') + command('let dumped2 = msgpackdump(parsed)') eq({"\n"}, eval('parsed')) eq(1, eval('dumped ==# dumped2')) end) it('dump and restore special mapping with floating-point value', function() - execute('let todump = {"_TYPE": v:msgpack_types.float, "_VAL": 0.125}') + command('let todump = {"_TYPE": v:msgpack_types.float, "_VAL": 0.125}') eq({0.125}, eval('msgpackparse(msgpackdump([todump]))')) end) end) @@ -394,52 +394,53 @@ describe('msgpackparse() function', function() before_each(clear) it('restores nil as v:null', function() - execute('let dumped = ["\\xC0"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\xC0"]') + command('let parsed = msgpackparse(dumped)') eq('[v:null]', eval('string(parsed)')) end) it('restores boolean false as v:false', function() - execute('let dumped = ["\\xC2"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\xC2"]') + command('let parsed = msgpackparse(dumped)') eq({false}, eval('parsed')) end) it('restores boolean true as v:true', function() - execute('let dumped = ["\\xC3"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\xC3"]') + command('let parsed = msgpackparse(dumped)') eq({true}, eval('parsed')) end) it('restores FIXSTR as special dict', function() - execute('let dumped = ["\\xa2ab"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\xa2ab"]') + command('let parsed = msgpackparse(dumped)') eq({{_TYPE={}, _VAL={'ab'}}}, eval('parsed')) eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.string')) end) it('restores BIN 8 as string', function() - execute('let dumped = ["\\xC4\\x02ab"]') + command('let dumped = ["\\xC4\\x02ab"]') eq({'ab'}, eval('msgpackparse(dumped)')) end) it('restores FIXEXT1 as special dictionary', function() - execute('let dumped = ["\\xD4\\x10", ""]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\xD4\\x10", ""]') + command('let parsed = msgpackparse(dumped)') eq({{_TYPE={}, _VAL={0x10, {"", ""}}}}, eval('parsed')) eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.ext')) end) it('restores MAP with BIN key as special dictionary', function() - execute('let dumped = ["\\x81\\xC4\\x01a\\xC4\\n"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\x81\\xC4\\x01a\\xC4\\n"]') + command('let parsed = msgpackparse(dumped)') eq({{_TYPE={}, _VAL={{'a', ''}}}}, eval('parsed')) eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.map')) end) it('restores MAP with duplicate STR keys as special dictionary', function() - execute('let dumped = ["\\x82\\xA1a\\xC4\\n\\xA1a\\xC4\\n"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\x82\\xA1a\\xC4\\n\\xA1a\\xC4\\n"]') + -- FIXME Internal error bug + command('silent! let parsed = msgpackparse(dumped)') eq({{_TYPE={}, _VAL={ {{_TYPE={}, _VAL={'a'}}, ''}, {{_TYPE={}, _VAL={'a'}}, ''}}} }, eval('parsed')) eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.map')) @@ -448,8 +449,8 @@ describe('msgpackparse() function', function() end) it('restores MAP with MAP key as special dictionary', function() - execute('let dumped = ["\\x81\\x80\\xC4\\n"]') - execute('let parsed = msgpackparse(dumped)') + command('let dumped = ["\\x81\\x80\\xC4\\n"]') + command('let parsed = msgpackparse(dumped)') eq({{_TYPE={}, _VAL={{{}, ''}}}}, eval('parsed')) eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.map')) end) @@ -494,7 +495,7 @@ describe('msgpackparse() function', function() end) it('fails to parse a partial', function() - execute('function T() dict\nendfunction') + command('function T() dict\nendfunction') eq('Vim(call):E686: Argument of msgpackparse() must be a List', exc_exec('call msgpackparse(function("T", [1, 2], {}))')) end) @@ -514,10 +515,10 @@ describe('msgpackdump() function', function() end) it('can dump generic mapping with generic mapping keys and values', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('let todumpv1 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('let todumpv2 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('call add(todump._VAL, [todumpv1, todumpv2])') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('let todumpv1 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('let todumpv2 = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('call add(todump._VAL, [todumpv1, todumpv2])') eq({'\129\128\128'}, eval('msgpackdump([todump])')) end) @@ -530,130 +531,130 @@ describe('msgpackdump() function', function() end) it('can v:null', function() - execute('let todump = v:null') + command('let todump = v:null') end) it('can dump special bool mapping (true)', function() - execute('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 1}') + command('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 1}') eq({'\195'}, eval('msgpackdump([todump])')) end) it('can dump special bool mapping (false)', function() - execute('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 0}') + command('let todump = {"_TYPE": v:msgpack_types.boolean, "_VAL": 0}') eq({'\194'}, eval('msgpackdump([todump])')) end) it('can dump special nil mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.nil, "_VAL": 0}') + command('let todump = {"_TYPE": v:msgpack_types.nil, "_VAL": 0}') eq({'\192'}, eval('msgpackdump([todump])')) end) it('can dump special ext mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') + command('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}') eq({'\212\005', ''}, eval('msgpackdump([todump])')) end) it('can dump special array mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": [5, [""]]}') eq({'\146\005\145\196\n'}, eval('msgpackdump([todump])')) end) it('can dump special UINT64_MAX mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.integer}') - execute('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') + command('let todump = {"_TYPE": v:msgpack_types.integer}') + command('let todump._VAL = [1, 3, 0x7FFFFFFF, 0x7FFFFFFF]') eq({'\207\255\255\255\255\255\255\255\255'}, eval('msgpackdump([todump])')) end) it('can dump special INT64_MIN mapping', function() - execute('let todump = {"_TYPE": v:msgpack_types.integer}') - execute('let todump._VAL = [-1, 2, 0, 0]') + command('let todump = {"_TYPE": v:msgpack_types.integer}') + command('let todump._VAL = [-1, 2, 0, 0]') eq({'\211\128\n\n\n\n\n\n\n'}, eval('msgpackdump([todump])')) end) it('fails to dump a function reference', function() - execute('let Todump = function("tr")') + command('let Todump = function("tr")') eq('Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, itself: attempt to dump function reference', exc_exec('call msgpackdump([Todump])')) end) it('fails to dump a partial', function() - execute('function T() dict\nendfunction') - execute('let Todump = function("T", [1, 2], {})') + command('function T() dict\nendfunction') + command('let Todump = function("T", [1, 2], {})') eq('Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, itself: attempt to dump function reference', exc_exec('call msgpackdump([Todump])')) end) it('fails to dump a function reference in a list', function() - execute('let todump = [function("tr")]') + command('let todump = [function("tr")]') eq('Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, index 0: attempt to dump function reference', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive list', function() - execute('let todump = [[[]]]') - execute('call add(todump[0][0], todump)') + command('let todump = [[[]]]') + command('call add(todump[0][0], todump)') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0, index 0, index 0', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive dict', function() - execute('let todump = {"d": {"d": {}}}') - execute('call extend(todump.d.d, {"d": todump})') + command('let todump = {"d": {"d": {}}}') + command('call extend(todump.d.d, {"d": todump})') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key \'d\', key \'d\', key \'d\'', exc_exec('call msgpackdump([todump])')) end) it('can dump dict with two same dicts inside', function() - execute('let inter = {}') - execute('let todump = {"a": inter, "b": inter}') + command('let inter = {}') + command('let todump = {"a": inter, "b": inter}') eq({"\130\161a\128\161b\128"}, eval('msgpackdump([todump])')) end) it('can dump list with two same lists inside', function() - execute('let inter = []') - execute('let todump = [inter, inter]') + command('let inter = []') + command('let todump = [inter, inter]') eq({"\146\144\144"}, eval('msgpackdump([todump])')) end) it('fails to dump a recursive list in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') - execute('call add(todump._VAL, todump)') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') + command('call add(todump._VAL, todump)') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive (key) map in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('call add(todump._VAL, [todump, 0])') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('call add(todump._VAL, [todump, 0])') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 1', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive (val) map in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') - execute('call add(todump._VAL, [0, todump])') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": []}') + command('call add(todump._VAL, [0, todump])') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key 0 at index 0 from special map', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive (key) map in a special dict, _VAL reference', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') - execute('call add(todump._VAL[0][0], todump._VAL)') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') + command('call add(todump._VAL[0][0], todump._VAL)') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key [[[[...@0], []]]] at index 0 from special map, index 0', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive (val) map in a special dict, _VAL reference', function() - execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') - execute('call add(todump._VAL[0][1], todump._VAL)') + command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') + command('call add(todump._VAL[0][1], todump._VAL)') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key [] at index 0 from special map, index 0', exc_exec('call msgpackdump([todump])')) end) it('fails to dump a recursive (val) special list in a special dict', function() - execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') - execute('call add(todump._VAL, [0, todump._VAL])') + command('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}') + command('call add(todump._VAL, [0, todump._VAL])') eq('Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0, index 1', exc_exec('call msgpackdump([todump])')) end) @@ -689,7 +690,7 @@ describe('msgpackdump() function', function() end) it('fails to dump a partial', function() - execute('function T() dict\nendfunction') + command('function T() dict\nendfunction') eq('Vim(call):E686: Argument of msgpackdump() must be a List', exc_exec('call msgpackdump(function("T", [1, 2], {}))')) end) diff --git a/test/functional/eval/reltime_spec.lua b/test/functional/eval/reltime_spec.lua index 0b19d372ec..0181f09024 100644 --- a/test/functional/eval/reltime_spec.lua +++ b/test/functional/eval/reltime_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok -local neq, execute, funcs = helpers.neq, helpers.execute, helpers.funcs +local neq, command, funcs = helpers.neq, helpers.command, helpers.funcs local reltime, reltimestr, reltimefloat = funcs.reltime, funcs.reltimestr, funcs.reltimefloat describe('reltimestr(), reltimefloat()', function() @@ -8,7 +8,7 @@ describe('reltimestr(), reltimefloat()', function() it('Checks', function() local now = reltime() - execute('sleep 10m') + command('sleep 10m') local later = reltime() local elapsed = reltime(now) diff --git a/test/functional/eval/setpos_spec.lua b/test/functional/eval/setpos_spec.lua index 2e27cd8ac0..6a8b3a8732 100644 --- a/test/functional/eval/setpos_spec.lua +++ b/test/functional/eval/setpos_spec.lua @@ -3,7 +3,7 @@ local setpos = helpers.funcs.setpos local getpos = helpers.funcs.getpos local insert = helpers.insert local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local eval = helpers.eval local eq = helpers.eq local exc_exec = helpers.exc_exec @@ -16,7 +16,7 @@ describe('setpos() function', function() First line of text Second line of text Third line of text]]) - execute('new') + command('new') insert([[ Line of text 1 Line of text 2 @@ -34,7 +34,8 @@ describe('setpos() function', function() it('can set lowercase marks in the current buffer', function() setpos("'d", {0, 2, 1, 0}) eq(getpos("'d"), {0, 2, 1, 0}) - execute('undo', 'call setpos("\'d", [2, 3, 1, 0])') + command('undo') + command('call setpos("\'d", [2, 3, 1, 0])') eq(getpos("'d"), {0, 3, 1, 0}) end) it('can set lowercase marks in other buffers', function() @@ -42,7 +43,7 @@ describe('setpos() function', function() eq(0, retval) setpos("'d", {1, 2, 1, 0}) eq(getpos("'d"), {0, 0, 0, 0}) - execute('wincmd w') + command('wincmd w') eq(eval('bufnr("%")'), 1) eq(getpos("'d"), {0, 2, 1, 0}) end) diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua index 4c5d63ce23..3d9358447e 100644 --- a/test/functional/eval/special_vars_spec.lua +++ b/test/functional/eval/special_vars_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local exc_exec = helpers.exc_exec -local execute = helpers.execute +local command = helpers.command local funcs = helpers.funcs local clear = helpers.clear local eval = helpers.eval @@ -12,7 +12,7 @@ describe('Special values', function() before_each(clear) it('do not cause error when freed', function() - execute([[ + command([[ function Test() try return v:true @@ -109,7 +109,7 @@ describe('Special values', function() it('does not work with +=/-=/.=', function() meths.set_var('true', true) meths.set_var('false', false) - execute('let null = v:null') + command('let null = v:null') eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let true += 1')) eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let false += 1')) diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index ee75b593ff..bf95752e3b 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -1,6 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, call, clear, eval, execute, feed, nvim = - helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.execute, + +local nvim_dir = helpers.nvim_dir +local eq, call, clear, eval, feed_command, feed, nvim = + helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command, helpers.feed, helpers.nvim local Screen = require('test.functional.ui.screen') @@ -31,7 +33,7 @@ describe('system()', function() describe('command passed as a List', function() local function printargs_path() - return helpers.nvim_dir..'/printargs-test' + return nvim_dir..'/printargs-test' .. (helpers.os_name() == 'windows' and '.exe' or '') end @@ -43,10 +45,10 @@ describe('system()', function() it('parameter validation does NOT modify v:shell_error', function() -- 1. Call system() with invalid parameters. -- 2. Assert that v:shell_error was NOT set. - execute('call system({})') + feed_command('call system({})') eq('E475: Invalid argument: expected String or List', eval('v:errmsg')) eq(0, eval('v:shell_error')) - execute('call system([])') + feed_command('call system([])') eq('E474: Invalid argument', eval('v:errmsg')) eq(0, eval('v:shell_error')) @@ -57,9 +59,9 @@ describe('system()', function() -- 1. Call system() with invalid parameters. -- 2. Assert that v:shell_error was NOT modified. - execute('call system({})') + feed_command('call system({})') eq(old_val, eval('v:shell_error')) - execute('call system([])') + feed_command('call system([])') eq(old_val, eval('v:shell_error')) end) @@ -182,7 +184,7 @@ describe('system()', function() end) it('to backgrounded command does not crash', function() -- This is indeterminate, just exercise the codepath. May get E5677. - execute('call system("echo -n echoed &")') + feed_command('call system("echo -n echoed &")') local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") if v_errnum then eq("E5677:", v_errnum) @@ -197,7 +199,7 @@ describe('system()', function() end) it('to backgrounded command does not crash', function() -- This is indeterminate, just exercise the codepath. May get E5677. - execute('call system("cat - &")') + feed_command('call system("cat - &")') local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") if v_errnum then eq("E5677:", v_errnum) diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index b3c4cd07eb..2dd9968a01 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local ok, feed, eq, eval = helpers.ok, helpers.feed, helpers.eq, helpers.eval local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run -local clear, execute, funcs = helpers.clear, helpers.execute, helpers.funcs +local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs local curbufmeths = helpers.curbufmeths describe('timers', function() @@ -17,14 +17,14 @@ describe('timers', function() end) it('works one-shot', function() - execute("call timer_start(50, 'MyHandler')") + command("call timer_start(50, 'MyHandler')") eq(0,eval("g:val")) run(nil, nil, nil, 200) eq(1,eval("g:val")) end) it('works one-shot when repeat=0', function() - execute("call timer_start(50, 'MyHandler', {'repeat': 0})") + command("call timer_start(50, 'MyHandler', {'repeat': 0})") eq(0,eval("g:val")) run(nil, nil, nil, 200) eq(1,eval("g:val")) @@ -32,14 +32,14 @@ describe('timers', function() it('works with repeat two', function() - execute("call timer_start(50, 'MyHandler', {'repeat': 2})") + command("call timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) run(nil, nil, nil, 300) eq(2,eval("g:val")) end) it('are triggered during sleep', function() - execute("call timer_start(50, 'MyHandler', {'repeat': 2})") + command("call timer_start(50, 'MyHandler', {'repeat': 2})") nvim_async("command", "sleep 10") eq(0,eval("g:val")) run(nil, nil, nil, 300) @@ -63,12 +63,12 @@ describe('timers', function() end) it('are paused when event processing is disabled', function() - execute("call timer_start(50, 'MyHandler', {'repeat': -1})") + command("call timer_start(50, 'MyHandler', {'repeat': -1})") run(nil, nil, nil, 100) local count = eval("g:val") -- shows two line error message and thus invokes the return prompt. -- if we start to allow event processing here, we need to change this test. - execute("throw 'fatal error'") + feed(':throw "fatal error"<CR>') run(nil, nil, nil, 300) feed("<cr>") local diff = eval("g:val") - count @@ -76,7 +76,7 @@ describe('timers', function() end) it('are triggered in blocking getchar() call', function() - execute("call timer_start(50, 'MyHandler', {'repeat': -1})") + command("call timer_start(50, 'MyHandler', {'repeat': -1})") nvim_async("command", "let g:c = getchar()") run(nil, nil, nil, 300) feed("c") @@ -157,7 +157,7 @@ describe('timers', function() endif endfunc ]]) - execute("call timer_start(50, 'MyHandler', {'repeat': -1})") + command("call timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) run(nil, nil, nil, 300) eq(3,eval("g:val")) @@ -170,8 +170,8 @@ describe('timers', function() let g:val2 += 1 endfunc ]]) - execute("call timer_start(50, 'MyHandler', {'repeat': 3})") - execute("call timer_start(100, 'MyHandler2', {'repeat': 2})") + command("call timer_start(50, 'MyHandler', {'repeat': 3})") + command("call timer_start(100, 'MyHandler2', {'repeat': 2})") run(nil, nil, nil, 300) eq(3,eval("g:val")) eq(2,eval("g:val2")) @@ -186,7 +186,7 @@ describe('timers', function() let g:val += 1 endfunc ]]) - execute("call timer_start(5, 'MyHandler', {'repeat': 1})") + command("call timer_start(5, 'MyHandler', {'repeat': 1})") run(nil, nil, nil, 300) eq(1,eval("g:val")) end) @@ -201,7 +201,7 @@ describe('timers', function() echo "evil" endfunc ]]) - execute("call timer_start(100, 'MyHandler', {'repeat': 1})") + command("call timer_start(100, 'MyHandler', {'repeat': 1})") feed(":good") screen:sleep(200) screen:expect([[ diff --git a/test/functional/ex_cmds/arg_spec.lua b/test/functional/ex_cmds/arg_spec.lua index e11b90532f..6d31f05c2a 100644 --- a/test/functional/ex_cmds/arg_spec.lua +++ b/test/functional/ex_cmds/arg_spec.lua @@ -1,5 +1,5 @@ local helpers = require("test.functional.helpers")(after_each) -local eq, execute, funcs = helpers.eq, helpers.execute, helpers.funcs +local eq, command, funcs = helpers.eq, helpers.command, helpers.funcs local ok = helpers.ok local clear = helpers.clear @@ -9,15 +9,15 @@ describe(":argument", function() end) it("does not restart :terminal buffer", function() - execute("terminal") + command("terminal") helpers.feed([[<C-\><C-N>]]) - execute("argadd") + command("argadd") helpers.feed([[<C-\><C-N>]]) local bufname_before = funcs.bufname("%") local bufnr_before = funcs.bufnr("%") helpers.ok(nil ~= string.find(bufname_before, "^term://")) -- sanity - execute("argument 1") + command("argument 1") helpers.feed([[<C-\><C-N>]]) local bufname_after = funcs.bufname("%") diff --git a/test/functional/ex_cmds/bang_filter_spec.lua b/test/functional/ex_cmds/bang_filter_spec.lua index a320e6d018..aaec983b73 100644 --- a/test/functional/ex_cmds/bang_filter_spec.lua +++ b/test/functional/ex_cmds/bang_filter_spec.lua @@ -1,7 +1,7 @@ -- Specs for bang/filter commands local helpers = require('test.functional.helpers')(after_each) -local feed, execute, clear = helpers.feed, helpers.execute, helpers.clear +local feed, command, clear = helpers.feed, helpers.command, helpers.clear local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdir if helpers.pending_win32(pending) then return end @@ -28,7 +28,7 @@ describe('issues', function() end) it('#3269 Last line of shell output is not truncated', function() - execute([[nnoremap <silent>\l :!ls bang_filter_spec<cr>]]) + command([[nnoremap <silent>\l :!ls bang_filter_spec<cr>]]) feed([[\l]]) screen:expect([[ ~ | diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index 5bf4d22d0f..059cb26d5d 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -6,7 +6,7 @@ local helpers = require('test.functional.helpers')(after_each) local eq = helpers.eq local call = helpers.call local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local exc_exec = helpers.exc_exec if helpers.pending_win32(pending) then return end @@ -58,7 +58,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(globalwin)) eq(0, lwd(globalwin, tabnr)) - execute('bot split') + command('bot split') local localwin = call('winnr') -- Initial window is still using globalDir eq(globalDir, cwd(localwin)) @@ -66,7 +66,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(globalwin)) eq(0, lwd(globalwin, tabnr)) - execute('silent l' .. cmd .. ' ' .. directories.window) + command('silent l' .. cmd .. ' ' .. directories.window) -- From window with local dir, the original window -- is still reporting the global dir eq(globalDir, cwd(globalwin)) @@ -80,7 +80,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(1, lwd(localwin)) eq(1, lwd(localwin, tabnr)) - execute('tabnew') + command('tabnew') -- From new tab page, original window reports global dir eq(globalDir, cwd(globalwin, tabnr)) eq(0, lwd(globalwin, tabnr)) @@ -100,8 +100,8 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(-1, 0)) eq(0, lwd(-1, globaltab)) - execute('tabnew') - execute('silent t' .. cmd .. ' ' .. directories.tab) + command('tabnew') + command('silent t' .. cmd .. ' ' .. directories.tab) local localtab = call('tabpagenr') -- From local tab page, original tab reports globalDir @@ -114,7 +114,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(1, lwd(-1, 0)) eq(1, lwd(-1, localtab)) - execute('tabnext') + command('tabnext') -- From original tab page, local reports as such eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab)) eq(1, lwd(-1, localtab)) @@ -128,13 +128,13 @@ for _, cmd in ipairs {'cd', 'chdir'} do end) it('works with tab-local pwd', function() - execute('silent t' .. cmd .. ' ' .. directories.tab) + command('silent t' .. cmd .. ' ' .. directories.tab) eq(directories.start, cwd(-1, -1)) eq(0, lwd(-1, -1)) end) it('works with window-local pwd', function() - execute('silent l' .. cmd .. ' ' .. directories.window) + command('silent l' .. cmd .. ' ' .. directories.window) eq(directories.start, cwd(-1, -1)) eq(0, lwd(-1, -1)) end) @@ -145,18 +145,18 @@ for _, cmd in ipairs {'cd', 'chdir'} do local globalDir = directories.start -- Create a new tab and change directory - execute('tabnew') - execute('silent t' .. cmd .. ' ' .. directories.tab) + command('tabnew') + command('silent t' .. cmd .. ' ' .. directories.tab) eq(globalDir .. '/' .. directories.tab, tcwd()) -- Create a new tab and verify it has inherited the directory - execute('tabnew') + command('tabnew') eq(globalDir .. '/' .. directories.tab, tcwd()) -- Change tab and change back, verify that directories are correct - execute('tabnext') + command('tabnext') eq(globalDir, tcwd()) - execute('tabprevious') + command('tabprevious') eq(globalDir .. '/' .. directories.tab, tcwd()) end) end) @@ -164,7 +164,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do it('works', function() local globalDir = directories.start -- Create a new tab first and verify that is has the same working dir - execute('tabnew') + command('tabnew') eq(globalDir, cwd()) eq(globalDir, tcwd()) -- has no tab-local directory eq(0, tlwd()) @@ -172,7 +172,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Change tab-local working directory and verify it is different - execute('silent t' .. cmd .. ' ' .. directories.tab) + command('silent t' .. cmd .. ' ' .. directories.tab) eq(globalDir .. '/' .. directories.tab, cwd()) eq(cwd(), tcwd()) -- working directory maches tab directory eq(1, tlwd()) @@ -180,46 +180,46 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Create a new window in this tab to test `:lcd` - execute('new') + command('new') eq(1, tlwd()) -- Still tab-local working directory eq(0, wlwd()) -- Still no window-local working directory eq(globalDir .. '/' .. directories.tab, cwd()) - execute('silent l' .. cmd .. ' ../' .. directories.window) + command('silent l' .. cmd .. ' ../' .. directories.window) eq(globalDir .. '/' .. directories.window, cwd()) eq(globalDir .. '/' .. directories.tab, tcwd()) eq(1, wlwd()) -- Verify the first window still has the tab local directory - execute('wincmd w') + command('wincmd w') eq(globalDir .. '/' .. directories.tab, cwd()) eq(globalDir .. '/' .. directories.tab, tcwd()) eq(0, wlwd()) -- No window-local directory -- Change back to initial tab and verify working directory has stayed - execute('tabnext') + command('tabnext') eq(globalDir, cwd() ) eq(0, tlwd()) eq(0, wlwd()) -- Verify global changes don't affect local ones - execute('silent ' .. cmd .. ' ' .. directories.global) + command('silent ' .. cmd .. ' ' .. directories.global) eq(globalDir .. '/' .. directories.global, cwd()) - execute('tabnext') + command('tabnext') eq(globalDir .. '/' .. directories.tab, cwd()) eq(globalDir .. '/' .. directories.tab, tcwd()) eq(0, wlwd()) -- Still no window-local directory in this window -- Unless the global change happened in a tab with local directory - execute('silent ' .. cmd .. ' ..') + command('silent ' .. cmd .. ' ..') eq(globalDir, cwd() ) eq(0 , tlwd()) eq(0 , wlwd()) -- Which also affects the first tab - execute('tabnext') + command('tabnext') eq(globalDir, cwd()) -- But not in a window with its own local directory - execute('tabnext | wincmd w') + command('tabnext | wincmd w') eq(globalDir .. '/' .. directories.window, cwd() ) eq(0 , tlwd()) eq(globalDir .. '/' .. directories.window, wcwd()) @@ -280,8 +280,8 @@ describe("getcwd()", function () end) it("returns empty string if working directory does not exist", function() - execute("cd "..directories.global) - execute("call delete('../"..directories.global.."', 'd')") + command("cd "..directories.global) + command("call delete('../"..directories.global.."', 'd')") eq("", helpers.eval("getcwd()")) end) end) diff --git a/test/functional/ex_cmds/ctrl_c_spec.lua b/test/functional/ex_cmds/ctrl_c_spec.lua index 072fd2ad10..993bfa0dba 100644 --- a/test/functional/ex_cmds/ctrl_c_spec.lua +++ b/test/functional/ex_cmds/ctrl_c_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, source = helpers.clear, helpers.feed, helpers.source -local execute = helpers.execute +local command = helpers.command describe("CTRL-C (mapped)", function() before_each(function() @@ -20,7 +20,7 @@ describe("CTRL-C (mapped)", function() nnoremap <C-C> <NOP> ]]) - execute("silent edit! test/functional/fixtures/bigfile.txt") + command("silent edit! test/functional/fixtures/bigfile.txt") local screen = Screen.new(52, 6) screen:attach() screen:set_default_attr_ids({ @@ -47,7 +47,7 @@ describe("CTRL-C (mapped)", function() end -- The test is time-sensitive. Try different sleep values. - local ms_values = {1, 10, 100} + local ms_values = {1, 10, 100, 1000, 10000} for i, ms in ipairs(ms_values) do if i < #ms_values then local status, _ = pcall(test_ctrl_c, ms) diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua index 99db5ea333..9105b84367 100644 --- a/test/functional/ex_cmds/drop_spec.lua +++ b/test/functional/ex_cmds/drop_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command describe(":drop", function() local screen @@ -15,7 +15,7 @@ describe(":drop", function() [2] = {reverse = true}, [3] = {bold = true}, }) - execute("set laststatus=2") + feed_command("set laststatus=2") end) after_each(function() @@ -23,7 +23,7 @@ describe(":drop", function() end) it("works like :e when called with only one window open", function() - execute("drop tmp1.vim") + feed_command("drop tmp1.vim") screen:expect([[ ^ | {0:~ }| @@ -39,10 +39,10 @@ describe(":drop", function() end) it("switches to an open window showing the buffer", function() - execute("edit tmp1") - execute("vsplit") - execute("edit tmp2") - execute("drop tmp1") + feed_command("edit tmp1") + feed_command("vsplit") + feed_command("edit tmp2") + feed_command("drop tmp1") screen:expect([[ {2:|}^ | {0:~ }{2:|}{0:~ }| @@ -58,11 +58,11 @@ describe(":drop", function() end) it("splits off a new window when a buffer can't be abandoned", function() - execute("edit tmp1") - execute("vsplit") - execute("edit tmp2") + feed_command("edit tmp1") + feed_command("vsplit") + feed_command("edit tmp2") feed("iABC<esc>") - execute("drop tmp3") + feed_command("drop tmp3") screen:expect([[ ^ {2:|} | {0:~ }{2:|}{0:~ }| diff --git a/test/functional/ex_cmds/edit_spec.lua b/test/functional/ex_cmds/edit_spec.lua index 3cc5f5fb95..6ed500a293 100644 --- a/test/functional/ex_cmds/edit_spec.lua +++ b/test/functional/ex_cmds/edit_spec.lua @@ -1,7 +1,8 @@ local helpers = require("test.functional.helpers")(after_each) -local eq, execute, funcs = helpers.eq, helpers.execute, helpers.funcs +local eq, command, funcs = helpers.eq, helpers.command, helpers.funcs local ok = helpers.ok local clear = helpers.clear +local feed = helpers.feed describe(":edit", function() before_each(function() @@ -9,13 +10,13 @@ describe(":edit", function() end) it("without arguments does not restart :terminal buffer", function() - execute("terminal") - helpers.feed([[<C-\><C-N>]]) + command("terminal") + feed([[<C-\><C-N>]]) local bufname_before = funcs.bufname("%") local bufnr_before = funcs.bufnr("%") helpers.ok(nil ~= string.find(bufname_before, "^term://")) -- sanity - execute("edit") + command("edit") local bufname_after = funcs.bufname("%") local bufnr_after = funcs.bufnr("%") diff --git a/test/functional/ex_cmds/encoding_spec.lua b/test/functional/ex_cmds/encoding_spec.lua index 87ed7a2d0a..0769259be4 100644 --- a/test/functional/ex_cmds/encoding_spec.lua +++ b/test/functional/ex_cmds/encoding_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, execute, feed = helpers.clear, helpers.execute, helpers.feed +local clear, feed_command, feed = helpers.clear, helpers.feed_command, helpers.feed local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval describe('&encoding', function() @@ -12,7 +12,7 @@ describe('&encoding', function() end) it('cannot be changed after setup', function() - execute('set encoding=latin1') + feed_command('set encoding=latin1') -- error message expected feed('<cr>') neq(nil, string.find(eval('v:errmsg'), '^E474:')) @@ -31,7 +31,7 @@ describe('&encoding', function() end) it('can be set to utf-8 without error', function() - execute('set encoding=utf-8') + feed_command('set encoding=utf-8') eq("", eval('v:errmsg')) clear('--cmd', 'set enc=utf-8') diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua index 13f88b7e03..43ef1bd424 100644 --- a/test/functional/ex_cmds/grep_spec.lua +++ b/test/functional/ex_cmds/grep_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, execute, feed, ok, eval = - helpers.clear, helpers.execute, helpers.feed, helpers.ok, helpers.eval +local clear, feed_command, feed, ok, eval = + helpers.clear, helpers.feed_command, helpers.feed, helpers.ok, helpers.eval describe(':grep', function() before_each(clear) @@ -11,10 +11,10 @@ describe(':grep', function() return end - execute([[set grepprg=grep\ -r]]) + feed_command([[set grepprg=grep\ -r]]) -- Change to test directory so that the test does not run too long. - execute('cd test') - execute('grep a **/*') + feed_command('cd test') + feed_command('grep a **/*') feed('<cr>') -- Press ENTER ok(eval('len(getqflist())') > 9000) -- IT'S OVER 9000!!1 end) diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua index 52df9e1592..57198600b9 100644 --- a/test/functional/ex_cmds/menu_spec.lua +++ b/test/functional/ex_cmds/menu_spec.lua @@ -1,23 +1,23 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim -local expect, feed, command = helpers.expect, helpers.feed, helpers.command +local clear, command, nvim = helpers.clear, helpers.command, helpers.nvim +local expect, feed = helpers.expect, helpers.feed local eq, eval = helpers.eq, helpers.eval describe(':emenu', function() before_each(function() clear() - execute('nnoremenu Test.Test inormal<ESC>') - execute('inoremenu Test.Test insert') - execute('vnoremenu Test.Test x') - execute('cnoremenu Test.Test cmdmode') + command('nnoremenu Test.Test inormal<ESC>') + command('inoremenu Test.Test insert') + command('vnoremenu Test.Test x') + command('cnoremenu Test.Test cmdmode') - execute('nnoremenu Edit.Paste p') - execute('cnoremenu Edit.Paste <C-R>"') + command('nnoremenu Edit.Paste p') + command('cnoremenu Edit.Paste <C-R>"') end) it('executes correct bindings in normal mode without using API', function() - execute('emenu Test.Test') + command('emenu Test.Test') expect('normal') end) diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index a161e49fc6..656b3f9bae 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -1,7 +1,7 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) -local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute +local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command local feed, nvim_prog, wait = helpers.feed, helpers.nvim_prog, helpers.wait local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn @@ -27,12 +27,12 @@ describe(':oldfiles', function() it('shows most recently used files', function() local screen = Screen.new(100, 5) screen:attach() - execute('edit testfile1') - execute('edit testfile2') - execute('wshada ' .. shada_file) - execute('rshada! ' .. shada_file) + feed_command('edit testfile1') + feed_command('edit testfile2') + feed_command('wshada ' .. shada_file) + feed_command('rshada! ' .. shada_file) local oldfiles = helpers.meths.get_vvar('oldfiles') - execute('oldfiles') + feed_command('oldfiles') screen:expect([[ testfile2 | 1: ]].. add_padding(oldfiles[1]) ..[[ | @@ -50,14 +50,14 @@ describe(':browse oldfiles', function() before_each(function() _clear() - execute('edit testfile1') + feed_command('edit testfile1') filename = buf.get_name() - execute('edit testfile2') + feed_command('edit testfile2') filename2 = buf.get_name() - execute('wshada ' .. shada_file) + feed_command('wshada ' .. shada_file) wait() _clear() - execute('rshada! ' .. shada_file) + feed_command('rshada! ' .. shada_file) -- Ensure nvim is out of "Press ENTER..." prompt. feed('<cr>') @@ -70,7 +70,7 @@ describe(':browse oldfiles', function() ok(filename == oldfiles[1] or filename == oldfiles[2]) ok(filename2 == oldfiles[1] or filename2 == oldfiles[2]) - execute('browse oldfiles') + feed_command('browse oldfiles') end) after_each(function() diff --git a/test/functional/ex_cmds/recover_spec.lua b/test/functional/ex_cmds/recover_spec.lua index af1296c94c..36bf85015a 100644 --- a/test/functional/ex_cmds/recover_spec.lua +++ b/test/functional/ex_cmds/recover_spec.lua @@ -2,8 +2,8 @@ local helpers = require('test.functional.helpers')(after_each) local lfs = require('lfs') -local execute, eq, clear, eval, feed, expect, source = - helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed, +local feed_command, eq, clear, eval, feed, expect, source = + helpers.feed_command, helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.expect, helpers.source if helpers.pending_win32(pending) then return end @@ -13,7 +13,7 @@ describe(':recover', function() it('fails if given a non-existent swapfile', function() local swapname = 'bogus-swapfile' - execute('recover '..swapname) -- This should not segfault. #2117 + feed_command('recover '..swapname) -- This should not segfault. #2117 eq('E305: No swap file found for '..swapname, eval('v:errmsg')) end) @@ -40,12 +40,12 @@ describe(':preserve', function() ]] source(init) - execute('set swapfile fileformat=unix undolevels=-1') + feed_command('set swapfile fileformat=unix undolevels=-1') -- Put swapdir at the start of the 'directory' list. #1836 - execute('set directory^='..swapdir..'//') - execute('edit '..testfile) + feed_command('set directory^='..swapdir..'//') + feed_command('edit '..testfile) feed('isometext<esc>') - execute('preserve') + feed_command('preserve') source('redir => g:swapname | swapname | redir END') local swappath1 = eval('g:swapname') @@ -59,8 +59,8 @@ describe(':preserve', function() source(init) -- Use the "SwapExists" event to choose the (R)ecover choice at the dialog. - execute('autocmd SwapExists * let v:swapchoice = "r"') - execute('silent edit '..testfile) + feed_command('autocmd SwapExists * let v:swapchoice = "r"') + feed_command('silent edit '..testfile) source('redir => g:swapname | swapname | redir END') local swappath2 = eval('g:swapname') diff --git a/test/functional/ex_cmds/syntax_spec.lua b/test/functional/ex_cmds/syntax_spec.lua new file mode 100644 index 0000000000..c9e96703de --- /dev/null +++ b/test/functional/ex_cmds/syntax_spec.lua @@ -0,0 +1,17 @@ +local helpers = require('test.functional.helpers')(after_each) + +local eq = helpers.eq +local clear = helpers.clear +local exc_exec = helpers.exc_exec + +describe(':syntax', function() + before_each(clear) + + describe('keyword', function() + it('does not crash when group name contains unprintable characters', + function() + eq('Vim(syntax):E669: Unprintable character in group name', + exc_exec('syntax keyword \024 foo bar')) + end) + end) +end) diff --git a/test/functional/ex_cmds/undojoin_spec.lua b/test/functional/ex_cmds/undojoin_spec.lua index ba1e46ceb3..7803906619 100644 --- a/test/functional/ex_cmds/undojoin_spec.lua +++ b/test/functional/ex_cmds/undojoin_spec.lua @@ -5,7 +5,7 @@ local clear = helpers.clear local insert = helpers.insert local feed = helpers.feed local expect = helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command local exc_exec = helpers.exc_exec describe(':undojoin command', function() @@ -14,10 +14,10 @@ describe(':undojoin command', function() insert([[ Line of text 1 Line of text 2]]) - execute('goto 1') + feed_command('goto 1') end) it('joins changes in a buffer', function() - execute('undojoin | delete') + feed_command('undojoin | delete') expect([[ Line of text 2]]) feed('u') @@ -26,7 +26,7 @@ describe(':undojoin command', function() end) it('does not corrupt undolist when connected with redo', function() feed('ixx<esc>') - execute('undojoin | redo') + feed_command('undojoin | redo') expect([[ xxLine of text 1 Line of text 2]]) diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index 9c2687971e..863d439080 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -1,11 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local lfs = require('lfs') -local eq, eval, clear, write_file, execute, source, insert = +local eq, eval, clear, write_file, source, insert = helpers.eq, helpers.eval, helpers.clear, helpers.write_file, - helpers.execute, helpers.source, helpers.insert + helpers.source, helpers.insert local redir_exec = helpers.redir_exec local exc_exec = helpers.exc_exec local command = helpers.command +local feed_command = helpers.feed_command local funcs = helpers.funcs local meths = helpers.meths @@ -33,9 +34,9 @@ describe(':write', function() end) it('&backupcopy=auto preserves symlinks', function() - execute('set backupcopy=auto') + command('set backupcopy=auto') write_file('test_bkc_file.txt', 'content0') - execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -46,9 +47,9 @@ describe(':write', function() end) it('&backupcopy=no replaces symlink with new file', function() - execute('set backupcopy=no') + command('set backupcopy=no') write_file('test_bkc_file.txt', 'content0') - execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -69,7 +70,7 @@ describe(':write', function() insert(text) -- Blocks until a consumer reads the FIFO. - execute("write >> test_fifo") + feed_command("write >> test_fifo") -- Read the FIFO, this will unblock the :write above. local fifo = assert(io.open("test_fifo")) diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua index e1216fa5d4..b6fcae0cf4 100644 --- a/test/functional/ex_cmds/wundo_spec.lua +++ b/test/functional/ex_cmds/wundo_spec.lua @@ -1,20 +1,21 @@ -- Specs for :wundo and underlying functions local helpers = require('test.functional.helpers')(after_each) -local execute, clear, eval, feed, spawn, nvim_prog, set_session = - helpers.execute, helpers.clear, helpers.eval, helpers.feed, helpers.spawn, +local command, clear, eval, spawn, nvim_prog, set_session = + helpers.command, helpers.clear, helpers.eval, helpers.spawn, helpers.nvim_prog, helpers.set_session describe(':wundo', function() before_each(clear) + after_each(function() + os.remove(eval('getcwd()') .. '/foo') + end) it('safely fails on new, non-empty buffer', function() - feed('iabc<esc>') - execute('wundo foo') -- This should not segfault. #1027 + command('normal! iabc') + command('wundo foo') -- This should not segfault. #1027 --TODO: check messages for error message - - os.remove(eval('getcwd()') .. '/foo') --cleanup end) end) @@ -23,7 +24,7 @@ describe('u_* functions', function() local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed', '-c', 'set undodir=. undofile'}) set_session(session) - execute('echo "True"') -- Should not error out due to crashed Neovim + command('echo "True"') -- Should not error out due to crashed Neovim session:close() end) end) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index 37f45da2d4..eebbd70f2b 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -1,8 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local lfs = require('lfs') -local execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file - = helpers.execute, helpers.eq, helpers.neq, helpers.spawn, - helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file +local command, eq, neq, spawn, nvim_prog, set_session, write_file = + helpers.command, helpers.eq, helpers.neq, helpers.spawn, + helpers.nvim_prog, helpers.set_session, helpers.write_file describe(':wshada', function() local shada_file = 'wshada_test' @@ -24,8 +24,7 @@ describe(':wshada', function() it('creates a shada file', function() -- file should _not_ exist eq(nil, lfs.attributes(shada_file)) - execute('wsh! '..shada_file) - wait() + command('wsh! '..shada_file) -- file _should_ exist neq(nil, lfs.attributes(shada_file)) end) @@ -40,8 +39,7 @@ describe(':wshada', function() eq(text, io.open(shada_file):read()) neq(nil, lfs.attributes(shada_file)) - execute('wsh! '..shada_file) - wait() + command('wsh! '..shada_file) -- File should have been overwritten with a shada file. local fp = io.open(shada_file, 'r') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 2e308186fe..a23f0e1215 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -8,6 +8,7 @@ local Session = require('nvim.session') local TcpStream = require('nvim.tcp_stream') local SocketStream = require('nvim.socket_stream') local ChildProcessStream = require('nvim.child_process_stream') +local Paths = require('test.config.paths') local check_cores = global_helpers.check_cores local check_logs = global_helpers.check_logs @@ -20,7 +21,11 @@ local dedent = global_helpers.dedent local start_dir = lfs.currentdir() -- XXX: NVIM_PROG takes precedence, QuickBuild sets it. -local nvim_prog = os.getenv('NVIM_PROG') or os.getenv('NVIM_PRG') or 'build/bin/nvim' +local nvim_prog = ( + os.getenv('NVIM_PROG') + or os.getenv('NVIM_PRG') + or Paths.test_build_dir .. '/bin/nvim' +) -- Default settings for the test session. local nvim_set = 'set shortmess+=I background=light noswapfile noautoindent' ..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' @@ -246,12 +251,13 @@ local function retry(max, max_ms, fn) return result end if (max and tries >= max) or (luv.now() - start_time > timeout) then - break + if type(result) == "string" then + result = "\nretry() attempts: "..tostring(tries).."\n"..result + end + error(result) end tries = tries + 1 end - -- Do not use pcall() for the final attempt, let the failure bubble up. - return fn() end local function clear(...) @@ -304,7 +310,7 @@ end -- Executes an ex-command by user input. Because nvim_input() is used, VimL -- errors will not manifest as client (lua) errors. Use command() for that. -local function execute(...) +local function feed_command(...) for _, v in ipairs({...}) do if v:sub(1, 1) ~= '/' then -- not a search command, prefix with colon @@ -565,7 +571,7 @@ local module = { insert = insert, iswin = iswin, feed = feed, - execute = execute, + feed_command = feed_command, eval = nvim_eval, call = nvim_call, command = nvim_command, diff --git a/test/functional/legacy/002_filename_recognition_spec.lua b/test/functional/legacy/002_filename_recognition_spec.lua index 5a833281e7..26a62d92fe 100644 --- a/test/functional/legacy/002_filename_recognition_spec.lua +++ b/test/functional/legacy/002_filename_recognition_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('filename recognition', function() setup(clear) @@ -17,17 +17,17 @@ describe('filename recognition', function() fourth test for URL:\\machine.name\tmp\vimtest2d, and other text]]) -- Go to the first URL and append it to the beginning - execute('/^first', '/tmp', 'call append(0, expand("<cfile>"))') + feed_command('/^first', '/tmp', 'call append(0, expand("<cfile>"))') -- Repeat for the second URL -- this time, navigate to the word "URL" instead of "tmp" - execute('/^second', '/URL', 'call append(1, expand("<cfile>"))') + feed_command('/^second', '/URL', 'call append(1, expand("<cfile>"))') -- Repeat for the remaining URLs. This time, the 'isfname' option must be -- set to allow '\' in filenames - execute('set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\') - execute('/^third', '/name', 'call append(2, expand("<cfile>"))') - execute('/^fourth', '/URL', 'call append(3, expand("<cfile>"))') + feed_command('set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\') + feed_command('/^third', '/name', 'call append(2, expand("<cfile>"))') + feed_command('/^fourth', '/URL', 'call append(3, expand("<cfile>"))') -- Delete the initial text, which now starts at line 5 feed('5GdG') diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua index 83388bd1eb..27835fea28 100644 --- a/test/functional/legacy/003_cindent_spec.lua +++ b/test/functional/legacy/003_cindent_spec.lua @@ -5,14 +5,14 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -- Inserts text as usual, and additionally positions the cursor on line 1 and -- sets 'cindent' and tab settings. (In the original "test3.in" the modeline at -- the top of the file takes care of this.) local function insert_(content) insert(content) - execute('1', 'set cin ts=4 sw=4') + feed_command('1', 'set cin ts=4 sw=4') end describe('cindent', function() @@ -20,21 +20,21 @@ describe('cindent', function() it('1 is working', function() insert_([=[ - + /* start of AUTO matically checked vim: set ts=4 : */ { if (test) cmd1; cmd2; } - + { if (test) cmd1; else cmd2; } - + { if (test) { @@ -42,7 +42,7 @@ describe('cindent', function() cmd2; } } - + { if (test) { @@ -50,14 +50,14 @@ describe('cindent', function() else } } - + { while (this) if (test) cmd1; cmd2; } - + { while (this) if (test) @@ -65,25 +65,25 @@ describe('cindent', function() else cmd2; } - + { if (test) { cmd; } - + if (test) cmd; } - + { if (test) { cmd; } - + if (test) cmd; } - + { cmd1; for (blah) @@ -92,7 +92,7 @@ describe('cindent', function() cmd2; cmd3; } - + { cmd1; for (blah) @@ -100,7 +100,7 @@ describe('cindent', function() if (test) cmd2; cmd3; - + if (test) { cmd1; @@ -108,23 +108,23 @@ describe('cindent', function() 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 @@ -132,14 +132,14 @@ describe('cindent', function() 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 + @@ -151,12 +151,12 @@ describe('cindent', function() 1234; c = 1; } - + /* testje for indent with empty line - + here */ - + { if (testing && not a joke || @@ -171,8 +171,8 @@ describe('cindent', function() line up here)) hay; } - - + + { switch (c) { @@ -191,7 +191,7 @@ describe('cindent', function() testing; } } - + { if (cond) { foo; @@ -201,7 +201,7 @@ describe('cindent', function() bar; } } - + { if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf alsdkfj (asldk;fj @@ -210,7 +210,7 @@ describe('cindent', function() asdfasdf;))) asdfasdf; } - + int func(a, b) int a; @@ -223,7 +223,7 @@ describe('cindent', function() (c2 || c3) ) } - + { while (asd) { @@ -245,13 +245,13 @@ describe('cindent', function() asdf; } } - + { s = "/*"; b = ';' s = "/*"; b = ';'; a = b; } - + { switch (a) { @@ -285,7 +285,7 @@ describe('cindent', function() break; } } - + { if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && (bp_to->b_p_initialized || @@ -297,57 +297,57 @@ describe('cindent', function() 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 { @@ -360,7 +360,7 @@ describe('cindent', function() 2, "two", 3, "three" }; - + float matrix[3][3] = { { @@ -380,14 +380,14 @@ describe('cindent', function() } }; } - + { /* blah ( blah */ /* where does this go? */ - + /* blah ( blah */ cmd; - + func(arg1, /* comment */ arg2); @@ -398,7 +398,7 @@ describe('cindent', function() c; /* Hey, NOW it indents?! */ } } - + { func(arg1, arg2, @@ -406,7 +406,7 @@ describe('cindent', function() /* Hey, what am I doing here? Is this coz of the ","? */ } } - + main () { if (cond) @@ -420,7 +420,7 @@ describe('cindent', function() a = d; return; } - + { case 2: if (asdf && asdfasdf) @@ -431,42 +431,42 @@ describe('cindent', function() 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; @@ -474,7 +474,7 @@ describe('cindent', function() a = b + 1; asdfasdf } - + { for ( int i = 0; i < 10; i++ ) @@ -482,13 +482,13 @@ describe('cindent', function() } i = 0; } - + class bob { int foo() {return 1;} int bar; } - + main() { while(1) @@ -501,32 +501,32 @@ describe('cindent', function() } 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*/); @@ -538,12 +538,12 @@ describe('cindent', function() } } } - + { f1(/*comment*/); f2(); } - + { do { if (foo) { @@ -552,25 +552,25 @@ describe('cindent', function() } 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) @@ -581,23 +581,23 @@ describe('cindent', function() } 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) \ @@ -616,19 +616,19 @@ describe('cindent', function() #endif } #endif - + int y; // comment // comment - + // comment - + { Constructor(int a, int b ) : BaseClass(a) { } } - + void foo() { char one, @@ -645,13 +645,13 @@ describe('cindent', function() kees, jan; } - + { t(int f, int d); // ) d(); } - + Constructor::Constructor(int a, int b ) : @@ -661,33 +661,33 @@ describe('cindent', function() 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) { @@ -696,24 +696,24 @@ describe('cindent', function() case abc: asdf(); break; - + case 999: baer(); break; } } - + public: // <-- this was incoreectly indented before!! void testfall(); protected: void testfall(); }; - + class CAbc : public BaseClass1, protected BaseClass2 { }; - + static struct { int a; @@ -729,7 +729,7 @@ describe('cindent', function() 456 } }; - + static struct { int a; @@ -739,7 +739,7 @@ describe('cindent', function() { 123, 456 }, { 123, 456 } }; - + void asdf() /* ind_maxparen may cause trouble here */ { if ((0 @@ -769,17 +769,17 @@ describe('cindent', function() && 1 && 1)) break; } - + foo() { a = cond ? foo() : asdf + asdf; - + a = cond ? foo() : asdf + asdf; } - + int main(void) { if (a) @@ -788,7 +788,7 @@ describe('cindent', function() else 3; next_line_of_code(); } - + barry() { Foo::Foo (int one, @@ -796,14 +796,14 @@ describe('cindent', function() : something(4) {} } - + barry() { Foo::Foo (int one, int two) : something(4) {} } - + Constructor::Constructor(int a, int b ) : @@ -822,7 +822,7 @@ describe('cindent', function() && lele); lulu; } - + int main () { switch (c) @@ -832,13 +832,13 @@ describe('cindent', function() } } } - + main() { (void) MyFancyFuasdfadsfnction( argument); } - + main() { char foo[] = "/*"; @@ -846,7 +846,7 @@ describe('cindent', function() df */ hello } - + /* valid namespaces with normal indent */ namespace { @@ -885,7 +885,7 @@ describe('cindent', function() 22222222222222222; } } - + /* invalid namespaces use block indent */ namespace test test2 { 111111111111111111111; @@ -925,7 +925,7 @@ describe('cindent', function() } )foo"; } - + { int a[4] = { [0] = 0, @@ -934,12 +934,12 @@ describe('cindent', function() [3] = 3, }; } - + { a = b[2] + 3; } - + { if (1) /* aaaaa @@ -947,7 +947,7 @@ describe('cindent', function() */ a = 1; } - + void func() { switch (foo) @@ -974,29 +974,29 @@ describe('cindent', function() break; } } - + /* end of AUTO */ ]=]) - execute('/start of AUTO') + feed_command('/start of AUTO') feed('=/end of AUTO<cr>') expect([=[ - + /* start of AUTO matically checked vim: set ts=4 : */ { if (test) cmd1; cmd2; } - + { if (test) cmd1; else cmd2; } - + { if (test) { @@ -1004,7 +1004,7 @@ describe('cindent', function() cmd2; } } - + { if (test) { @@ -1012,14 +1012,14 @@ describe('cindent', function() else } } - + { while (this) if (test) cmd1; cmd2; } - + { while (this) if (test) @@ -1027,25 +1027,25 @@ describe('cindent', function() else cmd2; } - + { if (test) { cmd; } - + if (test) cmd; } - + { if (test) { cmd; } - + if (test) cmd; } - + { cmd1; for (blah) @@ -1054,7 +1054,7 @@ describe('cindent', function() cmd2; cmd3; } - + { cmd1; for (blah) @@ -1062,7 +1062,7 @@ describe('cindent', function() if (test) cmd2; cmd3; - + if (test) { cmd1; @@ -1070,23 +1070,23 @@ describe('cindent', function() 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 @@ -1094,14 +1094,14 @@ describe('cindent', function() 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 + @@ -1113,12 +1113,12 @@ describe('cindent', function() 1234; c = 1; } - + /* testje for indent with empty line - + here */ - + { if (testing && not a joke || @@ -1133,8 +1133,8 @@ describe('cindent', function() line up here)) hay; } - - + + { switch (c) { @@ -1153,7 +1153,7 @@ describe('cindent', function() testing; } } - + { if (cond) { foo; @@ -1163,7 +1163,7 @@ describe('cindent', function() bar; } } - + { if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf alsdkfj (asldk;fj @@ -1172,7 +1172,7 @@ describe('cindent', function() asdfasdf;))) asdfasdf; } - + int func(a, b) int a; @@ -1185,7 +1185,7 @@ describe('cindent', function() (c2 || c3) ) } - + { while (asd) { @@ -1207,13 +1207,13 @@ describe('cindent', function() asdf; } } - + { s = "/*"; b = ';' s = "/*"; b = ';'; a = b; } - + { switch (a) { @@ -1247,7 +1247,7 @@ describe('cindent', function() break; } } - + { if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && (bp_to->b_p_initialized || @@ -1259,57 +1259,57 @@ describe('cindent', function() 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 { @@ -1322,7 +1322,7 @@ describe('cindent', function() 2, "two", 3, "three" }; - + float matrix[3][3] = { { @@ -1342,14 +1342,14 @@ describe('cindent', function() } }; } - + { /* blah ( blah */ /* where does this go? */ - + /* blah ( blah */ cmd; - + func(arg1, /* comment */ arg2); @@ -1360,7 +1360,7 @@ describe('cindent', function() c; /* Hey, NOW it indents?! */ } } - + { func(arg1, arg2, @@ -1368,7 +1368,7 @@ describe('cindent', function() /* Hey, what am I doing here? Is this coz of the ","? */ } } - + main () { if (cond) @@ -1382,7 +1382,7 @@ describe('cindent', function() a = d; return; } - + { case 2: if (asdf && asdfasdf) @@ -1393,42 +1393,42 @@ describe('cindent', function() 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; @@ -1436,7 +1436,7 @@ describe('cindent', function() a = b + 1; asdfasdf } - + { for ( int i = 0; i < 10; i++ ) @@ -1444,13 +1444,13 @@ describe('cindent', function() } i = 0; } - + class bob { int foo() {return 1;} int bar; } - + main() { while(1) @@ -1463,32 +1463,32 @@ describe('cindent', function() } 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*/); @@ -1500,12 +1500,12 @@ describe('cindent', function() } } } - + { f1(/*comment*/); f2(); } - + { do { if (foo) { @@ -1514,25 +1514,25 @@ describe('cindent', function() } 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) @@ -1543,23 +1543,23 @@ describe('cindent', function() } 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) \ @@ -1578,19 +1578,19 @@ describe('cindent', function() #endif } #endif - + int y; // comment // comment - + // comment - + { Constructor(int a, int b ) : BaseClass(a) { } } - + void foo() { char one, @@ -1607,13 +1607,13 @@ describe('cindent', function() kees, jan; } - + { t(int f, int d); // ) d(); } - + Constructor::Constructor(int a, int b ) : @@ -1623,33 +1623,33 @@ describe('cindent', function() 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) { @@ -1658,24 +1658,24 @@ describe('cindent', function() case abc: asdf(); break; - + case 999: baer(); break; } } - + public: // <-- this was incoreectly indented before!! void testfall(); protected: void testfall(); }; - + class CAbc : public BaseClass1, protected BaseClass2 { }; - + static struct { int a; @@ -1691,7 +1691,7 @@ describe('cindent', function() 456 } }; - + static struct { int a; @@ -1701,7 +1701,7 @@ describe('cindent', function() { 123, 456 }, { 123, 456 } }; - + void asdf() /* ind_maxparen may cause trouble here */ { if ((0 @@ -1731,17 +1731,17 @@ describe('cindent', function() && 1 && 1)) break; } - + foo() { a = cond ? foo() : asdf + asdf; - + a = cond ? foo() : asdf + asdf; } - + int main(void) { if (a) @@ -1750,7 +1750,7 @@ describe('cindent', function() else 3; next_line_of_code(); } - + barry() { Foo::Foo (int one, @@ -1758,14 +1758,14 @@ describe('cindent', function() : something(4) {} } - + barry() { Foo::Foo (int one, int two) : something(4) {} } - + Constructor::Constructor(int a, int b ) : @@ -1784,7 +1784,7 @@ describe('cindent', function() && lele); lulu; } - + int main () { switch (c) @@ -1794,13 +1794,13 @@ describe('cindent', function() } } } - + main() { (void) MyFancyFuasdfadsfnction( argument); } - + main() { char foo[] = "/*"; @@ -1808,7 +1808,7 @@ describe('cindent', function() df */ hello } - + /* valid namespaces with normal indent */ namespace { @@ -1847,7 +1847,7 @@ describe('cindent', function() 22222222222222222; } } - + /* invalid namespaces use block indent */ namespace test test2 { 111111111111111111111; @@ -1887,7 +1887,7 @@ describe('cindent', function() } )foo"; } - + { int a[4] = { [0] = 0, @@ -1896,12 +1896,12 @@ describe('cindent', function() [3] = 3, }; } - + { a = b[2] + 3; } - + { if (1) /* aaaaa @@ -1909,7 +1909,7 @@ describe('cindent', function() */ a = 1; } - + void func() { switch (foo) @@ -1936,16 +1936,16 @@ describe('cindent', function() break; } } - + /* end of AUTO */ ]=]) end) it('2 is working', function() insert_([=[ - + { - + /* this is * a real serious important big * comment @@ -1954,14 +1954,14 @@ describe('cindent', function() } ]=]) - execute('set tw=0 wm=60 columns=80 noai fo=croq') - execute('/serious/e') + feed_command('set tw=0 wm=60 columns=80 noai fo=croq') + feed_command('/serious/e') feed('a about life, the universe, and the rest<esc>') expect([=[ - + { - + /* this is * a real serious * about life, the @@ -1976,48 +1976,48 @@ describe('cindent', function() it('3 is working', function() insert_([=[ - + { /* * Testing for comments, without 'cin' set */ - + /* * what happens here? */ - + /* the end of the comment, try inserting a line below */ - + /* how about this one */ } ]=]) - execute('set nocin') - execute('/comments') + feed_command('set nocin') + feed_command('/comments') feed('joabout life<esc>/happens<cr>') feed('jothere<esc>/below<cr>') feed('oline<esc>/this<cr>') feed('Ohello<esc>') expect([=[ - + { /* * 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 */ @@ -2027,19 +2027,19 @@ describe('cindent', function() it('4 is working', function() insert_([=[ - + { var = this + that + vec[0] * vec[0] + vec[1] * vec[1] + vec2[2] * vec[2]; } ]=]) - execute('set cin') - execute('/vec2') + feed_command('set cin') + feed_command('/vec2') feed('==<cr>') expect([=[ - + { var = this + that + vec[0] * vec[0] + vec[1] * vec[1] @@ -2050,7 +2050,7 @@ describe('cindent', function() it('5 is working', function() insert_([=[ - + { asdf asdflkajds f; if (tes & ting) { @@ -2067,14 +2067,14 @@ describe('cindent', function() } ]=]) - execute('set cin') - execute('set cino=}4') - execute('/testing1') + feed_command('set cin') + feed_command('set cino=}4') + feed_command('/testing1') feed('k2==/testing2<cr>') feed('k2==<cr>') expect([=[ - + { asdf asdflkajds f; if (tes & ting) { @@ -2094,7 +2094,7 @@ describe('cindent', function() it('6 is working', function() insert_([=[ - + main ( int first_par, /* * Comment for * first par @@ -2114,17 +2114,17 @@ describe('cindent', function() * second par */ ); - + } ]=]) - execute('set cin') - execute('set cino=(0,)20') - execute('/main') + feed_command('set cin') + feed_command('set cino=(0,)20') + feed_command('/main') feed('=][<cr>') expect([=[ - + main ( int first_par, /* * Comment for * first par @@ -2144,14 +2144,14 @@ describe('cindent', function() * second par */ ); - + } ]=]) end) it('7 is working', function() insert_([=[ - + main(void) { /* Make sure that cino=X0s is not parsed like cino=Xs. */ @@ -2164,13 +2164,13 @@ describe('cindent', function() } ]=]) - execute('set cin') - execute('set cino=es,n0s') - execute('/main') + feed_command('set cin') + feed_command('set cino=es,n0s') + feed_command('/main') feed('=][<cr>') expect([=[ - + main(void) { /* Make sure that cino=X0s is not parsed like cino=Xs. */ @@ -2186,7 +2186,7 @@ describe('cindent', function() it('8 is working', function() insert_([=[ - + { do { @@ -2202,12 +2202,12 @@ describe('cindent', function() } ]=]) - execute('set cin') - execute('set cino=') + feed_command('set cin') + feed_command('set cino=') feed(']]=][<cr>') expect([=[ - + { do { @@ -2226,16 +2226,16 @@ describe('cindent', function() it('9 is working', function() insert_([=[ - + void f() { if ( k() ) { l(); - + } else { /* Start (two words) end */ m(); } - + n(); } ]=]) @@ -2243,16 +2243,16 @@ describe('cindent', function() feed(']]=][<cr>') expect([=[ - + void f() { if ( k() ) { l(); - + } else { /* Start (two words) end */ m(); } - + n(); } ]=]) @@ -2267,7 +2267,7 @@ describe('cindent', function() -- indented properly. And that's why we've had to add one explicitly. insert_([=[ { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT. - + void f() { if ( k() ) @@ -2280,12 +2280,12 @@ describe('cindent', function() } ]=]) - execute('set cino={s,e-s') + feed_command('set cino={s,e-s') feed(']]=][<cr>') expect([=[ { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT. - + void f() { if ( k() ) @@ -2301,7 +2301,7 @@ describe('cindent', function() it('11 is working', function() insert_([=[ - + void bar(void) { static array[2][2] = @@ -2309,12 +2309,12 @@ describe('cindent', function() { 1, 2 }, { 3, 4 }, } - + while (a) { foo(&a); } - + { int a; { @@ -2323,7 +2323,7 @@ describe('cindent', function() } b = a; } - + void func(void) { a = 1; @@ -2336,11 +2336,11 @@ describe('cindent', function() /* foo */ ]=]) - execute('set cino={s,fs') + feed_command('set cino={s,fs') feed(']]=/ foo<cr>') expect([=[ - + void bar(void) { static array[2][2] = @@ -2348,12 +2348,12 @@ describe('cindent', function() { 1, 2 }, { 3, 4 }, } - + while (a) { foo(&a); } - + { int a; { @@ -2362,7 +2362,7 @@ describe('cindent', function() } b = a; } - + void func(void) { a = 1; @@ -2378,7 +2378,7 @@ describe('cindent', function() it('12 is working', function() insert_([=[ - + a() { do { @@ -2390,12 +2390,12 @@ describe('cindent', function() } ]=]) - execute('set cino=') - execute('/while') + feed_command('set cino=') + feed_command('/while') feed('ohere<esc>') expect([=[ - + a() { do { @@ -2411,7 +2411,7 @@ describe('cindent', function() it('13 is working', function() insert_([=[ - + a() { label1: @@ -2420,12 +2420,12 @@ describe('cindent', function() } ]=]) - execute('set cino= com=') - execute('/comment') + feed_command('set cino= com=') + feed_command('/comment') feed('olabel2: b();<cr>label3 /* post */:<cr>/* pre */ label4:<cr>f(/*com*/);<cr>if (/*com*/)<cr>cmd();<esc>') expect([=[ - + a() { label1: @@ -2443,26 +2443,26 @@ describe('cindent', function() it('14 is working', function() insert_([=[ - + /* * A simple comment */ - + /* ** A different comment */ ]=]) - execute('set comments& comments^=s:/*,m:**,ex:*/') - execute('/simple') + feed_command('set comments& comments^=s:/*,m:**,ex:*/') + feed_command('/simple') feed('=5j<cr>') expect([=[ - + /* * A simple comment */ - + /* ** A different comment */ @@ -2471,26 +2471,26 @@ describe('cindent', function() it('15 is working', function() insert_([=[ - - + + void f() { - + /********* A comment. *********/ } ]=]) - execute('set cino=c0') - execute('set comments& comments-=s1:/* comments^=s0:/*') + feed_command('set cino=c0') + feed_command('set comments& comments-=s1:/* comments^=s0:/*') feed('2kdd]]=][<cr>') expect([=[ - + void f() { - + /********* A comment. *********/ @@ -2500,26 +2500,26 @@ describe('cindent', function() it('16 is working', function() insert_([=[ - - + + void f() { - + /********* A comment. *********/ } ]=]) - execute('set cino=c0,C1') - execute('set comments& comments-=s1:/* comments^=s0:/*') + feed_command('set cino=c0,C1') + feed_command('set comments& comments-=s1:/* comments^=s0:/*') feed('2kdd]]=][<cr>') expect([=[ - + void f() { - + /********* A comment. *********/ @@ -2529,7 +2529,7 @@ describe('cindent', function() it('17 is working', function() insert_([=[ - + void f() { c = c1 && @@ -2540,11 +2540,11 @@ describe('cindent', function() } ]=]) - execute('set cino=') + feed_command('set cino=') feed(']]=][<cr>') expect([=[ - + void f() { c = c1 && @@ -2558,8 +2558,8 @@ describe('cindent', function() it('18 is working', function() insert_([=[ - - + + void f() { c = c1 && @@ -2570,11 +2570,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(s') + feed_command('set cino=(s') feed('2kdd]]=][<cr>') expect([=[ - + void f() { c = c1 && @@ -2588,8 +2588,8 @@ describe('cindent', function() it('19 is working', function() insert_([=[ - - + + void f() { c = c1 && @@ -2600,11 +2600,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(s,U1 ') + feed_command('set cino=(s,U1 ') feed('2kdd]]=][<cr>') expect([=[ - + void f() { c = c1 && @@ -2618,8 +2618,8 @@ describe('cindent', function() it('20 is working', function() insert_([=[ - - + + void f() { if ( c1 @@ -2629,11 +2629,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(0') + feed_command('set cino=(0') feed('2kdd]]=][<cr>') expect([=[ - + void f() { if ( c1 @@ -2646,8 +2646,8 @@ describe('cindent', function() it('21 is working', function() insert_([=[ - - + + void f() { if ( c1 @@ -2657,11 +2657,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(0,w1 ') + feed_command('set cino=(0,w1 ') feed('2kdd]]=][<cr>') expect([=[ - + void f() { if ( c1 @@ -2674,8 +2674,8 @@ describe('cindent', function() it('22 is working', function() insert_([=[ - - + + void f() { c = c1 && ( @@ -2689,11 +2689,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(s') + feed_command('set cino=(s') feed('2kdd]]=][<cr>') expect([=[ - + void f() { c = c1 && ( @@ -2710,8 +2710,8 @@ describe('cindent', function() it('23 is working', function() insert_([=[ - - + + void f() { c = c1 && ( @@ -2725,11 +2725,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(s,m1 ') + feed_command('set cino=(s,m1 ') feed('2kdd]]=][<cr>') expect([=[ - + void f() { c = c1 && ( @@ -2746,8 +2746,8 @@ describe('cindent', function() it('24 is working', function() insert_([=[ - - + + void f() { switch (x) @@ -2762,11 +2762,11 @@ describe('cindent', function() } ]=]) - execute('set cino=b1') + feed_command('set cino=b1') feed('2kdd]]=][<cr>') expect([=[ - + void f() { switch (x) @@ -2784,8 +2784,8 @@ describe('cindent', function() it('25 is working', function() insert_([=[ - - + + void f() { invokeme( @@ -2801,11 +2801,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(0,W5') + feed_command('set cino=(0,W5') feed('2kdd]]=][<cr>') expect([=[ - + void f() { invokeme( @@ -2824,8 +2824,8 @@ describe('cindent', function() it('26 is working', function() insert_([=[ - - + + void f() { statement; @@ -2834,11 +2834,11 @@ describe('cindent', function() } ]=]) - execute('set cino=/6') + feed_command('set cino=/6') feed('2kdd]]=][<cr>') expect([=[ - + void f() { statement; @@ -2850,8 +2850,8 @@ describe('cindent', function() it('27 is working', function() insert_([=[ - - + + void f() { statement; @@ -2860,12 +2860,12 @@ describe('cindent', function() } ]=]) - execute('set cino=') + feed_command('set cino=') feed('2kdd]]/comment 1/+1<cr>') feed('==<cr>') expect([=[ - + void f() { statement; @@ -2877,12 +2877,12 @@ describe('cindent', function() it('28 is working', function() insert_([=[ - - + + class CAbc { int Test() { return FALSE; } - + public: // comment void testfall(); protected: @@ -2890,15 +2890,15 @@ describe('cindent', function() }; ]=]) - execute('set cino=g0') + feed_command('set cino=g0') feed('2kdd]]=][<cr>') expect([=[ - + class CAbc { int Test() { return FALSE; } - + public: // comment void testfall(); protected: @@ -2909,8 +2909,8 @@ describe('cindent', function() it('29 is working', function() insert_([=[ - - + + class Foo : public Bar { public: @@ -2921,11 +2921,11 @@ describe('cindent', function() }; ]=]) - execute('set cino=(0,gs,hs') + feed_command('set cino=(0,gs,hs') feed('2kdd]]=][<cr>') expect([=[ - + class Foo : public Bar { public: @@ -2939,8 +2939,8 @@ describe('cindent', function() it('30 is working', function() insert_([=[ - - + + void foo() { @@ -2951,11 +2951,11 @@ describe('cindent', function() } ]=]) - execute('set cino=+20') + feed_command('set cino=+20') feed('2kdd]]=][<cr>') expect([=[ - + void foo() { @@ -2969,8 +2969,8 @@ describe('cindent', function() it('31 is working', function() insert_([=[ - - + + { averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( asdasdf, @@ -2978,9 +2978,9 @@ describe('cindent', function() asdfadsf), asdfasdf ); - + /* those are ugly, but consequent */ - + func()->asd(asdasdf, averylongfunctionname( abc, @@ -2994,7 +2994,7 @@ describe('cindent', function() ), asdasdf ); - + averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( abc, dec)->asdfasdfasdf( @@ -3009,11 +3009,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(0,W2s') + feed_command('set cino=(0,W2s') feed('2kdd]]=][<cr>') expect([=[ - + { averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( asdasdf, @@ -3021,9 +3021,9 @@ describe('cindent', function() asdfadsf), asdfasdf ); - + /* those are ugly, but consequent */ - + func()->asd(asdasdf, averylongfunctionname( abc, @@ -3037,7 +3037,7 @@ describe('cindent', function() ), asdasdf ); - + averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( abc, dec)->asdfasdfasdf( @@ -3055,8 +3055,8 @@ describe('cindent', function() it('32 is working', function() insert_([=[ - - + + int main () { if (cond1 && @@ -3066,11 +3066,11 @@ describe('cindent', function() } ]=]) - execute('set cino=M1') + feed_command('set cino=M1') feed('2kdd]]=][<cr>') expect([=[ - + int main () { if (cond1 && @@ -3083,8 +3083,8 @@ describe('cindent', function() it('33 is working', function() insert_([=[ - - + + void func(int a #if defined(FOO) , int b @@ -3095,11 +3095,11 @@ describe('cindent', function() } ]=]) - execute('set cino=(0,ts') + feed_command('set cino=(0,ts') feed('2kdd2j=][<cr>') expect([=[ - + void func(int a #if defined(FOO) , int b @@ -3113,9 +3113,9 @@ describe('cindent', function() it('34 is working', function() insert_([=[ - - - + + + void func(int a #if defined(FOO) @@ -3127,12 +3127,12 @@ describe('cindent', function() } ]=]) - execute('set cino=(0') + feed_command('set cino=(0') feed('2kdd2j=][<cr>') expect([=[ - - + + void func(int a #if defined(FOO) @@ -3147,8 +3147,8 @@ describe('cindent', function() it('35 is working', function() insert_([=[ - - + + void func(void) { if(x==y) @@ -3159,7 +3159,7 @@ describe('cindent', function() } printf("Foo!\n"); } - + void func1(void) { char* tab[] = {"foo", "bar", @@ -3167,37 +3167,37 @@ describe('cindent', function() "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) @@ -3206,14 +3206,14 @@ describe('cindent', function() int c; { } - + void func5( int a, int b) { } - + void func6( int a) @@ -3221,11 +3221,11 @@ describe('cindent', function() } ]=]) - execute('set cino&') + feed_command('set cino&') feed('2kdd2j=7][<cr>') expect([=[ - + void func(void) { if(x==y) @@ -3236,7 +3236,7 @@ describe('cindent', function() } printf("Foo!\n"); } - + void func1(void) { char* tab[] = {"foo", "bar", @@ -3244,37 +3244,37 @@ describe('cindent', function() "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) @@ -3283,14 +3283,14 @@ describe('cindent', function() int c; { } - + void func5( int a, int b) { } - + void func6( int a) @@ -3301,17 +3301,17 @@ describe('cindent', function() it('36 is working', function() insert_([=[ - - + + void func(void) { int tab[] = { 1, 2, 3, 4, 5, 6}; - + printf("Indent this line correctly!\n"); - + switch (foo) { case bar: @@ -3328,21 +3328,21 @@ describe('cindent', function() } ]=]) - execute('set cino&') - execute('set cino+=l1') + feed_command('set cino&') + feed_command('set cino+=l1') feed('2kdd2j=][<cr>') expect([=[ - + void func(void) { int tab[] = { 1, 2, 3, 4, 5, 6}; - + printf("Indent this line correctly!\n"); - + switch (foo) { case bar: @@ -3362,8 +3362,8 @@ describe('cindent', function() it('37 is working', function() insert_([=[ - - + + void func(void) { cout << "a" @@ -3373,11 +3373,11 @@ describe('cindent', function() } ]=]) - execute('set cino&') + feed_command('set cino&') feed('2kdd2j=][<cr>') expect([=[ - + void func(void) { cout << "a" @@ -3390,7 +3390,7 @@ describe('cindent', function() it('38 is working', function() insert_([=[ - + void func(void) { /* @@ -3399,11 +3399,11 @@ describe('cindent', function() } ]=]) - execute('set com=s1:/*,m:*,ex:*/') + feed_command('set com=s1:/*,m:*,ex:*/') feed(']]3jofoo();<esc>') expect([=[ - + void func(void) { /* @@ -3416,8 +3416,8 @@ describe('cindent', function() it('39 is working', function() insert_([=[ - - + + void func(void) { for (int i = 0; i < 10; ++i) @@ -3429,11 +3429,11 @@ describe('cindent', function() } ]=]) - execute('set cino&') + feed_command('set cino&') feed('2kdd2j=][<cr>') expect([=[ - + void func(void) { for (int i = 0; i < 10; ++i) @@ -3448,8 +3448,8 @@ describe('cindent', function() it('40 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3457,7 +3457,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3465,7 +3465,7 @@ describe('cindent', function() (c2 || c3)) { } - + if ( c1 && ( c2 || c3)) @@ -3477,11 +3477,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,(0') + feed_command('set cino=k2s,(0') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3489,7 +3489,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3497,7 +3497,7 @@ describe('cindent', function() (c2 || c3)) { } - + if ( c1 && ( c2 || c3)) @@ -3512,8 +3512,8 @@ describe('cindent', function() it('41 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3521,7 +3521,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3529,7 +3529,7 @@ describe('cindent', function() (c2 || c3)) { } - + if ( c1 && ( c2 || c3)) @@ -3541,11 +3541,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,(s') + feed_command('set cino=k2s,(s') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3553,7 +3553,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3561,7 +3561,7 @@ describe('cindent', function() (c2 || c3)) { } - + if ( c1 && ( c2 || c3)) @@ -3576,8 +3576,8 @@ describe('cindent', function() it('42 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3585,7 +3585,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3597,7 +3597,7 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + c = c1 && ( c2 || @@ -3606,11 +3606,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,(s,U1') + feed_command('set cino=k2s,(s,U1') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3618,7 +3618,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3630,7 +3630,7 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + c = c1 && ( c2 || @@ -3642,8 +3642,8 @@ describe('cindent', function() it('43 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3651,7 +3651,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3663,12 +3663,12 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + if ( c1 && ( c2 || c3)) foo; - + a_long_line( argument, argument); @@ -3677,11 +3677,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,(0,W4') + feed_command('set cino=k2s,(0,W4') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3689,7 +3689,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3701,12 +3701,12 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + if ( c1 && ( c2 || c3)) foo; - + a_long_line( argument, argument); @@ -3718,8 +3718,8 @@ describe('cindent', function() it('44 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3727,7 +3727,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3742,11 +3742,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,u2') + feed_command('set cino=k2s,u2') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3754,7 +3754,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3772,8 +3772,8 @@ describe('cindent', function() it('45 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3781,7 +3781,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3793,7 +3793,7 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + if ( c1 && ( c2 || c3)) @@ -3805,11 +3805,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2s,(0,w1') + feed_command('set cino=k2s,(0,w1') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3817,7 +3817,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3829,7 +3829,7 @@ describe('cindent', function() && (c22345 || c3)) printf("foo\n"); - + if ( c1 && ( c2 || c3)) @@ -3844,8 +3844,8 @@ describe('cindent', function() it('46 is working', function() insert_([=[ - - + + void func(void) { if (condition1 @@ -3853,7 +3853,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3864,11 +3864,11 @@ describe('cindent', function() } ]=]) - execute('set cino=k2,(s') + feed_command('set cino=k2,(s') feed('2kdd3j=][<cr>') expect([=[ - + void func(void) { if (condition1 @@ -3876,7 +3876,7 @@ describe('cindent', function() action(); function(argument1 && argument2); - + if (c1 && (c2 || c3)) foo; @@ -3890,7 +3890,7 @@ describe('cindent', function() it('47 is working', function() insert_([=[ - + NAMESPACESTART /* valid namespaces with normal indent */ namespace @@ -3930,7 +3930,7 @@ describe('cindent', function() 22222222222222222; } } - + /* invalid namespaces use block indent */ namespace test test2 { 111111111111111111111; @@ -3956,12 +3956,12 @@ describe('cindent', function() NAMESPACEEND ]=]) - execute('set cino=N-s') - execute('/^NAMESPACESTART') + feed_command('set cino=N-s') + feed_command('/^NAMESPACESTART') feed('=/^NAMESPACEEND<cr>') expect([=[ - + NAMESPACESTART /* valid namespaces with normal indent */ namespace @@ -4001,7 +4001,7 @@ describe('cindent', function() 22222222222222222; } } - + /* invalid namespaces use block indent */ namespace test test2 { 111111111111111111111; @@ -4030,7 +4030,7 @@ describe('cindent', function() it('48 is working', function() insert_([=[ - + JSSTART var bar = { foo: { @@ -4047,12 +4047,12 @@ describe('cindent', function() JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART var bar = { foo: { @@ -4072,7 +4072,7 @@ describe('cindent', function() it('49 is working', function() insert_([=[ - + JSSTART var foo = [ 1, @@ -4082,12 +4082,12 @@ describe('cindent', function() JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART var foo = [ 1, @@ -4100,7 +4100,7 @@ describe('cindent', function() it('50 is working', function() insert_([=[ - + JSSTART function bar() { var foo = [ @@ -4112,12 +4112,12 @@ describe('cindent', function() JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART function bar() { var foo = [ @@ -4132,10 +4132,10 @@ describe('cindent', function() it('51 is working', function() insert_([=[ - + JSSTART (function($){ - + if (cond && cond) { stmt; @@ -4143,18 +4143,18 @@ describe('cindent', function() 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, @@ -4168,19 +4168,19 @@ describe('cindent', function() } }, 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; @@ -4190,20 +4190,20 @@ describe('cindent', function() } }); } - + })(jQuery); JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART (function($){ - + if (cond && cond) { stmt; @@ -4211,18 +4211,18 @@ describe('cindent', function() 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, @@ -4236,19 +4236,19 @@ describe('cindent', function() } }, 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; @@ -4258,7 +4258,7 @@ describe('cindent', function() } }); } - + })(jQuery); JSEND ]=]) @@ -4266,7 +4266,7 @@ describe('cindent', function() it('52 is working', function() insert_([=[ - + JSSTART function init(options) { $(this).data(class_name+'_public',$.extend({},{ @@ -4285,12 +4285,12 @@ describe('cindent', function() JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART function init(options) { $(this).data(class_name+'_public',$.extend({},{ @@ -4312,7 +4312,7 @@ describe('cindent', function() it('53 is working', function() insert_([=[ - + JSSTART (function($){ function init(options) { @@ -4333,12 +4333,12 @@ describe('cindent', function() JSEND ]=]) - execute('set cino=j1,J1') - execute('/^JSSTART') + feed_command('set cino=j1,J1') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART (function($){ function init(options) { @@ -4362,7 +4362,7 @@ describe('cindent', function() it('javascript indent / vim-patch 7.4.670', function() insert_([=[ - + JSSTART // Results of JavaScript indent // 1 @@ -4379,7 +4379,7 @@ describe('cindent', function() 'i' ]; }()) - + // 2 (function(){ var a = [ @@ -4400,7 +4400,7 @@ describe('cindent', function() 'i' ]; }()) - + // 3 (function(){ var a = [ @@ -4423,7 +4423,7 @@ describe('cindent', function() 'i' ]; }()) - + // 4 { var a = [ @@ -4433,7 +4433,7 @@ describe('cindent', function() var b; var c; } - + // 5 { var a = [ @@ -4444,7 +4444,7 @@ describe('cindent', function() 3 ]; } - + // 6 { var a = [ @@ -4456,7 +4456,7 @@ describe('cindent', function() 3 ]; } - + // 7 { var a = [ @@ -4468,7 +4468,7 @@ describe('cindent', function() 3 ]; } - + // 8 var x = [ (function(){ @@ -4483,7 +4483,7 @@ describe('cindent', function() i; }) ]; - + // 9 var a = [ 0 + @@ -4502,7 +4502,7 @@ describe('cindent', function() 'h', 'i' ]; - + // 10 var a, b, @@ -4517,12 +4517,12 @@ describe('cindent', function() ]=]) -- :set cino=j1,J1,+2 - execute('set cino=j1,J1,+2') - execute('/^JSSTART') + feed_command('set cino=j1,J1,+2') + feed_command('/^JSSTART') feed('=/^JSEND<cr>') expect([=[ - + JSSTART // Results of JavaScript indent // 1 @@ -4539,7 +4539,7 @@ describe('cindent', function() 'i' ]; }()) - + // 2 (function(){ var a = [ @@ -4560,7 +4560,7 @@ describe('cindent', function() 'i' ]; }()) - + // 3 (function(){ var a = [ @@ -4583,7 +4583,7 @@ describe('cindent', function() 'i' ]; }()) - + // 4 { var a = [ @@ -4593,7 +4593,7 @@ describe('cindent', function() var b; var c; } - + // 5 { var a = [ @@ -4604,7 +4604,7 @@ describe('cindent', function() 3 ]; } - + // 6 { var a = [ @@ -4616,7 +4616,7 @@ describe('cindent', function() 3 ]; } - + // 7 { var a = [ @@ -4628,7 +4628,7 @@ describe('cindent', function() 3 ]; } - + // 8 var x = [ (function(){ @@ -4643,7 +4643,7 @@ describe('cindent', function() i; }) ]; - + // 9 var a = [ 0 + @@ -4662,7 +4662,7 @@ describe('cindent', function() 'h', 'i' ]; - + // 10 var a, b, diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua index 3e5cdd2ff2..9b0df024c8 100644 --- a/test/functional/legacy/004_bufenter_with_modelines_spec.lua +++ b/test/functional/legacy/004_bufenter_with_modelines_spec.lua @@ -1,10 +1,9 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for autocommand that changes current buffer on BufEnter event. -- Check if modelines are interpreted for the correct buffer. local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('BufEnter with modelines', function() setup(clear) @@ -20,34 +19,34 @@ describe('BufEnter with modelines', function() this is a test end of test file Xxx]]) - execute('au BufEnter Xxx brew') + feed_command('au BufEnter Xxx brew') -- Write test file Xxx - execute('/start of') - execute('.,/end of/w! Xxx') - execute('set ai modeline modelines=3') + feed_command('/start of') + feed_command('.,/end of/w! Xxx') + feed_command('set ai modeline modelines=3') -- Split to Xxx, autocmd will do :brew - execute('sp Xxx') + feed_command('sp Xxx') -- Append text with autoindent to this file feed('G?this is a<CR>') feed('othis should be auto-indented<Esc>') -- Go to Xxx, no autocmd anymore - execute('au! BufEnter Xxx') - execute('buf Xxx') + feed_command('au! BufEnter Xxx') + feed_command('buf Xxx') -- Append text without autoindent to Xxx feed('G?this is a<CR>') feed('othis should be in column 1<Esc>') - execute('wq') + feed_command('wq') -- Include Xxx in the current file feed('G:r Xxx<CR>') -- Vim issue #57 do not move cursor on <c-o> when autoindent is set - execute('set fo+=r') + feed_command('set fo+=r') feed('G') feed('o# abcdef<Esc>2hi<CR><c-o>d0<Esc>') feed('o# abcdef<Esc>2hi<c-o>d0<Esc>') diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua index 895f4ad181..417842c52d 100644 --- a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua +++ b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua @@ -3,7 +3,8 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe('test5', function() setup(clear) @@ -18,35 +19,37 @@ describe('test5', function() this is a test end of test file Xxx]]) - execute('w! Xxx0') - execute('au BufLeave Xxx bwipe') - execute('/start of') + command('w! Xxx0') + command('au BufLeave Xxx bwipe') + command('/start of') -- Write test file Xxx. - execute('.,/end of/w! Xxx') + command('.,/end of/w! Xxx') -- Split to Xxx. - execute('sp Xxx') + command('sp Xxx') -- Delete buffer Xxx, now we're back here. - execute('bwipe') + command('bwipe') feed('G?this is a<cr>') feed('othis is some more text<esc>') + wait() -- Append some text to this file. -- Write current file contents. - execute('?start?,$yank A') + command('?start?,$yank A') -- Delete current buffer, get an empty one. - execute('bwipe!') + command('bwipe!') -- Append an extra line to the output register. feed('ithis is another test line<esc>:yank A<cr>') + wait() -- Output results - execute('%d') - execute('0put a') - execute('$d') + command('%d') + command('0put a') + command('$d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/006_argument_list_spec.lua b/test/functional/legacy/006_argument_list_spec.lua index 764854314f..dac58df8a5 100644 --- a/test/functional/legacy/006_argument_list_spec.lua +++ b/test/functional/legacy/006_argument_list_spec.lua @@ -2,8 +2,9 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, dedent, eq = helpers.execute, helpers.dedent, helpers.eq +local command, dedent, eq = helpers.command, helpers.dedent, helpers.eq local curbuf_contents = helpers.curbuf_contents +local wait = helpers.wait describe('argument list', function() setup(clear) @@ -16,10 +17,11 @@ describe('argument list', function() this is a test this is a test end of test file Xxx]]) + wait() + + command('au BufReadPost Xxx2 next Xxx2 Xxx1') + command('/^start of') - execute('au BufReadPost Xxx2 next Xxx2 Xxx1') - execute('/^start of') - -- Write test file Xxx1 feed('A1<Esc>:.,/end of/w! Xxx1<cr>') @@ -28,29 +30,31 @@ describe('argument list', function() -- Write test file Xxx3 feed('$r3:.,/end of/w! Xxx3<cr>') + wait() -- Redefine arglist; go to Xxx1 - execute('next! Xxx1 Xxx2 Xxx3') - + command('next! Xxx1 Xxx2 Xxx3') + -- Open window for all args - execute('all') - + command('all') + -- Write contents of Xxx1 - execute('%yank A') + command('%yank A') -- Append contents of last window (Xxx1) feed('') - execute('%yank A') - + wait() + command('%yank A') + -- should now be in Xxx2 - execute('rew') - + command('rew') + -- Append contents of Xxx2 - execute('%yank A') + command('%yank A') - execute('%d') - execute('0put=@a') - execute('$d') + command('%d') + command('0put=@a') + command('$d') eq(dedent([[ start of test file Xxx1 diff --git a/test/functional/legacy/007_ball_buffer_list_spec.lua b/test/functional/legacy/007_ball_buffer_list_spec.lua index e54525fd06..8501faabec 100644 --- a/test/functional/legacy/007_ball_buffer_list_spec.lua +++ b/test/functional/legacy/007_ball_buffer_list_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe(':ball', function() setup(clear) @@ -14,44 +14,44 @@ describe(':ball', function() this is a test end of test file Xxx]]) - execute('w! Xxx0') + feed_command('w! Xxx0') feed('gg') -- Write test file Xxx1 feed('A1:.,/end of/w! Xxx1<cr>') - execute('sp Xxx1') - execute('close') + feed_command('sp Xxx1') + feed_command('close') -- Write test file Xxx2 feed('$r2:.,/end of/w! Xxx2<cr>') - execute('sp Xxx2') - execute('close') + feed_command('sp Xxx2') + feed_command('close') -- Write test file Xxx3 feed('$r3:.,/end of/w! Xxx3<cr>') - execute('sp Xxx3') - execute('close') + feed_command('sp Xxx3') + feed_command('close') - execute('au BufReadPost Xxx2 bwipe') + feed_command('au BufReadPost Xxx2 bwipe') -- Open window for all args, close Xxx2 feed('$r4:ball<cr>') -- Write contents of this file - execute('%yank A') + feed_command('%yank A') -- Append contents of second window (Xxx1) feed('') - execute('%yank A') + feed_command('%yank A') -- Append contents of last window (this file) feed('') - execute('%yank A') + feed_command('%yank A') - execute('bf') - execute('%d') - execute('0put=@a') - execute('$d') + feed_command('bf') + feed_command('%d') + feed_command('0put=@a') + feed_command('$d') expect([[ start of test file Xxx4 diff --git a/test/functional/legacy/008_autocommands_spec.lua b/test/functional/legacy/008_autocommands_spec.lua index 2c398d3c73..7474f1e068 100644 --- a/test/functional/legacy/008_autocommands_spec.lua +++ b/test/functional/legacy/008_autocommands_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, source = helpers.feed, helpers.source -local clear, execute, expect, eq, eval = helpers.clear, helpers.execute, helpers.expect, helpers.eq, helpers.eval +local clear, feed_command, expect, eq, eval = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.eval local write_file, wait, dedent = helpers.write_file, helpers.wait, helpers.dedent local io = require('io') @@ -25,15 +25,15 @@ describe('autocommands that delete and unload buffers:', function() before_each(clear) it('BufWritePre, BufUnload', function() - execute('au BufWritePre Xxx1 bunload') - execute('au BufWritePre Xxx2 bwipe') - execute('e Xxx2') + feed_command('au BufWritePre Xxx1 bunload') + feed_command('au BufWritePre Xxx2 bwipe') + feed_command('e Xxx2') eq('Xxx2', eval('bufname("%")')) - execute('e Xxx1') + feed_command('e Xxx1') eq('Xxx1', eval('bufname("%")')) -- The legacy test file did not check the error message. - execute('let v:errmsg = "no error"') - execute('write') + feed_command('let v:errmsg = "no error"') + feed_command('write') -- Discard all "hit enter" prompts and messages. feed('<C-L>') eq('E203: Autocommands deleted or unloaded buffer to be written', @@ -41,11 +41,11 @@ describe('autocommands that delete and unload buffers:', function() eq('Xxx2', eval('bufname("%")')) expect(text2) -- Start editing Xxx2. - execute('e! Xxx2') + feed_command('e! Xxx2') -- The legacy test file did not check the error message. - execute('let v:errmsg = "no error"') + feed_command('let v:errmsg = "no error"') -- Write Xxx2, will delete the buffer and give an error msg. - execute('w') + feed_command('w') -- Discard all "hit enter" prompts and messages. feed('<C-L>') eq('E203: Autocommands deleted or unloaded buffer to be written', @@ -73,17 +73,17 @@ describe('autocommands that delete and unload buffers:', function() au BufUnload * call CloseAll() au VimLeave * call WriteToOut() ]]) - execute('e Xxx2') + feed_command('e Xxx2') -- Discard all "hit enter" prompts and messages. feed('<C-L>') - execute('e Xxx1') + feed_command('e Xxx1') -- Discard all "hit enter" prompts and messages. feed('<C-L>') - execute('e Makefile') -- an existing file + feed_command('e Makefile') -- an existing file feed('<C-L>') - execute('sp new2') + feed_command('sp new2') feed('<C-L>') - execute('q') + feed_command('q') wait() eq('VimLeave done', string.match(io.open('test.out', 'r'):read('*all'), "^%s*(.-)%s*$")) diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua deleted file mode 100644 index 7481c639cf..0000000000 --- a/test/functional/legacy/009_bufleave_autocommand_spec.lua +++ /dev/null @@ -1,22 +0,0 @@ --- Test for Bufleave autocommand that deletes the buffer we are about to edit. - -local helpers = require('test.functional.helpers')(after_each) -local clear, insert = helpers.clear, helpers.insert -local execute, expect = helpers.execute, helpers.expect - -describe('BufLeave autocommand', function() - setup(clear) - - it('is working', function() - insert([[ - start of test file xx - end of test file xx]]) - - execute('au BufLeave * bwipe yy') - execute('e yy') - - expect([[ - start of test file xx - end of test file xx]]) - end) -end) diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index ba899f8119..e01af4583b 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -14,8 +14,8 @@ local helpers= require('test.functional.helpers')(after_each) local lfs = require('lfs') -local clear, execute, expect, eq, neq, dedent, write_file, feed = - helpers.clear, helpers.execute, helpers.expect, helpers.eq, helpers.neq, +local clear, feed_command, expect, eq, neq, dedent, write_file, feed = + helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.dedent, helpers.write_file, helpers.feed if helpers.pending_win32(pending) then return end @@ -66,26 +66,26 @@ describe('file reading, writing and bufnew and filter autocommands', function() it('FileReadPost (using gzip)', function() prepare_gz_file('Xtestfile', text1) - execute('let $GZIP = ""') + feed_command('let $GZIP = ""') --execute('au FileChangedShell * echo "caught FileChangedShell"') - execute('set bin') - execute("au FileReadPost *.gz '[,']!gzip -d") + feed_command('set bin') + feed_command("au FileReadPost *.gz '[,']!gzip -d") -- Read and decompress the testfile. - execute('$r Xtestfile.gz') + feed_command('$r Xtestfile.gz') expect('\n'..text1) end) it('BufReadPre, BufReadPost (using gzip)', function() prepare_gz_file('Xtestfile', text1) local gzip_data = io.open('Xtestfile.gz'):read('*all') - execute('let $GZIP = ""') + feed_command('let $GZIP = ""') -- Setup autocommands to decompress before reading and re-compress afterwards. - execute("au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand('<afile>'))") - execute("au BufReadPre *.gz call rename(expand('<afile>:r'), expand('<afile>'))") - execute("au BufReadPost *.gz call rename(expand('<afile>'), expand('<afile>:r'))") - execute("au BufReadPost *.gz exe '!gzip ' . shellescape(expand('<afile>:r'))") + feed_command("au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand('<afile>'))") + feed_command("au BufReadPre *.gz call rename(expand('<afile>:r'), expand('<afile>'))") + feed_command("au BufReadPost *.gz call rename(expand('<afile>'), expand('<afile>:r'))") + feed_command("au BufReadPost *.gz exe '!gzip ' . shellescape(expand('<afile>:r'))") -- Edit compressed file. - execute('e! Xtestfile.gz') + feed_command('e! Xtestfile.gz') -- Discard all prompts and messages. feed('<C-L>') -- Expect the decompressed file in the buffer. @@ -96,11 +96,11 @@ describe('file reading, writing and bufnew and filter autocommands', function() it('FileReadPre, FileReadPost', function() prepare_gz_file('Xtestfile', text1) - execute('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand("<afile>"))') - execute('au FileReadPre *.gz call rename(expand("<afile>:r"), expand("<afile>"))') - execute("au! FileReadPost *.gz '[,']s/l/L/") + feed_command('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand("<afile>"))') + feed_command('au FileReadPre *.gz call rename(expand("<afile>:r"), expand("<afile>"))') + feed_command("au! FileReadPost *.gz '[,']s/l/L/") -- Read compressed file. - execute('$r Xtestfile.gz') + feed_command('$r Xtestfile.gz') -- Discard all prompts and messages. feed('<C-L>') expect([[ @@ -121,17 +121,17 @@ describe('file reading, writing and bufnew and filter autocommands', function() end it('FileAppendPre, FileAppendPost', function() - execute('au BufNewFile *.c read Xtest.c') + feed_command('au BufNewFile *.c read Xtest.c') -- Will load Xtest.c. - execute('e! foo.c') - execute("au FileAppendPre *.out '[,']s/new/NEW/") - execute('au FileAppendPost *.out !cat Xtest.c >>test.out') + feed_command('e! foo.c') + feed_command("au FileAppendPre *.out '[,']s/new/NEW/") + feed_command('au FileAppendPost *.out !cat Xtest.c >>test.out') -- Append it to the output file. - execute('w>>test.out') + feed_command('w>>test.out') -- Discard all prompts and messages. feed('<C-L>') -- Expect the decompressed file in the buffer. - execute('e test.out') + feed_command('e test.out') expect([[ /* @@ -166,18 +166,18 @@ describe('file reading, writing and bufnew and filter autocommands', function() * Here is a new .c file */]])) -- Need temp files here. - execute('set shelltemp') - execute('au FilterReadPre *.out call rename(expand("<afile>"), expand("<afile>") . ".t")') - execute('au FilterReadPre *.out exe "silent !sed s/e/E/ " . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))') - execute('au FilterReadPre *.out exe "silent !rm " . shellescape(expand("<afile>")) . ".t"') - execute("au FilterReadPost *.out '[,']s/x/X/g") + feed_command('set shelltemp') + feed_command('au FilterReadPre *.out call rename(expand("<afile>"), expand("<afile>") . ".t")') + feed_command('au FilterReadPre *.out exe "silent !sed s/e/E/ " . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))') + feed_command('au FilterReadPre *.out exe "silent !rm " . shellescape(expand("<afile>")) . ".t"') + feed_command("au FilterReadPost *.out '[,']s/x/X/g") -- Edit the output file. - execute('e! test.out') - execute('23,$!cat') + feed_command('e! test.out') + feed_command('23,$!cat') -- Discard all prompts and messages. feed('<C-L>') -- Remove CR for when sed adds them. - execute([[23,$s/\r$//]]) + feed_command([[23,$s/\r$//]]) expect([[ startstart start of testfile diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua index cef31ae405..cec4f93737 100644 --- a/test/functional/legacy/012_directory_spec.lua +++ b/test/functional/legacy/012_directory_spec.lua @@ -3,12 +3,19 @@ -- - "./dir", in directory relative to file -- - "dir", in directory relative to current dir -local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') -local insert, eq = helpers.insert, helpers.eq -local neq, eval = helpers.neq, helpers.eval -local clear, execute = helpers.clear, helpers.execute -local wait, write_file = helpers.wait, helpers.write_file +local helpers = require('test.functional.helpers')(after_each) +local lfs = require('lfs') + +local eq = helpers.eq +local neq = helpers.neq +local wait = helpers.wait +local funcs = helpers.funcs +local meths = helpers.meths +local clear = helpers.clear +local insert = helpers.insert +local command = helpers.command +local write_file = helpers.write_file +local curbufmeths = helpers.curbufmeths local function ls_dir_sorted(dirname) local files = {} @@ -36,7 +43,7 @@ describe("'directory' option", function() clear() end) teardown(function() - execute('qall!') + command('qall!') helpers.rmdir('Xtest.je') helpers.rmdir('Xtest2') os.remove('Xtest1') @@ -49,21 +56,22 @@ describe("'directory' option", function() line 3 Abcdefghij end of testfile]]) - execute('set swapfile') - execute('set dir=.,~') + meths.set_option('swapfile', true) + curbufmeths.set_option('swapfile', true) + meths.set_option('directory', '.') -- sanity check: files should not exist yet. eq(nil, lfs.attributes('.Xtest1.swp')) - execute('e! Xtest1') + command('edit! Xtest1') wait() - eq('Xtest1', eval('buffer_name("%")')) + eq('Xtest1', funcs.buffer_name('%')) -- Verify that the swapfile exists. In the legacy test this was done by -- reading the output from :!ls. neq(nil, lfs.attributes('.Xtest1.swp')) - execute('set dir=./Xtest2,.,~') - execute('e Xtest1') + meths.set_option('directory', './Xtest2,.') + command('edit Xtest1') wait() -- swapfile should no longer exist in CWD. @@ -71,9 +79,9 @@ describe("'directory' option", function() eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2")) - execute('set dir=Xtest.je,~') - execute('e Xtest2/Xtest3') - eq(1, eval('&swapfile')) + meths.set_option('directory', 'Xtest.je') + command('edit Xtest2/Xtest3') + eq(true, curbufmeths.get_option('swapfile')) wait() eq({ "Xtest3" }, ls_dir_sorted("Xtest2")) diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua index 48d4042ff2..8423aa3d11 100644 --- a/test/functional/legacy/015_alignment_spec.lua +++ b/test/functional/legacy/015_alignment_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('alignment', function() setup(clear) @@ -19,7 +19,7 @@ describe('alignment', function() asdfa a xasdfa a asxxdfa a - + test for :center a a fa afd asdf @@ -28,7 +28,7 @@ describe('alignment', function() asdfa a xasdfa asdfasdfasdfasdfasdf asxxdfa a - + test for :right a a fa a @@ -111,34 +111,34 @@ describe('alignment', function() asxxdfa axxxoikey asxa;ofa axxxoikey asdfaqwer axxxoikey - + xxxxx xx xxxxxx xxxxxxx xxxxxxxxx xxx xxxx xxxxx xxxxx xxx xx xxxxxxxxxxxxxxxxxx xxxxx xxxx, xxxx xxxx xxxx xxxx xxx xx xx xx xxxxxxx. xxxx xxxx. - + > xx xx, xxxx xxxx xxx xxxx xxx xxxxx xxx xxx xxxxxxx xxx xxxxx > xxxxxx xxxxxxx: xxxx xxxxxxx, xx xxxxxx xxxx xxxxxxxxxx - + aa aa aa aa bb bb bb bb cc cc cc cc]]) - execute('set tw=65') + feed_command('set tw=65') feed([[:/^\s*test for :left/,/^\s*test for :center/ left<cr>]]) feed([[:/^\s*test for :center/,/^\s*test for :right/ center<cr>]]) feed([[:/^\s*test for :right/,/^xxx/-1 right<cr>]]) - execute('set fo+=tcroql tw=72') + feed_command('set fo+=tcroql tw=72') feed('/xxxxxxxx$<cr>') feed('0gq6kk<cr>') -- Undo/redo here to make the next undo only work on the following changes. feed('u<cr>') - execute('map gg :.,.+2s/^/x/<CR>kk:set tw=3<CR>gqq') - execute('/^aa') + feed_command('map gg :.,.+2s/^/x/<CR>kk:set tw=3<CR>gqq') + feed_command('/^aa') feed('ggu<cr>') -- Assert buffer contents. @@ -151,7 +151,7 @@ describe('alignment', function() asdfa a xasdfa a asxxdfa a - + test for :center a a fa afd asdf @@ -160,7 +160,7 @@ describe('alignment', function() asdfa a xasdfa asdfasdfasdfasdfasdf asxxdfa a - + test for :right a a fa a @@ -243,14 +243,14 @@ describe('alignment', function() asxxdfa axxxoikey asxa;ofa axxxoikey asdfaqwer axxxoikey - + xxxxx xx xxxxxx xxxxxxx xxxxxxxxx xxx xxxx xxxxx xxxxx xxx xx xxxxxxxxxxxxxxxxxx xxxxx xxxx, xxxx xxxx xxxx xxxx xxx xx xx xx xxxxxxx. xxxx xxxx. - + > xx xx, xxxx xxxx xxx xxxx xxx xxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxx > xxxxxxx: xxxx xxxxxxx, xx xxxxxx xxxx xxxxxxxxxx - + aa aa aa aa bb bb bb bb cc cc cc cc]]) diff --git a/test/functional/legacy/018_unset_smart_indenting_spec.lua b/test/functional/legacy/018_unset_smart_indenting_spec.lua index ba1eac02cb..94fbb283f4 100644 --- a/test/functional/legacy/018_unset_smart_indenting_spec.lua +++ b/test/functional/legacy/018_unset_smart_indenting_spec.lua @@ -1,11 +1,15 @@ -- Tests for not doing smart indenting when it isn't set. local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect + +local feed = helpers.feed +local clear = helpers.clear +local insert = helpers.insert +local expect = helpers.expect +local feed_command = helpers.feed_command describe('unset smart indenting', function() - setup(clear) + before_each(clear) it('is working', function() insert([[ @@ -15,8 +19,8 @@ describe('unset smart indenting', function() test text test text]]) - execute('set nocin nosi ai') - execute('/some') + feed_command('set nocin nosi ai') + feed_command('/some') feed('2cc#test<Esc>') expect([[ diff --git a/test/functional/legacy/019_smarttab_expandtab_spec.lua b/test/functional/legacy/019_smarttab_expandtab_spec.lua index 2287a9f786..ecb24885bb 100644 --- a/test/functional/legacy/019_smarttab_expandtab_spec.lua +++ b/test/functional/legacy/019_smarttab_expandtab_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and "dv_"]], function() setup(clear) @@ -19,24 +19,24 @@ describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and test text Second line beginning with whitespace]]) - execute('set smarttab expandtab ts=8 sw=4') + feed_command('set smarttab expandtab ts=8 sw=4') -- Make sure that backspace works, no matter what termcap is used. - execute('set t_kD=x7f t_kb=x08') + feed_command('set t_kD=x7f t_kb=x08') - execute('/some') + feed_command('/some') feed('r ') - execute('set noexpandtab') - execute('/other') + feed_command('set noexpandtab') + feed_command('/other') feed('r <cr>') -- Test replacing with Tabs and then backspacing to undo it. feed('0wR <bs><bs><bs><esc><cr>') -- Test replacing with Tabs. feed('0wR <esc><cr>') -- Test that copyindent works with expandtab set. - execute('set expandtab smartindent copyindent ts=8 sw=8 sts=8') + feed_command('set expandtab smartindent copyindent ts=8 sw=8 sts=8') feed('o{<cr>x<esc>') - execute('set nosol') - execute('/Second line/') + feed_command('set nosol') + feed_command('/Second line/') -- Test "dv_" feed('fwdv_') diff --git a/test/functional/legacy/020_blockwise_visual_spec.lua b/test/functional/legacy/020_blockwise_visual_spec.lua index 660348a792..8d90b1c77d 100644 --- a/test/functional/legacy/020_blockwise_visual_spec.lua +++ b/test/functional/legacy/020_blockwise_visual_spec.lua @@ -1,11 +1,10 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests Blockwise Visual when there are TABs before the text. -- First test for undo working properly when executing commands from a register. -- Also test this in an empty buffer. local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('blockwise visual', function() setup(clear) @@ -26,15 +25,15 @@ Ox jAy kdd]]) feed(":let @a = 'Ox<C-v><Esc>jAy<C-v><Esc>kdd'<cr>") feed('G0k@au') - execute('new') + feed_command('new') feed('@auY') - execute('quit') + feed_command('quit') feed('GP') - execute('/start here') + feed_command('/start here') feed('"by$<C-v>jjlld') - execute('/456') + feed_command('/456') feed('<C-v>jj"bP') - execute('$-3,$d') + feed_command('$-3,$d') expect([[ 123start here56 diff --git a/test/functional/legacy/021_control_wi_spec.lua b/test/functional/legacy/021_control_wi_spec.lua index 787a384fca..87d9deed7a 100644 --- a/test/functional/legacy/021_control_wi_spec.lua +++ b/test/functional/legacy/021_control_wi_spec.lua @@ -1,9 +1,8 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('CTRL-W CTRL-I', function() setup(clear) @@ -20,18 +19,18 @@ describe('CTRL-W CTRL-I', function() test text]]) -- Search for the second occurence of start and append to register - execute('/start') + feed_command('/start') feed('2[<C-i>') - execute('yank A') + feed_command('yank A') -- Same as above but using different keystrokes. feed('?start<cr>') feed('2<C-w><Tab>') - execute('yank A') + feed_command('yank A') -- Clean buffer and put register feed('ggdG"ap') - execute('1d') + feed_command('1d') -- The buffer should now contain: expect([[ diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua index 092440bb16..fb4b782011 100644 --- a/test/functional/legacy/022_line_ending_spec.lua +++ b/test/functional/legacy/022_line_ending_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('line ending', function() setup(clear) @@ -14,8 +14,8 @@ describe('line ending', function() this one does<C-V><C-M> and the last one doesn't]], '<ESC>') - execute('set ta tx') - execute('e!') + feed_command('set ta tx') + feed_command('e!') expect("this lines ends in a\r\n".. "this one doesn't\n".. diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua index 95ab983d24..e705397a2b 100644 --- a/test/functional/legacy/023_edit_arguments_spec.lua +++ b/test/functional/legacy/023_edit_arguments_spec.lua @@ -2,7 +2,8 @@ local helpers = require('test.functional.helpers')(after_each) local clear, insert = helpers.clear, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe(':edit', function() setup(clear) @@ -12,31 +13,32 @@ describe(':edit', function() The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar" foo|bar foo/bar]]) + wait() -- Prepare some test files - execute('$-1w! Xfile1') - execute('$w! Xfile2') - execute('w! Xfile0') + command('$-1w! Xfile1') + command('$w! Xfile2') + command('w! Xfile0') -- Open Xfile using '+' range - execute('edit +1 Xfile1') - execute('s/|/PIPE/') - execute('yank A') - execute('w! Xfile1') + command('edit +1 Xfile1') + command('s/|/PIPE/') + command('yank A') + command('w! Xfile1') -- Open Xfile2 using '|' range - execute('edit Xfile2|1') - execute("s/\\//SLASH/") - execute('yank A') - execute('w! Xfile2') + command('edit Xfile2|1') + command("s/\\//SLASH/") + command('yank A') + command('w! Xfile2') -- Clean first buffer and put @a - execute('bf') - execute('%d') - execute('0put a') + command('bf') + command('%d') + command('0put a') -- Remove empty line - execute('$d') + command('$d') -- The buffer should now contain expect([[ diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua index 99224f9e08..0d51b4da26 100644 --- a/test/functional/legacy/025_jump_tag_hidden_spec.lua +++ b/test/functional/legacy/025_jump_tag_hidden_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect if helpers.pending_win32(pending) then return end @@ -21,30 +21,30 @@ describe('jump to a tag with hidden set', function() SECTION_OFF]]) - execute('w! Xxx') - execute('set hidden') + feed_command('w! Xxx') + feed_command('set hidden') -- Create a link from test25.dir to the current directory. - execute('!rm -f test25.dir') - execute('!ln -s . test25.dir') + feed_command('!rm -f test25.dir') + feed_command('!ln -s . test25.dir') -- Create tags.text, with the current directory name inserted. - execute('/tags line') - execute('r !pwd') + feed_command('/tags line') + feed_command('r !pwd') feed('d$/test<cr>') feed('hP:.w! tags.test<cr>') -- Try jumping to a tag in the current file, but with a path that contains a -- symbolic link. When wrong, this will give the ATTENTION message. The next -- space will then be eaten by hit-return, instead of moving the cursor to 'd'. - execute('set tags=tags.test') + feed_command('set tags=tags.test') feed('G<C-]> x:yank a<cr>') - execute('!rm -f Xxx test25.dir tags.test') + feed_command('!rm -f Xxx test25.dir tags.test') -- Put @a and remove empty line - execute('%d') - execute('0put a') - execute('$d') + feed_command('%d') + feed_command('0put a') + feed_command('$d') -- Assert buffer contents. expect("#efine SECTION_OFF 3") diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua index 74ef34bb20..ea8abed7ae 100644 --- a/test/functional/legacy/026_execute_while_if_spec.lua +++ b/test/functional/legacy/026_execute_while_if_spec.lua @@ -1,9 +1,11 @@ -- Test for :execute, :while and :if local helpers = require('test.functional.helpers')(after_each) + local clear = helpers.clear -local execute, expect = helpers.execute, helpers.expect +local expect = helpers.expect local source = helpers.source +local command = helpers.command describe(':execute, :while and :if', function() setup(clear) @@ -37,7 +39,7 @@ describe(':execute, :while and :if', function() ]]) -- Remove empty line - execute('1d') + command('1d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/028_source_ctrl_v_spec.lua b/test/functional/legacy/028_source_ctrl_v_spec.lua index a8c43260be..fabf831341 100644 --- a/test/functional/legacy/028_source_ctrl_v_spec.lua +++ b/test/functional/legacy/028_source_ctrl_v_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('CTRL-V at the end of the line', function() setup(clear) @@ -24,8 +24,8 @@ describe('CTRL-V at the end of the line', function() feed(':%s/X/<C-v><C-v>/g<cr>') feed(':/firstline/+1,/lastline/-1w! Xtestfile<cr>') - execute('so Xtestfile') - execute('%d') + feed_command('so Xtestfile') + feed_command('%d') feed('Gmm__1<Esc><Esc>__2<Esc>__3<Esc><Esc>__4<Esc>__5<Esc>') feed(":'m,$s/<C-v><C-@>/0/g<cr>") diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua index 7a183fcbec..460b9291bf 100644 --- a/test/functional/legacy/029_join_spec.lua +++ b/test/functional/legacy/029_join_spec.lua @@ -1,8 +1,12 @@ -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +local feed = helpers.feed +local clear = helpers.clear +local insert = helpers.insert +local expect = helpers.expect +local feed_command = helpers.feed_command describe('joining lines', function() before_each(clear) @@ -46,19 +50,19 @@ describe('joining lines', function() -- Switch off 'joinspaces', then join some lines in the buffer using "J". -- Also set a few marks and record their movement when joining lines. - execute('set nojoinspaces') - execute('/firstline/') + feed_command('set nojoinspaces') + feed_command('/firstline/') feed('j"td/^$/<cr>') feed('PJjJjJjJjJjJjJjJjJjJjJjJjJjJ') feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p') -- Do the same with 'joinspaces' on. - execute('set joinspaces') + feed_command('set joinspaces') feed('j"tp') feed('JjJjJjJjJjJjJjJjJjJjJjJjJjJ') feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$po<esc>') - execute('1d') + feed_command('1d') expect([[ asdfasdf. asdf @@ -129,20 +133,20 @@ describe('joining lines', function() } ]]) - execute('/^{/+1') - execute('set comments=s1:/*,mb:*,ex:*/,://') - execute('set nojoinspaces') - execute('set backspace=eol,start') + feed_command('/^{/+1') + feed_command('set comments=s1:/*,mb:*,ex:*/,://') + feed_command('set nojoinspaces') + feed_command('set backspace=eol,start') -- With 'joinspaces' switched off, join lines using both "J" and :join and -- verify that comment leaders are stripped or kept as appropriate. - execute('.,+3join') + feed_command('.,+3join') feed('j4J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('j3J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('j3J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('jj3J<cr>') expect([[ @@ -180,22 +184,22 @@ describe('joining lines', function() -- As mentioned above, we mimic the wrong initial cursor position in the old -- test by advancing one line further. - execute([[/^\d\+ this]], '+1') + feed_command([[/^\d\+ this]], '+1') -- Test with the default 'backspace' setting. feed('Avim1<c-u><esc><cr>') feed('Avim2<c-g>u<c-u><esc><cr>') - execute('set cpo-=<') - execute('inoremap <c-u> <left><c-u>') + feed_command('set cpo-=<') + feed_command('inoremap <c-u> <left><c-u>') feed('Avim3<c-u><esc><cr>') - execute('iunmap <c-u>') + feed_command('iunmap <c-u>') feed('Avim4<c-u><c-u><esc><cr>') -- Test with 'backspace' set to the compatible setting. - execute('set backspace=') + feed_command('set backspace=') feed('A vim5<esc>A<c-u><c-u><esc><cr>') feed('A vim6<esc>Azwei<c-g>u<c-u><esc><cr>') - execute('inoremap <c-u> <left><c-u>') + feed_command('inoremap <c-u> <left><c-u>') feed('A vim7<c-u><c-u><esc><cr>') expect([[ @@ -283,29 +287,29 @@ describe('joining lines', function() } ]]) - execute('/^{/+1') - execute([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]]) - execute('set comments+=s1:/*,mb:*,ex:*/,://') - execute('set comments+=s1:>#,mb:#,ex:#<,:<') - execute('set backspace=eol,start') + feed_command('/^{/+1') + feed_command([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]]) + feed_command('set comments+=s1:/*,mb:*,ex:*/,://') + feed_command('set comments+=s1:>#,mb:#,ex:#<,:<') + feed_command('set backspace=eol,start') -- With 'joinspaces' on (the default setting), again join lines and verify -- that comment leaders are stripped or kept as appropriate. - execute('.,+3join') + feed_command('.,+3join') feed('j4J<cr>') - execute('.,+8join') + feed_command('.,+8join') feed('j9J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('j3J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('j3J<cr>') - execute('.,+2join') + feed_command('.,+2join') feed('jj3J<cr>') feed('j') - execute('.,+2join') + feed_command('.,+2join') feed('jj3J<cr>') feed('j') - execute('.,+5join') + feed_command('.,+5join') feed('j6J<cr>') feed('oSome code!<cr>// Make sure backspacing does not remove this comment leader.<esc>0i<bs><esc>') diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua index 5fd78b2c59..7384fdf847 100644 --- a/test/functional/legacy/030_fileformats_spec.lua +++ b/test/functional/legacy/030_fileformats_spec.lua @@ -1,8 +1,9 @@ -- Test for a lot of variations of the 'fileformats' option local helpers = require('test.functional.helpers')(after_each) -local feed, clear, execute = helpers.feed, helpers.clear, helpers.execute +local feed, clear, command = helpers.feed, helpers.clear, helpers.command local eq, write_file = helpers.eq, helpers.write_file +local wait = helpers.wait if helpers.pending_win32(pending) then return end @@ -45,198 +46,214 @@ describe('fileformats option', function() it('is working', function() -- Try reading and writing with 'fileformats' empty. - execute('set fileformats=') - execute('set fileformat=unix') - execute('e! XXUnix') - execute('w! test.out') - execute('e! XXDos') - execute('w! XXtt01') - execute('e! XXMac') - execute('w! XXtt02') - execute('bwipe XXUnix XXDos XXMac') - execute('set fileformat=dos') - execute('e! XXUnix') - execute('w! XXtt11') - execute('e! XXDos') - execute('w! XXtt12') - execute('e! XXMac') - execute('w! XXtt13') - execute('bwipe XXUnix XXDos XXMac') - execute('set fileformat=mac') - execute('e! XXUnix') - execute('w! XXtt21') - execute('e! XXDos') - execute('w! XXtt22') - execute('e! XXMac') - execute('w! XXtt23') - execute('bwipe XXUnix XXDos XXMac') + command('set fileformats=') + command('set fileformat=unix') + command('e! XXUnix') + command('w! test.out') + command('e! XXDos') + command('w! XXtt01') + command('e! XXMac') + command('w! XXtt02') + command('bwipe XXUnix XXDos XXMac') + command('set fileformat=dos') + command('e! XXUnix') + command('w! XXtt11') + command('e! XXDos') + command('w! XXtt12') + command('e! XXMac') + command('w! XXtt13') + command('bwipe XXUnix XXDos XXMac') + command('set fileformat=mac') + command('e! XXUnix') + command('w! XXtt21') + command('e! XXDos') + command('w! XXtt22') + command('e! XXMac') + command('w! XXtt23') + command('bwipe XXUnix XXDos XXMac') -- Try reading and writing with 'fileformats' set to one format. - execute('set fileformats=unix') - execute('e! XXUxDsMc') - execute('w! XXtt31') - execute('bwipe XXUxDsMc') - execute('set fileformats=dos') - execute('e! XXUxDsMc') - execute('w! XXtt32') - execute('bwipe XXUxDsMc') - execute('set fileformats=mac') - execute('e! XXUxDsMc') - execute('w! XXtt33') - execute('bwipe XXUxDsMc') + command('set fileformats=unix') + command('e! XXUxDsMc') + command('w! XXtt31') + command('bwipe XXUxDsMc') + command('set fileformats=dos') + command('e! XXUxDsMc') + command('w! XXtt32') + command('bwipe XXUxDsMc') + command('set fileformats=mac') + command('e! XXUxDsMc') + command('w! XXtt33') + command('bwipe XXUxDsMc') -- Try reading and writing with 'fileformats' set to two formats. - execute('set fileformats=unix,dos') - execute('e! XXUxDsMc') - execute('w! XXtt41') - execute('bwipe XXUxDsMc') - execute('e! XXUxMac') - execute('w! XXtt42') - execute('bwipe XXUxMac') - execute('e! XXDosMac') - execute('w! XXtt43') - execute('bwipe XXDosMac') - execute('set fileformats=unix,mac') - execute('e! XXUxDs') - execute('w! XXtt51') - execute('bwipe XXUxDs') - execute('e! XXUxDsMc') - execute('w! XXtt52') - execute('bwipe XXUxDsMc') - execute('e! XXDosMac') - execute('w! XXtt53') - execute('bwipe XXDosMac') - execute('e! XXEol') + command('set fileformats=unix,dos') + command('e! XXUxDsMc') + command('w! XXtt41') + command('bwipe XXUxDsMc') + command('e! XXUxMac') + command('w! XXtt42') + command('bwipe XXUxMac') + command('e! XXDosMac') + command('w! XXtt43') + command('bwipe XXDosMac') + command('set fileformats=unix,mac') + command('e! XXUxDs') + command('w! XXtt51') + command('bwipe XXUxDs') + command('e! XXUxDsMc') + command('w! XXtt52') + command('bwipe XXUxDsMc') + command('e! XXDosMac') + command('w! XXtt53') + command('bwipe XXDosMac') + command('e! XXEol') feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>') - execute('w! XXtt54') - execute('bwipe XXEol') - execute('set fileformats=dos,mac') - execute('e! XXUxDs') - execute('w! XXtt61') - execute('bwipe XXUxDs') - execute('e! XXUxMac') + wait() + command('w! XXtt54') + command('bwipeout! XXEol') + command('set fileformats=dos,mac') + command('e! XXUxDs') + command('w! XXtt61') + command('bwipe XXUxDs') + command('e! XXUxMac') feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>') - execute('w! XXtt62') - execute('bwipe XXUxMac') - execute('e! XXUxDsMc') - execute('w! XXtt63') - execute('bwipe XXUxDsMc') - execute('e! XXMacEol') + wait() + command('w! XXtt62') + command('bwipeout! XXUxMac') + command('e! XXUxDsMc') + command('w! XXtt63') + command('bwipe XXUxDsMc') + command('e! XXMacEol') feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>') - execute('w! XXtt64') - execute('bwipe XXMacEol') + wait() + command('w! XXtt64') + command('bwipeout! XXMacEol') -- Try reading and writing with 'fileformats' set to three formats. - execute('set fileformats=unix,dos,mac') - execute('e! XXUxDsMc') - execute('w! XXtt71') - execute('bwipe XXUxDsMc') - execute('e! XXEol') + command('set fileformats=unix,dos,mac') + command('e! XXUxDsMc') + command('w! XXtt71') + command('bwipe XXUxDsMc') + command('e! XXEol') feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>') - execute('w! XXtt72') - execute('bwipe XXEol') - execute('set fileformats=mac,dos,unix') - execute('e! XXUxDsMc') - execute('w! XXtt81') - execute('bwipe XXUxDsMc') - execute('e! XXEol') + wait() + command('w! XXtt72') + command('bwipeout! XXEol') + command('set fileformats=mac,dos,unix') + command('e! XXUxDsMc') + command('w! XXtt81') + command('bwipe XXUxDsMc') + command('e! XXEol') feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>') - execute('w! XXtt82') - execute('bwipe XXEol') + wait() + command('w! XXtt82') + command('bwipeout! XXEol') -- Try with 'binary' set. - execute('set fileformats=mac,unix,dos') - execute('set binary') - execute('e! XXUxDsMc') - execute('w! XXtt91') - execute('bwipe XXUxDsMc') - execute('set fileformats=mac') - execute('e! XXUxDsMc') - execute('w! XXtt92') - execute('bwipe XXUxDsMc') - execute('set fileformats=dos') - execute('e! XXUxDsMc') - execute('w! XXtt93') + command('set fileformats=mac,unix,dos') + command('set binary') + command('e! XXUxDsMc') + command('w! XXtt91') + command('bwipe XXUxDsMc') + command('set fileformats=mac') + command('e! XXUxDsMc') + command('w! XXtt92') + command('bwipe XXUxDsMc') + command('set fileformats=dos') + command('e! XXUxDsMc') + command('w! XXtt93') -- Append "END" to each file so that we can see what the last written -- char was. - execute('set fileformat=unix nobin') + command('set fileformat=unix nobin') feed('ggdGaEND<esc>') - execute('w >>XXtt01') - execute('w >>XXtt02') - execute('w >>XXtt11') - execute('w >>XXtt12') - execute('w >>XXtt13') - execute('w >>XXtt21') - execute('w >>XXtt22') - execute('w >>XXtt23') - execute('w >>XXtt31') - execute('w >>XXtt32') - execute('w >>XXtt33') - execute('w >>XXtt41') - execute('w >>XXtt42') - execute('w >>XXtt43') - execute('w >>XXtt51') - execute('w >>XXtt52') - execute('w >>XXtt53') - execute('w >>XXtt54') - execute('w >>XXtt61') - execute('w >>XXtt62') - execute('w >>XXtt63') - execute('w >>XXtt64') - execute('w >>XXtt71') - execute('w >>XXtt72') - execute('w >>XXtt81') - execute('w >>XXtt82') - execute('w >>XXtt91') - execute('w >>XXtt92') - execute('w >>XXtt93') + wait() + command('w >>XXtt01') + command('w >>XXtt02') + command('w >>XXtt11') + command('w >>XXtt12') + command('w >>XXtt13') + command('w >>XXtt21') + command('w >>XXtt22') + command('w >>XXtt23') + command('w >>XXtt31') + command('w >>XXtt32') + command('w >>XXtt33') + command('w >>XXtt41') + command('w >>XXtt42') + command('w >>XXtt43') + command('w >>XXtt51') + command('w >>XXtt52') + command('w >>XXtt53') + command('w >>XXtt54') + command('w >>XXtt61') + command('w >>XXtt62') + command('w >>XXtt63') + command('w >>XXtt64') + command('w >>XXtt71') + command('w >>XXtt72') + command('w >>XXtt81') + command('w >>XXtt82') + command('w >>XXtt91') + command('w >>XXtt92') + command('w >>XXtt93') -- Concatenate the results. -- Make fileformat of test.out the native fileformat. -- Add a newline at the end. - execute('set binary') - execute('e! test.out') - execute('$r XXtt01') - execute('$r XXtt02') + command('set binary') + command('e! test.out') + command('$r XXtt01') + command('$r XXtt02') feed('Go1<esc>') - execute('$r XXtt11') - execute('$r XXtt12') - execute('$r XXtt13') + wait() + command('$r XXtt11') + command('$r XXtt12') + command('$r XXtt13') feed('Go2<esc>') - execute('$r XXtt21') - execute('$r XXtt22') - execute('$r XXtt23') + wait() + command('$r XXtt21') + command('$r XXtt22') + command('$r XXtt23') feed('Go3<esc>') - execute('$r XXtt31') - execute('$r XXtt32') - execute('$r XXtt33') + wait() + command('$r XXtt31') + command('$r XXtt32') + command('$r XXtt33') feed('Go4<esc>') - execute('$r XXtt41') - execute('$r XXtt42') - execute('$r XXtt43') + wait() + command('$r XXtt41') + command('$r XXtt42') + command('$r XXtt43') feed('Go5<esc>') - execute('$r XXtt51') - execute('$r XXtt52') - execute('$r XXtt53') - execute('$r XXtt54') + wait() + command('$r XXtt51') + command('$r XXtt52') + command('$r XXtt53') + command('$r XXtt54') feed('Go6<esc>') - execute('$r XXtt61') - execute('$r XXtt62') - execute('$r XXtt63') - execute('$r XXtt64') + wait() + command('$r XXtt61') + command('$r XXtt62') + command('$r XXtt63') + command('$r XXtt64') feed('Go7<esc>') - execute('$r XXtt71') - execute('$r XXtt72') + wait() + command('$r XXtt71') + command('$r XXtt72') feed('Go8<esc>') - execute('$r XXtt81') - execute('$r XXtt82') + wait() + command('$r XXtt81') + command('$r XXtt82') feed('Go9<esc>') - execute('$r XXtt91') - execute('$r XXtt92') - execute('$r XXtt93') + wait() + command('$r XXtt91') + command('$r XXtt92') + command('$r XXtt93') feed('Go10<esc>') - execute('$r XXUnix') - execute('set nobinary ff&') + wait() + command('$r XXUnix') + command('set nobinary ff&') -- Assert buffer contents. This has to be done manually as -- helpers.expect() calls helpers.dedent() which messes up the white space diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua index d41eadaa00..64c67c9882 100644 --- a/test/functional/legacy/031_close_commands_spec.lua +++ b/test/functional/legacy/031_close_commands_spec.lua @@ -16,7 +16,7 @@ local clear = helpers.clear local source = helpers.source local insert = helpers.insert local expect = helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command describe('Commands that close windows and/or buffers', function() local function cleanup() @@ -38,40 +38,40 @@ describe('Commands that close windows and/or buffers', function() feed('GA 1<Esc>:$w! Xtest1<CR>') feed('$r2:$w! Xtest2<CR>') feed('$r3:$w! Xtest3<CR>') - execute('n! Xtest1 Xtest2') + feed_command('n! Xtest1 Xtest2') feed('A 1<Esc>:set hidden<CR>') -- Test for working :n when hidden set - execute('n') + feed_command('n') expect('testtext 2') -- Test for failing :rew when hidden not set - execute('set nohidden') + feed_command('set nohidden') feed('A 2<Esc>:rew<CR>') expect('testtext 2 2') -- Test for working :rew when hidden set - execute('set hidden') - execute('rew') + feed_command('set hidden') + feed_command('rew') expect('testtext 1 1') -- Test for :all keeping a buffer when it's modified - execute('set nohidden') + feed_command('set nohidden') feed('A 1<Esc>:sp<CR>') - execute('n Xtest2 Xtest3') - execute('all') - execute('1wincmd w') + feed_command('n Xtest2 Xtest3') + feed_command('all') + feed_command('1wincmd w') expect('testtext 1 1 1') -- Test abandoning changed buffer, should be unloaded even when 'hidden' set - execute('set hidden') + feed_command('set hidden') feed('A 1<Esc>:q!<CR>') expect('testtext 2 2') - execute('unhide') + feed_command('unhide') expect('testtext 2 2') -- Test ":hide" hides anyway when 'hidden' not set - execute('set nohidden') + feed_command('set nohidden') feed('A 2<Esc>:hide<CR>') expect('testtext 3') @@ -80,42 +80,42 @@ describe('Commands that close windows and/or buffers', function() expect('testtext 3 3') -- Test ":edit" working in modified buffer when 'hidden' set - execute('set hidden') - execute('e Xtest1') + feed_command('set hidden') + feed_command('e Xtest1') expect('testtext 1') -- Test ":close" not hiding when 'hidden' not set in modified buffer - execute('sp Xtest3') - execute('set nohidden') + feed_command('sp Xtest3') + feed_command('set nohidden') feed('A 3<Esc>:close<CR>') expect('testtext 3 3 3') -- Test ":close!" does hide when 'hidden' not set in modified buffer feed('A 3<Esc>:close!<CR>') - execute('set nohidden') + feed_command('set nohidden') expect('testtext 1') -- Test ":all!" hides changed buffer - execute('sp Xtest4') + feed_command('sp Xtest4') feed('GA 4<Esc>:all!<CR>') - execute('1wincmd w') + feed_command('1wincmd w') expect('testtext 2 2 2') -- Test ":q!" and hidden buffer. - execute('bw! Xtest1 Xtest2 Xtest3 Xtest4') - execute('sp Xtest1') - execute('wincmd w') - execute('bw!') - execute('set modified') - execute('bot sp Xtest2') - execute('set modified') - execute('bot sp Xtest3') - execute('set modified') - execute('wincmd t') - execute('hide') - execute('q!') + feed_command('bw! Xtest1 Xtest2 Xtest3 Xtest4') + feed_command('sp Xtest1') + feed_command('wincmd w') + feed_command('bw!') + feed_command('set modified') + feed_command('bot sp Xtest2') + feed_command('set modified') + feed_command('bot sp Xtest3') + feed_command('set modified') + feed_command('wincmd t') + feed_command('hide') + feed_command('q!') expect('testtext 3') - execute('q!') + feed_command('q!') feed('<CR>') expect('testtext 1') source([[ diff --git a/test/functional/legacy/033_lisp_indent_spec.lua b/test/functional/legacy/033_lisp_indent_spec.lua index b4abb02ac2..2b79ee024b 100644 --- a/test/functional/legacy/033_lisp_indent_spec.lua +++ b/test/functional/legacy/033_lisp_indent_spec.lua @@ -1,10 +1,10 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for 'lisp' -- If the lisp feature is not enabled, this will fail! local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe('lisp indent', function() setup(clear) @@ -13,7 +13,7 @@ describe('lisp indent', function() insert([[ (defun html-file (base) (format nil "~(~A~).html" base)) - + (defmacro page (name title &rest body) (let ((ti (gensym))) `(with-open-file (*standard-output* @@ -26,29 +26,30 @@ describe('lisp indent', function() (as h2 (string-upcase ,ti))) (brs 3) ,@body)))) - + ;;; Utilities for generating links - + (defmacro with-link (dest &rest body) `(progn (format t "<a href=\"~A\">" (html-file ,dest)) ,@body (princ "</a>")))]]) - execute('set lisp') - execute('/^(defun') + command('set lisp') + command('/^(defun') feed('=G:/^(defun/,$yank A<cr>') + wait() -- Put @a and clean empty line - execute('%d') - execute('0put a') - execute('$d') + command('%d') + command('0put a') + command('$d') -- Assert buffer contents. expect([[ (defun html-file (base) (format nil "~(~A~).html" base)) - + (defmacro page (name title &rest body) (let ((ti (gensym))) `(with-open-file (*standard-output* @@ -61,9 +62,9 @@ describe('lisp indent', function() (as h2 (string-upcase ,ti))) (brs 3) ,@body)))) - + ;;; Utilities for generating links - + (defmacro with-link (dest &rest body) `(progn (format t "<a href=\"~A\">" (html-file ,dest)) diff --git a/test/functional/legacy/034_user_function_spec.lua b/test/functional/legacy/034_user_function_spec.lua index 38989cd982..0b7dfc4f0e 100644 --- a/test/functional/legacy/034_user_function_spec.lua +++ b/test/functional/legacy/034_user_function_spec.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('user functions, expr-mappings, overwrite protected builtin functions and regression on calling expressions', function() setup(clear) @@ -72,19 +72,19 @@ describe('user functions, expr-mappings, overwrite protected builtin functions a feed('(one<cr>') feed('(two<cr>') feed('[(one again<esc>') - execute('call append(line("$"), max([1, 2, 3]))') - execute('call extend(g:, {"max": function("min")})') - execute('call append(line("$"), max([1, 2, 3]))') - execute('try') + feed_command('call append(line("$"), max([1, 2, 3]))') + feed_command('call extend(g:, {"max": function("min")})') + feed_command('call append(line("$"), max([1, 2, 3]))') + feed_command('try') -- Regression: the first line below used to throw "E110: Missing ')'" -- Second is here just to prove that this line is correct when not -- skipping rhs of &&. - execute([[ $put =(0&&(function('tr'))(1, 2, 3))]]) - execute([[ $put =(1&&(function('tr'))(1, 2, 3))]]) - execute('catch') - execute([[ $put ='!!! Unexpected exception:']]) - execute(' $put =v:exception') - execute('endtry') + feed_command([[ $put =(0&&(function('tr'))(1, 2, 3))]]) + feed_command([[ $put =(1&&(function('tr'))(1, 2, 3))]]) + feed_command('catch') + feed_command([[ $put ='!!! Unexpected exception:']]) + feed_command(' $put =v:exception') + feed_command('endtry') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/035_increment_and_decrement_spec.lua b/test/functional/legacy/035_increment_and_decrement_spec.lua index 3b9f7a9d85..84eb9c0eee 100644 --- a/test/functional/legacy/035_increment_and_decrement_spec.lua +++ b/test/functional/legacy/035_increment_and_decrement_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('increment and decrement commands', function() setup(clear) @@ -19,25 +19,25 @@ describe('increment and decrement commands', function() -- Increment and decrement numbers in the first row, interpreting the -- numbers as decimal, octal or hexadecimal. - execute('set nrformats=bin,octal,hex', '1') + feed_command('set nrformats=bin,octal,hex', '1') feed('63l102ll64128$') -- For the second row, treat the numbers as decimal or octal. -- 0x100 should be interpreted as decimal 0, the character x, and decimal 100. - execute('set nrformats=octal', '2') + feed_command('set nrformats=octal', '2') feed('0w102l2w65129blx6lD') -- For the third row, treat the numbers as decimal or hexadecimal. -- 077 should be interpreted as decimal 77. - execute('set nrformats=hex', '3') + feed_command('set nrformats=hex', '3') feed('0101l257Txldt ') -- For the fourth row, interpret all numbers as decimal. - execute('set nrformats=', '4') + feed_command('set nrformats=', '4') feed('0200l100w78') -- For the last row, interpret as binary and hexadecimal. - execute('set nrformats=bin,hex', '5') + feed_command('set nrformats=bin,hex', '5') feed('010065l6432') expect([[ diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua index 15287b9901..110f7dd852 100644 --- a/test/functional/legacy/036_regexp_character_classes_spec.lua +++ b/test/functional/legacy/036_regexp_character_classes_spec.lua @@ -1,7 +1,7 @@ -- Test character classes in regexp using regexpengine 0, 1, 2. local helpers = require('test.functional.helpers')(after_each) -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, command, expect = helpers.clear, helpers.command, helpers.expect local source, write_file = helpers.source, helpers.write_file local function sixlines(text) @@ -14,7 +14,7 @@ end local function diff(text, nodedent) local fname = helpers.tmpname() - execute('w! '..fname) + command('w! '..fname) helpers.wait() local data = io.open(fname):read('*all') if nodedent then @@ -45,7 +45,7 @@ describe('character classes in regexp', function() end) before_each(function() clear() - execute('e test36.in') + command('e test36.in') end) teardown(function() os.remove('test36.in') diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua index dcbc9c39f7..2dfc959a8c 100644 --- a/test/functional/legacy/038_virtual_replace_spec.lua +++ b/test/functional/legacy/038_virtual_replace_spec.lua @@ -2,31 +2,31 @@ local helpers = require('test.functional.helpers')(after_each) local feed = helpers.feed -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('Virtual replace mode', function() setup(clear) it('is working', function() -- Make sure that backspace works, no matter what termcap is used. - execute('set t_kD=x7f t_kb=x08') + feed_command('set t_kD=x7f t_kb=x08') -- Use vi default for 'smarttab' - execute('set nosmarttab') + feed_command('set nosmarttab') feed('ggdGa<cr>') feed('abcdefghi<cr>') feed('jk<tab>lmn<cr>') feed('<Space><Space><Space><Space>opq<tab>rst<cr>') feed('<C-d>uvwxyz<cr>') feed('<esc>gg') - execute('set ai') - execute('set bs=2') + feed_command('set ai') + feed_command('set bs=2') feed('gR0<C-d> 1<cr>') feed('A<cr>') feed('BCDEFGHIJ<cr>') feed('<tab>KL<cr>') feed('MNO<cr>') feed('PQR<esc>G') - execute('ka') + feed_command('ka') feed('o0<C-d><cr>') feed('abcdefghi<cr>') feed('jk<tab>lmn<cr>') diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua index 63335985cc..dffef50950 100644 --- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua +++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua @@ -5,14 +5,14 @@ local helpers = require('test.functional.helpers')(after_each) local nvim, eq = helpers.meths, helpers.eq local insert, feed = helpers.insert, helpers.feed local clear, expect = helpers.clear, helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command describe('Visual block mode', function() before_each(function() clear() - execute('set ts&vi sw&vi sts&vi noet') -- Vim compatible + feed_command('set ts&vi sw&vi sts&vi noet') -- Vim compatible end) it('should shift, insert, replace and change a block', function() @@ -55,9 +55,9 @@ describe('Visual block mode', function() cccc dddd]]) - execute('/^aa') + feed_command('/^aa') feed('l<C-v>jjjlllI<Right><Right> <ESC>') - execute('/xaaa$') + feed_command('/xaaa$') feed('<C-v>jjjI<lt>><Left>p<ESC>') expect([[ @@ -84,13 +84,13 @@ describe('Visual block mode', function() 4567]]) -- Test for Visual block was created with the last <C-v>$. - execute('/^A23$/') + feed_command('/^A23$/') feed('l<C-v>j$Aab<ESC>') -- Test for Visual block was created with the middle <C-v>$ (1). - execute('/^B23$/') + feed_command('/^B23$/') feed('l<C-v>j$hAab<ESC>') -- Test for Visual block was created with the middle <C-v>$ (2). - execute('/^C23$/') + feed_command('/^C23$/') feed('l<C-v>j$hhAab<ESC>') expect([[ @@ -112,8 +112,8 @@ describe('Visual block mode', function() ]]) -- Test for Visual block insert when virtualedit=all and utf-8 encoding. - execute('set ve=all') - execute('/\t\tline') + feed_command('set ve=all') + feed_command('/\t\tline') feed('07l<C-v>jjIx<ESC>') expect([[ @@ -199,10 +199,10 @@ describe('Visual block mode', function() 98765]]) -- Test cursor position. When virtualedit=block and Visual block mode and $gj. - execute('set ve=block') + feed_command('set ve=block') feed('G2l') feed('2k<C-v>$gj<ESC>') - execute([[let cpos=getpos("'>")]]) + feed_command([[let cpos=getpos("'>")]]) local cpos = nvim.get_var('cpos') local expected = { col = 4, @@ -223,7 +223,7 @@ describe('Visual block mode', function() #define BO_CRSR 0x0004]]) -- Block_insert when replacing spaces in front of the block with tabs. - execute('set ts=8 sts=4 sw=4') + feed_command('set ts=8 sts=4 sw=4') feed('ggf0<C-v>2jI<TAB><ESC>') expect([[ diff --git a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua index b6451eb720..b526d82519 100644 --- a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua +++ b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua @@ -1,8 +1,10 @@ -- Test for writing and reading a file of over 100 Kbyte local helpers = require('test.functional.helpers')(after_each) + local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe('writing and reading a file of over 100 Kbyte', function() setup(clear) @@ -16,17 +18,18 @@ describe('writing and reading a file of over 100 Kbyte', function() This is the end]]) feed('kY3000p2GY3000p') + wait() - execute('w! test.out') - execute('%d') - execute('e! test.out') - execute('yank A') - execute('3003yank A') - execute('6005yank A') - execute('%d') - execute('0put a') - execute('$d') - execute('w!') + command('w! test.out') + command('%d') + command('e! test.out') + command('yank A') + command('3003yank A') + command('6005yank A') + command('%d') + command('0put a') + command('$d') + command('w!') expect([[ This is the start diff --git a/test/functional/legacy/043_magic_settings_spec.lua b/test/functional/legacy/043_magic_settings_spec.lua index f174751de2..a88ccc2b42 100644 --- a/test/functional/legacy/043_magic_settings_spec.lua +++ b/test/functional/legacy/043_magic_settings_spec.lua @@ -1,9 +1,8 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for regexp with various magic settings. local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('regexp with magic settings', function() setup(clear) @@ -21,27 +20,27 @@ describe('regexp with magic settings', function() 9 foobar ]]) - execute('/^1') - execute([[/a*b\{2}c\+/e]]) + feed_command('/^1') + feed_command([[/a*b\{2}c\+/e]]) feed([[x/\Md\*e\{2}f\+/e<cr>]]) feed('x:set nomagic<cr>') - execute([[/g\*h\{2}i\+/e]]) + feed_command([[/g\*h\{2}i\+/e]]) feed([[x/\mj*k\{2}l\+/e<cr>]]) feed([[x/\vm*n{2}o+/e<cr>]]) feed([[x/\V^aa$<cr>]]) feed('x:set magic<cr>') - execute([[/\v(a)(b)\2\1\1/e]]) + feed_command([[/\v(a)(b)\2\1\1/e]]) feed([[x/\V[ab]\(\[xy]\)\1<cr>]]) feed('x:$<cr>') - execute('set undolevels=100') + feed_command('set undolevels=100') feed('dv?bar?<cr>') feed('Yup:<cr>') - execute('?^1?,$yank A') + feed_command('?^1?,$yank A') -- Put @a and clean empty line - execute('%d') - execute('0put a') - execute('$d') + feed_command('%d') + feed_command('0put a') + feed_command('$d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua index c6883e4902..074ee094b4 100644 --- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua +++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -- Runs the test protocol with the given 'regexpengine' setting. In the old test -- suite the test protocol was duplicated in test44 and test99, the only @@ -32,19 +32,19 @@ local function run_test_with_regexpengine(regexpengine) k combinations l ä ö ü ᾱ̆́]]) - execute('set re=' .. regexpengine) + feed_command('set re=' .. regexpengine) -- Lines 1-8. Exercise regexp search with various magic settings. On each -- line the character on which the cursor is expected to land is deleted. feed('/^1<cr>') feed([[/a*b\{2}c\+/e<cr>x]]) feed([[/\Md\*e\{2}f\+/e<cr>x]]) - execute('set nomagic') + feed_command('set nomagic') feed([[/g\*h\{2}i\+/e<cr>x]]) feed([[/\mj*k\{2}l\+/e<cr>x]]) feed([[/\vm*n{2}o+/e<cr>x]]) feed([[/\V^aa$<cr>x]]) - execute('set magic') + feed_command('set magic') feed([[/\v(a)(b)\2\1\1/e<cr>x]]) feed([[/\V[ab]\(\[xy]\)\1<cr>x]]) @@ -57,7 +57,7 @@ local function run_test_with_regexpengine(regexpengine) -- Line b. Find word by change of word class. -- (The "<" character in this test step seemed to confuse our "feed" test -- helper, which is why we've resorted to "execute" here.) - execute([[/ち\<カヨ\>は]]) + feed_command([[/ち\<カヨ\>は]]) feed('x') -- Lines c-i. Test \%u, [\u], and friends. @@ -73,28 +73,28 @@ local function run_test_with_regexpengine(regexpengine) -- Line k. Test substitution with combining characters by executing register -- contents. - execute([[let @w=':%s#comb[i]nations#œ̄ṣ́m̥̄ᾱ̆́#g']]) - execute('@w') + feed_command([[let @w=':%s#comb[i]nations#œ̄ṣ́m̥̄ᾱ̆́#g']]) + feed_command('@w') -- Line l. Ex command ":s/ \?/ /g" should NOT split multi-byte characters -- into bytes (fixed by vim-7.3.192). - execute([[/^l]]) - execute([[s/ \?/ /g]]) + feed_command([[/^l]]) + feed_command([[s/ \?/ /g]]) -- Additional tests. Test matchstr() with multi-byte characters. feed('G') - execute([[put =matchstr(\"אבגד\", \".\", 0, 2)]]) -- ב - execute([[put =matchstr(\"אבגד\", \"..\", 0, 2)]]) -- בג - execute([[put =matchstr(\"אבגד\", \".\", 0, 0)]]) -- א - execute([[put =matchstr(\"אבגד\", \".\", 4, -1)]]) -- ג + feed_command([[put =matchstr(\"אבגד\", \".\", 0, 2)]]) -- ב + feed_command([[put =matchstr(\"אבגד\", \"..\", 0, 2)]]) -- בג + feed_command([[put =matchstr(\"אבגד\", \".\", 0, 0)]]) -- א + feed_command([[put =matchstr(\"אבגד\", \".\", 4, -1)]]) -- ג -- Test that a search with "/e" offset wraps around at the end of the buffer. - execute('new') - execute([[$put =['dog(a', 'cat('] ]]) + feed_command('new') + feed_command([[$put =['dog(a', 'cat('] ]]) feed('/(/e+<cr>') feed('"ayn') - execute('bd!') - execute([[$put ='']]) + feed_command('bd!') + feed_command([[$put ='']]) feed('G"ap') -- Assert buffer contents. diff --git a/test/functional/legacy/045_folding_spec.lua b/test/functional/legacy/045_folding_spec.lua index 5c8292c324..6ca1176aea 100644 --- a/test/functional/legacy/045_folding_spec.lua +++ b/test/functional/legacy/045_folding_spec.lua @@ -2,8 +2,8 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) -local feed, insert, execute, expect_any = - helpers.feed, helpers.insert, helpers.execute, helpers.expect_any +local feed, insert, feed_command, expect_any = + helpers.feed, helpers.insert, helpers.feed_command, helpers.expect_any describe('folding', function() local screen @@ -28,15 +28,15 @@ describe('folding', function() -- Basic test if a fold can be created, opened, moving to the end and -- closed. - execute('1') + feed_command('1') feed('zf2j') - execute('call append("$", "manual " . getline(foldclosed(".")))') + feed_command('call append("$", "manual " . getline(foldclosed(".")))') feed('zo') - execute('call append("$", foldclosed("."))') + feed_command('call append("$", foldclosed("."))') feed(']z') - execute('call append("$", getline("."))') + feed_command('call append("$", getline("."))') feed('zc') - execute('call append("$", getline(foldclosed(".")))') + feed_command('call append("$", getline(foldclosed(".")))') expect_any([[ manual 1 aa @@ -52,15 +52,15 @@ describe('folding', function() ee {{{ }}} ff }}} ]]) - execute('set fdm=marker fdl=1') - execute('2') - execute('call append("$", "line 2 foldlevel=" . foldlevel("."))') + feed_command('set fdm=marker fdl=1') + feed_command('2') + feed_command('call append("$", "line 2 foldlevel=" . foldlevel("."))') feed('[z') - execute('call append("$", foldlevel("."))') + feed_command('call append("$", foldlevel("."))') feed('jo{{ <esc>r{jj') -- writes '{{{' and moves 2 lines bot - execute('call append("$", foldlevel("."))') + feed_command('call append("$", foldlevel("."))') feed('kYpj') - execute('call append("$", foldlevel("."))') + feed_command('call append("$", foldlevel("."))') helpers.wait() screen:expect([[ @@ -80,15 +80,15 @@ describe('folding', function() it("foldmethod=indent", function() screen:try_resize(20, 8) - execute('set fdm=indent sw=2') + feed_command('set fdm=indent sw=2') insert([[ aa bb cc last ]]) - execute('call append("$", "foldlevel line3=" . foldlevel(3))') - execute('call append("$", foldlevel(2))') + feed_command('call append("$", "foldlevel line3=" . foldlevel(3))') + feed_command('call append("$", foldlevel(2))') feed('zR') helpers.wait() @@ -119,23 +119,23 @@ describe('folding', function() a jj b kk last]]) - execute('set fdm=syntax fdl=0') - execute('syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3') - execute('syn region Fd1 start="ee" end="ff" fold contained') - execute('syn region Fd2 start="gg" end="hh" fold contained') - execute('syn region Fd3 start="commentstart" end="commentend" fold contained') + feed_command('set fdm=syntax fdl=0') + feed_command('syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3') + feed_command('syn region Fd1 start="ee" end="ff" fold contained') + feed_command('syn region Fd2 start="gg" end="hh" fold contained') + feed_command('syn region Fd3 start="commentstart" end="commentend" fold contained') feed('Gzk') - execute('call append("$", "folding " . getline("."))') + feed_command('call append("$", "folding " . getline("."))') feed('k') - execute('call append("$", getline("."))') + feed_command('call append("$", getline("."))') feed('jAcommentstart <esc>Acommentend<esc>') - execute('set fdl=1') + feed_command('set fdl=1') feed('3j') - execute('call append("$", getline("."))') - execute('set fdl=0') + feed_command('call append("$", getline("."))') + feed_command('set fdl=0') feed('zO<C-L>j') -- <C-L> redraws screen - execute('call append("$", getline("."))') - execute('set fdl=0') + feed_command('call append("$", getline("."))') + feed_command('set fdl=0') expect_any([[ folding 9 ii 3 cc @@ -158,7 +158,7 @@ describe('folding', function() b kk last ]]) - execute([[ + feed_command([[ fun Flvl() let l = getline(v:lnum) if l =~ "bb$" @@ -173,15 +173,15 @@ describe('folding', function() return "=" endfun ]]) - execute('set fdm=expr fde=Flvl()') - execute('/bb$') - execute('call append("$", "expr " . foldlevel("."))') - execute('/hh$') - execute('call append("$", foldlevel("."))') - execute('/ii$') - execute('call append("$", foldlevel("."))') - execute('/kk$') - execute('call append("$", foldlevel("."))') + feed_command('set fdm=expr fde=Flvl()') + feed_command('/bb$') + feed_command('call append("$", "expr " . foldlevel("."))') + feed_command('/hh$') + feed_command('call append("$", foldlevel("."))') + feed_command('/ii$') + feed_command('call append("$", foldlevel("."))') + feed_command('/kk$') + feed_command('call append("$", foldlevel("."))') expect_any([[ expr 2 @@ -199,11 +199,11 @@ describe('folding', function() Test fdm=indent START line3 line4]]) - execute('set noai nosta ') - execute('set fdm=indent') - execute('1m1') + feed_command('set noai nosta ') + feed_command('set fdm=indent') + feed_command('1m1') feed('2jzc') - execute('m0') + feed_command('m0') feed('zR') expect_any([[ diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index d4d9b7d997..60d29246ff 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -1,11 +1,12 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for ":highlight". local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local eq = helpers.eq local wait = helpers.wait +local exc_exec = helpers.exc_exec if helpers.pending_win32(pending) then return end @@ -16,7 +17,8 @@ describe(':highlight', function() local screen = Screen.new(35, 10) screen:attach() -- Basic test if ":highlight" doesn't crash - execute('set more', 'highlight') + command('set more') + feed(':highlight<CR>') -- FIXME(tarruda): We need to be sure the prompt is displayed before -- continuing, or risk a race condition where some of the following input -- is discarded resulting in test failure @@ -34,65 +36,51 @@ describe(':highlight', function() ]]) feed('q') wait() -- wait until we're back to normal - execute('hi Search') + command('hi Search') -- Test setting colors. -- Test clearing one color and all doesn't generate error or warning - execute('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan') - execute('hi Group2 cterm=NONE') - execute('hi Group3 cterm=bold') - execute('redir! @a') - execute('hi NewGroup') - execute('hi Group2') - execute('hi Group3') - execute('hi clear NewGroup') - execute('hi NewGroup') - execute('hi Group2') - execute('hi Group2 NONE') - execute('hi Group2') - execute('hi clear') - execute('hi Group3') - execute([[hi Crash cterm='asdf]]) - execute('redir END') + command('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan') + command('hi Group2 cterm=NONE') + command('hi Group3 cterm=bold') + command('redir! @a') + command('hi NewGroup') + command('hi Group2') + command('hi Group3') + command('hi clear NewGroup') + command('hi NewGroup') + command('hi Group2') + command('hi Group2 NONE') + command('hi Group2') + command('hi clear') + command('hi Group3') + eq('Vim(highlight):E475: Invalid argument: cterm=\'asdf', + exc_exec([[hi Crash cterm='asdf]])) + command('redir END') -- Filter ctermfg and ctermbg, the numbers depend on the terminal - execute('0put a') - execute([[%s/ctermfg=\d*/ctermfg=2/]]) - execute([[%s/ctermbg=\d*/ctermbg=3/]]) - - -- Filter out possibly translated error message - execute('%s/E475: [^:]*:/E475:/') + command('0put a') + command([[%s/ctermfg=\d*/ctermfg=2/]]) + command([[%s/ctermbg=\d*/ctermbg=3/]]) -- Fix the fileformat - execute('set ff&') - execute('$d') + command('set ff&') + command('$d') -- Assert buffer contents. expect([[ - - + NewGroup xxx cterm=italic ctermfg=2 ctermbg=3 guifg=#00ff00 guibg=Cyan - Group2 xxx cleared - Group3 xxx cterm=bold - - NewGroup xxx cleared - Group2 xxx cleared - - Group2 xxx cleared - - - Group3 xxx cleared - - E475: cterm='asdf]]) + Group3 xxx cleared]]) screen:detach() end) end) diff --git a/test/functional/legacy/054_buffer_local_autocommands_spec.lua b/test/functional/legacy/054_buffer_local_autocommands_spec.lua index 1f7c4dee6a..c8b9dfa98f 100644 --- a/test/functional/legacy/054_buffer_local_autocommands_spec.lua +++ b/test/functional/legacy/054_buffer_local_autocommands_spec.lua @@ -1,33 +1,37 @@ -- Some tests for buffer-local autocommands local helpers = require('test.functional.helpers')(after_each) -local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq -local curbuf_contents = helpers.curbuf_contents + +local clear = helpers.clear +local expect = helpers.expect +local command = helpers.command + +local fname = 'Xtest-functional-legacy-054' describe('BufLeave <buffer>', function() setup(clear) it('is working', function() - execute('w! xx') - execute('au BufLeave <buffer> norm Ibuffer-local autocommand') - execute('au BufLeave <buffer> update') - + command('write! ' .. fname) + command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand') + command('autocmd BufLeave <buffer> update') + -- Here, autocommand for xx shall append a line -- But autocommand shall not apply to buffer named <buffer> - execute('e somefile') + command('edit somefile') -- Here, autocommand shall be auto-deleted - execute('bwipe xx') - + command('bwipeout ' .. fname) + -- Nothing shall be written - execute('e xx') - execute('e somefile') - execute('e xx') + command('edit ' .. fname) + command('edit somefile') + command('edit ' .. fname) - eq('buffer-local autocommand', curbuf_contents()) + expect('buffer-local autocommand') end) teardown(function() - os.remove('xx') + os.remove(fname) end) end) diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index dbe9e1bc7f..e84c415eb0 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, source = helpers.feed, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('list and dictionary types', function() before_each(clear) @@ -20,7 +20,7 @@ describe('list and dictionary types', function() $put =v:exception[:14] endtry]]) expect([[ - + [1, 'as''d', [1, 2, function('strlen')], {'a': 1}] {'a': 1} 1 @@ -38,7 +38,7 @@ describe('list and dictionary types', function() $put =string(l[0:8]) $put =string(l[8:-1])]]) expect([=[ - + [1, 'as''d', [1, 2, function('strlen')], {'a': 1}] ['as''d', [1, 2, function('strlen')], {'a': 1}] [1, 'as''d', [1, 2, function('strlen')]] @@ -84,7 +84,7 @@ describe('list and dictionary types', function() call filter(d, 'v:key =~ ''[ac391]''') $put =string(d)]]) expect([[ - + {'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}asd ['-1', '1', 'b'] ['asd', [1, 2, function('strlen')], {'a': 1}] @@ -134,7 +134,7 @@ describe('list and dictionary types', function() unlet d[-1] $put =string(d)]]) expect([[ - + [1, 'as''d', {'a': 1}] [4] {'1': 99, '3': 33}]]) @@ -142,42 +142,42 @@ describe('list and dictionary types', function() it("removing items out of range: silently skip items that don't exist", function() -- We can not use source() here as we want to ignore all errors. - execute('lang C') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[2:1]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[2:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[2:3]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[2:4]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[2:5]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-1:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-2:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-3:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-4:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-5:2]') - execute('$put =string(l)') - execute('let l = [0, 1, 2, 3]') - execute('unlet l[-6:2]') - execute('$put =string(l)') + feed_command('lang C') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[2:1]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[2:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[2:3]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[2:4]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[2:5]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-1:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-2:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-3:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-4:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-5:2]') + feed_command('$put =string(l)') + feed_command('let l = [0, 1, 2, 3]') + feed_command('unlet l[-6:2]') + feed_command('$put =string(l)') expect([=[ - + [0, 1, 2, 3] [0, 1, 3] [0, 1] @@ -208,7 +208,7 @@ describe('list and dictionary types', function() $put =v:exception[:14] endtry]]) expect([[ - + 2 3 Vim(let):E687: @@ -257,7 +257,7 @@ describe('list and dictionary types', function() " Must be almost empty now. $put =string(d)]]) expect([[ - + 3000 2900 2001 1600 1501 Vim(let):E716: 1500 NONE 2999 @@ -277,7 +277,7 @@ describe('list and dictionary types', function() let Fn = dict.func call Fn('xxx')]]) expect([[ - + len: 3 again: 3 xxx3]]) @@ -324,7 +324,7 @@ describe('list and dictionary types', function() let l3 = deepcopy(l2) $put ='same list: ' . (l3[1] is l3[2])]]) expect([[ - + Vim(let):E698: same list: 1]]) end) @@ -394,7 +394,7 @@ describe('list and dictionary types', function() endfor endfor]=]) expect([[ - + depth is 0 0000-000 ppppppp @@ -499,7 +499,7 @@ describe('list and dictionary types', function() endfor endfor]=]) expect([[ - + depth is 0 0000-000 ppppppp @@ -647,7 +647,7 @@ describe('list and dictionary types', function() $put =string(l)]]) expect([=[ - + Locks and commands or functions: No :unlet after lock on dict: Vim(unlet):E741: @@ -676,7 +676,7 @@ describe('list and dictionary types', function() end) it('locked variables (part 2)', function() - execute( + feed_command( 'let l = [1, 2, 3, 4]', 'lockvar! l', '$put =string(l)', @@ -691,7 +691,7 @@ describe('list and dictionary types', function() 'let l[1:2] = [0, 1]', '$put =string(l)') expect([=[ - + [1, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4] @@ -708,7 +708,7 @@ describe('list and dictionary types', function() $put ='exists g:footest#x:'.exists('g:footest#x') $put ='g:footest#x: '.g:footest#x]]) expect([[ - + locked g:footest#x:-1 exists g:footest#x:0 g:footest#x: 1]]) @@ -749,9 +749,9 @@ describe('list and dictionary types', function() $put ='caught ' . v:exception endtry endfunction]]) - execute('call Test(1, 2, [3, 4], {5: 6})') + feed_command('call Test(1, 2, [3, 4], {5: 6})') expect([=[ - + caught a:000 caught a:000[0] caught a:000[2] @@ -779,7 +779,7 @@ describe('list and dictionary types', function() $put =string(sort(copy(l), 'i')) $put =string(sort(copy(l)))]=]) expect([=[ - + ['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5] [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'] [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'] @@ -805,7 +805,7 @@ describe('list and dictionary types', function() $put =string(split('abc', '\zs')) $put =string(split('abc', '\zs', 1))]]) expect([=[ - + ['aa', 'bb'] ['aa', 'bb'] ['', 'aa', 'bb', ''] @@ -827,7 +827,7 @@ describe('list and dictionary types', function() $put =(l != deepcopy(l)) $put =(d != deepcopy(d))]]) expect([[ - + 1 1 0 @@ -845,7 +845,7 @@ describe('list and dictionary types', function() $put =(l == lcopy) $put =(dict4 == dict4copy)]]) expect([[ - + 1 1]]) end) @@ -856,7 +856,7 @@ describe('list and dictionary types', function() call extend(l, l) $put =string(l)]]) expect([=[ - + [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]]=]) end) @@ -866,7 +866,7 @@ describe('list and dictionary types', function() call extend(d, d) $put =string(d)]]) expect([[ - + {'a': {'b': 'B'}}]]) end) @@ -881,7 +881,7 @@ describe('list and dictionary types', function() endtry $put =string(d)]]) expect([[ - + Vim(call):E737: a {'a': {'b': 'B'}}]]) end) @@ -892,29 +892,29 @@ describe('list and dictionary types', function() let l[:] = [1, 2] $put =string(l)]]) expect([=[ - + [1, 2]]=]) end) it('vim patch 7.3.637', function() - execute('let a = "No error caught"') - execute('try') - execute(' foldopen') - execute('catch') - execute(" let a = matchstr(v:exception,'^[^ ]*')") - execute('endtry') + feed_command('let a = "No error caught"') + feed_command('try') + feed_command(' foldopen') + feed_command('catch') + feed_command(" let a = matchstr(v:exception,'^[^ ]*')") + feed_command('endtry') feed('o<C-R>=a<CR><esc>') - execute('lang C') - execute('redir => a') + feed_command('lang C') + feed_command('redir => a') -- The test failes if this is not in one line. - execute("try|foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry") - execute('redir END') + feed_command("try|foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry") + feed_command('redir END') feed('o<C-R>=a<CR><esc>') expect([[ - + Vim(foldopen):E490: - - + + Error detected while processing : E492: Not an editor command: foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry ]]) diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua index 6984ad0de2..bdc2c9779c 100644 --- a/test/functional/legacy/057_sort_spec.lua +++ b/test/functional/legacy/057_sort_spec.lua @@ -1,9 +1,10 @@ -- Tests for :sort command. local helpers = require('test.functional.helpers')(after_each) -local insert, execute, clear, expect, eq, eval, source = helpers.insert, - helpers.execute, helpers.clear, helpers.expect, helpers.eq, helpers.eval, - helpers.source + +local insert, command, clear, expect, eq, wait = helpers.insert, + helpers.command, helpers.clear, helpers.expect, helpers.eq, helpers.wait +local exc_exec = helpers.exc_exec describe(':sort', function() local text = [[ @@ -26,9 +27,10 @@ describe(':sort', function() it('alphabetical', function() insert(text) - execute('sort') + wait() + command('sort') expect([[ - + 123b a a122 @@ -65,12 +67,13 @@ describe(':sort', function() b321 b321b ]]) - execute('sort n') + wait() + command('sort n') expect([[ abc ab a - + -24 x-22 0 @@ -89,9 +92,10 @@ describe(':sort', function() it('hexadecimal', function() insert(text) - execute('sort x') + wait() + command('sort x') expect([[ - + a ab abc @@ -110,9 +114,10 @@ describe(':sort', function() it('alphabetical, unique', function() insert(text) - execute('sort u') + wait() + command('sort u') expect([[ - + 123b a a122 @@ -130,7 +135,8 @@ describe(':sort', function() it('alphabetical, reverse', function() insert(text) - execute('sort!') + wait() + command('sort!') expect([[ c321d c123d @@ -151,7 +157,8 @@ describe(':sort', function() it('numerical, reverse', function() insert(text) - execute('sort! n') + wait() + command('sort! n') expect([[ b322b b321b @@ -164,7 +171,7 @@ describe(':sort', function() b123 a123 a122 - + a ab abc]]) @@ -172,7 +179,8 @@ describe(':sort', function() it('unique, reverse', function() insert(text) - execute('sort! u') + wait() + command('sort! u') expect([[ c321d c123d @@ -192,12 +200,13 @@ describe(':sort', function() it('octal', function() insert(text) - execute('sort o') + wait() + command('sort o') expect([[ abc ab a - + a122 a123 b123 @@ -213,7 +222,8 @@ describe(':sort', function() it('reverse, hexadecimal', function() insert(text) - execute('sort! x') + wait() + command('sort! x') expect([[ c321d c123d @@ -234,10 +244,11 @@ describe(':sort', function() it('alphabetical, skip first character', function() insert(text) - execute('sort/./') + wait() + command('sort/./') expect([[ a - + a122 a123 b123 @@ -255,11 +266,12 @@ describe(':sort', function() it('alphabetical, skip first 2 characters', function() insert(text) - execute('sort/../') + wait() + command('sort/../') expect([[ ab a - + a321 b321 b321 @@ -276,11 +288,12 @@ describe(':sort', function() it('alphabetical, unique, skip first 2 characters', function() insert(text) - execute('sort/../u') + wait() + command('sort/../u') expect([[ ab a - + a321 b321 b321b @@ -296,12 +309,13 @@ describe(':sort', function() it('numerical, skip first character', function() insert(text) - execute('sort/./n') + wait() + command('sort/./n') expect([[ abc ab a - + a122 a123 b123 @@ -317,9 +331,10 @@ describe(':sort', function() it('alphabetical, sort on first character', function() insert(text) - execute('sort/./r') + wait() + command('sort/./r') expect([[ - + 123b abc ab @@ -338,10 +353,11 @@ describe(':sort', function() it('alphabetical, sort on first 2 characters', function() insert(text) - execute('sort/../r') + wait() + command('sort/../r') expect([[ a - + 123b a123 a122 @@ -359,7 +375,8 @@ describe(':sort', function() it('numerical, sort on first character', function() insert(text) - execute('sort/./rn') + wait() + command('sort/./rn') expect([[ abc ab @@ -380,12 +397,13 @@ describe(':sort', function() it('alphabetical, skip past first digit', function() insert(text) - execute([[sort/\d/]]) + wait() + command([[sort/\d/]]) expect([[ abc ab a - + a321 b321 b321 @@ -401,12 +419,13 @@ describe(':sort', function() it('alphabetical, sort on first digit', function() insert(text) - execute([[sort/\d/r]]) + wait() + command([[sort/\d/r]]) expect([[ abc ab a - + a123 a122 b123 @@ -422,12 +441,13 @@ describe(':sort', function() it('numerical, skip past first digit', function() insert(text) - execute([[sort/\d/n]]) + wait() + command([[sort/\d/n]]) expect([[ abc ab a - + a321 b321 c321d @@ -443,12 +463,13 @@ describe(':sort', function() it('numerical, sort on first digit', function() insert(text) - execute([[sort/\d/rn]]) + wait() + command([[sort/\d/rn]]) expect([[ abc ab a - + a123 a122 b123 @@ -464,12 +485,13 @@ describe(':sort', function() it('alphabetical, skip past first 2 digits', function() insert(text) - execute([[sort/\d\d/]]) + wait() + command([[sort/\d\d/]]) expect([[ abc ab a - + a321 b321 b321 @@ -485,12 +507,13 @@ describe(':sort', function() it('numerical, skip past first 2 digits', function() insert(text) - execute([[sort/\d\d/n]]) + wait() + command([[sort/\d\d/n]]) expect([[ abc ab a - + a321 b321 c321d @@ -506,12 +529,13 @@ describe(':sort', function() it('hexadecimal, skip past first 2 digits', function() insert(text) - execute([[sort/\d\d/x]]) + wait() + command([[sort/\d\d/x]]) expect([[ abc ab a - + a321 b321 b321 @@ -527,12 +551,13 @@ describe(':sort', function() it('alpha, on first 2 digits', function() insert(text) - execute([[sort/\d\d/r]]) + wait() + command([[sort/\d\d/r]]) expect([[ abc ab a - + a123 a122 b123 @@ -548,12 +573,13 @@ describe(':sort', function() it('numeric, on first 2 digits', function() insert(text) - execute([[sort/\d\d/rn]]) + wait() + command([[sort/\d\d/rn]]) expect([[ abc ab a - + a123 a122 b123 @@ -569,12 +595,13 @@ describe(':sort', function() it('hexadecimal, on first 2 digits', function() insert(text) - execute([[sort/\d\d/rx]]) + wait() + command([[sort/\d\d/rx]]) expect([[ abc ab a - + a123 a122 b123 @@ -591,13 +618,7 @@ describe(':sort', function() it('fails with wrong arguments', function() insert(text) -- This should fail with "E474: Invalid argument". - source([[ - try - sort no - catch - let tmpvar = v:exception - endtry]]) - eq('Vim(sort):E474: Invalid argument', eval('tmpvar')) + eq('Vim(sort):E474: Invalid argument', exc_exec('sort no')) expect(text) end) @@ -617,7 +638,8 @@ describe(':sort', function() 0b100010 0b100100 0b100010]]) - execute([[sort b]]) + wait() + command([[sort b]]) expect([[ 0b000000 0b001000 @@ -651,7 +673,8 @@ describe(':sort', function() 0b101010 0b000000 b0b111000]]) - execute([[sort b]]) + wait() + command([[sort b]]) expect([[ 0b000000 a0b001000 @@ -677,7 +700,8 @@ describe(':sort', function() 1.15e-6 -1.1e3 -1.01e3]]) - execute([[sort f]]) + wait() + command([[sort f]]) expect([[ -1.1e3 -1.01e3 diff --git a/test/functional/legacy/059_utf8_spell_checking_spec.lua b/test/functional/legacy/059_utf8_spell_checking_spec.lua index 2fb8f3557d..120e469ab2 100644 --- a/test/functional/legacy/059_utf8_spell_checking_spec.lua +++ b/test/functional/legacy/059_utf8_spell_checking_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect local write_file, call = helpers.write_file, helpers.call if helpers.pending_win32(pending) then return end @@ -15,44 +15,44 @@ end describe("spell checking with 'encoding' set to utf-8", function() setup(function() clear() - execute("syntax off") + feed_command("syntax off") write_latin1('Xtest1.aff',[[ SET ISO8859-1 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ - + FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ - + SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ¿ SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep? - + MIDWORD '- - + KEP = RAR ? BAD ! - + PFX I N 1 PFX I 0 in . - + PFX O Y 1 PFX O 0 out . - + SFX S Y 2 SFX S 0 s [^s] SFX S 0 es s - + SFX N N 3 SFX N 0 en [^n] SFX N 0 nen n SFX N 0 n . - + REP 3 REP g ch REP ch g REP svp s.v.p. - + MAP 9 MAP aàáâãäå MAP eèéêë @@ -79,39 +79,39 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest2.aff', [[ SET ISO8859-1 - + FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ - + PFXPOSTPONE - + MIDWORD '- - + KEP = RAR ? BAD ! - + PFX I N 1 PFX I 0 in . - + PFX O Y 1 PFX O 0 out [a-z] - + SFX S Y 2 SFX S 0 s [^s] SFX S 0 es s - + SFX N N 3 SFX N 0 en [^n] SFX N 0 nen n SFX N 0 n . - + REP 3 REP g ch REP ch g REP svp s.v.p. - + MAP 9 MAP aàáâãäå MAP eèéêë @@ -125,7 +125,7 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest3.aff', [[ SET ISO8859-1 - + COMPOUNDMIN 3 COMPOUNDRULE m* NEEDCOMPOUND x @@ -139,21 +139,21 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest4.aff', [[ SET ISO8859-1 - + FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ - + COMPOUNDRULE m+ COMPOUNDRULE sm*e COMPOUNDRULE sm+ COMPOUNDMIN 3 COMPOUNDWORDMAX 3 COMPOUNDFORBIDFLAG t - + COMPOUNDSYLMAX 5 SYLLABLE aáeéiíoóöõuúüûy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui - + MAP 9 MAP aàáâãäå MAP eèéêë @@ -164,23 +164,23 @@ describe("spell checking with 'encoding' set to utf-8", function() MAP cç MAP yÿý MAP sß - + NEEDAFFIX x - + PFXPOSTPONE - + MIDWORD '- - + SFX q N 1 SFX q 0 -ok . - + SFX a Y 2 SFX a 0 s . SFX a 0 ize/t . - + PFX p N 1 PFX p 0 pre . - + PFX P N 1 PFX P 0 nou . ]]) @@ -196,28 +196,28 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest5.aff', [[ SET ISO8859-1 - + FLAG long - + NEEDAFFIX !! - + COMPOUNDRULE ssmm*ee - + NEEDCOMPOUND xx COMPOUNDPERMITFLAG pp - + SFX 13 Y 1 SFX 13 0 bork . - + SFX a1 Y 1 SFX a1 0 a1 . - + SFX aé Y 1 SFX aé 0 aé . - + PFX zz Y 1 PFX zz 0 pre/pp . - + PFX yy Y 1 PFX yy 0 nou . ]]) @@ -231,26 +231,26 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest6.aff', [[ SET ISO8859-1 - + FLAG caplong - + NEEDAFFIX A! - + COMPOUNDRULE sMm*Ee - + NEEDCOMPOUND Xx - + COMPOUNDPERMITFLAG p - + SFX N3 Y 1 SFX N3 0 bork . - + SFX A1 Y 1 SFX A1 0 a1 . - + SFX Aé Y 1 SFX Aé 0 aé . - + PFX Zz Y 1 PFX Zz 0 pre/p . ]]) @@ -264,29 +264,29 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest7.aff', [[ SET ISO8859-1 - + FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ - + FLAG num - + NEEDAFFIX 9999 - + COMPOUNDRULE 2,77*123 - + NEEDCOMPOUND 1 COMPOUNDPERMITFLAG 432 - + SFX 61003 Y 1 SFX 61003 0 meat . - + SFX 391 Y 1 SFX 391 0 a1 . - + SFX 111 Y 1 SFX 111 0 aé . - + PFX 17 Y 1 PFX 17 0 pre/432 . ]]) @@ -300,7 +300,7 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) write_latin1('Xtest8.aff', [[ SET ISO8859-1 - + NOSPLITSUGS ]]) write_latin1('Xtest8.dic', [[ @@ -319,37 +319,37 @@ describe("spell checking with 'encoding' set to utf-8", function() write_latin1('Xtest-sal.aff', [[ SET ISO8859-1 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ - + FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ - + MIDWORD '- - + KEP = RAR ? BAD ! - + PFX I N 1 PFX I 0 in . - + PFX O Y 1 PFX O 0 out . - + SFX S Y 2 SFX S 0 s [^s] SFX S 0 es s - + SFX N N 3 SFX N 0 en [^n] SFX N 0 nen n SFX N 0 n . - + REP 3 REP g ch REP ch g REP svp s.v.p. - + MAP 9 MAP aàáâãäå MAP eèéêë @@ -360,7 +360,7 @@ describe("spell checking with 'encoding' set to utf-8", function() MAP cç MAP yÿý MAP sß - + SAL AH(AEIOUY)-^ *H SAL AR(AEIOUY)-^ *R SAL A(HR)^ * @@ -550,60 +550,60 @@ describe("spell checking with 'encoding' set to utf-8", function() 1good: wrong OK puts. Test the end bad: inputs comment ok Ok. test déôl end the badend - + test2: elequint test elekwint test elekwent asdf ]]) test_one(1, 1) - execute([[$put =soundfold('goobledygoook')]]) - execute([[$put =soundfold('kóopërÿnôven')]]) - execute([[$put =soundfold('oeverloos gezwets edale')]]) + feed_command([[$put =soundfold('goobledygoook')]]) + feed_command([[$put =soundfold('kóopërÿnôven')]]) + feed_command([[$put =soundfold('oeverloos gezwets edale')]]) -- And now with SAL instead of SOFO items; test automatic reloading. os.execute('cp -f Xtest-sal.aff Xtest.aff') - execute('mkspell! Xtest Xtest') - execute([[$put =soundfold('goobledygoook')]]) - execute([[$put =soundfold('kóopërÿnôven')]]) - execute([[$put =soundfold('oeverloos gezwets edale')]]) + feed_command('mkspell! Xtest Xtest') + feed_command([[$put =soundfold('goobledygoook')]]) + feed_command([[$put =soundfold('kóopërÿnôven')]]) + feed_command([[$put =soundfold('oeverloos gezwets edale')]]) -- Also use an addition file. - execute('mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add') - execute('set spellfile=Xtest.utf-8.add') - execute('/^test2:') + feed_command('mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add') + feed_command('set spellfile=Xtest.utf-8.add') + feed_command('/^test2:') feed(']s') - execute('let [str, a] = spellbadword()') - execute('$put =str') - execute('set spl=Xtest_us.utf-8.spl') - execute('/^test2:') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') + feed_command('set spl=Xtest_us.utf-8.spl') + feed_command('/^test2:') feed(']smm') - execute('let [str, a] = spellbadword()') - execute('$put =str') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') feed('`m]s') - execute('let [str, a] = spellbadword()') - execute('$put =str') - execute('set spl=Xtest_gb.utf-8.spl') - execute('/^test2:') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') + feed_command('set spl=Xtest_gb.utf-8.spl') + feed_command('/^test2:') feed(']smm') - execute('let [str, a] = spellbadword()') - execute('$put =str') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') feed('`m]s') - execute('let [str, a] = spellbadword()') - execute('$put =str') - execute('set spl=Xtest_nz.utf-8.spl') - execute('/^test2:') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') + feed_command('set spl=Xtest_nz.utf-8.spl') + feed_command('/^test2:') feed(']smm') - execute('let [str, a] = spellbadword()') - execute('$put =str') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') feed('`m]s') - execute('let [str, a] = spellbadword()') - execute('$put =str') - execute('set spl=Xtest_ca.utf-8.spl') - execute('/^test2:') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') + feed_command('set spl=Xtest_ca.utf-8.spl') + feed_command('/^test2:') feed(']smm') - execute('let [str, a] = spellbadword()') - execute('$put =str') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') feed('`m]s') - execute('let [str, a] = spellbadword()') - execute('$put =str') - execute('1,/^test 1-1/-1d') + feed_command('let [str, a] = spellbadword()') + feed_command('$put =str') + feed_command('1,/^test 1-1/-1d') expect([[ test 1-1 # file: Xtest.utf-8.spl @@ -667,7 +667,7 @@ describe("spell checking with 'encoding' set to utf-8", function() ]]) -- Postponed prefixes. test_one(2, 1) - execute('1,/^test 2-1/-1d') + feed_command('1,/^test 2-1/-1d') expect([=[ test 2-1 # file: Xtest.utf-8.spl @@ -711,13 +711,13 @@ describe("spell checking with 'encoding' set to utf-8", function() it('part 3-3', function() insert([[ Test rules for compounding. - + 3good: foo mï foobar foofoobar barfoo barbarfoo bad: bar la foomï barmï mïfoo mïbar mïmï lala mïla lamï foola labar badend ]]) test_one(3, 3) - execute('1,/^test 3-3/-1d') + feed_command('1,/^test 3-3/-1d') expect([=[ test 3-3 # file: Xtest.utf-8.spl @@ -755,7 +755,7 @@ describe("spell checking with 'encoding' set to utf-8", function() it('part 4-4', function() insert([[ Tests for compounding. - + 4good: word util bork prebork start end wordutil wordutils pro-ok bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork tomato tomatotomato startend startword startwordword startwordend @@ -770,7 +770,7 @@ describe("spell checking with 'encoding' set to utf-8", function() badend ]]) test_one(4, 4) - execute('1,/^test 4-4/-1d') + feed_command('1,/^test 4-4/-1d') expect([=[ test 4-4 # file: Xtest.utf-8.spl @@ -823,7 +823,7 @@ describe("spell checking with 'encoding' set to utf-8", function() it('part 5-5', function() insert([[ Test affix flags with two characters - + 5good: fooa1 fooaé bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart @@ -831,7 +831,7 @@ describe("spell checking with 'encoding' set to utf-8", function() badend ]]) test_one(5, 5) - execute('1,/^test 5-5/-1d') + feed_command('1,/^test 5-5/-1d') expect([=[ test 5-5 # file: Xtest.utf-8.spl @@ -878,7 +878,7 @@ describe("spell checking with 'encoding' set to utf-8", function() badend ]]) test_one(6, 6) - execute('1,/^test 6-6/-1d') + feed_command('1,/^test 6-6/-1d') expect([=[ test 6-6 # file: Xtest.utf-8.spl @@ -924,7 +924,7 @@ describe("spell checking with 'encoding' set to utf-8", function() -- Compound words. test_one(7, 7) -- Assert buffer contents. - execute('1,/^test 7-7/-1d') + feed_command('1,/^test 7-7/-1d') expect([=[ test 7-7 # file: Xtest.utf-8.spl @@ -968,7 +968,7 @@ describe("spell checking with 'encoding' set to utf-8", function() -- NOSPLITSUGS test_one(8, 8) -- Assert buffer contents. - execute('1,/^test 8-8/-1d') + feed_command('1,/^test 8-8/-1d') expect([=[ test 8-8 # file: Xtest.utf-8.spl @@ -992,7 +992,7 @@ describe("spell checking with 'encoding' set to utf-8", function() -- NOSPLITSUGS test_one(9, 9) -- Assert buffer contents. - execute('1,/^test 9-9/-1d') + feed_command('1,/^test 9-9/-1d') expect([=[ test 9-9 # file: Xtest.utf-8.spl diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua index aeb2001d11..1a8ef067d0 100644 --- a/test/functional/legacy/061_undo_tree_spec.lua +++ b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,8 +1,8 @@ -- Tests for undo tree and :earlier and :later. local helpers = require('test.functional.helpers')(after_each) +local feed_command = helpers.feed_command local write_file = helpers.write_file -local execute = helpers.execute local command = helpers.command local source = helpers.source local expect = helpers.expect @@ -44,7 +44,7 @@ describe('undo tree:', function() -- function to allow multiple attempts. local function test_earlier_later() clear() - execute('e Xtest') + feed_command('e Xtest') -- Assert that no undo history is present. eq({}, eval('undotree().entries')) -- Delete three characters and undo. @@ -88,13 +88,13 @@ describe('undo tree:', function() feed('Ab<esc>') feed('Ac<esc>') expect_line('123456abc') - execute('earlier 1s') + feed_command('earlier 1s') expect_line('123456') - execute('earlier 3s') + feed_command('earlier 3s') expect_line('123456789') - execute('later 1s') + feed_command('later 1s') expect_line('123456') - execute('later 1h') + feed_command('later 1h') expect_line('123456abc') end @@ -103,28 +103,28 @@ describe('undo tree:', function() it('file-write specifications', function() feed('ione one one<esc>') - execute('w Xtest') + feed_command('w Xtest') feed('otwo<esc>') feed('otwo<esc>') - execute('w') + feed_command('w') feed('othree<esc>') - execute('earlier 1f') + feed_command('earlier 1f') expect([[ one one one two two]]) - execute('earlier 1f') + feed_command('earlier 1f') expect('one one one') - execute('earlier 1f') + feed_command('earlier 1f') expect_empty_buffer() - execute('later 1f') + feed_command('later 1f') expect('one one one') - execute('later 1f') + feed_command('later 1f') expect([[ one one one two two]]) - execute('later 1f') + feed_command('later 1f') expect([[ one one one two @@ -193,20 +193,20 @@ describe('undo tree:', function() feed('ob<esc>') feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]]) expect([[ - + a b 12034]]) feed('uu') expect([[ - + a b 1]]) feed('oc<esc>') feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]]) expect([[ - + a b 1 @@ -214,16 +214,16 @@ describe('undo tree:', function() 12034]]) feed('u') expect([[ - + a b 1 c 12]]) feed('od<esc>') - execute('so! Xtest.source') + feed_command('so! Xtest.source') expect([[ - + a b 1 @@ -233,7 +233,7 @@ describe('undo tree:', function() 12123]]) feed('u') expect([[ - + a b 1 @@ -246,7 +246,7 @@ describe('undo tree:', function() -- interactive use (even in Vim; see ":help :undojoin"): feed(normal_commands) expect([[ - + a b 1 @@ -256,7 +256,7 @@ describe('undo tree:', function() 12123]]) feed('u') expect([[ - + a b 1 diff --git a/test/functional/legacy/062_tab_pages_spec.lua b/test/functional/legacy/062_tab_pages_spec.lua index 71a0a77354..eae0a8d51a 100644 --- a/test/functional/legacy/062_tab_pages_spec.lua +++ b/test/functional/legacy/062_tab_pages_spec.lua @@ -1,17 +1,18 @@ -- Tests for tab pages local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source, clear, execute, expect, eval, eq = +local feed, insert, source, clear, command, expect, eval, eq = helpers.feed, helpers.insert, helpers.source, helpers.clear, - helpers.execute, helpers.expect, helpers.eval, helpers.eq + helpers.command, helpers.expect, helpers.eval, helpers.eq +local exc_exec = helpers.exc_exec describe('tab pages', function() before_each(clear) it('can be opened and closed', function() - execute('tabnew') + command('tabnew') eq(2, eval('tabpagenr()')) - execute('quit') + command('quit') eq(1, eval('tabpagenr()')) end) @@ -25,7 +26,7 @@ describe('tab pages', function() tabrewind ]]) eq('this is tab page 1', eval("getline('$')")) - execute('tablast') + command('tablast') eq('this is tab page 4', eval("getline('$')")) end) @@ -44,7 +45,7 @@ describe('tab pages', function() eq(100, eval('gettabvar(2, "val_num")')) eq('SetTabVar test', eval('gettabvar(2, "val_str")')) eq({'red', 'blue', 'green'}, eval('gettabvar(2, "val_list")')) - execute('tabnext 2') + command('tabnext 2') eq(100, eval('t:val_num')) eq('SetTabVar test', eval('t:val_str')) eq({'red', 'blue', 'green'}, eval('t:val_list')) @@ -52,8 +53,8 @@ describe('tab pages', function() it('work together with the drop feature and loaded buffers', function() -- Test for ":tab drop exist-file" to keep current window. - execute('sp test1') - execute('tab drop test1') + command('sp test1') + command('tab drop test1') eq(1, eval('tabpagenr("$")')) eq(2, eval('winnr("$")')) eq(1, eval('winnr()')) @@ -61,8 +62,8 @@ describe('tab pages', function() it('work together with the drop feature and new files', function() -- Test for ":tab drop new-file" to keep current window of tabpage 1. - execute('split') - execute('tab drop newfile') + command('split') + command('tab drop newfile') eq(2, eval('tabpagenr("$")')) eq(2, eval('tabpagewinnr(1, "$")')) eq(1, eval('tabpagewinnr(1)')) @@ -71,53 +72,49 @@ describe('tab pages', function() it('work together with the drop feature and multi loaded buffers', function() -- Test for ":tab drop multi-opend-file" to keep current tabpage and -- window. - execute('new test1') - execute('tabnew') - execute('new test1') - execute('tab drop test1') + command('new test1') + command('tabnew') + command('new test1') + command('tab drop test1') eq(2, eval('tabpagenr()')) eq(2, eval('tabpagewinnr(2, "$")')) eq(1, eval('tabpagewinnr(2)')) end) it('can be navigated with :tabmove', function() - execute('lang C') - execute('for i in range(9) | tabnew | endfor') + command('lang C') + command('for i in range(9) | tabnew | endfor') feed('1gt') eq(1, eval('tabpagenr()')) - execute('tabmove 5') + command('tabmove 5') eq(5, eval('tabpagenr()')) - execute('.tabmove') + command('.tabmove') eq(5, eval('tabpagenr()')) - execute('tabmove -') + command('tabmove -') eq(4, eval('tabpagenr()')) - execute('tabmove +') + command('tabmove +') eq(5, eval('tabpagenr()')) - execute('tabmove -2') + command('tabmove -2') eq(3, eval('tabpagenr()')) - execute('tabmove +4') + command('tabmove +4') eq(7, eval('tabpagenr()')) - execute('tabmove') + command('tabmove') eq(10, eval('tabpagenr()')) - execute('0tabmove') + command('0tabmove') eq(1, eval('tabpagenr()')) - execute('$tabmove') + command('$tabmove') eq(10, eval('tabpagenr()')) - execute('tabmove 0') + command('tabmove 0') eq(1, eval('tabpagenr()')) - execute('tabmove $') + command('tabmove $') eq(10, eval('tabpagenr()')) - execute('3tabmove') + command('3tabmove') eq(4, eval('tabpagenr()')) - execute('7tabmove 5') + command('7tabmove 5') eq(5, eval('tabpagenr()')) - execute('let a="No error caught."') - execute('try') - execute('tabmove foo') - execute('catch E474') - execute('let a="E474 caught."') - execute('endtry') - eq('E474 caught.', eval('a')) + command('let a="No error caught."') + eq('Vim(tabmove):E474: Invalid argument: tabmove foo', + exc_exec('tabmove foo')) end) it('can trigger certain autocommands', function() diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua index 5818bb6b3a..a505a2db30 100644 --- a/test/functional/legacy/063_match_and_matchadd_spec.lua +++ b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -2,9 +2,11 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local feed, insert = helpers.feed, helpers.insert -local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute + +local eval, clear, command = helpers.eval, helpers.clear, helpers.command local eq, neq = helpers.eq, helpers.neq +local insert = helpers.insert +local redir_exec = helpers.redir_exec describe('063: Test for ":match", "matchadd()" and related functions', function() setup(clear) @@ -15,12 +17,12 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( -- Check that "matcharg()" returns the correct group and pattern if a match -- is defined. - execute("highlight MyGroup1 term=bold ctermbg=red guibg=red") - execute("highlight MyGroup2 term=italic ctermbg=green guibg=green") - execute("highlight MyGroup3 term=underline ctermbg=blue guibg=blue") - execute("match MyGroup1 /TODO/") - execute("2match MyGroup2 /FIXME/") - execute("3match MyGroup3 /XXX/") + command("highlight MyGroup1 term=bold ctermbg=red guibg=red") + command("highlight MyGroup2 term=italic ctermbg=green guibg=green") + command("highlight MyGroup3 term=underline ctermbg=blue guibg=blue") + command("match MyGroup1 /TODO/") + command("2match MyGroup2 /FIXME/") + command("3match MyGroup3 /XXX/") eq({'MyGroup1', 'TODO'}, eval('matcharg(1)')) eq({'MyGroup2', 'FIXME'}, eval('matcharg(2)')) eq({'MyGroup3', 'XXX'}, eval('matcharg(3)')) @@ -31,18 +33,18 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( eq({}, eval('matcharg(4)')) -- Check that "matcharg()" returns ['', ''] if a match is not defined. - execute("match") - execute("2match") - execute("3match") + command("match") + command("2match") + command("3match") eq({'', ''}, eval('matcharg(1)')) eq({'', ''}, eval('matcharg(2)')) eq({'', ''}, eval('matcharg(3)')) -- Check that "matchadd()" and "getmatches()" agree on added matches and -- that default values apply. - execute("let m1 = matchadd('MyGroup1', 'TODO')") - execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") + command("let m1 = matchadd('MyGroup1', 'TODO')") + command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") + command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 4}, {group = 'MyGroup2', pattern = 'FIXME', priority = 42, id = 5}, {group = 'MyGroup3', pattern = 'XXX', priority = 60, id = 17}}, @@ -50,56 +52,57 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( -- Check that "matchdelete()" deletes the matches defined in the previous -- test correctly. - execute("call matchdelete(m1)") - execute("call matchdelete(m2)") - execute("call matchdelete(m3)") + command("call matchdelete(m1)") + command("call matchdelete(m2)") + command("call matchdelete(m3)") eq({}, eval('getmatches()')) --- Check that "matchdelete()" returns 0 if successful and otherwise -1. - execute("let m = matchadd('MyGroup1', 'TODO')") + command("let m = matchadd('MyGroup1', 'TODO')") eq(0, eval('matchdelete(m)')) -- matchdelete throws error and returns -1 on failure neq(true, pcall(function() eval('matchdelete(42)') end)) - execute("let r2 = matchdelete(42)") + eq('\nE803: ID not found: 42', + redir_exec("let r2 = matchdelete(42)")) eq(-1, eval('r2')) -- Check that "clearmatches()" clears all matches defined by ":match" and -- "matchadd()". - execute("let m1 = matchadd('MyGroup1', 'TODO')") - execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") - execute("match MyGroup1 /COFFEE/") - execute("2match MyGroup2 /HUMPPA/") - execute("3match MyGroup3 /VIM/") - execute("call clearmatches()") + command("let m1 = matchadd('MyGroup1', 'TODO')") + command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") + command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") + command("match MyGroup1 /COFFEE/") + command("2match MyGroup2 /HUMPPA/") + command("3match MyGroup3 /VIM/") + command("call clearmatches()") eq({}, eval('getmatches()')) -- Check that "setmatches()" restores a list of matches saved by -- "getmatches()" without changes. (Matches with equal priority must also -- remain in the same order.) - execute("let m1 = matchadd('MyGroup1', 'TODO')") - execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") - execute("match MyGroup1 /COFFEE/") - execute("2match MyGroup2 /HUMPPA/") - execute("3match MyGroup3 /VIM/") - execute("let ml = getmatches()") + command("let m1 = matchadd('MyGroup1', 'TODO')") + command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") + command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") + command("match MyGroup1 /COFFEE/") + command("2match MyGroup2 /HUMPPA/") + command("3match MyGroup3 /VIM/") + command("let ml = getmatches()") local ml = eval("ml") - execute("call clearmatches()") - execute("call setmatches(ml)") + command("call clearmatches()") + command("call setmatches(ml)") eq(ml, eval('getmatches()')) -- Check that "setmatches()" can correctly restore the matches from matchaddpos() - execute("call clearmatches()") - execute("call setmatches(ml)") + command("call clearmatches()") + command("call setmatches(ml)") eq(ml, eval('getmatches()')) -- Check that "setmatches()" will not add two matches with the same ID. The -- expected behaviour (for now) is to add the first match but not the -- second and to return -1. - execute("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])") - feed("<cr>") + eq('\nE801: ID already taken: 1', + redir_exec("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")) eq(-1, eval("r1")) eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 1}}, eval('getmatches()')) @@ -108,18 +111,17 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( -- return values.) eq(0,eval("setmatches([])")) eq(0,eval("setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])")) - execute("call clearmatches()") - execute("let rf1 = setmatches(0)") + command("call clearmatches()") + eq('\nE714: List required', redir_exec("let rf1 = setmatches(0)")) eq(-1, eval('rf1')) - execute("let rf2 = setmatches([0])") + eq('\nE474: Invalid argument', redir_exec("let rf2 = setmatches([0])")) eq(-1, eval('rf2')) - execute("let rf3 = setmatches([{'wrong key': 'wrong value'}])") - feed("<cr>") + eq('\nE474: Invalid argument', redir_exec("let rf3 = setmatches([{'wrong key': 'wrong value'}])")) eq(-1, eval('rf3')) -- Check that "matchaddpos()" positions matches correctly insert('abcdefghijklmnopq') - execute("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)") + command("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)") screen:expect([[ abcd{1:e}fg{1:hij}klmnop^q | ~ | @@ -128,9 +130,9 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( | ]], {[1] = {background = Screen.colors.Red}}, {{bold = true, foreground = Screen.colors.Blue}}) - execute("call clearmatches()") - execute("call setline(1, 'abcdΣabcdef')") - execute("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])") + command("call clearmatches()") + command("call setline(1, 'abcdΣabcdef')") + command("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])") screen:expect([[ abc{1:dΣ}ab{1:cd}e^f | ~ | diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua index d12ea502f3..ad1b004085 100644 --- a/test/functional/legacy/065_float_and_logic_operators_spec.lua +++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local insert, source = helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, expect = helpers.clear, helpers.expect describe('floating point and logical operators', function() setup(clear) @@ -44,14 +44,7 @@ describe('floating point and logical operators', function() $put ='abs' $put =printf('%d', abs(1456)) $put =printf('%d', abs(-4)) - ]]) - - -- The test will throw an error if this line is included in a source() - -- call. The vim expression throws a exception "E745: Using a List as a - -- Number" which is fatal in a source() call but not in a execute() call. - execute([[$put =printf('%d', abs([1, 2, 3]))]]) - - source([[ + silent! $put =printf('%d', abs([1, 2, 3])) $put =printf('%g', abs(14.56)) $put =printf('%g', abs(-54.32)) $put ='ceil' @@ -100,12 +93,9 @@ describe('floating point and logical operators', function() $put =and(invert(127), 65535) $put =and(invert(16), 65535) $put =and(invert(128), 65535) + silent! $put =invert(1.0) ]]) - -- This line can not be included in a source() call. It throws a "E805: - -- Using a Float as a Number". Also compare comment above. - execute('$put =invert(1.0)') - -- Assert buffer contents. expect([=[ Results of test65: diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua index 72fa7d881b..7c4984362f 100644 --- a/test/functional/legacy/066_visual_block_tab_spec.lua +++ b/test/functional/legacy/066_visual_block_tab_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('visual block shift and tab characters', function() setup(clear) @@ -24,23 +24,23 @@ describe('visual block shift and tab characters', function() feed('gg') feed([[fe<C-v>4jR<esc>ugvr1:'<lt>,'>yank A<cr>]]) - execute('/^abcdefgh') + feed_command('/^abcdefgh') feed('<C-v>4jI <esc>j<lt><lt>11|D') feed('j7|a <esc>') feed('j7|a <esc>') feed('j7|a <esc>4k13|<C-v>4j<lt>') - execute('$-5,$yank A') - execute([[$-4,$s/\s\+//g]]) + feed_command('$-5,$yank A') + feed_command([[$-4,$s/\s\+//g]]) feed('<C-v>4kI <esc>j<lt><lt>') feed('j7|a <esc>') feed('j7|a <esc>') feed('j7|a <esc>4k13|<C-v>4j3<lt>') - execute('$-4,$yank A') + feed_command('$-4,$yank A') -- Put @a and clean empty lines - execute('%d') - execute('0put a') - execute('$d') + feed_command('%d') + feed_command('0put a') + feed_command('$d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua index 8f6b881ed8..4a77bf838a 100644 --- a/test/functional/legacy/067_augroup_exists_spec.lua +++ b/test/functional/legacy/067_augroup_exists_spec.lua @@ -3,32 +3,34 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect describe('augroup when calling exists()', function() setup(clear) it('is working', function() - execute('let results=[]') - execute('call add(results, "##BufEnter: " . exists("##BufEnter"))') - execute('call add(results, "#BufEnter: " . exists("#BufEnter"))') - execute('au BufEnter * let g:entered=1') - execute('call add(results, "#BufEnter: " . exists("#BufEnter"))') - execute('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))') - execute('augroup auexists', 'au BufEnter * let g:entered=1', 'augroup END') - execute('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))') - execute('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))') - execute('au BufEnter *.test let g:entered=1') - execute('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))') - execute('edit testfile.test') - execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') - execute('au BufEnter <buffer> let g:entered=1') - execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') - execute('edit testfile2.test') - execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') - execute('bf') - execute('call append(0, results)') - execute('$d') + command('let results=[]') + command('call add(results, "##BufEnter: " . exists("##BufEnter"))') + command('call add(results, "#BufEnter: " . exists("#BufEnter"))') + command('au BufEnter * let g:entered=1') + command('call add(results, "#BufEnter: " . exists("#BufEnter"))') + command('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))') + command('augroup auexists') + command('au BufEnter * let g:entered=1') + command('augroup END') + command('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))') + command('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))') + command('au BufEnter *.test let g:entered=1') + command('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))') + command('edit testfile.test') + command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') + command('au BufEnter <buffer> let g:entered=1') + command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') + command('edit testfile2.test') + command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))') + command('bf') + command('call append(0, results)') + command('$d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/068_text_formatting_spec.lua b/test/functional/legacy/068_text_formatting_spec.lua index e232e5073d..772dbc14cf 100644 --- a/test/functional/legacy/068_text_formatting_spec.lua +++ b/test/functional/legacy/068_text_formatting_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed = helpers.feed local clear = helpers.clear local insert = helpers.insert -local execute = helpers.execute +local feed_command = helpers.feed_command local expect = helpers.expect describe('text formatting', function() @@ -15,195 +15,195 @@ describe('text formatting', function() -- mode so it has to be escaped with <C-V>. insert([[ Results of test68: - - + + { - - + + } - - + + { a b - + a } - - + + { a } - - + + { a b #a b } - - + + { 1 a # 1 a } - - + + { - + x a b c - + } - - + + { # 1 a b } - - + + { # x # a b } - - + + { 1aa 2bb } - - + + /* abc def ghi jkl * mno pqr stu */ - - + + # 1 xxxxx ]]) - execute('/^{/+1') - execute('set noai tw=2 fo=t') + feed_command('/^{/+1') + feed_command('set noai tw=2 fo=t') feed('gRa b<esc>') - execute('/^{/+1') - execute('set ai tw=2 fo=tw') + feed_command('/^{/+1') + feed_command('set ai tw=2 fo=tw') feed('gqgqjjllab<esc>') - execute('/^{/+1') - execute('set tw=3 fo=t') + feed_command('/^{/+1') + feed_command('set tw=3 fo=t') feed('gqgqo<cr>') feed('a <C-V><C-A><esc><esc>') - execute('/^{/+1') - execute('set tw=2 fo=tcq1 comments=:#') + feed_command('/^{/+1') + feed_command('set tw=2 fo=tcq1 comments=:#') feed('gqgqjgqgqo<cr>') feed('a b<cr>') feed('#a b<esc>') - execute('/^{/+1') - execute('set tw=5 fo=tcn comments=:#') + feed_command('/^{/+1') + feed_command('set tw=5 fo=tcn comments=:#') feed('A b<esc>jA b<esc>') - execute('/^{/+3') - execute('set tw=5 fo=t2a si') + feed_command('/^{/+3') + feed_command('set tw=5 fo=t2a si') feed('i <esc>A_<esc>') - execute('/^{/+1') - execute('set tw=5 fo=qn comments=:#') + feed_command('/^{/+1') + feed_command('set tw=5 fo=qn comments=:#') feed('gwap<cr>') - execute('/^{/+1') - execute('set tw=5 fo=q2 comments=:#') + feed_command('/^{/+1') + feed_command('set tw=5 fo=q2 comments=:#') feed('gwap<cr>') - execute('/^{/+2') - execute('set tw& fo=a') + feed_command('/^{/+2') + feed_command('set tw& fo=a') feed('I^^<esc><esc>') - execute('/mno pqr/') - execute('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/') + feed_command('/mno pqr/') + feed_command('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/') feed('A vwx yz<esc>') - execute('/^#/') - execute('setl tw=12 fo=tqnc comments=:#') + feed_command('/^#/') + feed_command('setl tw=12 fo=tqnc comments=:#') feed('A foobar<esc>') -- Assert buffer contents. expect([[ Results of test68: - - + + { a b } - - + + { a b - + a b } - - + + { a - + a } - - + + { a b #a b - + a b #a b } - - + + { 1 a b # 1 a # b } - - + + { - + x a b_ c - + } - - + + { # 1 a # b } - - + + { # x a # b } - - + + { 1aa ^^2bb } - - + + /* abc def ghi jkl * mno pqr stu * vwx yz */ - - + + # 1 xxxxx # foobar ]]) diff --git a/test/functional/legacy/069_multibyte_formatting_spec.lua b/test/functional/legacy/069_multibyte_formatting_spec.lua index 6edcd8b7f2..38ca25d57a 100644 --- a/test/functional/legacy/069_multibyte_formatting_spec.lua +++ b/test/functional/legacy/069_multibyte_formatting_spec.lua @@ -4,8 +4,8 @@ -- Also test byteidx() and byteidxcomp() local helpers = require('test.functional.helpers')(after_each) -local feed, insert, eq, eval, clear, execute, expect = helpers.feed, - helpers.insert, helpers.eq, helpers.eval, helpers.clear, helpers.execute, +local feed, insert, eq, eval, clear, feed_command, expect = helpers.feed, + helpers.insert, helpers.eq, helpers.eval, helpers.clear, helpers.feed_command, helpers.expect describe('multibyte text', function() @@ -17,8 +17,8 @@ describe('multibyte text', function() XYZ abc XYZ }]]) - execute('/^{/+1') - execute('set tw=2 fo=t') + feed_command('/^{/+1') + feed_command('set tw=2 fo=t') feed('gqgqjgqgqo<cr>') feed('XYZ<cr>') feed('abc XYZ<esc><esc>') @@ -43,8 +43,8 @@ describe('multibyte text', function() XY X Y }]]) - execute('/^{/+1') - execute('set tw=1 fo=tm') + feed_command('/^{/+1') + feed_command('set tw=1 fo=tm') feed('gqgqjgqgqjgqgqjgqgqjgqgqo<cr>') feed('X<cr>') feed('Xa<cr>') @@ -89,8 +89,8 @@ describe('multibyte text', function() abX c abXY }]]) - execute('/^{/+1') - execute('set tw=2 fo=tm') + feed_command('/^{/+1') + feed_command('set tw=2 fo=tm') feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo<cr>') feed('X<cr>') feed('Xa<cr>') @@ -156,8 +156,8 @@ describe('multibyte text', function() X Xa }]]) - execute('/^{/+1') - execute('set ai tw=2 fo=tm') + feed_command('/^{/+1') + feed_command('set ai tw=2 fo=tm') feed('gqgqjgqgqo<cr>') feed('X<cr>') feed('Xa<esc>') @@ -179,8 +179,8 @@ describe('multibyte text', function() X Xa }]]) - execute('/^{/+1') - execute('set noai tw=2 fo=tm') + feed_command('/^{/+1') + feed_command('set noai tw=2 fo=tm') feed('gqgqjgqgqo<cr>') -- Literal spaces will be trimmed from the by feed(). feed('<space><space>X<cr>') @@ -211,8 +211,8 @@ describe('multibyte text', function() XXa XXY }]]) - execute('/^{/+1') - execute('set tw=2 fo=cqm comments=n:X') + feed_command('/^{/+1') + feed_command('set tw=2 fo=cqm comments=n:X') feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo<cr>') feed('X<cr>') feed('Xa<cr>') @@ -261,8 +261,8 @@ describe('multibyte text', function() { }]]) - execute('/^{/+1') - execute('set tw=2 fo=tm') + feed_command('/^{/+1') + feed_command('set tw=2 fo=tm') feed('RXa<esc>') expect([[ { @@ -276,8 +276,8 @@ describe('multibyte text', function() { ‘ two three ’ four }]]) - execute('/^{/+1') - execute('set mps+=‘:’') + feed_command('/^{/+1') + feed_command('set mps+=‘:’') feed('d%<cr>') expect([[ { @@ -299,8 +299,8 @@ describe('multibyte text', function() insert([[ á x]]) - execute('set whichwrap+=h') - execute('/^x') + feed_command('set whichwrap+=h') + feed_command('/^x') feed('dh') expect([[ áx]]) @@ -308,9 +308,9 @@ describe('multibyte text', function() it('can be queried with byteidx() and byteidxcomp()', function() -- One char of two bytes. - execute("let a = '.é.'") + feed_command("let a = '.é.'") -- Normal e with composing char. - execute("let b = '.é.'") + feed_command("let b = '.é.'") eq(0, eval('byteidx(a, 0)')) eq(1, eval('byteidx(a, 1)')) eq(3, eval('byteidx(a, 2)')) diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua index 4682a82008..b4927e779e 100644 --- a/test/functional/legacy/072_undo_file_spec.lua +++ b/test/functional/legacy/072_undo_file_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('72', function() setup(clear) @@ -13,34 +13,34 @@ describe('72', function() insert([[ 1111 ----- 2222 ----- - + 123456789]]) -- Test 'undofile': first a simple one-line change. - execute('set visualbell') - execute('set ul=100 undofile undodir=. nomore') - execute('e! Xtestfile') + feed_command('set visualbell') + feed_command('set ul=100 undofile undodir=. nomore') + feed_command('e! Xtestfile') feed('ggdGithis is one line<esc>:set ul=100<cr>') - execute('s/one/ONE/') - execute('set ul=100') - execute('w') - execute('bwipe!') - execute('e Xtestfile') + feed_command('s/one/ONE/') + feed_command('set ul=100') + feed_command('w') + feed_command('bwipe!') + feed_command('e Xtestfile') feed('u:.w! test.out<cr>') -- Test 'undofile', change in original file fails check. - execute('set noundofile') - execute('e! Xtestfile') - execute('s/line/Line/') - execute('w') - execute('set undofile') - execute('bwipe!') - execute('e Xtestfile') + feed_command('set noundofile') + feed_command('e! Xtestfile') + feed_command('s/line/Line/') + feed_command('w') + feed_command('set undofile') + feed_command('bwipe!') + feed_command('e Xtestfile') ---- TODO: this beeps. feed('u:.w >>test.out<cr>') -- Test 'undofile', add 10 lines, delete 6 lines, undo 3. - execute('set undofile') + feed_command('set undofile') feed('ggdGione<cr>') feed('two<cr>') feed('three<cr>') @@ -57,20 +57,20 @@ describe('72', function() feed('dd:set ul=100<cr>') feed('dd:set ul=100<cr>') feed('dd:set ul=100<cr>') - execute('w') - execute('bwipe!') - execute('e Xtestfile') + feed_command('w') + feed_command('bwipe!') + feed_command('e Xtestfile') feed('uuu:w >>test.out<cr>') -- Test that reading the undofiles when setting undofile works. - execute('set noundofile ul=0') + feed_command('set noundofile ul=0') feed('i<cr>') feed('<esc>u:e! Xtestfile<cr>') - execute('set undofile ul=100') + feed_command('set undofile ul=100') feed('uuuuuu:w >>test.out<cr>') ---- Open the output to see if it meets the expections - execute('e! test.out') + feed_command('e! test.out') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua index e8292db8c1..e17b463e30 100644 --- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua +++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -2,8 +2,8 @@ local helpers = require('test.functional.helpers')(after_each) local lfs = require('lfs') -local clear, execute, eq, neq, eval, wait, spawn = - helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.eval, +local clear, command, eq, neq, eval, wait, spawn = + helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval, helpers.wait, helpers.spawn describe('storing global variables in ShaDa files', function() @@ -26,31 +26,29 @@ describe('storing global variables in ShaDa files', function() 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} - execute( - -- This will cause a few errors, do it silently. - 'set visualbell', - 'set shada+=!', - "let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}", - -- Store a really long list. Initially this was testing line wrapping in - -- viminfo, but shada files has no line wrapping, no matter how long the - -- list is. - 'let MY_GLOBAL_LIST=range(1,100)' - ) + command('set visualbell') + command('set shada+=!') + command('let MY_GLOBAL_DICT={\'foo\': 1, \'bar\': 0, \'longvarible\': 1000}') + -- Store a really long list. Initially this was testing line wrapping in + -- viminfo, but shada files has no line wrapping, no matter how long the + -- list is. + command('let MY_GLOBAL_LIST=range(1, 100)') + eq(test_dict, eval('MY_GLOBAL_DICT')) eq(test_list, eval('MY_GLOBAL_LIST')) - execute('wsh! ' .. tempname) + command('wsh! ' .. tempname) wait() -- Assert that the shada file exists. neq(nil, lfs.attributes(tempname)) - execute('unlet MY_GLOBAL_DICT', - 'unlet MY_GLOBAL_LIST') + command('unlet MY_GLOBAL_DICT') + command('unlet MY_GLOBAL_LIST') -- Assert that the variables where deleted. eq(0, eval('exists("MY_GLOBAL_DICT")')) eq(0, eval('exists("MY_GLOBAL_LIST")')) - execute('rsh! ' .. tempname) + command('rsh! ' .. tempname) eq(test_list, eval('MY_GLOBAL_LIST')) eq(test_dict, eval('MY_GLOBAL_DICT')) diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua index e9d2acdaf5..fcfd33ec46 100644 --- a/test/functional/legacy/075_maparg_spec.lua +++ b/test/functional/legacy/075_maparg_spec.lua @@ -3,46 +3,48 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe('maparg()', function() setup(clear) it('is working', function() - execute('set cpo-=<') + command('set cpo-=<') -- Test maparg() with a string result - execute('map foo<C-V> is<F4>foo') - execute('vnoremap <script> <buffer> <expr> <silent> bar isbar') - execute([[call append('$', maparg('foo<C-V>'))]]) - execute([[call append('$', string(maparg('foo<C-V>', '', 0, 1)))]]) - execute([[call append('$', string(maparg('bar', '', 0, 1)))]]) - execute('map <buffer> <nowait> foo bar') - execute([[call append('$', string(maparg('foo', '', 0, 1)))]]) - execute('map abc x<char-114>x') - execute([[call append('$', maparg('abc'))]]) - execute('map abc y<S-char-114>y') - execute([[call append('$', maparg('abc'))]]) + command('map foo<C-V> is<F4>foo') + command('vnoremap <script> <buffer> <expr> <silent> bar isbar') + command([[call append('$', maparg('foo<C-V>'))]]) + command([[call append('$', string(maparg('foo<C-V>', '', 0, 1)))]]) + command([[call append('$', string(maparg('bar', '', 0, 1)))]]) + command('map <buffer> <nowait> foo bar') + command([[call append('$', string(maparg('foo', '', 0, 1)))]]) + command('map abc x<char-114>x') + command([[call append('$', maparg('abc'))]]) + command('map abc y<S-char-114>y') + command([[call append('$', maparg('abc'))]]) feed('Go<esc>:<cr>') + wait() -- Outside of the range, minimum - execute('inoremap <Char-0x1040> a') - execute([[execute "normal a\u1040\<Esc>"]]) + command('inoremap <Char-0x1040> a') + command([[execute "normal a\u1040\<Esc>"]]) -- Inside of the range, minimum - execute('inoremap <Char-0x103f> b') - execute([[execute "normal a\u103f\<Esc>"]]) + command('inoremap <Char-0x103f> b') + command([[execute "normal a\u103f\<Esc>"]]) -- Inside of the range, maximum - execute('inoremap <Char-0xf03f> c') - execute([[execute "normal a\uf03f\<Esc>"]]) + command('inoremap <Char-0xf03f> c') + command([[execute "normal a\uf03f\<Esc>"]]) -- Outside of the range, maximum - execute('inoremap <Char-0xf040> d') - execute([[execute "normal a\uf040\<Esc>"]]) + command('inoremap <Char-0xf040> d') + command([[execute "normal a\uf040\<Esc>"]]) -- Remove empty line - execute('1d') + command('1d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua index b43263300d..c692127213 100644 --- a/test/functional/legacy/077_mf_hash_grow_spec.lua +++ b/test/functional/legacy/077_mf_hash_grow_spec.lua @@ -7,8 +7,12 @@ -- If it isn't available then the test will be skipped. local helpers = require('test.functional.helpers')(after_each) + local feed = helpers.feed -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local wait = helpers.wait +local clear = helpers.clear +local expect = helpers.expect +local command = helpers.command describe('mf_hash_grow()', function() setup(clear) @@ -18,19 +22,21 @@ describe('mf_hash_grow()', function() pending('was not tested because cksum was not found', function() end) else it('is working', function() - execute('set fileformat=unix undolevels=-1') + command('set fileformat=unix undolevels=-1') -- Fill the buffer with numbers 1 - 2000000 - execute('let i = 1') - execute('while i <= 2000000 | call append(i, range(i, i + 99)) | let i += 100 | endwhile') + command('let i = 1') + command('while i <= 2000000 | call append(i, range(i, i + 99)) | let i += 100 | endwhile') -- Delete empty first line, save to Xtest, and clear buffer feed('ggdd<cr>') - execute('w! Xtest') + wait() + command('w! Xtest') feed('ggdG<cr>') + wait() -- Calculate the cksum of Xtest and delete first line - execute('r !cksum Xtest') + command('r !cksum Xtest') feed('ggdd<cr>') -- Assert correct output of cksum. diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua index 6b4d82a4c0..faeb61e3af 100644 --- a/test/functional/legacy/080_substitute_spec.lua +++ b/test/functional/legacy/080_substitute_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect local eq, eval = helpers.eq, helpers.eval describe('substitue()', function() @@ -46,17 +46,17 @@ describe('substitue()', function() end it('with "set magic" (TEST_1)', function() - execute('set magic') + feed_command('set magic') test_1_and_2() end) it('with "set nomagic" (TEST_2)', function() - execute('set nomagic') + feed_command('set nomagic') test_1_and_2() end) it('with sub-replace-expression (TEST_3)', function() - execute('set magic&') + feed_command('set magic&') eq('a\\a', eval([[substitute('aAa', 'A', '\="\\"', '')]])) eq('b\\\\b', eval([[substitute('bBb', 'B', '\="\\\\"', '')]])) eq('c\rc', eval([[substitute('cCc', 'C', '\="]]..'\r'..[["', '')]])) @@ -70,7 +70,7 @@ describe('substitue()', function() end) it('with submatch() (TEST_4)', function() - execute('set magic&') + feed_command('set magic&') eq('a\\a', eval([[substitute('aAa', 'A', ]] .. [['\=substitute(submatch(0), ".", "\\", "")', '')]])) eq('b\\b', eval([[substitute('bBb', 'B', ]] .. @@ -92,7 +92,7 @@ describe('substitue()', function() end) it('with submatch() (TEST_5)', function() - execute('set magic&') + feed_command('set magic&') eq('A123456789987654321', eval([[substitute('A123456789', ]] .. [['A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', ]] .. [['\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . ]] .. @@ -110,7 +110,7 @@ describe('substitue()', function() -- #2943. it('with submatch or \\ze (TEST_7)', function() - execute('set magic&') + feed_command('set magic&') eq('A\rA', eval("substitute('A\rA', 'A.', '\\=submatch(0)', '')")) eq('B\nB', eval([[substitute("B\nB", 'B.', '\=submatch(0)', '')]])) eq("['B\n']B", @@ -120,7 +120,7 @@ describe('substitue()', function() end) it('with \\zs and \\ze (TEST_10)', function() - execute('set magic&') + feed_command('set magic&') eq('a1a2a3a', eval([[substitute('123', '\zs', 'a', 'g')]])) eq('aaa', eval([[substitute('123', '\zs.', 'a', 'g')]])) eq('1a2a3a', eval([[substitute('123', '.\zs', 'a', 'g')]])) @@ -140,11 +140,11 @@ describe(':substitue', function() ,,X ,,Y ,,Z]]) - execute('set magic&') - execute([[1s/\(^\|,\)\ze\(,\|X\)/\1N/g]]) - execute([[2s/\(^\|,\)\ze\(,\|Y\)/\1N/gc]]) + feed_command('set magic&') + feed_command([[1s/\(^\|,\)\ze\(,\|X\)/\1N/g]]) + feed_command([[2s/\(^\|,\)\ze\(,\|Y\)/\1N/gc]]) feed('a') -- For the dialog of the previous :s command. - execute([[3s/\(^\|,\)\ze\(,\|Z\)/\1N/gc]]) + feed_command([[3s/\(^\|,\)\ze\(,\|Z\)/\1N/gc]]) feed('yy') -- For the dialog of the previous :s command. expect([[ N,,NX @@ -154,8 +154,8 @@ describe(':substitue', function() it('with confirmation dialog (TEST_9)', function() insert('xxx') - execute('set magic&') - execute('s/x/X/gc') + feed_command('set magic&') + feed_command('s/x/X/gc') feed('yyq') -- For the dialog of the previous :s command. expect('XXx') end) diff --git a/test/functional/legacy/081_coptions_movement_spec.lua b/test/functional/legacy/081_coptions_movement_spec.lua index 2ac1332687..993aff2ba2 100644 --- a/test/functional/legacy/081_coptions_movement_spec.lua +++ b/test/functional/legacy/081_coptions_movement_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('coptions', function() setup(clear) @@ -16,18 +16,18 @@ describe('coptions', function() ccc two three four ddd yee yoo four]]) - execute('set cpo-=;') + feed_command('set cpo-=;') feed('gg0tt;D') feed('j0fz;D') feed('j$Fy;D') feed('j$Ty;D') - execute('set cpo+=;') + feed_command('set cpo+=;') feed('j0tt;;D') feed('j$Ty;;D') - + expect([[ aaa two z diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua index d6f3c45e1f..cfc0b96bce 100644 --- a/test/functional/legacy/082_string_comparison_spec.lua +++ b/test/functional/legacy/082_string_comparison_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, source = helpers.feed, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('case-insensitive string comparison in UTF-8', function() setup(clear) @@ -106,11 +106,11 @@ describe('case-insensitive string comparison in UTF-8', function() ]]) -- Test that g~ap changes one paragraph only. - execute('new') + feed_command('new') feed('iabcd<cr><cr>defg<esc>gg0g~ap') - execute('let lns = getline(1,3)') - execute('q!') - execute([[call append(line('$'), lns)]]) + feed_command('let lns = getline(1,3)') + feed_command('q!') + feed_command([[call append(line('$'), lns)]]) -- Assert buffer contents. expect([=[ diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua index 818914eeb9..9809ce5b88 100644 --- a/test/functional/legacy/084_curswant_spec.lua +++ b/test/functional/legacy/084_curswant_spec.lua @@ -25,7 +25,7 @@ describe('curswant', function() let curswant_after = winsaveview().curswant return [a:option_name, curswant_before, curswant_after] endfunction - + new put =['1234567890', '12345'] 1 delete _ @@ -33,7 +33,7 @@ describe('curswant', function() for option_name in target_option_names call add(result, TestCurswant(option_name)) endfor - + new put =map(copy(result), 'join(v:val, '' '')') 1 delete _ diff --git a/test/functional/legacy/088_conceal_tabs_spec.lua b/test/functional/legacy/088_conceal_tabs_spec.lua index 00e7312bf8..c9414679ab 100644 --- a/test/functional/legacy/088_conceal_tabs_spec.lua +++ b/test/functional/legacy/088_conceal_tabs_spec.lua @@ -2,8 +2,8 @@ -- tabulators. local helpers = require('test.functional.helpers')(after_each) -local feed, insert, clear, execute = - helpers.feed, helpers.insert, helpers.clear, helpers.execute +local feed, insert, clear, feed_command = + helpers.feed, helpers.insert, helpers.clear, helpers.feed_command local expect_pos = function(row, col) return helpers.eq({row, col}, helpers.eval('[screenrow(), screencol()]')) @@ -17,19 +17,19 @@ describe('cursor and column position with conceal and tabulators', function() start: .concealed. text |concealed| text - + .concealed. text |concealed| text - + .a. .b. .c. .d. |a| |b| |c| |d|]]) -- Conceal settings. - execute('set conceallevel=2') - execute('set concealcursor=nc') - execute('syntax match test /|/ conceal') + feed_command('set conceallevel=2') + feed_command('set concealcursor=nc') + feed_command('syntax match test /|/ conceal') -- Start test. - execute('/^start:') + feed_command('/^start:') feed('ztj') expect_pos(2, 1) -- We should end up in the same column when running these commands on the @@ -78,10 +78,10 @@ describe('cursor and column position with conceal and tabulators', function() expect_pos(9, 25) feed('$') expect_pos(9, 26) - execute('set lbr') + feed_command('set lbr') feed('$') expect_pos(9, 26) - execute('set list listchars=tab:>-') + feed_command('set list listchars=tab:>-') feed('0') expect_pos(9, 1) feed('W') diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua index f8564384e9..44f1664abe 100644 --- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua +++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('store cursor position in session file in UTF-8', function() setup(clear) @@ -29,15 +29,15 @@ describe('store cursor position in session file in UTF-8', function() -- This test requires the buffer to correspond to a file on disk, here named -- "test.in", because otherwise :mksession won't write out the cursor column -- info needed for verification. - execute('write! test.in') + feed_command('write! test.in') - execute('set sessionoptions=buffers splitbelow fileencoding=utf-8') + feed_command('set sessionoptions=buffers splitbelow fileencoding=utf-8') -- Move the cursor through the buffer lines and position it with "|". Using -- :split after every normal mode command is a trick to have multiple -- cursors on the screen that can all be stored in the session file. - execute('/^start:') - execute('vsplit') + feed_command('/^start:') + feed_command('vsplit') feed('j16|:split<cr>') feed('j16|:split<cr>') feed('j16|:split<cr>') @@ -49,9 +49,9 @@ describe('store cursor position in session file in UTF-8', function() -- Again move the cursor through the buffer and position it with "|". This -- time also perform a horizontal scroll at every step. - execute('wincmd l') - execute('/^start:') - execute('set nowrap') + feed_command('wincmd l') + feed_command('/^start:') + feed_command('set nowrap') feed('j16|3zl:split<cr>') feed('j016|3zl:split<cr>') feed('j016|3zl:split<cr>') @@ -62,9 +62,9 @@ describe('store cursor position in session file in UTF-8', function() feed('j016|3zl:split<cr>') -- Create the session file, read it back in, and prepare for verification. - execute('mksession! test.out') - execute('new test.out') - execute([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) + feed_command('mksession! test.out') + feed_command('new test.out') + feed_command([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua index 40be7dcca4..49bc43f76f 100644 --- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua +++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect if helpers.pending_win32(pending) then return end @@ -30,13 +30,13 @@ describe('store cursor position in session file in Latin-1', function() A three mulTibyte characters]]) -- Must write buffer to disk for :mksession. See the comments in -- "092_mksession_cursor_cols_utf8_spec.lua". - execute('write! test.in') + feed_command('write! test.in') - execute('set sessionoptions=buffers splitbelow fileencoding=latin1') + feed_command('set sessionoptions=buffers splitbelow fileencoding=latin1') -- Move the cursor through the buffer lines and position it with "|". - execute('/^start:') - execute('vsplit') + feed_command('/^start:') + feed_command('vsplit') feed('j16|:split<cr>') feed('j16|:split<cr>') feed('j16|:split<cr>') @@ -48,9 +48,9 @@ describe('store cursor position in session file in Latin-1', function() -- Again move the cursor through the buffer and position it with "|". This -- time also perform a horizontal scroll at every step. - execute('wincmd l') - execute('/^start:') - execute('set nowrap') + feed_command('wincmd l') + feed_command('/^start:') + feed_command('set nowrap') feed('j16|3zl:split<cr>') feed('j016|3zl:split<cr>') feed('j016|3zl:split<cr>') @@ -61,9 +61,9 @@ describe('store cursor position in session file in Latin-1', function() feed('j016|3zl:split<cr>') -- Create the session file, read it back in, and prepare for verification. - execute('mksession! test.out') - execute('new test.out') - execute([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) + feed_command('mksession! test.out') + feed_command('new test.out') + feed_command([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/094_visual_mode_operators_spec.lua b/test/functional/legacy/094_visual_mode_operators_spec.lua index a52fa00672..84e384050a 100644 --- a/test/functional/legacy/094_visual_mode_operators_spec.lua +++ b/test/functional/legacy/094_visual_mode_operators_spec.lua @@ -6,7 +6,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -- Vim script user functions needed for some of the test cases. local function source_user_functions() @@ -54,38 +54,38 @@ describe('Visual mode and operator', function() it('simple change in Visual mode', function() insert([[ apple banana cherry - + line 1 line 1 line 2 line 2 line 3 line 3 line 4 line 4 line 5 line 5 line 6 line 6 - + xxxxxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxx]]) -- Exercise characterwise Visual mode plus operator, with count and repeat. - execute('/^apple') + feed_command('/^apple') feed('lvld.l3vd.') -- Same in linewise Visual mode. - execute('/^line 1') + feed_command('/^line 1') feed('Vcnewline<esc>j.j2Vd.') -- Same in blockwise Visual mode. - execute('/^xxxx') + feed_command('/^xxxx') feed('<c-v>jlc <esc>l.l2<c-v>c----<esc>l.') -- Assert buffer contents. expect([[ a y - + newline newline - + --------x --------x xxxx--------x @@ -98,15 +98,15 @@ describe('Visual mode and operator', function() JambuRambutanBananaTangerineMango]]) -- Set up Visual mode mappings. - execute('vnoremap W /\\u/s-1<CR>') - execute('vnoremap iW :<C-U>call SelectInCaps()<CR>') + feed_command('vnoremap W /\\u/s-1<CR>') + feed_command('vnoremap iW :<C-U>call SelectInCaps()<CR>') -- Do a simple change using the simple vmap, also with count and repeat. - execute('/^Kiwi') + feed_command('/^Kiwi') feed('vWcNo<esc>l.fD2vd.') -- Same, using the vmap that maps to an Ex command. - execute('/^Jambu') + feed_command('/^Jambu') feed('llviWc-<esc>l.l2vdl.') -- Assert buffer contents. @@ -122,20 +122,20 @@ describe('Visual mode and operator', function() LemonNectarineZ]]) -- Set up Operator-pending mode mappings. - execute('onoremap W /\\u/<CR>') - execute('onoremap <Leader>W :<C-U>call MoveToCap()<CR>') - execute('onoremap iW :<C-U>call SelectInCaps()<CR>') + feed_command('onoremap W /\\u/<CR>') + feed_command('onoremap <Leader>W :<C-U>call MoveToCap()<CR>') + feed_command('onoremap iW :<C-U>call SelectInCaps()<CR>') -- Do a simple change using the simple omap, also with count and repeat. - execute('/^Pineapple') + feed_command('/^Pineapple') feed('cW-<esc>l.l2.l.') -- Same, using the omap that maps to an Ex command to move the cursor. - execute('/^Juniper') + feed_command('/^Juniper') feed('g?\\WfD.') -- Same, using the omap that uses Ex and Visual mode (custom text object). - execute('/^Lemon') + feed_command('/^Lemon') feed('yiWPlciWNew<esc>fr.') -- Assert buffer contents. @@ -159,7 +159,7 @@ describe('Visual mode and operator', function() -- changed, taking into account the v/V/<c-v> modifier given; or -- - abort the operation by pressing Escape: no change to the buffer is -- carried out. - execute('/^zzzz') + feed_command('/^zzzz') feed([[dV:<cr>dv:<cr>:set noma | let v:errmsg = ''<cr>]]) feed([[d:<cr>:set ma | put = v:errmsg =~# '^E21' ? 'ok' : 'failed'<cr>]]) feed([[dv:<esc>dV:<esc>:set noma | let v:errmsg = ''<cr>]]) @@ -180,7 +180,7 @@ describe('Visual mode and operator', function() feed('v$p') expect([[ - + x]]) end) @@ -189,7 +189,7 @@ describe('Visual mode and operator', function() feed('kkv$d') expect([[ - + b c]]) end) @@ -199,7 +199,7 @@ describe('Visual mode and operator', function() feed('kkvj$d') expect([[ - + c]]) end) @@ -208,7 +208,7 @@ describe('Visual mode and operator', function() feed('v$d') expect([[ - + a b ]]) @@ -219,7 +219,7 @@ describe('Visual mode and operator', function() feed('kvj$d') expect([[ - + a ]]) end) @@ -235,7 +235,7 @@ describe('Visual mode and operator', function() feed('kkgh<End><Del>') expect([[ - + b c]]) end) @@ -245,7 +245,7 @@ describe('Visual mode and operator', function() feed('kkgh<Down><End><Del>') expect([[ - + c]]) end) @@ -254,7 +254,7 @@ describe('Visual mode and operator', function() feed('gh<End><Del>') expect([[ - + a b ]]) @@ -265,7 +265,7 @@ describe('Visual mode and operator', function() feed('kgh<Down><End><Del>') expect([[ - + a ]]) end) @@ -281,7 +281,7 @@ describe('Visual mode and operator', function() feed(' kkgH<Del> ') expect([[ - + b c]]) end) @@ -291,7 +291,7 @@ describe('Visual mode and operator', function() feed('kkgH<Down><Del>') expect([[ - + c]]) end) @@ -300,7 +300,7 @@ describe('Visual mode and operator', function() feed('gH<Del>') expect([[ - + a b]]) end) @@ -310,7 +310,7 @@ describe('Visual mode and operator', function() feed('kgH<Down><Del>') expect([[ - + a]]) end) end) @@ -318,25 +318,25 @@ describe('Visual mode and operator', function() describe('v_p:', function() it('replace last character with line register at middle line', function() put_aaabbbccc() - execute('-2yank') + feed_command('-2yank') feed('k$vp') expect([[ - + aaa bb aaa - + ccc]]) end) it('replace last character with line register at middle line selecting newline', function() put_aaabbbccc() - execute('-2yank') + feed_command('-2yank') feed('k$v$p') expect([[ - + aaa bb aaa @@ -345,11 +345,11 @@ describe('Visual mode and operator', function() it('replace last character with line register at last line', function() put_aaabbbccc() - execute('-2yank') + feed_command('-2yank') feed('$vp') expect([[ - + aaa bbb cc @@ -359,11 +359,11 @@ describe('Visual mode and operator', function() it('replace last character with line register at last line selecting newline', function() put_aaabbbccc() - execute('-2yank') + feed_command('-2yank') feed('$v$p') expect([[ - + aaa bbb cc @@ -380,7 +380,7 @@ describe('Visual mode and operator', function() feed('kv3lyjv3lpgvcxxx<Esc>') expect([[ - + zzz xxx ]]) end) @@ -392,7 +392,7 @@ describe('Visual mode and operator', function() feed('0v3l<Esc>gvcxxx<Esc>') expect([[ - + xxx ]]) end) end) diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua index eac8d6356d..85c4fe0ec4 100644 --- a/test/functional/legacy/096_location_list_spec.lua +++ b/test/functional/legacy/096_location_list_spec.lua @@ -8,7 +8,7 @@ local helpers = require('test.functional.helpers')(after_each) local source = helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, command, expect = helpers.clear, helpers.command, helpers.expect describe('location list', function() setup(clear) @@ -28,7 +28,7 @@ describe('location list', function() function! ReadTestProtocol(name) let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '') let word = substitute(base, '\v(.*)\..*', '\1', '') - + setl modifiable setl noreadonly setl noswapfile @@ -37,9 +37,9 @@ describe('location list', function() " For problem 2: " 'buftype' has to be set to reproduce the constant opening of new windows. setl buftype=nofile - + call setline(1, word) - + setl nomodified setl nomodifiable setl readonly @@ -71,74 +71,77 @@ describe('location list', function() ]]) -- Set up the result buffer "test.out". - execute('enew') - execute('w! test.out') - execute('b 1') + command('enew') + command('w! test.out') + command('b 1') -- Test A. -- Open a new buffer as the sole window, rewind and open the prepopulated -- location list and navigate through the entries. - execute('lrewind') - execute('enew') - execute('lopen') - execute('lnext', 'lnext', 'lnext', 'lnext') + command('lrewind') + command('enew') + command('lopen') + command(('lnext|'):rep(4)) -- Split the window, copying the location list, then open the copied -- location list and again navigate forward. - execute('vert split') - execute('wincmd L') - execute('lopen') - execute('wincmd p') - execute('lnext') + command('vert split') + command('wincmd L') + command('lopen') + command('wincmd p') + command('lnext') -- Record the current file name and the file name of the corresponding -- location list entry, then open the result buffer. - execute('let fileName = expand("%")') - execute('wincmd p') - execute([[let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')]]) - execute('wincmd n') - execute('wincmd K') - execute('b test.out') + command('let fileName = expand("%")') + command('wincmd p') + command([[let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')]]) + command('wincmd n') + command('wincmd K') + command('b test.out') -- Prepare test output and write it to the result buffer. - execute([[let fileName = substitute(fileName, '\\', '/', 'g')]]) - execute([[let locationListFileName = substitute(locationListFileName, '\\', '/', 'g')]]) - execute([[call append(line('$'), "Test A:")]]) - execute([[call append(line('$'), " - file name displayed: " . fileName)]]) - execute([[call append(line('$'), " - quickfix claims that the file name displayed is: " . locationListFileName)]]) - execute('w') + command([[let fileName = substitute(fileName, '\\', '/', 'g')]]) + command([[let locationListFileName = substitute(locationListFileName, '\\', '/', 'g')]]) + command([[call append(line('$'), "Test A:")]]) + command([[call append(line('$'), " - file name displayed: " . fileName)]]) + command([[call append(line('$'), " - quickfix claims that the file name displayed is: " . locationListFileName)]]) + command('w') -- Clean slate for the next test. - execute('wincmd o') - execute('b 1') + command('wincmd o') + command('b 1') -- Test B. -- Rewind the location list, then open it and browse through it by running -- ":{number}" followed by Enter repeatedly in the location list window. - execute('lrewind') - execute('lopen') - execute('2', [[exe "normal \\<CR>"]]) - execute('wincmd p') - execute('3', [[exe "normal \<CR>"]]) - execute('wincmd p') - execute('4', [[exe "normal \<CR>"]]) + command('lrewind') + command('lopen') + command('2') + command([[exe "normal \\<CR>"]]) + command('wincmd p') + command('3') + command([[exe "normal \<CR>"]]) + command('wincmd p') + command('4') + command([[exe "normal \<CR>"]]) -- Record the number of windows open, then go back to the result buffer. - execute('let numberOfWindowsOpen = winnr("$")') - execute('wincmd n') - execute('wincmd K') - execute('b test.out') + command('let numberOfWindowsOpen = winnr("$")') + command('wincmd n') + command('wincmd K') + command('b test.out') -- Prepare test output and write it to the result buffer. - execute('call append(line("$"), "Test B:")') - execute('call append(line("$"), " - number of window open: " . numberOfWindowsOpen)') - execute('w') + command('call append(line("$"), "Test B:")') + command('call append(line("$"), " - number of window open: " . numberOfWindowsOpen)') + command('w') -- Clean slate. - execute('wincmd o') - execute('b 1') + command('wincmd o') + command('b 1') -- Test C. @@ -146,38 +149,41 @@ describe('location list', function() -- Enter browsing. But this time, move the location list window to the top -- to check whether it (the first window found) will be reused when we try -- to open new windows. - execute('lrewind') - execute('lopen') - execute('wincmd K') - execute('2', [[exe "normal \<CR>"]]) - execute('wincmd p') - execute('3', [[exe "normal \<CR>"]]) - execute('wincmd p') - execute('4', [[exe "normal \<CR>"]]) + command('lrewind') + command('lopen') + command('wincmd K') + command('2') + command([[exe "normal \<CR>"]]) + command('wincmd p') + command('3') + command([[exe "normal \<CR>"]]) + command('wincmd p') + command('4') + command([[exe "normal \<CR>"]]) -- Record the 'buftype' of window 1 (the location list) and the buffer name -- of window 2 (the current "test protocol" buffer), then go back to the -- result buffer. - execute('1wincmd w') - execute('let locationListWindowBufType = &buftype') - execute('2wincmd w') - execute('let bufferName = expand("%")') - execute('wincmd n') - execute('wincmd K') - execute('b test.out') + command('1wincmd w') + command('let locationListWindowBufType = &buftype') + command('2wincmd w') + command('let bufferName = expand("%")') + command('wincmd n') + command('wincmd K') + command('b test.out') -- Prepare test output and write it to the result buffer. - execute([[let bufferName = substitute(bufferName, '\\', '/', 'g')]]) - execute([[call append(line("$"), "Test C:")]]) - execute([[call append(line('$'), " - 'buftype' of the location list window: " . locationListWindowBufType)]]) - execute([[call append(line('$'), " - buffer displayed in the 2nd window: " . bufferName)]]) - execute('w') - execute('wincmd o') - execute('b 1') + command([[let bufferName = substitute(bufferName, '\\', '/', 'g')]]) + command([[call append(line("$"), "Test C:")]]) + command([[call append(line('$'), " - 'buftype' of the location list window: " . locationListWindowBufType)]]) + command([[call append(line('$'), " - buffer displayed in the 2nd window: " . bufferName)]]) + command('w') + command('wincmd o') + command('b 1') -- Assert buffer contents. expect([[ - + Test A: - file name displayed: test://bar.txt - quickfix claims that the file name displayed is: test://bar.txt diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua index 23f1427cb5..6b63a317f1 100644 --- a/test/functional/legacy/097_glob_path_spec.lua +++ b/test/functional/legacy/097_glob_path_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect if helpers.pending_win32(pending) then return end @@ -19,26 +19,26 @@ describe('glob() and globpath()', function() it('is working', function() -- Make sure glob() doesn't use the shell - execute('set shell=doesnotexist') + command('set shell=doesnotexist') -- Consistent sorting of file names - execute('set nofileignorecase') + command('set nofileignorecase') - execute([[$put =glob('Xxx\{')]]) - execute([[$put =glob('Xxx\$')]]) + command([[$put =glob('Xxx\{')]]) + command([[$put =glob('Xxx\$')]]) - execute('w! Xxx{') - execute([[w! Xxx\$]]) - execute([[$put =glob('Xxx\{')]]) - execute([[$put =glob('Xxx\$')]]) + command('silent w! Xxx{') + command([[w! Xxx\$]]) + command([[$put =glob('Xxx\{')]]) + command([[$put =glob('Xxx\$')]]) - execute("$put =string(globpath('sautest/autoload', '*.vim'))") - execute("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))") + command("$put =string(globpath('sautest/autoload', '*.vim'))") + command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))") expect([=[ - - - + + + Xxx{ Xxx$ 'sautest/autoload/Test104.vim diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua index fa29e5fbe8..eff755221c 100644 --- a/test/functional/legacy/101_hlsearch_spec.lua +++ b/test/functional/legacy/101_hlsearch_spec.lua @@ -2,52 +2,52 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('v:hlsearch', function() setup(clear) it('is working', function() -- Last abc: Q - execute('new') - execute([[call setline(1, repeat(['aaa'], 10))]]) - execute('set hlsearch nolazyredraw') - execute('let r=[]') - execute('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])') - execute('/aaa') - execute('AddR') - execute('nohlsearch') - execute('AddR') - execute('let v:hlsearch=1') - execute('AddR') - execute('let v:hlsearch=0') - execute('AddR') - execute('set hlsearch') - execute('AddR') - execute('let v:hlsearch=0') - execute('AddR') + feed_command('new') + feed_command([[call setline(1, repeat(['aaa'], 10))]]) + feed_command('set hlsearch nolazyredraw') + feed_command('let r=[]') + feed_command('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])') + feed_command('/aaa') + feed_command('AddR') + feed_command('nohlsearch') + feed_command('AddR') + feed_command('let v:hlsearch=1') + feed_command('AddR') + feed_command('let v:hlsearch=0') + feed_command('AddR') + feed_command('set hlsearch') + feed_command('AddR') + feed_command('let v:hlsearch=0') + feed_command('AddR') feed('n:AddR<cr>') - execute('let v:hlsearch=0') - execute('AddR') - execute('/') - execute('AddR') - execute('set nohls') - execute('/') - execute('AddR') - execute('let r1=r[0][0]') + feed_command('let v:hlsearch=0') + feed_command('AddR') + feed_command('/') + feed_command('AddR') + feed_command('set nohls') + feed_command('/') + feed_command('AddR') + feed_command('let r1=r[0][0]') -- I guess it is not guaranteed that screenattr outputs always the same character - execute([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]]) - execute('try') - execute(' let v:hlsearch=[]') - execute('catch') - execute([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]]) - execute('endtry') - execute('bwipeout!') - execute('$put=r') - execute('call garbagecollect(1)') - execute('call getchar()') - execute('1d', '1d') + feed_command([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]]) + feed_command('try') + feed_command(' let v:hlsearch=[]') + feed_command('catch') + feed_command([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]]) + feed_command('endtry') + feed_command('bwipeout!') + feed_command('$put=r') + feed_command('call garbagecollect(1)') + feed_command('call getchar()') + feed_command('1d', '1d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua index c1a6c57956..c8ee423ff3 100644 --- a/test/functional/legacy/102_fnameescape_spec.lua +++ b/test/functional/legacy/102_fnameescape_spec.lua @@ -2,19 +2,19 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect describe('fnameescape', function() setup(clear) it('is working', function() - execute('let fname = "Xspa ce"') - execute('try', 'exe "w! " . fnameescape(fname)', "put='Space'", 'endtry') - execute('let fname = "Xemark!"') - execute('try', 'exe "w! " . fnameescape(fname)', "put='ExclamationMark'", 'endtry') + command('let fname = "Xspa ce"') + command('try | exe "w! " . fnameescape(fname) | put=\'Space\' | endtry') + command('let fname = "Xemark!"') + command('try | exe "w! " . fnameescape(fname) | put=\'ExclamationMark\' | endtry') expect([[ - + Space ExclamationMark]]) end) diff --git a/test/functional/legacy/104_let_assignment_spec.lua b/test/functional/legacy/104_let_assignment_spec.lua index 27c3715231..a03bb026f6 100644 --- a/test/functional/legacy/104_let_assignment_spec.lua +++ b/test/functional/legacy/104_let_assignment_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect describe(':let', function() setup(clear) it('is working', function() - execute('set runtimepath+=test/functional/fixtures') + command('set runtimepath+=test/functional/fixtures') -- Test to not autoload when assigning. It causes internal error. source([[ @@ -34,7 +34,7 @@ describe(':let', function() endfor]]) -- Remove empty line - execute('1d') + command('1d') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua index 2b17d63378..5d76adc786 100644 --- a/test/functional/legacy/106_errorformat_spec.lua +++ b/test/functional/legacy/106_errorformat_spec.lua @@ -2,19 +2,19 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect describe('errorformat', function() setup(clear) it('is working', function() - execute("set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#") - execute("cgetexpr ['WWWW', 'EEEE', 'CCCC']") - execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") - execute("cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']") - execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") - execute("cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']") - execute("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") + command("set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#") + command("cgetexpr ['WWWW', 'EEEE', 'CCCC']") + command("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") + command("cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']") + command("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") + command("cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']") + command("$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))") expect([=[ diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua index 610bac7f21..836a0f8f24 100644 --- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua +++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -2,8 +2,11 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') + +local wait = helpers.wait +local clear = helpers.clear local insert = helpers.insert -local clear, execute = helpers.clear, helpers.execute +local command = helpers.command if helpers.pending_win32(pending) then return end @@ -15,31 +18,34 @@ describe('107', function() screen:attach() insert('start:') - execute('new') - execute('call setline(1, range(1,256))') - execute('let r=[]') - execute('func! GetScreenStr(row)') - execute(' let str = ""') - execute(' for c in range(1,3)') - execute(' let str .= nr2char(screenchar(a:row, c))') - execute(' endfor') - execute(' return str') - execute('endfunc') - execute([[exe ":norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"]]) - execute('let s3=GetScreenStr(1)') - execute('wincmd p') - execute('call add(r, [line("w0"), s3])') - execute([[exe ":norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"]]) - execute('let s3=GetScreenStr(1)') - execute('wincmd p') - execute('call add(r, [line("w0"), s3])') - execute([[exe ":norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"]]) - execute('let s3=GetScreenStr(1)') - execute(':wincmd p') - execute('call add(r, [line("w0"), s3])') - execute('bwipeout!') - execute('$put=r') - execute('call garbagecollect(1)') + wait() + command('new') + command('call setline(1, range(1,256))') + command('let r=[]') + command([[ + func! GetScreenStr(row) + let str = "" + for c in range(1,3) + let str .= nr2char(screenchar(a:row, c)) + endfor + return str + endfunc + ]]) + command([[exe ":norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"]]) + command('let s3=GetScreenStr(1)') + command('wincmd p') + command('call add(r, [line("w0"), s3])') + command([[exe ":norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"]]) + command('let s3=GetScreenStr(1)') + command('wincmd p') + command('call add(r, [line("w0"), s3])') + command([[exe ":norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"]]) + command('let s3=GetScreenStr(1)') + command(':wincmd p') + command('call add(r, [line("w0"), s3])') + command('bwipeout!') + command('$put=r') + command('call garbagecollect(1)') screen:expect([[ start: | @@ -55,7 +61,7 @@ describe('107', function() ~ | ~ | ~ | - :call garbagecollect(1) | + 3 more lines | ]]) end) end) diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua index a03092e446..b2e2fa4ed3 100644 --- a/test/functional/legacy/108_backtrace_debug_commands_spec.lua +++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -2,32 +2,32 @@ local helpers = require('test.functional.helpers')(after_each) local feed, clear = helpers.feed, helpers.clear -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('108', function() before_each(clear) it('is working', function() - execute('lang mess C') - execute('function! Foo()') - execute(' let var1 = 1') - execute(' let var2 = Bar(var1) + 9') - execute(' return var2') - execute('endfunction') - execute('function! Bar(var)') - execute(' let var1 = 2 + a:var') - execute(' let var2 = Bazz(var1) + 4') - execute(' return var2') - execute('endfunction') - execute('function! Bazz(var)') - execute(' let var1 = 3 + a:var') - execute(' let var3 = "another var"') - execute(' return var1') - execute('endfunction') - execute('new') - execute('debuggreedy') - execute('redir => out') - execute('debug echo Foo()') + feed_command('lang mess C') + feed_command('function! Foo()') + feed_command(' let var1 = 1') + feed_command(' let var2 = Bar(var1) + 9') + feed_command(' return var2') + feed_command('endfunction') + feed_command('function! Bar(var)') + feed_command(' let var1 = 2 + a:var') + feed_command(' let var2 = Bazz(var1) + 4') + feed_command(' return var2') + feed_command('endfunction') + feed_command('function! Bazz(var)') + feed_command(' let var1 = 3 + a:var') + feed_command(' let var3 = "another var"') + feed_command(' return var1') + feed_command('endfunction') + feed_command('new') + feed_command('debuggreedy') + feed_command('redir => out') + feed_command('debug echo Foo()') feed('step<cr>') feed('step<cr>') feed('step<cr>') @@ -83,9 +83,9 @@ describe('108', function() feed('fram<cr>') feed([[echo "\n- final result 19:"<cr>]]) feed('cont<cr>') - execute('0debuggreedy') - execute('redir END') - execute('$put =out') + feed_command('0debuggreedy') + feed_command('redir END') + feed_command('$put =out') -- Assert buffer contents. expect([=[ diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index b9075620dc..191f145095 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -1,7 +1,7 @@ -- Test argument list commands local helpers = require('test.functional.helpers')(after_each) -local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq +local clear, command, eq = helpers.clear, helpers.command, helpers.eq local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq if helpers.pending_win32(pending) then return end @@ -10,12 +10,12 @@ describe('argument list commands', function() before_each(clear) local function init_abc() - execute('args a b c') - execute('next') + command('args a b c') + command('next') end local function reset_arglist() - execute('arga a | %argd') + command('arga a | %argd') end local function assert_fails(cmd, err) @@ -23,183 +23,185 @@ describe('argument list commands', function() end it('test that argidx() works', function() - execute('args a b c') - execute('last') + command('args a b c') + command('last') eq(2, eval('argidx()')) - execute('%argdelete') + command('%argdelete') eq(0, eval('argidx()')) - execute('args a b c') + command('args a b c') eq(0, eval('argidx()')) - execute('next') + command('next') eq(1, eval('argidx()')) - execute('next') + command('next') eq(2, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(1, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(0, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(0, eval('argidx()')) end) it('test that argadd() works', function() - execute('%argdelete') - execute('argadd a b c') + -- Fails with “E474: Invalid argument”. Not sure whether it is how it is + -- supposed to behave. + -- command('%argdelete') + command('argadd a b c') eq(0, eval('argidx()')) - execute('%argdelete') - execute('argadd a') + command('%argdelete') + command('argadd a') eq(0, eval('argidx()')) - execute('argadd b c d') + command('argadd b c d') eq(0, eval('argidx()')) init_abc() - execute('argadd x') + command('argadd x') eq({'a', 'b', 'x', 'c'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() - execute('0argadd x') + command('0argadd x') eq({'x', 'a', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() - execute('1argadd x') + command('1argadd x') eq({'a', 'x', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() - execute('$argadd x') + command('$argadd x') eq({'a', 'b', 'c', 'x'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() - execute('$argadd x') - execute('+2argadd y') + command('$argadd x') + command('+2argadd y') eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()')) eq(1, eval('argidx()')) - execute('%argd') - execute('edit d') - execute('arga') + command('%argd') + command('edit d') + command('arga') eq(1, eval('len(argv())')) eq('d', eval('get(argv(), 0, "")')) - execute('%argd') - execute('new') - execute('arga') + command('%argd') + command('new') + command('arga') eq(0, eval('len(argv())')) end) it('test for [count]argument and [count]argdelete commands', function() reset_arglist() - execute('let save_hidden = &hidden') - execute('set hidden') - execute('let g:buffers = []') - execute('augroup TEST') - execute([[au BufEnter * call add(buffers, expand('%:t'))]]) - execute('augroup END') - - execute('argadd a b c d') - execute('$argu') - execute('$-argu') - execute('-argu') - execute('1argu') - execute('+2argu') - - execute('augroup TEST') - execute('au!') - execute('augroup END') + command('let save_hidden = &hidden') + command('set hidden') + command('let g:buffers = []') + command('augroup TEST') + command([[au BufEnter * call add(buffers, expand('%:t'))]]) + command('augroup END') + + command('argadd a b c d') + command('$argu') + command('$-argu') + command('-argu') + command('1argu') + command('+2argu') + + command('augroup TEST') + command('au!') + command('augroup END') eq({'d', 'c', 'b', 'a', 'c'}, eval('g:buffers')) - execute('redir => result') - execute('ar') - execute('redir END') + command('redir => result') + command('ar') + command('redir END') eq(1, eval([[result =~# 'a b \[c] d']])) - execute('.argd') + command('.argd') eq({'a', 'b', 'd'}, eval('argv()')) - execute('-argd') + command('-argd') eq({'a', 'd'}, eval('argv()')) - execute('$argd') + command('$argd') eq({'a'}, eval('argv()')) - execute('1arga c') - execute('1arga b') - execute('$argu') - execute('$arga x') + command('1arga c') + command('1arga b') + command('$argu') + command('$arga x') eq({'a', 'b', 'c', 'x'}, eval('argv()')) - execute('0arga Y') + command('0arga Y') eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()')) - execute('%argd') + command('%argd') eq({}, eval('argv()')) - execute('arga a b c d e f') - execute('2,$-argd') + command('arga a b c d e f') + command('2,$-argd') eq({'a', 'f'}, eval('argv()')) - execute('let &hidden = save_hidden') + command('let &hidden = save_hidden') -- Setting the argument list should fail when the current buffer has -- unsaved changes - execute('%argd') - execute('enew!') - execute('set modified') + command('%argd') + command('enew!') + command('set modified') assert_fails('args x y z', 'E37:') - execute('args! x y z') + command('args! x y z') eq({'x', 'y', 'z'}, eval('argv()')) eq('x', eval('expand("%:t")')) - execute('%argdelete') + command('%argdelete') assert_fails('argument', 'E163:') end) it('test for 0argadd and 0argedit', function() reset_arglist() - execute('arga a b c d') - execute('2argu') - execute('0arga added') + command('arga a b c d') + command('2argu') + command('0arga added') eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('%argd') - execute('arga a b c d') - execute('2argu') - execute('0arge edited') + command('%argd') + command('arga a b c d') + command('2argu') + command('0arge edited') eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('2argu') - execute('arga third') + command('2argu') + command('arga third') eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()')) end) it('test for argc()', function() reset_arglist() eq(0, eval('argc()')) - execute('argadd a b') + command('argadd a b') eq(2, eval('argc()')) end) it('test for arglistid()', function() reset_arglist() - execute('arga a b') + command('arga a b') eq(0, eval('arglistid()')) - execute('split') - execute('arglocal') + command('split') + command('arglocal') eq(1, eval('arglistid()')) - execute('tabnew | tabfirst') + command('tabnew | tabfirst') eq(0, eval('arglistid(2)')) eq(1, eval('arglistid(1, 1)')) eq(0, eval('arglistid(2, 1)')) eq(1, eval('arglistid(1, 2)')) - execute('tabonly | only | enew!') - execute('argglobal') + command('tabonly | only | enew!') + command('argglobal') eq(0, eval('arglistid()')) end) @@ -207,95 +209,95 @@ describe('argument list commands', function() reset_arglist() eq({}, eval('argv()')) eq('', eval('argv(2)')) - execute('argadd a b c d') + command('argadd a b c d') eq('c', eval('argv(2)')) end) it('test for :argedit command', function() reset_arglist() - execute('argedit a') + command('argedit a') eq({'a'}, eval('argv()')) eq('a', eval('expand("%:t")')) - execute('argedit b') + command('argedit b') eq({'a', 'b'}, eval('argv()')) eq('b', eval('expand("%:t")')) - execute('argedit a') + command('argedit a') eq({'a', 'b'}, eval('argv()')) eq('a', eval('expand("%:t")')) - execute('argedit c') + command('argedit c') eq({'a', 'c', 'b'}, eval('argv()')) - execute('0argedit x') + command('0argedit x') eq({'x', 'a', 'c', 'b'}, eval('argv()')) - execute('enew! | set modified') + command('enew! | set modified') assert_fails('argedit y', 'E37:') - execute('argedit! y') + command('argedit! y') eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()')) - execute('%argd') + command('%argd') -- Nvim allows unescaped spaces in filename on all platforms. #6010 - execute('argedit a b') + command('argedit a b') eq({'a b'}, eval('argv()')) end) it('test for :argdelete command', function() reset_arglist() - execute('args aa a aaa b bb') - execute('argdelete a*') + command('args aa a aaa b bb') + command('argdelete a*') eq({'b', 'bb'}, eval('argv()')) eq('aa', eval('expand("%:t")')) - execute('last') - execute('argdelete %') + command('last') + command('argdelete %') eq({'b'}, eval('argv()')) assert_fails('argdelete', 'E471:') assert_fails('1,100argdelete', 'E16:') - execute('%argd') + command('%argd') end) it('test for the :next, :prev, :first, :last, :rewind commands', function() reset_arglist() - execute('args a b c d') - execute('last') + command('args a b c d') + command('last') eq(3, eval('argidx()')) assert_fails('next', 'E165:') - execute('prev') + command('prev') eq(2, eval('argidx()')) - execute('Next') + command('Next') eq(1, eval('argidx()')) - execute('first') + command('first') eq(0, eval('argidx()')) assert_fails('prev', 'E164:') - execute('3next') + command('3next') eq(3, eval('argidx()')) - execute('rewind') + command('rewind') eq(0, eval('argidx()')) - execute('%argd') + command('%argd') end) it('test for autocommand that redefines the argument list, when doing ":all"', function() - execute('autocmd BufReadPost Xxx2 next Xxx2 Xxx1') - execute("call writefile(['test file Xxx1'], 'Xxx1')") - execute("call writefile(['test file Xxx2'], 'Xxx2')") - execute("call writefile(['test file Xxx3'], 'Xxx3')") - - execute('new') + command('autocmd BufReadPost Xxx2 next Xxx2 Xxx1') + command("call writefile(['test file Xxx1'], 'Xxx1')") + command("call writefile(['test file Xxx2'], 'Xxx2')") + command("call writefile(['test file Xxx3'], 'Xxx3')") + + command('new') -- redefine arglist; go to Xxx1 - execute('next! Xxx1 Xxx2 Xxx3') + command('next! Xxx1 Xxx2 Xxx3') -- open window for all args - execute('all') + command('all') eq('test file Xxx1', eval('getline(1)')) - execute('wincmd w') - execute('wincmd w') + command('wincmd w') + command('wincmd w') eq('test file Xxx1', eval('getline(1)')) -- should now be in Xxx2 - execute('rewind') + command('rewind') eq('test file Xxx2', eval('getline(1)')) - - execute('autocmd! BufReadPost Xxx2') - execute('enew! | only') - execute("call delete('Xxx1')") - execute("call delete('Xxx2')") - execute("call delete('Xxx3')") - execute('argdelete Xxx*') - execute('bwipe! Xxx1 Xxx2 Xxx3') + + command('autocmd! BufReadPost Xxx2') + command('enew! | only') + command("call delete('Xxx1')") + command("call delete('Xxx2')") + command("call delete('Xxx3')") + command('argdelete Xxx*') + command('bwipe! Xxx1 Xxx2 Xxx3') end) end) diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 5c7268486a..d6255d42e7 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local nvim, call = helpers.meths, helpers.call local clear, eq = helpers.clear, helpers.eq -local source, execute = helpers.source, helpers.execute +local source, command = helpers.source, helpers.command local exc_exec = helpers.exc_exec local function expected_errors(errors) @@ -55,7 +55,7 @@ describe('assert function:', function() it('should change v:errors when expected is not equal to actual', function() -- Lua does not tell integer from float. - execute('call assert_equal(1, 1.0)') + command('call assert_equal(1, 1.0)') expected_errors({'Expected 1 but got 1.0'}) end) @@ -219,8 +219,8 @@ describe('assert function:', function() -- assert_fails({cmd}, [, {error}]) describe('assert_fails', function() it('should change v:errors when error does not match v:errmsg', function() - execute([[call assert_fails('xxx', {})]]) - execute([[call assert_match("Expected {} but got 'E731:", v:errors[0])]]) + command([[call assert_fails('xxx', {})]]) + command([[call assert_match("Expected {} but got 'E731:", v:errors[0])]]) expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"}) end) diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua index 06f7c1dd11..466e3ed830 100644 --- a/test/functional/legacy/autochdir_spec.lua +++ b/test/functional/legacy/autochdir_spec.lua @@ -1,7 +1,7 @@ local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local clear, eq = helpers.clear, helpers.eq -local eval, execute = helpers.eval, helpers.execute +local eval, command = helpers.eval, helpers.command describe('autochdir behavior', function() local dir = 'Xtest-functional-legacy-autochdir' @@ -17,9 +17,9 @@ describe('autochdir behavior', function() -- Tests vim/vim/777 without test_autochdir(). it('sets filename', function() - execute('set acd') - execute('new') - execute('w '..dir..'/Xtest') + command('set acd') + command('new') + command('w '..dir..'/Xtest') eq('Xtest', eval("expand('%')")) eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]])) end) diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 28037e17c5..0c7e43bf31 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -4,7 +4,7 @@ local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local curbuf, buf = helpers.curbuf, helpers.bufmeths local curwin = helpers.curwin local redir_exec = helpers.redir_exec -local source, execute = helpers.source, helpers.execute +local source, command = helpers.source, helpers.command local function declare_hook_function() source([[ @@ -23,9 +23,9 @@ local function declare_hook_function() endfu ]]) end - + local function set_hook(pattern) - execute( + command( 'au OptionSet ' .. pattern .. ' :call AutoCommand(expand("<amatch>"), bufnr("%"), winnr())' @@ -33,7 +33,7 @@ local function set_hook(pattern) end local function init_var() - execute('let g:ret = []') + command('let g:ret = []') end local function get_result() @@ -88,9 +88,9 @@ end local function make_buffer() local old_buf = curbuf() - execute('botright new') + command('botright new') local new_buf = curbuf() - execute('wincmd p') -- move previous window + command('wincmd p') -- move previous window neq(old_buf, new_buf) eq(old_buf, curbuf()) @@ -100,10 +100,10 @@ end local function get_new_window_number() local old_win = curwin() - execute('botright new') + command('botright new') local new_win = curwin() local new_winnr = redir_exec('echo winnr()') - execute('wincmd p') -- move previous window + command('wincmd p') -- move previous window neq(old_win, new_win) eq(old_win, curwin()) @@ -122,42 +122,42 @@ describe('au OptionSet', function() end) it('should be called in setting number option', function() - execute('set nu') + command('set nu') expected_combination({'number', 0, 1, 'global'}) - execute('setlocal nonu') + command('setlocal nonu') expected_combination({'number', 1, 0, 'local'}) - execute('setglobal nonu') + command('setglobal nonu') expected_combination({'number', 1, 0, 'global'}) end) it('should be called in setting autoindent option',function() - execute('setlocal ai') + command('setlocal ai') expected_combination({'autoindent', 0, 1, 'local'}) - execute('setglobal ai') + command('setglobal ai') expected_combination({'autoindent', 0, 1, 'global'}) - execute('set noai') + command('set noai') expected_combination({'autoindent', 1, 0, 'global'}) end) it('should be called in inverting global autoindent option',function() - execute('set ai!') + command('set ai!') expected_combination({'autoindent', 0, 1, 'global'}) end) it('should be called in being unset local autoindent option',function() - execute('setlocal ai') + command('setlocal ai') expected_combination({'autoindent', 0, 1, 'local'}) - execute('setlocal ai<') + command('setlocal ai<') expected_combination({'autoindent', 1, 0, 'local'}) end) it('should be called in setting global list and number option at the same time',function() - execute('set list nu') + command('set list nu') expected_combination( {'list', 0, 1, 'global'}, {'number', 0, 1, 'global'} @@ -165,41 +165,41 @@ describe('au OptionSet', function() end) it('should not print anything, use :noa', function() - execute('noa set nolist nonu') + command('noa set nolist nonu') expected_empty() end) it('should be called in setting local acd', function() - execute('setlocal acd') + command('setlocal acd') expected_combination({'autochdir', 0, 1, 'local'}) end) it('should be called in setting autoread', function() - execute('set noar') + command('set noar') expected_combination({'autoread', 1, 0, 'global'}) - execute('setlocal ar') + command('setlocal ar') expected_combination({'autoread', 0, 1, 'local'}) end) it('should be called in inverting global autoread', function() - execute('setglobal invar') + command('setglobal invar') expected_combination({'autoread', 1, 0, 'global'}) end) it('should be called in setting backspace option through :let', function() - execute('let &bs=""') + command('let &bs=""') expected_combination({'backspace', 'indent,eol,start', '', 'global'}) end) describe('being set by setbufvar()', function() it('should not trigger because option name is invalid', function() - execute('call setbufvar(1, "&l:bk", 1)') + command('silent! call setbufvar(1, "&l:bk", 1)') expected_empty() end) it('should trigger using correct option name', function() - execute('call setbufvar(1, "&backup", 1)') + command('call setbufvar(1, "&backup", 1)') expected_combination({'backup', 0, 1, 'local'}) end) @@ -207,7 +207,7 @@ describe('au OptionSet', function() local new_buffer = make_buffer() local new_bufnr = buf.get_number(new_buffer) - execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') + command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}}) end) end) @@ -224,16 +224,16 @@ describe('au OptionSet', function() it('should be called iff setting readonly', function() set_hook('readonly') - execute('set nu') + command('set nu') expected_empty() - execute('setlocal ro') + command('setlocal ro') expected_combination({'readonly', 0, 1, 'local'}) - execute('setglobal ro') + command('setglobal ro') expected_combination({'readonly', 0, 1, 'global'}) - execute('set noro') + command('set noro') expected_combination({'readonly', 1, 0, 'global'}) end) @@ -241,14 +241,14 @@ describe('au OptionSet', function() it('should not trigger because option name does not match with backup', function() set_hook('backup') - execute('call setbufvar(1, "&l:bk", 1)') + command('silent! call setbufvar(1, "&l:bk", 1)') expected_empty() end) it('should trigger, use correct option name backup', function() set_hook('backup') - execute('call setbufvar(1, "&backup", 1)') + command('call setbufvar(1, "&backup", 1)') expected_combination({'backup', 0, 1, 'local'}) end) @@ -258,7 +258,7 @@ describe('au OptionSet', function() local new_buffer = make_buffer() local new_bufnr = buf.get_number(new_buffer) - execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') + command('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}}) end) end) @@ -267,14 +267,14 @@ describe('au OptionSet', function() it('should not trigger because option name does not match with backup', function() set_hook('backup') - execute('call setwinvar(1, "&l:bk", 1)') + command('silent! call setwinvar(1, "&l:bk", 1)') expected_empty() end) it('should trigger, use correct option name backup', function() set_hook('backup') - execute('call setwinvar(1, "&backup", 1)') + command('call setwinvar(1, "&backup", 1)') expected_combination({'backup', 0, 1, 'local'}) end) @@ -283,7 +283,7 @@ describe('au OptionSet', function() local new_winnr = get_new_window_number() - execute('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)') + command('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)') -- expected_combination({'cursorcolumn', 0, 1, 'local', {winnr = new_winnr}}) expected_empty() end) diff --git a/test/functional/legacy/autoformat_join_spec.lua b/test/functional/legacy/autoformat_join_spec.lua index 4110d66f5b..84d661c190 100644 --- a/test/functional/legacy/autoformat_join_spec.lua +++ b/test/functional/legacy/autoformat_join_spec.lua @@ -1,9 +1,9 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for setting the '[,'] marks when joining lines. local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect +local wait = helpers.wait describe('autoformat join', function() setup(clear) @@ -21,12 +21,13 @@ Results:]]) feed('gg') feed('0gqj<cr>') + wait() - execute([[let a=string(getpos("'[")).'/'.string(getpos("']"))]]) - execute("g/^This line/;'}-join") - execute([[let b=string(getpos("'[")).'/'.string(getpos("']"))]]) - execute("$put ='First test: Start/End '.string(a)") - execute("$put ='Second test: Start/End '.string(b)") + command([[let a=string(getpos("'[")).'/'.string(getpos("']"))]]) + command("g/^This line/;'}-join") + command([[let b=string(getpos("'[")).'/'.string(getpos("']"))]]) + command("$put ='First test: Start/End '.string(a)") + command("$put ='Second test: Start/End '.string(b)") expect([[ O sodales, ludite, vos qui attamen consulite per voster honur. diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua index 2504fe8e51..7594dba16c 100644 --- a/test/functional/legacy/breakindent_spec.lua +++ b/test/functional/legacy/breakindent_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('breakindent', function() setup(clear) @@ -10,186 +10,186 @@ describe('breakindent', function() it('is working', function() insert('dummy text') - execute('set wildchar=^E') - execute('10new') - execute('vsp') - execute('vert resize 20') - execute([[put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"]]) - execute('set ts=4 sw=4 sts=4 breakindent') - execute('fu! ScreenChar(line, width)') - execute(' let c=""') - execute(' for i in range(1,a:width)') - execute(' let c.=nr2char(screenchar(a:line, i))') - execute(' endfor') - execute([[ let c.="\n"]]) - execute(' for i in range(1,a:width)') - execute(' let c.=nr2char(screenchar(a:line+1, i))') - execute(' endfor') - execute([[ let c.="\n"]]) - execute(' for i in range(1,a:width)') - execute(' let c.=nr2char(screenchar(a:line+2, i))') - execute(' endfor') - execute(' return c') - execute('endfu') - execute('fu DoRecordScreen()') - execute(' wincmd l') - execute([[ $put =printf(\"\n%s\", g:test)]]) - execute(' $put =g:line1') - execute(' wincmd p') - execute('endfu') - execute('set briopt=min:0') - execute('let g:test="Test 1: Simple breakindent"') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test="Test 2: Simple breakindent + sbr=>>"') - execute('set sbr=>>') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test ="Test 3: Simple breakindent + briopt:sbr"') - execute('set briopt=sbr,min:0 sbr=++') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test ="Test 4: Simple breakindent + min width: 18"') - execute('set sbr= briopt=min:18') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test =" Test 5: Simple breakindent + shift by 2"') - execute('set briopt=shift:2,min:0') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test=" Test 6: Simple breakindent + shift by -1"') - execute('set briopt=shift:-1,min:0') - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - execute('let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"') - execute('set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') - execute('let line1=ScreenChar(line("."),10)') - execute('call DoRecordScreen()') - execute('let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"') - execute('set briopt=shift:1,sbr,min:0 nu sbr=# list lcs&vi') - execute('let line1=ScreenChar(line("."),10)') - execute('call DoRecordScreen()') - execute([[let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"]]) - execute('set briopt-=sbr') - execute('let line1=ScreenChar(line("."),10)') - execute('call DoRecordScreen()') - execute([[let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"]]) - execute('set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') - execute('let line1=ScreenChar(line("."),10)') - execute('call DoRecordScreen()') - execute('wincmd p') - execute([[let g:test="\n Test 11: strdisplaywidth when breakindent is on"]]) - execute('set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') + feed_command('set wildchar=^E') + feed_command('10new') + feed_command('vsp') + feed_command('vert resize 20') + feed_command([[put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"]]) + feed_command('set ts=4 sw=4 sts=4 breakindent') + feed_command('fu! ScreenChar(line, width)') + feed_command(' let c=""') + feed_command(' for i in range(1,a:width)') + feed_command(' let c.=nr2char(screenchar(a:line, i))') + feed_command(' endfor') + feed_command([[ let c.="\n"]]) + feed_command(' for i in range(1,a:width)') + feed_command(' let c.=nr2char(screenchar(a:line+1, i))') + feed_command(' endfor') + feed_command([[ let c.="\n"]]) + feed_command(' for i in range(1,a:width)') + feed_command(' let c.=nr2char(screenchar(a:line+2, i))') + feed_command(' endfor') + feed_command(' return c') + feed_command('endfu') + feed_command('fu DoRecordScreen()') + feed_command(' wincmd l') + feed_command([[ $put =printf(\"\n%s\", g:test)]]) + feed_command(' $put =g:line1') + feed_command(' wincmd p') + feed_command('endfu') + feed_command('set briopt=min:0') + feed_command('let g:test="Test 1: Simple breakindent"') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test="Test 2: Simple breakindent + sbr=>>"') + feed_command('set sbr=>>') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test ="Test 3: Simple breakindent + briopt:sbr"') + feed_command('set briopt=sbr,min:0 sbr=++') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test ="Test 4: Simple breakindent + min width: 18"') + feed_command('set sbr= briopt=min:18') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test =" Test 5: Simple breakindent + shift by 2"') + feed_command('set briopt=shift:2,min:0') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test=" Test 6: Simple breakindent + shift by -1"') + feed_command('set briopt=shift:-1,min:0') + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + feed_command('let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"') + feed_command('set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') + feed_command('let line1=ScreenChar(line("."),10)') + feed_command('call DoRecordScreen()') + feed_command('let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"') + feed_command('set briopt=shift:1,sbr,min:0 nu sbr=# list lcs&vi') + feed_command('let line1=ScreenChar(line("."),10)') + feed_command('call DoRecordScreen()') + feed_command([[let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"]]) + feed_command('set briopt-=sbr') + feed_command('let line1=ScreenChar(line("."),10)') + feed_command('call DoRecordScreen()') + feed_command([[let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"]]) + feed_command('set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') + feed_command('let line1=ScreenChar(line("."),10)') + feed_command('call DoRecordScreen()') + feed_command('wincmd p') + feed_command([[let g:test="\n Test 11: strdisplaywidth when breakindent is on"]]) + feed_command('set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') -- Skip leading tab when calculating text width. - execute('let text=getline(2)') + feed_command('let text=getline(2)') -- Text wraps 3 times. - execute('let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3') - execute('$put =g:test') - execute([[$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)]]) - execute([[let g:str="\t\t\t\t\t{"]]) - execute('let g:test=" Test 12: breakindent + long indent"') - execute('wincmd p') - execute('set all& breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4') - execute('$put =g:str') + feed_command('let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3') + feed_command('$put =g:test') + feed_command([[$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)]]) + feed_command([[let g:str="\t\t\t\t\t{"]]) + feed_command('let g:test=" Test 12: breakindent + long indent"') + feed_command('wincmd p') + feed_command('set all& breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4') + feed_command('$put =g:str') feed('zt') - execute('let line1=ScreenChar(1,10)') - execute('wincmd p') - execute('call DoRecordScreen()') + feed_command('let line1=ScreenChar(1,10)') + feed_command('wincmd p') + feed_command('call DoRecordScreen()') -- Test, that the string " a\tb\tc\td\te" is correctly displayed in a -- 20 column wide window (see bug report -- https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ ). - execute('only') - execute('vert 20new') - execute('set all& breakindent briopt=min:10') - execute([[call setline(1, [" a\tb\tc\td\te", " z y x w v"])]]) - execute([[/^\s*a]]) + feed_command('only') + feed_command('vert 20new') + feed_command('set all& breakindent briopt=min:10') + feed_command([[call setline(1, [" a\tb\tc\td\te", " z y x w v"])]]) + feed_command([[/^\s*a]]) feed('fbgjyl') - execute('let line1 = @0') - execute([[?^\s*z]]) + feed_command('let line1 = @0') + feed_command([[?^\s*z]]) feed('fygjyl') - execute('let line2 = @0') - execute('quit!') - execute([[$put ='Test 13: breakindent with wrapping Tab']]) - execute('$put =line1') - execute('$put =line2') - - execute('let g:test="Test 14: breakindent + visual blockwise delete #1"') - execute('set all& breakindent shada+=nX-test-breakindent.shada') - execute('30vnew') - execute('normal! 3a1234567890') - execute('normal! a abcde') - execute([[exec "normal! 0\<C-V>tex"]]) - execute('let line1=ScreenChar(line("."),8)') - execute('call DoRecordScreen()') - - execute('let g:test="Test 15: breakindent + visual blockwise delete #2"') - execute('%d') - execute('normal! 4a1234567890') - execute([[exec "normal! >>\<C-V>3f0x"]]) - execute('let line1=ScreenChar(line("."),20)') - execute('call DoRecordScreen()') - execute('quit!') + feed_command('let line2 = @0') + feed_command('quit!') + feed_command([[$put ='Test 13: breakindent with wrapping Tab']]) + feed_command('$put =line1') + feed_command('$put =line2') + + feed_command('let g:test="Test 14: breakindent + visual blockwise delete #1"') + feed_command('set all& breakindent shada+=nX-test-breakindent.shada') + feed_command('30vnew') + feed_command('normal! 3a1234567890') + feed_command('normal! a abcde') + feed_command([[exec "normal! 0\<C-V>tex"]]) + feed_command('let line1=ScreenChar(line("."),8)') + feed_command('call DoRecordScreen()') + + feed_command('let g:test="Test 15: breakindent + visual blockwise delete #2"') + feed_command('%d') + feed_command('normal! 4a1234567890') + feed_command([[exec "normal! >>\<C-V>3f0x"]]) + feed_command('let line1=ScreenChar(line("."),20)') + feed_command('call DoRecordScreen()') + feed_command('quit!') -- Assert buffer contents. expect([[ - + abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP - + Test 1: Simple breakindent abcd qrst GHIJ - + Test 2: Simple breakindent + sbr=>> abcd >>qr >>EF - + Test 3: Simple breakindent + briopt:sbr abcd ++ qrst ++ GHIJ - + Test 4: Simple breakindent + min width: 18 abcd qrstuv IJKLMN - + Test 5: Simple breakindent + shift by 2 abcd qr EF - + Test 6: Simple breakindent + shift by -1 abcd qrstu HIJKL - + Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr 2 ab ? m ? x - + Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr 2 ^Iabcd # opq # BCD - + Test 9: breakindent + shift by +1 + 'nu' + sbr=# list 2 ^Iabcd #op #AB - + Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n 2 ab ~ mn ~ yz - + Test 11: strdisplaywidth when breakindent is on strdisplaywidth: 46 == calculated: 64 { - + Test 12: breakindent + long indent 56 @@ -197,12 +197,12 @@ describe('breakindent', function() Test 13: breakindent with wrapping Tab d w - + Test 14: breakindent + visual blockwise delete #1 e ~ ~ - + Test 15: breakindent + visual blockwise delete #2 1234567890 ~ diff --git a/test/functional/legacy/changelist_spec.lua b/test/functional/legacy/changelist_spec.lua index c718da3736..72c9872163 100644 --- a/test/functional/legacy/changelist_spec.lua +++ b/test/functional/legacy/changelist_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('changelist', function() setup(clear) @@ -12,14 +12,14 @@ describe('changelist', function() insert("1\n2") feed('Gkylp') - execute('set ul=100') + feed_command('set ul=100') feed('Gylp') - execute('set ul=100') + feed_command('set ul=100') feed('gg') - execute('vsplit') - execute('try', 'normal g;', 'normal ggVGcpass', 'catch', 'normal ggVGcfail', 'endtry') + feed_command('vsplit') + feed_command('try', 'normal g;', 'normal ggVGcpass', 'catch', 'normal ggVGcfail', 'endtry') expect('pass') end) diff --git a/test/functional/legacy/charsearch_spec.lua b/test/functional/legacy/charsearch_spec.lua index ef3369728d..c1a59c9ee1 100644 --- a/test/functional/legacy/charsearch_spec.lua +++ b/test/functional/legacy/charsearch_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('charsearch', function() setup(clear) @@ -14,23 +14,23 @@ describe('charsearch', function() Zabcdefghijkemnokqretkvwxyz]]) -- Check that "fe" and ";" work. - execute('/^X') + feed_command('/^X') feed('ylfep;;p,,p') -- Check that save/restore works. - execute('/^Y') + feed_command('/^Y') feed('ylfep') - execute('let csave = getcharsearch()') + feed_command('let csave = getcharsearch()') feed('fip') - execute('call setcharsearch(csave)') + feed_command('call setcharsearch(csave)') feed(';p;p') -- Check that setcharsearch() changes the settings. - execute('/^Z') + feed_command('/^Z') feed('ylfep') - execute("call setcharsearch({'char': 'k'})") + feed_command("call setcharsearch({'char': 'k'})") feed(';p') - execute("call setcharsearch({'forward': 0})") + feed_command("call setcharsearch({'forward': 0})") feed('$;p') - execute("call setcharsearch({'until': 1})") + feed_command("call setcharsearch({'until': 1})") feed(';;p') -- Assert buffer contents. diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua index ad1812f22e..9b932e2ef0 100644 --- a/test/functional/legacy/close_count_spec.lua +++ b/test/functional/legacy/close_count_spec.lua @@ -1,133 +1,134 @@ -- Tests for :[count]close! and :[count]hide local helpers = require('test.functional.helpers')(after_each) -local feed, eval, eq, clear, execute = - helpers.feed, helpers.eval, helpers.eq, helpers.clear, helpers.execute + +local eq = helpers.eq +local wait = helpers.wait +local eval = helpers.eval +local feed = helpers.feed +local clear = helpers.clear +local command = helpers.command describe('close_count', function() setup(clear) it('is working', function() - execute('let tests = []') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('4wincmd w') - execute('close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('let tests = []') + command('for i in range(5)|new|endfor') + command('4wincmd w') + command('close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({6, 5, 4, 2, 1}, eval('buffers')) - execute('1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 4, 2, 1}, eval('buffers')) - execute('$close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 4, 2}, eval('buffers')) - execute('1wincmd w') - execute('2close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('2close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 2}, eval('buffers')) - execute('1wincmd w') - execute('new') - execute('new') - execute('2wincmd w') - execute('-1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('new') + command('new') + command('2wincmd w') + command('-1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({7, 5, 2}, eval('buffers')) - execute('2wincmd w') - execute('+1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('2wincmd w') + command('+1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({7, 5}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('only!') + command('b1') + command('let tests = []') + command('for i in range(5)|new|endfor') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({13, 12, 11, 10, 9, 1}, eval('buffers')) - execute('4wincmd w') - execute('.hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('4wincmd w') + command('.hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({13, 12, 11, 9, 1}, eval('buffers')) - execute('1hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 11, 9, 1}, eval('buffers')) - execute('$hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 11, 9}, eval('buffers')) - execute('1wincmd w') - execute('2hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('2hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 9}, eval('buffers')) - execute('1wincmd w') - execute('new') - execute('new') - execute('3wincmd w') - execute('-hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('new') + command('new') + command('3wincmd w') + command('-hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({15, 12, 9}, eval('buffers')) - execute('2wincmd w') - execute('+hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('2wincmd w') + command('+hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({15, 12}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('set hidden') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('1wincmd w') - execute('$ hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('only!') + command('b1') + command('let tests = []') + command('set hidden') + command('for i in range(5)|new|endfor') + command('1wincmd w') + command('$ hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 19, 18, 17, 16}, eval('buffers')) - execute('$-1 close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$-1 close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 19, 18, 16}, eval('buffers')) - execute('1wincmd w') - execute('.+close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('.+close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 18, 16}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('set hidden') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('4wincmd w') + command('only!') + command('b1') + command('let tests = []') + command('set hidden') + command('for i in range(5)|new|endfor') + command('4wincmd w') feed('<C-W>c<cr>') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({25, 24, 23, 21, 1}, eval('buffers')) feed('1<C-W>c<cr>') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 23, 21, 1}, eval('buffers')) feed('9<C-W>c<cr>') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 23, 21}, eval('buffers')) - execute('1wincmd w') + command('1wincmd w') feed('2<C-W>c<cr>') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 21}, eval('buffers')) end) end) diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua index c463ada968..ad5368430a 100644 --- a/test/functional/legacy/command_count_spec.lua +++ b/test/functional/legacy/command_count_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source, expect = helpers.clear, helpers.source, helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command describe('command_count', function() it('is working', function() @@ -87,35 +87,35 @@ describe('command_count', function() arga a b c d ]]) -- This can not be in the source() call as it will produce errors. - execute([[let v:errmsg = '']]) - execute('5argu') - execute([[call add(g:lines, '5argu ' . v:errmsg)]]) - execute('$argu') - execute([[call add(g:lines, '4argu ' . expand('%:t'))]]) - execute([[let v:errmsg = '']]) - execute('1argu') - execute([[call add(g:lines, '1argu ' . expand('%:t'))]]) - execute([[let v:errmsg = '']]) - execute('100b') - execute([[call add(g:lines, '100b ' . v:errmsg)]]) - execute('split') - execute('split') - execute('split') - execute('split') - execute([[let v:errmsg = '']]) - execute('0close') - execute([[call add(g:lines, '0close ' . v:errmsg)]]) - execute('$wincmd w') - execute('$close') - execute([[call add(g:lines, '$close ' . winnr())]]) - execute([[let v:errmsg = '']]) - execute('$+close') - execute([[call add(g:lines, '$+close ' . v:errmsg)]]) - execute('$tabe') - execute([[call add(g:lines, '$tabe ' . tabpagenr())]]) - execute([[let v:errmsg = '']]) - execute('$+tabe') - execute([[call add(g:lines, '$+tabe ' . v:errmsg)]]) + feed_command([[let v:errmsg = '']]) + feed_command('5argu') + feed_command([[call add(g:lines, '5argu ' . v:errmsg)]]) + feed_command('$argu') + feed_command([[call add(g:lines, '4argu ' . expand('%:t'))]]) + feed_command([[let v:errmsg = '']]) + feed_command('1argu') + feed_command([[call add(g:lines, '1argu ' . expand('%:t'))]]) + feed_command([[let v:errmsg = '']]) + feed_command('100b') + feed_command([[call add(g:lines, '100b ' . v:errmsg)]]) + feed_command('split') + feed_command('split') + feed_command('split') + feed_command('split') + feed_command([[let v:errmsg = '']]) + feed_command('0close') + feed_command([[call add(g:lines, '0close ' . v:errmsg)]]) + feed_command('$wincmd w') + feed_command('$close') + feed_command([[call add(g:lines, '$close ' . winnr())]]) + feed_command([[let v:errmsg = '']]) + feed_command('$+close') + feed_command([[call add(g:lines, '$+close ' . v:errmsg)]]) + feed_command('$tabe') + feed_command([[call add(g:lines, '$tabe ' . tabpagenr())]]) + feed_command([[let v:errmsg = '']]) + feed_command('$+tabe') + feed_command([[call add(g:lines, '$+tabe ' . v:errmsg)]]) source([[ only! e x diff --git a/test/functional/legacy/comparators_spec.lua b/test/functional/legacy/comparators_spec.lua index 27879b0f65..32e830a0af 100644 --- a/test/functional/legacy/comparators_spec.lua +++ b/test/functional/legacy/comparators_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq = helpers.clear, helpers.eq -local eval, execute = helpers.eval, helpers.execute +local eval, command = helpers.eval, helpers.command describe('comparators', function() before_each(clear) it('is working', function() - execute('set isident+=#') + command('set isident+=#') eq(1, eval('1 is#1')) end) end) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index cd19e31a79..aeaab335e8 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source -local eq, eval, execute = helpers.eq, helpers.eval, helpers.execute +local eq, eval, command = helpers.eq, helpers.eval, helpers.command if helpers.pending_win32(pending) then return end @@ -8,30 +8,30 @@ describe('Test for delete()', function() before_each(clear) it('file delete', function() - execute('split Xfile') - execute("call setline(1, ['a', 'b'])") - execute('wq') + command('split Xfile') + command("call setline(1, ['a', 'b'])") + command('wq') eq(eval("['a', 'b']"), eval("readfile('Xfile')")) eq(0, eval("delete('Xfile')")) eq(-1, eval("delete('Xfile')")) end) it('directory delete', function() - execute("call mkdir('Xdir1')") + command("call mkdir('Xdir1')") eq(1, eval("isdirectory('Xdir1')")) eq(0, eval("delete('Xdir1', 'd')")) eq(0, eval("isdirectory('Xdir1')")) eq(-1, eval("delete('Xdir1', 'd')")) end) it('recursive delete', function() - execute("call mkdir('Xdir1')") - execute("call mkdir('Xdir1/subdir')") - execute("call mkdir('Xdir1/empty')") - execute('split Xdir1/Xfile') - execute("call setline(1, ['a', 'b'])") - execute('w') - execute('w Xdir1/subdir/Xfile') - execute('close') + command("call mkdir('Xdir1')") + command("call mkdir('Xdir1/subdir')") + command("call mkdir('Xdir1/empty')") + command('split Xdir1/Xfile') + command("call setline(1, ['a', 'b'])") + command('w') + command('w Xdir1/subdir/Xfile') + command('close') eq(1, eval("isdirectory('Xdir1')")) eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')")) @@ -57,8 +57,8 @@ describe('Test for delete()', function() end) it('symlink directory delete', function() - execute("call mkdir('Xdir1')") - execute("silent !ln -s Xdir1 Xlink") + command("call mkdir('Xdir1')") + command("silent !ln -s Xdir1 Xlink") eq(1, eval("isdirectory('Xdir1')")) eq(1, eval("isdirectory('Xlink')")) -- Delete the link, not the directory diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua index 3684fe714d..d7ef508194 100644 --- a/test/functional/legacy/eval_spec.lua +++ b/test/functional/legacy/eval_spec.lua @@ -2,8 +2,11 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, command, expect = helpers.clear, helpers.command, helpers.expect local eq, eval, write_file = helpers.eq, helpers.eval, helpers.write_file +local wait = helpers.wait +local exc_exec = helpers.exc_exec +local dedent = helpers.dedent describe('eval', function() setup(function() @@ -37,17 +40,17 @@ describe('eval', function() end) it(':let', function() - execute('so test_eval_setup.vim') - execute([[let @" = 'abc']]) - execute('AR "') - execute([[let @" = "abc\n"]]) + command('so test_eval_setup.vim') + command([[let @" = 'abc']]) + command('AR "') + command([[let @" = "abc\n"]]) source('AR "') - execute([[let @" = "abc\<C-m>"]]) - execute('AR "') - execute([[let @= = '"abc"']]) - execute('AR =') + command([[let @" = "abc\<C-m>"]]) + command('AR "') + command([[let @= = '"abc"']]) + command('AR =') expect([[ - + ": type v; value: abc (['abc']), expr: abc (['abc']) ": type V; value: abc]].."\000 (['abc']), expr: abc\000"..[[ (['abc']) ": type V; value: abc]].."\r\000 (['abc\r']), expr: abc\r\000 (['abc\r"..[[']) @@ -55,32 +58,33 @@ describe('eval', function() end) it('basic setreg() tests', function() - execute('so test_eval_setup.vim') + command('so test_eval_setup.vim') insert('{{{1 Basic setreg tests') - execute([[call SetReg('a', 'abcA', 'c')]]) - execute([[call SetReg('b', 'abcB', 'v')]]) - execute([[call SetReg('c', 'abcC', 'l')]]) - execute([[call SetReg('d', 'abcD', 'V')]]) - execute([[call SetReg('e', 'abcE', 'b')]]) - execute([[call SetReg('f', 'abcF', "\<C-v>")]]) - execute([[call SetReg('g', 'abcG', 'b10')]]) - execute([[call SetReg('h', 'abcH', "\<C-v>10")]]) - execute([[call SetReg('I', 'abcI')]]) + command([[call SetReg('a', 'abcA', 'c')]]) + command([[call SetReg('b', 'abcB', 'v')]]) + command([[call SetReg('c', 'abcC', 'l')]]) + command([[call SetReg('d', 'abcD', 'V')]]) + command([[call SetReg('e', 'abcE', 'b')]]) + command([[call SetReg('f', 'abcF', "\<C-v>")]]) + command([[call SetReg('g', 'abcG', 'b10')]]) + command([[call SetReg('h', 'abcH', "\<C-v>10")]]) + command([[call SetReg('I', 'abcI')]]) feed('Go{{{1 Appending single lines with setreg()<esc>') - execute([[call SetReg('A', 'abcAc', 'c')]]) - execute([[call SetReg('A', 'abcAl', 'l')]]) - execute([[call SetReg('A', 'abcAc2','c')]]) - execute([[call SetReg('b', 'abcBc', 'ca')]]) - execute([[call SetReg('b', 'abcBb', 'ba')]]) - execute([[call SetReg('b', 'abcBc2','ca')]]) - execute([[call SetReg('b', 'abcBb2','b50a')]]) - execute([[call SetReg('C', 'abcCl', 'l')]]) - execute([[call SetReg('C', 'abcCc', 'c')]]) - execute([[call SetReg('D', 'abcDb', 'b')]]) - execute([[call SetReg('E', 'abcEb', 'b')]]) - execute([[call SetReg('E', 'abcEl', 'l')]]) - execute([[call SetReg('F', 'abcFc', 'c')]]) + wait() + command([[call SetReg('A', 'abcAc', 'c')]]) + command([[call SetReg('A', 'abcAl', 'l')]]) + command([[call SetReg('A', 'abcAc2','c')]]) + command([[call SetReg('b', 'abcBc', 'ca')]]) + command([[call SetReg('b', 'abcBb', 'ba')]]) + command([[call SetReg('b', 'abcBc2','ca')]]) + command([[call SetReg('b', 'abcBb2','b50a')]]) + command([[call SetReg('C', 'abcCl', 'l')]]) + command([[call SetReg('C', 'abcCc', 'c')]]) + command([[call SetReg('D', 'abcDb', 'b')]]) + command([[call SetReg('E', 'abcEb', 'b')]]) + command([[call SetReg('E', 'abcEl', 'l')]]) + command([[call SetReg('F', 'abcFc', 'c')]]) expect([[ {{{1 Basic setreg tests {{{2 setreg('a', 'abcA', 'c') @@ -191,14 +195,14 @@ describe('eval', function() end) it('appending NL with setreg()', function() - execute('so test_eval_setup.vim') - - execute([[call setreg('a', 'abcA2', 'c')]]) - execute([[call setreg('b', 'abcB2', 'v')]]) - execute([[call setreg('c', 'abcC2', 'l')]]) - execute([[call setreg('d', 'abcD2', 'V')]]) - execute([[call setreg('e', 'abcE2', 'b')]]) - execute([[call setreg('f', 'abcF2', "\<C-v>")]]) + command('so test_eval_setup.vim') + + command([[call setreg('a', 'abcA2', 'c')]]) + command([[call setreg('b', 'abcB2', 'v')]]) + command([[call setreg('c', 'abcC2', 'l')]]) + command([[call setreg('d', 'abcD2', 'V')]]) + command([[call setreg('e', 'abcE2', 'b')]]) + command([[call setreg('f', 'abcF2', "\<C-v>")]]) -- These registers where set like this in the old test_eval.in but never -- copied to the output buffer with SetReg(). They do not appear in -- test_eval.ok. Therefore they are commented out. @@ -206,14 +210,14 @@ describe('eval', function() --execute([[call setreg('h', 'abcH2', "\<C-v>10")]]) --execute([[call setreg('I', 'abcI2')]]) - execute([[call SetReg('A', "\n")]]) - execute([[call SetReg('B', "\n", 'c')]]) - execute([[call SetReg('C', "\n")]]) - execute([[call SetReg('D', "\n", 'l')]]) - execute([[call SetReg('E', "\n")]]) - execute([[call SetReg('F', "\n", 'b')]]) + command([[call SetReg('A', "\n")]]) + command([[call SetReg('B', "\n", 'c')]]) + command([[call SetReg('C', "\n")]]) + command([[call SetReg('D', "\n", 'l')]]) + command([[call SetReg('E', "\n")]]) + command([[call SetReg('F', "\n", 'b')]]) expect([[ - + {{{2 setreg('A', ']]..'\000'..[[') A: type V; value: abcA2]].."\000 (['abcA2']), expr: abcA2\000"..[[ (['abcA2']) == @@ -228,19 +232,19 @@ describe('eval', function() C: type V; value: abcC2]].."\000\000 (['abcC2', '']), expr: abcC2\000\000"..[[ (['abcC2', '']) == abcC2 - + == {{{2 setreg('D', ']]..'\000'..[[', 'l') D: type V; value: abcD2]].."\000\000 (['abcD2', '']), expr: abcD2\000\000"..[[ (['abcD2', '']) == abcD2 - + == {{{2 setreg('E', ']]..'\000'..[[') E: type V; value: abcE2]].."\000\000 (['abcE2', '']), expr: abcE2\000\000"..[[ (['abcE2', '']) == abcE2 - + == {{{2 setreg('F', ']]..'\000'..[[', 'b') F: type ]].."\0220; value: abcF2\000 (['abcF2', '']), expr: abcF2\000"..[[ (['abcF2', '']) @@ -250,27 +254,27 @@ describe('eval', function() end) it('setting and appending list with setreg()', function() - execute('so test_eval_setup.vim') - - execute([[$put ='{{{1 Setting lists with setreg()']]) - execute([=[call SetReg('a', ['abcA3'], 'c')]=]) - execute([=[call SetReg('b', ['abcB3'], 'l')]=]) - execute([=[call SetReg('c', ['abcC3'], 'b')]=]) - execute([=[call SetReg('d', ['abcD3'])]=]) - execute([=[call SetReg('e', [1, 2, 'abc', 3])]=]) - execute([=[call SetReg('f', [1, 2, 3])]=]) - - execute([[$put ='{{{1 Appending lists with setreg()']]) - execute([=[call SetReg('A', ['abcA3c'], 'c')]=]) - execute([=[call SetReg('b', ['abcB3l'], 'la')]=]) - execute([=[call SetReg('C', ['abcC3b'], 'lb')]=]) - execute([=[call SetReg('D', ['abcD32'])]=]) - execute([=[call SetReg('A', ['abcA32'])]=]) - execute([=[call SetReg('B', ['abcB3c'], 'c')]=]) - execute([=[call SetReg('C', ['abcC3l'], 'l')]=]) - execute([=[call SetReg('D', ['abcD3b'], 'b')]=]) + command('so test_eval_setup.vim') + + command([[$put ='{{{1 Setting lists with setreg()']]) + command([=[call SetReg('a', ['abcA3'], 'c')]=]) + command([=[call SetReg('b', ['abcB3'], 'l')]=]) + command([=[call SetReg('c', ['abcC3'], 'b')]=]) + command([=[call SetReg('d', ['abcD3'])]=]) + command([=[call SetReg('e', [1, 2, 'abc', 3])]=]) + command([=[call SetReg('f', [1, 2, 3])]=]) + + command([[$put ='{{{1 Appending lists with setreg()']]) + command([=[call SetReg('A', ['abcA3c'], 'c')]=]) + command([=[call SetReg('b', ['abcB3l'], 'la')]=]) + command([=[call SetReg('C', ['abcC3b'], 'lb')]=]) + command([=[call SetReg('D', ['abcD32'])]=]) + command([=[call SetReg('A', ['abcA32'])]=]) + command([=[call SetReg('B', ['abcB3c'], 'c')]=]) + command([=[call SetReg('C', ['abcC3l'], 'l')]=]) + command([=[call SetReg('D', ['abcD3b'], 'b')]=]) expect([[ - + {{{1 Setting lists with setreg() {{{2 setreg('a', ['abcA3'], 'c') a: type v; value: abcA3 (['abcA3']), expr: abcA3 (['abcA3']) @@ -359,9 +363,9 @@ describe('eval', function() -- the next expect() easier to write. This is neccessary because null -- bytes on a line by itself don't play well together with the dedent -- function used in expect(). - execute('%delete') - execute([[$put ='{{{1 Appending lists with NL with setreg()']]) - execute([=[call SetReg('A', ["\n", 'abcA3l2'], 'l')]=]) + command('%delete') + command([[$put ='{{{1 Appending lists with NL with setreg()']]) + command([=[call SetReg('A', ["\n", 'abcA3l2'], 'l')]=]) expect( '\n'.. '{{{1 Appending lists with NL with setreg()\n'.. @@ -374,8 +378,8 @@ describe('eval', function() '\000\n'.. 'abcA3l2\n'.. '==') - execute('%delete') - execute([=[call SetReg('B', ["\n", 'abcB3c2'], 'c')]=]) + command('%delete') + command([=[call SetReg('B', ["\n", 'abcB3c2'], 'c')]=]) expect( '\n'.. "{{{2 setreg('B', ['\000', 'abcB3c2'], 'c')\n".. @@ -386,8 +390,8 @@ describe('eval', function() 'abcB3c\n'.. '\000\n'.. 'abcB3c2=') - execute('%delete') - execute([=[call SetReg('C', ["\n", 'abcC3b2'], 'b')]=]) + command('%delete') + command([=[call SetReg('C', ["\n", 'abcC3b2'], 'b')]=]) expect( '\n'.. "{{{2 setreg('C', ['\000', 'abcC3b2'], 'b')\n".. @@ -398,8 +402,8 @@ describe('eval', function() ' abcC3l\n'.. ' \000\n'.. ' abcC3b2') - execute('%delete') - execute([=[call SetReg('D', ["\n", 'abcD3b50'],'b50')]=]) + command('%delete') + command([=[call SetReg('D', ["\n", 'abcD3b50'],'b50')]=]) expect( '\n'.. "{{{2 setreg('D', ['\000', 'abcD3b50'], 'b50')\n".. @@ -416,8 +420,8 @@ describe('eval', function() -- to make the expect() calls easier to write. Otherwise the null byte can -- make trouble on a line on its own. it('setting lists with NLs with setreg(), part 1', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('a', ['abcA4-0', "\n", "abcA4-2\n", "\nabcA4-3", "abcA4-4\nabcA4-4-2"])]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('a', ['abcA4-0', "\n", "abcA4-2\n", "\nabcA4-3", "abcA4-4\nabcA4-4-2"])]=]) expect( '\n'.. "{{{2 setreg('a', ['abcA4-0', '\000', 'abcA4-2\000', '\000abcA4-3', 'abcA4-4\000abcA4-4-2'])\n".. @@ -432,8 +436,8 @@ describe('eval', function() end) it('setting lists with NLs with setreg(), part 2', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('b', ['abcB4c-0', "\n", "abcB4c-2\n", "\nabcB4c-3", "abcB4c-4\nabcB4c-4-2"], 'c')]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('b', ['abcB4c-0', "\n", "abcB4c-2\n", "\nabcB4c-3", "abcB4c-4\nabcB4c-4-2"], 'c')]=]) expect( '\n'.. "{{{2 setreg('b', ['abcB4c-0', '\000', 'abcB4c-2\000', '\000abcB4c-3', 'abcB4c-4\000abcB4c-4-2'], 'c')\n".. @@ -447,8 +451,8 @@ describe('eval', function() end) it('setting lists with NLs with setreg(), part 3', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('c', ['abcC4l-0', "\n", "abcC4l-2\n", "\nabcC4l-3", "abcC4l-4\nabcC4l-4-2"], 'l')]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('c', ['abcC4l-0', "\n", "abcC4l-2\n", "\nabcC4l-3", "abcC4l-4\nabcC4l-4-2"], 'l')]=]) expect( '\n'.. "{{{2 setreg('c', ['abcC4l-0', '\000', 'abcC4l-2\000', '\000abcC4l-3', 'abcC4l-4\000abcC4l-4-2'], 'l')\n".. @@ -462,8 +466,8 @@ describe('eval', function() '==') end) it('setting lists with NLs with setreg(), part 4', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('d', ['abcD4b-0', "\n", "abcD4b-2\n", "\nabcD4b-3", "abcD4b-4\nabcD4b-4-2"], 'b')]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('d', ['abcD4b-0', "\n", "abcD4b-2\n", "\nabcD4b-3", "abcD4b-4\nabcD4b-4-2"], 'b')]=]) expect( '\n'.. "{{{2 setreg('d', ['abcD4b-0', '\000', 'abcD4b-2\000', '\000abcD4b-3', 'abcD4b-4\000abcD4b-4-2'], 'b')\n".. @@ -476,8 +480,8 @@ describe('eval', function() ' abcD4b-4\000abcD4b-4-2') end) it('setting lists with NLs with setreg(), part 5', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('e', ['abcE4b10-0', "\n", "abcE4b10-2\n", "\nabcE4b10-3", "abcE4b10-4\nabcE4b10-4-2"], 'b10')]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('e', ['abcE4b10-0', "\n", "abcE4b10-2\n", "\nabcE4b10-3", "abcE4b10-4\nabcE4b10-4-2"], 'b10')]=]) expect( '\n'.. "{{{2 setreg('e', ['abcE4b10-0', '\000', 'abcE4b10-2\000', '\000abcE4b10-3', 'abcE4b10-4\000abcE4b10-4-2'], 'b10')\n".. @@ -494,32 +498,32 @@ describe('eval', function() -- Precondition: "a is actually unset and "0 is nonempty eq('', eval("getregtype('a')")) eq('', eval("getreg('a')")) - execute("call setreg('0','text')") + command("call setreg('0','text')") -- This used to return a NULL list -- which setreg didn't handle - execute("let x = getreg('a',1,1)") - execute("call setreg('0',x)") + command("let x = getreg('a',1,1)") + command("call setreg('0',x)") -- nvim didn't crash and "0 was emptied eq(2, eval("1+1")) eq({}, eval("getreg('0',1,1)")) -- x is a mutable list - execute("let y = x") + command("let y = x") eq({}, eval("y")) - execute("call add(x, 'item')") + command("call add(x, 'item')") eq({'item'}, eval("y")) end) it('search and expressions', function() - execute('so test_eval_setup.vim') - execute([=[call SetReg('/', ['abc/'])]=]) - execute([=[call SetReg('/', ["abc/\n"])]=]) - execute([=[call SetReg('=', ['"abc/"'])]=]) - execute([=[call SetReg('=', ["\"abc/\n\""])]=]) + command('so test_eval_setup.vim') + command([=[call SetReg('/', ['abc/'])]=]) + command([=[call SetReg('/', ["abc/\n"])]=]) + command([=[call SetReg('=', ['"abc/"'])]=]) + command([=[call SetReg('=', ["\"abc/\n\""])]=]) expect([[ - + {{{2 setreg('/', ['abc/']) /: type v; value: abc/ (['abc/']), expr: abc/ (['abc/']) == @@ -536,35 +540,35 @@ describe('eval', function() describe('system clipboard', function() before_each(function() - execute('let &runtimepath = "test/functional/fixtures,".&runtimepath') - execute('call getreg("*")') -- force load of provider + command('let &runtimepath = "test/functional/fixtures,".&runtimepath') + command('call getreg("*")') -- force load of provider end) it('works', function() insert([[ Some first line (this text was at the top of the old test_eval.in). - + Note: system clipboard is saved, changed and restored. - + clipboard contents something else]]) - execute('so test_eval_setup.vim') + command('so test_eval_setup.vim') -- Save and restore system clipboard. - execute("let _clipreg = ['*', getreg('*'), getregtype('*')]") - execute('let _clipopt = &cb') - execute("let &cb='unnamed'") - execute('5y') - execute('AR *') - execute('tabdo :windo :echo "hi"') - execute('6y') - execute('AR *') - execute('let &cb=_clipopt') - execute("call call('setreg', _clipreg)") + command("let _clipreg = ['*', getreg('*'), getregtype('*')]") + command('let _clipopt = &cb') + command("let &cb='unnamed'") + command('5y') + command('AR *') + command('tabdo :windo :echo "hi"') + command('6y') + command('AR *') + command('let &cb=_clipopt') + command("call call('setreg', _clipreg)") expect([[ Some first line (this text was at the top of the old test_eval.in). - + Note: system clipboard is saved, changed and restored. - + clipboard contents something else *: type V; value: clipboard contents]]..'\00'..[[ (['clipboard contents']), expr: clipboard contents]]..'\00'..[[ (['clipboard contents']) @@ -582,17 +586,17 @@ describe('eval', function() $put =v:exception endtry endfun]]) - execute([[call ErrExe('call setreg()')]]) - execute([[call ErrExe('call setreg(1)')]]) - execute([[call ErrExe('call setreg(1, 2, 3, 4)')]]) - execute([=[call ErrExe('call setreg([], 2)')]=]) - execute([[call ErrExe('call setreg(1, {})')]]) - execute([=[call ErrExe('call setreg(1, 2, [])')]=]) - execute([=[call ErrExe('call setreg("/", ["1", "2"])')]=]) - execute([=[call ErrExe('call setreg("=", ["1", "2"])')]=]) - execute([=[call ErrExe('call setreg(1, ["", "", [], ""])')]=]) + command([[call ErrExe('call setreg()')]]) + command([[call ErrExe('call setreg(1)')]]) + command([[call ErrExe('call setreg(1, 2, 3, 4)')]]) + command([=[call ErrExe('call setreg([], 2)')]=]) + command([[call ErrExe('call setreg(1, {})')]]) + command([=[call ErrExe('call setreg(1, 2, [])')]=]) + command([=[call ErrExe('call setreg("/", ["1", "2"])')]=]) + command([=[call ErrExe('call setreg("=", ["1", "2"])')]=]) + command([=[call ErrExe('call setreg(1, ["", "", [], ""])')]=]) expect([[ - + Executing call setreg() Vim(call):E119: Not enough arguments for function: setreg Executing call setreg(1) @@ -614,48 +618,38 @@ describe('eval', function() end) it('function name not starting with a capital', function() - execute('try') - execute(' func! g:test()') - execute(' echo "test"') - execute(' endfunc') - execute('catch') - execute(' let tmp = v:exception') - execute('endtry') - eq('Vim(function):E128: Function name must start with a capital or "s:": g:test()', eval('tmp')) + eq('Vim(function):E128: Function name must start with a capital or "s:": g:test()\\nendfunction', + exc_exec(dedent([[ + function! g:test() + endfunction]]))) end) it('Function name followed by #', function() - execute('try') - execute(' func! test2() "#') - execute(' echo "test2"') - execute(' endfunc') - execute('catch') - execute(' let tmp = v:exception') - execute('endtry') - eq('Vim(function):E128: Function name must start with a capital or "s:": test2() "#', eval('tmp')) + eq('Vim(function):E128: Function name must start with a capital or "s:": test2() "#\\nendfunction', + exc_exec(dedent([[ + function! test2() "# + endfunction]]))) end) it('function name includes a colon', function() - execute('try') - execute(' func! b:test()') - execute(' echo "test"') - execute(' endfunc') - execute('catch') - execute(' let tmp = v:exception') - execute('endtry') - eq('Vim(function):E128: Function name must start with a capital or "s:": b:test()', eval('tmp')) + eq('Vim(function):E128: Function name must start with a capital or "s:": b:test()\\nendfunction', + exc_exec(dedent([[ + function! b:test() + endfunction]]))) end) it('function name starting with/without "g:", buffer-local funcref', function() - execute('function! g:Foo(n)') - execute(" $put ='called Foo(' . a:n . ')'") - execute('endfunction') - execute("let b:my_func = function('Foo')") - execute('call b:my_func(1)') - execute('echo g:Foo(2)') - execute('echo Foo(3)') + command([[ + function! g:Foo(n) + $put ='called Foo(' . a:n . ')' + endfunction + ]]) + command("let b:my_func = function('Foo')") + command('call b:my_func(1)') + command('echo g:Foo(2)') + command('echo Foo(3)') expect([[ - + called Foo(1) called Foo(2) called Foo(3)]]) @@ -664,20 +658,20 @@ describe('eval', function() it('script-local function used in Funcref must exist', function() source([[ " Vim script used in test_eval.in. Needed for script-local function. - + func! s:Testje() return "foo" endfunc - + let Bar = function('s:Testje') - + $put ='s:Testje exists: ' . exists('s:Testje') $put ='func s:Testje exists: ' . exists('*s:Testje') $put ='Bar exists: ' . exists('Bar') $put ='func Bar exists: ' . exists('*Bar') ]]) expect([[ - + s:Testje exists: 0 func s:Testje exists: 1 Bar exists: 1 @@ -685,12 +679,8 @@ describe('eval', function() end) it("using $ instead of '$' must give an error", function() - execute('try') - execute(" call append($, 'foobar')") - execute('catch') - execute(' let tmp = v:exception') - execute('endtry') - eq('Vim(call):E116: Invalid arguments for function append', eval('tmp')) + eq('Vim(call):E116: Invalid arguments for function append', + exc_exec('call append($, "foobar")')) end) it('getcurpos/setpos', function() @@ -699,13 +689,16 @@ describe('eval', function() 012345678 start:]]) - execute('/^012345678') + command('/^012345678') feed('6l') - execute('let sp = getcurpos()') + wait() + command('let sp = getcurpos()') feed('0') - execute("call setpos('.', sp)") + wait() + command("call setpos('.', sp)") feed('jyl') - execute('$put') + wait() + command('$put') expect([[ 012345678 012345678 @@ -715,18 +708,18 @@ describe('eval', function() end) it('substring and variable name', function() - execute("let str = 'abcdef'") - execute('let n = 3') + command("let str = 'abcdef'") + command('let n = 3') eq('def', eval('str[n:]')) eq('abcd', eval('str[:n]')) eq('d', eval('str[n:n]')) - execute('unlet n') - execute('let nn = 3') + command('unlet n') + command('let nn = 3') eq('def', eval('str[nn:]')) eq('abcd', eval('str[:nn]')) eq('d', eval('str[nn:nn]')) - execute('unlet nn') - execute('let b:nn = 4') + command('unlet nn') + command('let b:nn = 4') eq('ef', eval('str[b:nn:]')) eq('abcde', eval('str[:b:nn]')) eq('e', eval('str[b:nn:b:nn]')) diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua index 1e9e832536..801451b300 100644 --- a/test/functional/legacy/fixeol_spec.lua +++ b/test/functional/legacy/fixeol_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed = helpers.feed -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect if helpers.pending_win32(pending) then return end @@ -25,38 +25,38 @@ describe('fixeol', function() it('is working', function() -- First write two test files – with and without trailing EOL. -- Use Unix fileformat for consistency. - execute('set ff=unix') - execute('enew!') + feed_command('set ff=unix') + feed_command('enew!') feed('awith eol<esc>:w! XXEol<cr>') - execute('enew!') - execute('set noeol nofixeol') + feed_command('enew!') + feed_command('set noeol nofixeol') feed('awithout eol<esc>:w! XXNoEol<cr>') - execute('set eol fixeol') - execute('bwipe XXEol XXNoEol') + feed_command('set eol fixeol') + feed_command('bwipe XXEol XXNoEol') -- Try editing files with 'fixeol' disabled. - execute('e! XXEol') + feed_command('e! XXEol') feed('ostays eol<esc>:set nofixeol<cr>') - execute('w! XXTestEol') - execute('e! XXNoEol') + feed_command('w! XXTestEol') + feed_command('e! XXNoEol') feed('ostays without<esc>:set nofixeol<cr>') - execute('w! XXTestNoEol') - execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol') - execute('set fixeol') + feed_command('w! XXTestNoEol') + feed_command('bwipe XXEol XXNoEol XXTestEol XXTestNoEol') + feed_command('set fixeol') -- Append "END" to each file so that we can see what the last written char was. feed('ggdGaEND<esc>:w >>XXEol<cr>') - execute('w >>XXNoEol') - execute('w >>XXTestEol') - execute('w >>XXTestNoEol') + feed_command('w >>XXNoEol') + feed_command('w >>XXTestEol') + feed_command('w >>XXTestNoEol') -- Concatenate the results. - execute('e! test.out') + feed_command('e! test.out') feed('a0<esc>:$r XXEol<cr>') - execute('$r XXNoEol') + feed_command('$r XXNoEol') feed('Go1<esc>:$r XXTestEol<cr>') - execute('$r XXTestNoEol') - execute('w') + feed_command('$r XXTestNoEol') + feed_command('w') -- Assert buffer contents. expect([=[ diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua index 1b65f1ce95..12875460e0 100644 --- a/test/functional/legacy/function_sort_spec.lua +++ b/test/functional/legacy/function_sort_spec.lua @@ -1,10 +1,11 @@ local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear + local eq = helpers.eq +local neq = helpers.neq local eval = helpers.eval -local execute = helpers.execute +local clear = helpers.clear +local source = helpers.source local exc_exec = helpers.exc_exec -local neq = helpers.neq describe('sort', function() before_each(clear) @@ -31,14 +32,17 @@ describe('sort', function() end) it('ability to call sort() from a compare function', function() - execute('func Compare1(a, b) abort') - execute([[call sort(range(3), 'Compare2')]]) - execute('return a:a - a:b') - execute('endfunc') - - execute('func Compare2(a, b) abort') - execute('return a:a - a:b') - execute('endfunc') + source([[ + function Compare1(a, b) abort + call sort(range(3), 'Compare2') + return a:a - a:b + endfunc + + function Compare2(a, b) abort + return a:a - a:b + endfunc + ]]) + eq({1, 3, 5}, eval("sort([3, 1, 5], 'Compare1')")) end) diff --git a/test/functional/legacy/getcwd_spec.lua b/test/functional/legacy/getcwd_spec.lua index dcb56eb242..8fb31ccd22 100644 --- a/test/functional/legacy/getcwd_spec.lua +++ b/test/functional/legacy/getcwd_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local eq, eval, source = helpers.eq, helpers.eval, helpers.source -local call, clear, execute = helpers.call, helpers.clear, helpers.execute +local call, clear, command = helpers.call, helpers.clear, helpers.command if helpers.pending_win32(pending) then return end @@ -39,48 +39,48 @@ describe('getcwd', function() return bufname . ' ' . dirname . ' ' . lflag endfunction ]]) - execute('new') - execute('let cwd=getcwd()') + command('new') + command('let cwd=getcwd()') call('mkdir', 'Xtopdir') - execute('silent cd Xtopdir') + command('silent cd Xtopdir') call('mkdir', 'Xdir1') call('mkdir', 'Xdir2') call('mkdir', 'Xdir3') - execute('new a') - execute('new b') - execute('new c') - execute('3wincmd w') - execute('silent lcd Xdir1') + command('new a') + command('new b') + command('new c') + command('3wincmd w') + command('silent lcd Xdir1') eq('a Xdir1 1', eval('GetCwdInfo(0, 0)')) - execute('wincmd W') + command('wincmd W') eq('b Xtopdir 0', eval('GetCwdInfo(0, 0)')) - execute('wincmd W') - execute('silent lcd Xdir3') + command('wincmd W') + command('silent lcd Xdir3') eq('c Xdir3 1', eval('GetCwdInfo(0, 0)')) eq('a Xdir1 1', eval('GetCwdInfo(bufwinnr("a"), 0)')) eq('b Xtopdir 0', eval('GetCwdInfo(bufwinnr("b"), 0)')) eq('c Xdir3 1', eval('GetCwdInfo(bufwinnr("c"), 0)')) - execute('wincmd W') + command('wincmd W') eq('a Xdir1 1', eval('GetCwdInfo(bufwinnr("a"), tabpagenr())')) eq('b Xtopdir 0', eval('GetCwdInfo(bufwinnr("b"), tabpagenr())')) eq('c Xdir3 1', eval('GetCwdInfo(bufwinnr("c"), tabpagenr())')) - execute('tabnew x') - execute('new y') - execute('new z') - execute('3wincmd w') + command('tabnew x') + command('new y') + command('new z') + command('3wincmd w') eq('x Xtopdir 0', eval('GetCwdInfo(0, 0)')) - execute('wincmd W') - execute('silent lcd Xdir2') + command('wincmd W') + command('silent lcd Xdir2') eq('y Xdir2 1', eval('GetCwdInfo(0, 0)')) - execute('wincmd W') - execute('silent lcd Xdir3') + command('wincmd W') + command('silent lcd Xdir3') eq('z Xdir3 1', eval('GetCwdInfo(0, 0)')) eq('x Xtopdir 0', eval('GetCwdInfo(bufwinnr("x"), 0)')) eq('y Xdir2 1', eval('GetCwdInfo(bufwinnr("y"), 0)')) eq('z Xdir3 1', eval('GetCwdInfo(bufwinnr("z"), 0)')) - execute('let tp_nr = tabpagenr()') - execute('tabrewind') + command('let tp_nr = tabpagenr()') + command('tabrewind') eq('x Xtopdir 0', eval('GetCwdInfo(3, tp_nr)')) eq('y Xdir2 1', eval('GetCwdInfo(2, tp_nr)')) eq('z Xdir3 1', eval('GetCwdInfo(1, tp_nr)')) diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua index 82e7e3010f..029d95206e 100644 --- a/test/functional/legacy/glob2regpat_spec.lua +++ b/test/functional/legacy/glob2regpat_spec.lua @@ -1,16 +1,15 @@ -- Tests for signs local helpers = require('test.functional.helpers')(after_each) -local clear, execute = helpers.clear, helpers.execute -local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval +local clear, exc_exec = helpers.clear, helpers.exc_exec +local eq, eval = helpers.eq, helpers.eval describe('glob2regpat()', function() before_each(clear) it('handles invalid input', function() - execute('call glob2regpat(1.33)') - helpers.feed('<cr>') - neq(nil, string.find(eval('v:errmsg'), '^E806:')) + eq('Vim(call):E806: using Float as a String', + exc_exec('call glob2regpat(1.33)')) end) it('returns ^$ for empty input', function() eq('^$', eval("glob2regpat('')")) diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua index a76718ed8e..15273a4ad5 100644 --- a/test/functional/legacy/increment_spec.lua +++ b/test/functional/legacy/increment_spec.lua @@ -1,7 +1,7 @@ -- Tests for using Ctrl-A/Ctrl-X on visual selections local helpers = require('test.functional.helpers')(after_each) -local source, execute = helpers.source, helpers.execute +local source, command = helpers.source, helpers.command local call, clear = helpers.call, helpers.clear local eq, nvim = helpers.eq, helpers.meths @@ -742,14 +742,14 @@ describe('Ctrl-A/Ctrl-X on visual selections', function() local id = string.format('%02d', i) it('works on Test ' .. id, function() - execute('set nrformats&vi') -- &vi makes Vim compatible + command('set nrformats&vi') -- &vi makes Vim compatible call('Test_visual_increment_' .. id) eq({}, nvim.get_vvar('errors')) end) end it('does not drop leading zeroes', function() - execute('set nrformats&vi') -- &vi makes Vim compatible + command('set nrformats&vi') -- &vi makes Vim compatible call('Test_normal_increment_01') eq({}, nvim.get_vvar('errors')) end) diff --git a/test/functional/legacy/insertcount_spec.lua b/test/functional/legacy/insertcount_spec.lua index 3142f040b3..e53c9dc6ce 100644 --- a/test/functional/legacy/insertcount_spec.lua +++ b/test/functional/legacy/insertcount_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed_command, expect = helpers.feed_command, helpers.expect describe('insertcount', function() setup(clear) @@ -13,7 +13,7 @@ describe('insertcount', function() Second line Last line]]) - execute('/Second') + feed_command('/Second') feed('4gro') expect([[ diff --git a/test/functional/legacy/join_spec.lua b/test/functional/legacy/join_spec.lua index 3c4da8119c..d683d25eb0 100644 --- a/test/functional/legacy/join_spec.lua +++ b/test/functional/legacy/join_spec.lua @@ -2,19 +2,19 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq = helpers.clear, helpers.eq -local eval, execute = helpers.eval, helpers.execute +local eval, command = helpers.eval, helpers.command describe('joining lines', function() before_each(clear) it('is working', function() - execute('new') - execute([[call setline(1, ['one', 'two', 'three', 'four'])]]) - execute('normal J') + command('new') + command([[call setline(1, ['one', 'two', 'three', 'four'])]]) + command('normal J') eq('one two', eval('getline(1)')) - execute('%del') - execute([[call setline(1, ['one', 'two', 'three', 'four'])]]) - execute('normal 10J') + command('%del') + command([[call setline(1, ['one', 'two', 'three', 'four'])]]) + command('normal 10J') eq('one two three four', eval('getline(1)')) end) end) diff --git a/test/functional/legacy/lispwords_spec.lua b/test/functional/legacy/lispwords_spec.lua index 2ec51dca1b..57d8d51377 100644 --- a/test/functional/legacy/lispwords_spec.lua +++ b/test/functional/legacy/lispwords_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq = helpers.eq local eval = helpers.eval -local execute = helpers.execute +local command = helpers.command local source = helpers.source describe('lispwords', function() @@ -17,7 +17,7 @@ describe('lispwords', function() eq('bar,baz,quux', eval('&l:lispwords')) eq('bar,baz,quux', eval('&lispwords')) - execute('setlocal lispwords<') + command('setlocal lispwords<') eq('foo,bar,baz', eval('&g:lispwords')) eq('foo,bar,baz', eval('&l:lispwords')) eq('foo,bar,baz', eval('&lispwords')) diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua index d2838cddb6..3c0fa48e76 100644 --- a/test/functional/legacy/listchars_spec.lua +++ b/test/functional/legacy/listchars_spec.lua @@ -2,12 +2,12 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe("'listchars'", function() before_each(function() clear() - execute('set listchars&vi') + feed_command('set listchars&vi') end) it("works with 'list'", function() @@ -26,14 +26,14 @@ describe("'listchars'", function() dd ee ]]) - execute('let g:lines = []') + feed_command('let g:lines = []') -- Set up 'listchars', switch on 'list', and use the "GG" mapping to record -- what the buffer lines look like. - execute('set listchars+=tab:>-,space:.,trail:<') - execute('set list') - execute('/^start:/') - execute('normal! jzt') + feed_command('set listchars+=tab:>-,space:.,trail:<') + feed_command('set list') + feed_command('/^start:/') + feed_command('normal! jzt') feed('GG<cr>') feed('GG<cr>') feed('GG<cr>') @@ -41,7 +41,7 @@ describe("'listchars'", function() feed('GGH') -- Repeat without displaying "trail" spaces. - execute('set listchars-=trail:<') + feed_command('set listchars-=trail:<') feed('GG<cr>') feed('GG<cr>') feed('GG<cr>') @@ -49,8 +49,8 @@ describe("'listchars'", function() feed('GG') -- Delete the buffer contents and :put the collected lines. - execute('%d') - execute('put =g:lines', '1d') + feed_command('%d') + feed_command('put =g:lines', '1d') -- Assert buffer contents. expect([[ @@ -76,21 +76,21 @@ describe("'listchars'", function() -- Set up 'listchars', switch 'list' *off* (:list must show the 'listchars' -- even when 'list' is off), then run :list and collect the output. - execute('set listchars+=tab:>-,space:.,trail:<') - execute('set nolist') - execute('/^start:/') - execute('redir! => g:lines') - execute('+1,$list') - execute('redir END') + feed_command('set listchars+=tab:>-,space:.,trail:<') + feed_command('set nolist') + feed_command('/^start:/') + feed_command('redir! => g:lines') + feed_command('+1,$list') + feed_command('redir END') -- Delete the buffer contents and :put the collected lines. - execute('%d') - execute('put =g:lines', '1d') + feed_command('%d') + feed_command('put =g:lines', '1d') -- Assert buffer contents. expect([[ - - + + ..fff>--<<$ >-------gg>-----$ .....h>-$ diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua index eb979edc69..d39125c9e6 100644 --- a/test/functional/legacy/listlbr_spec.lua +++ b/test/functional/legacy/listlbr_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('listlbr', function() setup(clear) @@ -11,13 +11,13 @@ describe('listlbr', function() insert([[ dummy text]]) - execute('set wildchar=^E') - execute('10new') - execute('vsp') - execute('vert resize 20') - execute([[put =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]]) - execute('norm! zt') - execute('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap') + feed_command('set wildchar=^E') + feed_command('10new') + feed_command('vsp') + feed_command('vert resize 20') + feed_command([[put =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]]) + feed_command('norm! zt') + feed_command('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap') source([[ fu! ScreenChar(width) let c='' @@ -36,128 +36,128 @@ describe('listlbr', function() wincmd p endfu ]]) - execute('let g:test="Test 1: set linebreak"') - execute('redraw!') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') - - execute('let g:test="Test 2: set linebreak + set list"') - execute('set linebreak list listchars=') - execute('redraw!') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') - - execute('let g:test ="Test 3: set linebreak nolist"') - execute('set nolist linebreak') - execute('redraw!') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') - - execute('let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"') - execute('set nolist linebreak ts=8') - execute([[let line="1\t".repeat('a', winwidth(0)-2)]]) - execute('$put =line') - execute('$') - execute('norm! zt') - execute('redraw!') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') - execute([[let line="_S_\t bla"]]) - execute('$put =line') - execute('$') - execute('norm! zt') - - execute('let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"') - execute('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab') - execute('syn match ConcealVar contained /_/ conceal') - execute('syn match All /.*/ contains=ConcealVar') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') - execute('set cpo&vim linebreak') - - execute('let g:test ="Test 6: set linebreak with visual block mode"') - execute('let line="REMOVE: this not"') - execute('$put =g:test') - execute('$put =line') - execute('let line="REMOVE: aaaaaaaaaaaaa"') - execute('$put =line') - execute('1/^REMOVE:') + feed_command('let g:test="Test 1: set linebreak"') + feed_command('redraw!') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') + + feed_command('let g:test="Test 2: set linebreak + set list"') + feed_command('set linebreak list listchars=') + feed_command('redraw!') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') + + feed_command('let g:test ="Test 3: set linebreak nolist"') + feed_command('set nolist linebreak') + feed_command('redraw!') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') + + feed_command('let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"') + feed_command('set nolist linebreak ts=8') + feed_command([[let line="1\t".repeat('a', winwidth(0)-2)]]) + feed_command('$put =line') + feed_command('$') + feed_command('norm! zt') + feed_command('redraw!') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') + feed_command([[let line="_S_\t bla"]]) + feed_command('$put =line') + feed_command('$') + feed_command('norm! zt') + + feed_command('let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"') + feed_command('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab') + feed_command('syn match ConcealVar contained /_/ conceal') + feed_command('syn match All /.*/ contains=ConcealVar') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') + feed_command('set cpo&vim linebreak') + + feed_command('let g:test ="Test 6: set linebreak with visual block mode"') + feed_command('let line="REMOVE: this not"') + feed_command('$put =g:test') + feed_command('$put =line') + feed_command('let line="REMOVE: aaaaaaaaaaaaa"') + feed_command('$put =line') + feed_command('1/^REMOVE:') feed('0<C-V>jf x') - execute('$put') - execute('set cpo&vim linebreak') + feed_command('$put') + feed_command('set cpo&vim linebreak') - execute('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"') - execute('$put =g:test') + feed_command('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"') + feed_command('$put =g:test') feed('Golong line: <esc>40afoobar <esc>aTARGET at end<esc>') - execute([[exe "norm! $3B\<C-v>eAx\<Esc>"]]) - execute('set cpo&vim linebreak sbr=') + feed_command([[exe "norm! $3B\<C-v>eAx\<Esc>"]]) + feed_command('set cpo&vim linebreak sbr=') - execute('let g:test ="Test 8: set linebreak with visual char mode and changing block"') - execute('$put =g:test') + feed_command('let g:test ="Test 8: set linebreak with visual char mode and changing block"') + feed_command('$put =g:test') feed('Go1111-1111-1111-11-1111-1111-1111<esc>0f-lv3lc2222<esc>bgj.') - execute('let g:test ="Test 9: using redo after block visual mode"') - execute('$put =g:test') + feed_command('let g:test ="Test 9: using redo after block visual mode"') + feed_command('$put =g:test') feed('Go<CR>') feed('aaa<CR>') feed('aaa<CR>') feed('a<ESC>2k<C-V>2j~e.<CR>') - execute('let g:test ="Test 10: using normal commands after block-visual"') - execute('$put =g:test') - execute('set linebreak') + feed_command('let g:test ="Test 10: using normal commands after block-visual"') + feed_command('$put =g:test') + feed_command('set linebreak') feed('Go<cr>') feed('abcd{ef<cr>') feed('ghijklm<cr>') feed('no}pqrs<esc>2k0f{<C-V><C-V>c%<esc>') - execute('let g:test ="Test 11: using block replace mode after wrapping"') - execute('$put =g:test') - execute('set linebreak wrap') + feed_command('let g:test ="Test 11: using block replace mode after wrapping"') + feed_command('$put =g:test') + feed_command('set linebreak wrap') feed('Go<esc>150aa<esc>yypk147|<C-V>jr0<cr>') - execute('let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"') - execute('set list listchars=space:_,trail:-,tab:>-,eol:$') - execute('$put =g:test') - execute([[let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "]]) - execute('$put =line') - execute('$') - execute('norm! zt') - execute('redraw!') - execute('let line=ScreenChar(winwidth(0))') - execute('call DoRecordScreen()') + feed_command('let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"') + feed_command('set list listchars=space:_,trail:-,tab:>-,eol:$') + feed_command('$put =g:test') + feed_command([[let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "]]) + feed_command('$put =line') + feed_command('$') + feed_command('norm! zt') + feed_command('redraw!') + feed_command('let line=ScreenChar(winwidth(0))') + feed_command('call DoRecordScreen()') -- Assert buffer contents. expect([[ - + abcdef hijklmn pqrstuvwxyz_1060ABCDEFGHIJKLMNOP - + Test 1: set linebreak abcdef +hijklmn +pqrstuvwxyz_1060ABC +DEFGHIJKLMNOP - + Test 2: set linebreak + set list ^Iabcdef hijklmn^I +pqrstuvwxyz_1060ABC +DEFGHIJKLMNOP - + Test 3: set linebreak nolist abcdef +hijklmn +pqrstuvwxyz_1060ABC +DEFGHIJKLMNOP 1 aaaaaaaaaaaaaaaaaa - + Test 4: set linebreak with tab and 1 line as long as screen: should break! 1 +aaaaaaaaaaaaaaaaaa ~ ~ _S_ bla - + Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated) Sabbbbbb bla ~ @@ -173,19 +173,19 @@ describe('listlbr', function() Test 8: set linebreak with visual char mode and changing block 1111-2222-1111-11-1111-2222-1111 Test 9: using redo after block visual mode - + AaA AaA A Test 10: using normal commands after block-visual - + abcdpqrs Test 11: using block replace mode after wrapping aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$ a aaaaaaaaaaaaaaaaaaaaaa a - + Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$ a_ aaaaaaaaaaaaaaaaaaaa diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 1712219d04..56a5652184 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect, wait = helpers.execute, helpers.expect, helpers.wait +local feed_command, expect, wait = helpers.feed_command, helpers.expect, helpers.wait describe('mapping', function() before_each(clear) @@ -13,7 +13,7 @@ describe('mapping', function() ]]) -- Abbreviations with р (0x80) should work. - execute('inoreab чкпр vim') + feed_command('inoreab чкпр vim') feed('GAчкпр <esc>') expect([[ @@ -23,61 +23,61 @@ describe('mapping', function() it('Ctrl-c works in Insert mode', function() -- Mapping of ctrl-c in insert mode - execute('set cpo-=< cpo-=k') - execute('inoremap <c-c> <ctrl-c>') - execute('cnoremap <c-c> dummy') - execute('cunmap <c-c>') + feed_command('set cpo-=< cpo-=k') + feed_command('inoremap <c-c> <ctrl-c>') + feed_command('cnoremap <c-c> dummy') + feed_command('cunmap <c-c>') feed('GA<cr>') feed('TEST2: CTRL-C |') wait() feed('<c-c>A|<cr><esc>') wait() - execute('unmap <c-c>') - execute('unmap! <c-c>') + feed_command('unmap <c-c>') + feed_command('unmap! <c-c>') expect([[ - + TEST2: CTRL-C |<ctrl-c>A| ]]) end) it('Ctrl-c works in Visual mode', function() - execute([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]]) + feed_command([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]]) feed('GV') -- XXX: For some reason the mapping is only triggered -- when <C-c> is in a separate feed command. wait() feed('<c-c>') - execute('vunmap <c-c>') + feed_command('vunmap <c-c>') expect([[ - + vmap works]]) end) it('langmap', function() -- langmap should not get remapped in insert mode. - execute('inoremap { FAIL_ilangmap') - execute('set langmap=+{ langnoremap') + feed_command('inoremap { FAIL_ilangmap') + feed_command('set langmap=+{ langnoremap') feed('o+<esc>') -- Insert mode expr mapping with langmap. - execute('inoremap <expr> { "FAIL_iexplangmap"') + feed_command('inoremap <expr> { "FAIL_iexplangmap"') feed('o+<esc>') -- langmap should not get remapped in cmdline mode. - execute('cnoremap { FAIL_clangmap') + feed_command('cnoremap { FAIL_clangmap') feed('o+<esc>') - execute('cunmap {') + feed_command('cunmap {') -- cmdline mode expr mapping with langmap. - execute('cnoremap <expr> { "FAIL_cexplangmap"') + feed_command('cnoremap <expr> { "FAIL_cexplangmap"') feed('o+<esc>') - execute('cunmap {') + feed_command('cunmap {') -- Assert buffer contents. expect([[ - + + + + @@ -91,10 +91,10 @@ describe('mapping', function() ]]) -- Vim's issue #212 (feedkeys insert mapping at current position) - execute('nnoremap . :call feedkeys(".", "in")<cr>') + feed_command('nnoremap . :call feedkeys(".", "in")<cr>') feed('/^a b<cr>') feed('0qqdw.ifoo<esc>qj0@q<esc>') - execute('unmap .') + feed_command('unmap .') expect([[ fooc d fooc d @@ -103,23 +103,23 @@ describe('mapping', function() it('i_CTRL-G_U', function() -- <c-g>U<cursor> works only within a single line - execute('imapclear') - execute('imap ( ()<c-g>U<left>') + feed_command('imapclear') + feed_command('imap ( ()<c-g>U<left>') feed('G2o<esc>ki<cr>Test1: text with a (here some more text<esc>k.') -- test undo feed('G2o<esc>ki<cr>Test2: text wit a (here some more text [und undo]<c-g>u<esc>k.u') - execute('imapclear') - execute('set whichwrap=<,>,[,]') + feed_command('imapclear') + feed_command('set whichwrap=<,>,[,]') feed('G3o<esc>2k') - execute([[:exe ":norm! iTest3: text with a (parenthesis here\<C-G>U\<Right>new line here\<esc>\<up>\<up>."]]) + feed_command([[:exe ":norm! iTest3: text with a (parenthesis here\<C-G>U\<Right>new line here\<esc>\<up>\<up>."]]) expect([[ - - + + Test1: text with a (here some more text) Test1: text with a (here some more text) - - + + Test2: text wit a (here some more text [und undo]) new line here Test3: text with a (parenthesis here diff --git a/test/functional/legacy/marks_spec.lua b/test/functional/legacy/marks_spec.lua index 6ecba70f08..bcec179ca2 100644 --- a/test/functional/legacy/marks_spec.lua +++ b/test/functional/legacy/marks_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('marks', function() before_each(function() @@ -9,14 +9,14 @@ describe('marks', function() it('restores a deleted mark after delete-undo-redo-undo', function() insert([[ - + textline A textline B textline C - + Results:]]) - execute([[:/^\t/+1]]) + feed_command([[:/^\t/+1]]) feed([[maddu<C-R>u]]) source([[ let g:a = string(getpos("'a")) @@ -24,11 +24,11 @@ describe('marks', function() ]]) expect([=[ - + textline A textline B textline C - + Results: Mark after delete-undo-redo-undo: [0, 3, 2, 0]]=]) end) diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua index be9b66ee38..7a2ba1ecf2 100644 --- a/test/functional/legacy/nested_function_spec.lua +++ b/test/functional/legacy/nested_function_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, insert = helpers.clear, helpers.insert -local execute, expect, source = helpers.execute, helpers.expect, helpers.source +local command, expect, source = helpers.command, helpers.expect, helpers.source describe('test_nested_function', function() setup(clear) @@ -36,7 +36,7 @@ describe('test_nested_function', function() : endfunction : call s:{fn}() :endfunction]]) - execute('call NestedFunc()') + command('call NestedFunc()') -- Assert buffer contents. expect([[ diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 2d851819e3..c280888dda 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -1,7 +1,7 @@ -- Tests for 'packpath' and :packadd local helpers = require('test.functional.helpers')(after_each) -local clear, source, execute = helpers.clear, helpers.source, helpers.execute +local clear, source, command = helpers.clear, helpers.source, helpers.command local call, eq, nvim = helpers.call, helpers.eq, helpers.meths local feed = helpers.feed @@ -263,12 +263,12 @@ describe('packadd', function() [2] = {bold = true, reverse = true} }) - execute([[let optdir1 = &packpath . '/pack/mine/opt']]) - execute([[let optdir2 = &packpath . '/pack/candidate/opt']]) - execute([[call mkdir(optdir1 . '/pluginA', 'p')]]) - execute([[call mkdir(optdir1 . '/pluginC', 'p')]]) - execute([[call mkdir(optdir2 . '/pluginB', 'p')]]) - execute([[call mkdir(optdir2 . '/pluginC', 'p')]]) + command([[let optdir1 = &packpath . '/pack/mine/opt']]) + command([[let optdir2 = &packpath . '/pack/candidate/opt']]) + command([[call mkdir(optdir1 . '/pluginA', 'p')]]) + command([[call mkdir(optdir1 . '/pluginC', 'p')]]) + command([[call mkdir(optdir2 . '/pluginB', 'p')]]) + command([[call mkdir(optdir2 . '/pluginC', 'p')]]) end) it('works', function() diff --git a/test/functional/legacy/search_mbyte_spec.lua b/test/functional/legacy/search_mbyte_spec.lua index a5a5822a45..a365f79cdf 100644 --- a/test/functional/legacy/search_mbyte_spec.lua +++ b/test/functional/legacy/search_mbyte_spec.lua @@ -1,6 +1,10 @@ local helpers = require('test.functional.helpers')(after_each) + +local wait = helpers.wait +local clear = helpers.clear local insert = helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local expect = helpers.expect +local command = helpers.command describe('search_mbyte', function() before_each(clear) @@ -8,17 +12,18 @@ describe('search_mbyte', function() it("search('multi-byte char', 'bce')", function() insert([=[ Results: - + Test bce: A]=]) + wait() - execute('/^Test bce:/+1') - execute([[$put =search('A', 'bce', line('.'))]]) + command('/^Test bce:/+1') + command([[$put =search('A', 'bce', line('.'))]]) -- Assert buffer contents. expect([=[ Results: - + Test bce: A 4]=]) diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua index 7d4b7a3734..60f1edcd3f 100644 --- a/test/functional/legacy/searchpos_spec.lua +++ b/test/functional/legacy/searchpos_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local call = helpers.call local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local eq = helpers.eq local eval = helpers.eval local insert = helpers.insert @@ -19,7 +19,7 @@ describe('searchpos', function() call('cursor', 1, 2) eq({2, 1, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) - execute('set cpo-=c') + command('set cpo-=c') call('cursor', 1, 2) eq({1, 2, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) call('cursor', 1, 3) diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua index 11f371569d..deb268b1e8 100644 --- a/test/functional/legacy/set_spec.lua +++ b/test/functional/legacy/set_spec.lua @@ -1,30 +1,30 @@ -- Tests for :set local helpers = require('test.functional.helpers')(after_each) -local clear, execute, eval, eq = - helpers.clear, helpers.execute, helpers.eval, helpers.eq +local clear, command, eval, eq = + helpers.clear, helpers.command, helpers.eval, helpers.eq describe(':set', function() before_each(clear) it('handles backslash properly', function() - execute('set iskeyword=a,b,c') - execute('set iskeyword+=d') + command('set iskeyword=a,b,c') + command('set iskeyword+=d') eq('a,b,c,d', eval('&iskeyword')) - execute([[set iskeyword+=\\,e]]) + command([[set iskeyword+=\\,e]]) eq([[a,b,c,d,\,e]], eval('&iskeyword')) - execute('set iskeyword-=e') + command('set iskeyword-=e') eq([[a,b,c,d,\]], eval('&iskeyword')) - execute([[set iskeyword-=\]]) + command([[set iskeyword-=\]]) eq('a,b,c,d', eval('&iskeyword')) end) it('recognizes a trailing comma with +=', function() - execute('set wildignore=*.png,') - execute('set wildignore+=*.jpg') + command('set wildignore=*.png,') + command('set wildignore+=*.jpg') eq('*.png,*.jpg', eval('&wildignore')) end) end) diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua index e80a32455a..0e65edbcf8 100644 --- a/test/functional/legacy/signs_spec.lua +++ b/test/functional/legacy/signs_spec.lua @@ -1,23 +1,23 @@ -- Tests for signs local helpers = require('test.functional.helpers')(after_each) -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, command, expect = helpers.clear, helpers.command, helpers.expect describe('signs', function() setup(clear) it('is working', function() - execute('sign define JumpSign text=x') - execute([[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]]) + command('sign define JumpSign text=x') + command([[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]]) -- Split the window to the bottom to verify :sign-jump will stay in the current -- window if the buffer is displayed there. - execute('bot split') - execute([[exe 'sign jump 42 buffer=' . bufnr('')]]) - execute([[call append(line('$'), winnr())]]) + command('bot split') + command([[exe 'sign jump 42 buffer=' . bufnr('')]]) + command([[call append(line('$'), winnr())]]) -- Assert buffer contents. expect([[ - + 2]]) end) end) diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua index 15a93e3819..96f655cc41 100644 --- a/test/functional/legacy/textobjects_spec.lua +++ b/test/functional/legacy/textobjects_spec.lua @@ -1,14 +1,14 @@ local helpers = require('test.functional.helpers')(after_each) local call = helpers.call local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local expect = helpers.expect local source = helpers.source describe('Text object', function() before_each(function() clear() - execute('set shada=') + command('set shada=') source([[ function SelectionOut(data) new @@ -27,7 +27,7 @@ describe('Text object', function() end) it('Test for vi) without cpo-M', function() - execute('set cpo-=M') + command('set cpo-=M') call('SelectionOut', '(red \\(blue) green)') expect([[ @@ -38,7 +38,7 @@ describe('Text object', function() end) it('Test for vi) with cpo-M #1', function() - execute('set cpo+=M') + command('set cpo+=M') call('SelectionOut', '(red \\(blue) green)') expect([[ @@ -49,7 +49,7 @@ describe('Text object', function() end) it('Test for vi) with cpo-M #2', function() - execute('set cpo+=M') + command('set cpo+=M') call('SelectionOut', '(red (blue\\) green)') expect([[ diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index 4d4f55b9eb..02de6ab735 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -2,9 +2,10 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect local eq, eval = helpers.eq, helpers.eval local source = helpers.source +local wait = helpers.wait describe('utf8', function() before_each(clear) @@ -12,16 +13,17 @@ describe('utf8', function() it('is working', function() insert('start:') - execute('new') - execute('call setline(1, ["aaa", "あああ", "bbb"])') + command('new') + command('call setline(1, ["aaa", "あああ", "bbb"])') -- Visual block Insert adjusts for multi-byte char feed('gg0l<C-V>jjIx<Esc>') + wait() - execute('let r = getline(1, "$")') - execute('bwipeout!') - execute('$put=r') - execute('call garbagecollect(1)') + command('let r = getline(1, "$")') + command('bwipeout!') + command('$put=r') + command('call garbagecollect(1)') expect([[ start: @@ -75,7 +77,7 @@ describe('utf8', function() feed(":Test3 <C-L>'<C-B>$put='<CR>") expect([[ - + Test1 Test2 あた Test3 N]]) diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua index 171ec3de92..5412903866 100644 --- a/test/functional/legacy/wordcount_spec.lua +++ b/test/functional/legacy/wordcount_spec.lua @@ -2,8 +2,9 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute = helpers.clear, helpers.execute +local clear, command = helpers.clear, helpers.command local eq, eval = helpers.eq, helpers.eval +local wait = helpers.wait if helpers.pending_win32(pending) then return end @@ -11,14 +12,13 @@ describe('wordcount', function() before_each(clear) it('is working', function() - execute('set selection=inclusive') - execute('fileformat=unix') - execute('fileformats=unix') + command('set selection=inclusive fileformat=unix fileformats=unix') insert([=[ RESULT test:]=]) + wait() - execute('new') + command('new') source([=[ function DoRecordWin(...) wincmd k @@ -59,7 +59,7 @@ describe('wordcount', function() ) -- Test 2: some words, cursor at start - execute([[call PutInWindow('one two three')]]) + command([[call PutInWindow('one two three')]]) eq(eval('DoRecordWin([1, 1, 0])'), eval([=[ [['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}] @@ -67,7 +67,7 @@ describe('wordcount', function() ) -- Test 3: some words, cursor at end - execute([[call PutInWindow('one two three')]]) + command([[call PutInWindow('one two three')]]) eq(eval('DoRecordWin([2, 99, 0])'), eval([=[ [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}] @@ -75,17 +75,17 @@ describe('wordcount', function() ) -- Test 4: some words, cursor at end, ve=all - execute('set ve=all') - execute([[call PutInWindow('one two three')]]) + command('set ve=all') + command([[call PutInWindow('one two three')]]) eq(eval('DoRecordWin([2,99,0])'), eval([=[ [['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}] ]=]) ) - execute('set ve=') + command('set ve=') -- Test 5: several lines with words - execute([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=]) + command([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=]) eq(eval('DoRecordWin([4,99,0])'), eval([=[ [['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}] @@ -93,21 +93,21 @@ describe('wordcount', function() ) -- Test 6: one line with BOM set - execute([[call PutInWindow('one two three')]]) - execute('wincmd k') - execute('set bomb') - execute('wincmd j') + command([[call PutInWindow('one two three')]]) + command('wincmd k') + command('set bomb') + command('wincmd j') eq(eval('DoRecordWin([2,99,0])'), eval([=[ [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}] ]=]) ) - execute('wincmd k') - execute('set nobomb') - execute('wincmd j') + command('wincmd k') + command('set nobomb') + command('wincmd j') -- Test 7: one line with multibyte words - execute([=[call PutInWindow(['Äne M¤ne Müh'])]=]) + command([=[call PutInWindow(['Äne M¤ne Müh'])]=]) eq(eval('DoRecordWin([2,99,0])'), eval([=[ [['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}] @@ -115,7 +115,7 @@ describe('wordcount', function() ) -- Test 8: several lines with multibyte words - execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) + command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) eq(eval('DoRecordWin([3,99,0])'), eval([=[ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}] @@ -123,15 +123,16 @@ describe('wordcount', function() ) -- Test 9: visual mode, complete buffer - execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) - execute('wincmd k') - execute('set ls=2 stl=%{STL()}') + command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) + command('wincmd k') + command('set ls=2 stl=%{STL()}') -- -- Start visual mode quickly and select complete buffer. - execute('0') + command('0') feed('V2jy<cr>') - execute('set stl= ls=1') - execute('let log=DoRecordWin([3,99,0])') - execute('let log[1]=g:visual_stat') + wait() + command('set stl= ls=1') + command('let log=DoRecordWin([3,99,0])') + command('let log[1]=g:visual_stat') eq(eval('log'), eval([=[ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}] @@ -139,15 +140,16 @@ describe('wordcount', function() ) -- Test 10: visual mode (empty) - execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) - execute('wincmd k') - execute('set ls=2 stl=%{STL()}') + command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) + command('wincmd k') + command('set ls=2 stl=%{STL()}') -- Start visual mode quickly and select complete buffer. - execute('0') + command('0') feed('v$y<cr>') - execute('set stl= ls=1') - execute('let log=DoRecordWin([3,99,0])') - execute('let log[1]=g:visual_stat') + wait() + command('set stl= ls=1') + command('let log=DoRecordWin([3,99,0])') + command('let log[1]=g:visual_stat') eq(eval('log'), eval([=[ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}] @@ -155,15 +157,16 @@ describe('wordcount', function() ) -- Test 11: visual mode, single line - execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) - execute('wincmd k') - execute('set ls=2 stl=%{STL()}') + command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=]) + command('wincmd k') + command('set ls=2 stl=%{STL()}') -- Start visual mode quickly and select complete buffer. - execute('2') + command('2') feed('0v$y<cr>') - execute('set stl= ls=1') - execute('let log=DoRecordWin([3,99,0])') - execute('let log[1]=g:visual_stat') + wait() + command('set stl= ls=1') + command('let log=DoRecordWin([3,99,0])') + command('let log[1]=g:visual_stat') eq(eval('log'), eval([=[ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}] diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua index 765d373b82..4d54e07d6a 100644 --- a/test/functional/legacy/writefile_spec.lua +++ b/test/functional/legacy/writefile_spec.lua @@ -1,23 +1,23 @@ -- Tests for writefile() local helpers = require('test.functional.helpers')(after_each) -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, command, expect = helpers.clear, helpers.command, helpers.expect describe('writefile', function() setup(clear) it('is working', function() - execute('%delete _') - execute('let f = tempname()') - execute('call writefile(["over","written"], f, "b")') - execute('call writefile(["hello","world"], f, "b")') - execute('call writefile(["!", "good"], f, "a")') - execute('call writefile(["morning"], f, "ab")') - execute('call writefile(["", "vimmers"], f, "ab")') - execute('bwipeout!') - execute('$put =readfile(f)') - execute('1 delete _') - execute('call delete(f)') + command('%delete _') + command('let f = tempname()') + command('call writefile(["over","written"], f, "b")') + command('call writefile(["hello","world"], f, "b")') + command('call writefile(["!", "good"], f, "a")') + command('call writefile(["morning"], f, "ab")') + command('call writefile(["", "vimmers"], f, "ab")') + command('bwipeout!') + command('$put =readfile(f)') + command('1 delete _') + command('call delete(f)') -- Assert buffer contents. expect([[ diff --git a/test/functional/normal/count_spec.lua b/test/functional/normal/count_spec.lua index 700e1f3e81..94f741250a 100644 --- a/test/functional/normal/count_spec.lua +++ b/test/functional/normal/count_spec.lua @@ -4,13 +4,13 @@ local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command describe('v:count/v:count1', function() before_each(function() clear() - execute('map <silent> _x :<C-u>let g:count = "v:count=". v:count .", v:count1=". v:count1<CR>') + command('map <silent> _x :<C-u>let g:count = "v:count=". v:count .", v:count1=". v:count1<CR>') end) describe('in cmdwin', function() diff --git a/test/functional/normal/fold_spec.lua b/test/functional/normal/fold_spec.lua index fc055c4e7a..85e4631b61 100644 --- a/test/functional/normal/fold_spec.lua +++ b/test/functional/normal/fold_spec.lua @@ -4,7 +4,7 @@ local clear = helpers.clear local insert = helpers.insert local feed = helpers.feed local expect = helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command local funcs = helpers.funcs local foldlevel = funcs.foldlevel local foldclosedend = funcs.foldclosedend @@ -13,7 +13,7 @@ local eq = helpers.eq describe('Folds', function() local tempfname = 'Xtest-fold.txt' clear() - before_each(function() execute('enew!') end) + before_each(function() feed_command('enew!') end) after_each(function() os.remove(tempfname) end) it('manual folding adjusts with filter', function() insert([[ @@ -37,8 +37,8 @@ describe('Folds', function() 18 19 20]]) - execute('4,$fold', '%foldopen', '10,$fold', '%foldopen') - execute('1,8! cat') + feed_command('4,$fold', '%foldopen', '10,$fold', '%foldopen') + feed_command('1,8! cat') feed('5ggzdzMGdd') expect([[ 1 @@ -54,13 +54,13 @@ describe('Folds', function() describe('adjusting folds after :move', function() local function manually_fold_indent() -- setting foldmethod twice is a trick to get vim to set the folds for me - execute('set foldmethod=indent', 'set foldmethod=manual') + feed_command('set foldmethod=indent', 'set foldmethod=manual') -- Ensure that all folds will get closed (makes it easier to test the -- length of folds). - execute('set foldminlines=0') + feed_command('set foldminlines=0') -- Start with all folds open (so :move ranges aren't affected by closed -- folds). - execute('%foldopen!') + feed_command('%foldopen!') end local function get_folds() @@ -75,16 +75,16 @@ describe('Folds', function() -- This test is easy because we just need to ensure that the resulting -- fold is the same as calculated when creating folds from scratch. insert(insert_string) - execute(move_command) + feed_command(move_command) local after_move_folds = get_folds() -- Doesn't change anything, but does call foldUpdateAll() - execute('set foldminlines=0') + feed_command('set foldminlines=0') eq(after_move_folds, get_folds()) -- Set up the buffer with insert_string for the manual fold testing. - execute('enew!') + feed_command('enew!') insert(insert_string) manually_fold_indent() - execute(move_command) + feed_command(move_command) end it('neither closes nor corrupts folds', function() @@ -246,8 +246,8 @@ a]], '2,3m0') a a ]]) - execute('set foldmethod=indent', '2', '%foldopen') - execute('read ' .. tempfname) + feed_command('set foldmethod=indent', '2', '%foldopen') + feed_command('read ' .. tempfname) -- Just to check we have the correct file text. expect([[ a @@ -281,7 +281,7 @@ a]], '2,3m0') a a ]]) - execute('set foldmethod=indent', '3,5d') + feed_command('set foldmethod=indent', '3,5d') eq(5, funcs.foldclosedend(1)) end) it("doesn't combine folds that have a specified end", function() @@ -295,7 +295,7 @@ a]], '2,3m0') }}} ]]) - execute('set foldmethod=marker', '3,5d', '%foldclose') + feed_command('set foldmethod=marker', '3,5d', '%foldclose') eq(2, funcs.foldclosedend(1)) end) it('splits folds according to >N and <N with foldexpr', function() @@ -331,8 +331,8 @@ a]], '2,3m0') a a ]]) - execute('set foldmethod=expr', 'set foldexpr=TestFoldExpr(v:lnum)', '2', 'foldopen') - execute('read ' .. tempfname, '%foldclose') + feed_command('set foldmethod=expr', 'set foldexpr=TestFoldExpr(v:lnum)', '2', 'foldopen') + feed_command('read ' .. tempfname, '%foldclose') eq(2, funcs.foldclosedend(1)) eq(0, funcs.foldlevel(3)) eq(0, funcs.foldlevel(4)) diff --git a/test/functional/normal/lang_spec.lua b/test/functional/normal/lang_spec.lua new file mode 100644 index 0000000000..464b85d684 --- /dev/null +++ b/test/functional/normal/lang_spec.lua @@ -0,0 +1,59 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, insert, eq = helpers.clear, helpers.insert, helpers.eq +local execute, expect = helpers.execute, helpers.expect +local feed, eval = helpers.feed, helpers.eval +local exc_exec = helpers.exc_exec + +describe('gu and gU', function() + before_each(clear) + + it('works in any locale with default casemap', function() + eq('internal,keepascii', eval('&casemap')) + insert("iI") + feed("VgU") + expect("II") + feed("Vgu") + expect("ii") + end) + + describe('works in Turkish locale', function() + if helpers.pending_win32(pending) then return end + + clear() + if eval('has("mac")') ~= 0 then + pending("not yet on macOS", function() end) + return + end + + local err = exc_exec('lang ctype tr_TR.UTF-8') + if err ~= 0 then + pending("Locale tr_TR.UTF-8 not supported", function() end) + return + end + + before_each(function() + execute('lang ctype tr_TR.UTF-8') + end) + + it('with default casemap', function() + eq('internal,keepascii', eval('&casemap')) + -- expect ASCII behavior + insert("iI") + feed("VgU") + expect("II") + feed("Vgu") + expect("ii") + end) + + it('with casemap=""', function() + execute('set casemap=') + -- expect Turkish locale behavior + insert("iI") + feed("VgU") + expect("İI") + feed("Vgu") + expect("iı") + end) + + end) +end) diff --git a/test/functional/normal/put_spec.lua b/test/functional/normal/put_spec.lua index b3162364a6..148a35ec6b 100644 --- a/test/functional/normal/put_spec.lua +++ b/test/functional/normal/put_spec.lua @@ -8,23 +8,23 @@ local expect = helpers.expect local eq = helpers.eq local map = helpers.map local filter = helpers.filter -local execute = helpers.execute +local feed_command = helpers.feed_command local curbuf_contents = helpers.curbuf_contents local funcs = helpers.funcs local dedent = helpers.dedent local getreg = funcs.getreg local function reset() - execute('enew!') + feed_command('enew!') insert([[ Line of words 1 Line of words 2]]) - execute('goto 1') + feed_command('goto 1') feed('itest_string.<esc>u') funcs.setreg('a', 'test_stringa', 'V') funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b') funcs.setreg('"', 'test_string"', 'v') - execute('set virtualedit=') + feed_command('set virtualedit=') end -- We check the last inserted register ". in each of these tests because it is @@ -164,7 +164,7 @@ describe('put command', function() local function create_put_action(command_base, substitution) local temp_val = command_base:gsub('put', substitution) return function() - execute(temp_val) + feed_command(temp_val) return true end end @@ -642,7 +642,7 @@ describe('put command', function() -- Set curswant to '8' to be at the end of the tab character -- This is where the cursor is put back after the 'u' command. funcs.setpos('.', {0, 2, 1, 0, 8}) - execute('set autoindent') + feed_command('set autoindent') end ) end) @@ -653,7 +653,7 @@ describe('put command', function() test_stringx" Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end) end) @@ -664,7 +664,7 @@ describe('put command', function() Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 1, 16, 1, 17}) end, true) end) @@ -829,7 +829,7 @@ describe('put command', function() 'vp', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end, nil, @@ -844,7 +844,7 @@ describe('put command', function() base_expect_string, 'vp', function() - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 1, 16, 2, 18}) end, true, @@ -906,7 +906,7 @@ describe('put command', function() end) it('should ring the bell when deleting if not appropriate', function() - execute('goto 2') + feed_command('goto 2') feed('i<bs><esc>') expect([[ ine of words 1 @@ -921,7 +921,7 @@ describe('put command', function() end) it("should be unaffected by 'autoindent' with V\".2p", function() - execute('set autoindent') + feed_command('set autoindent') feed('i test_string.<esc>u') feed('V".2p') expect([[ diff --git a/test/functional/normal/undo_spec.lua b/test/functional/normal/undo_spec.lua index 55429f2e1e..a023ca3d90 100644 --- a/test/functional/normal/undo_spec.lua +++ b/test/functional/normal/undo_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local expect = helpers.expect local feed = helpers.feed local insert = helpers.insert @@ -23,7 +23,7 @@ describe('u CTRL-R g- g+', function() end local function undo_and_redo(hist_pos, undo, redo, expect_str) - execute('enew!') + command('enew!') create_history(hist_pos) local cur_contents = helpers.curbuf_contents() feed(undo) diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index f57fe5fa23..f43d8eeafa 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local meths = helpers.meths -local execute = helpers.execute +local command = helpers.command local clear = helpers.clear local eval = helpers.eval local eq = helpers.eq @@ -25,7 +25,7 @@ describe('startup defaults', function() local function expect_filetype(expected) local screen = Screen.new(48, 4) screen:attach() - execute('filetype') + command('filetype') screen:expect([[ ^ | ~ | diff --git a/test/functional/options/pastetoggle_spec.lua b/test/functional/options/pastetoggle_spec.lua index e449df31f5..ec3c60fe37 100644 --- a/test/functional/options/pastetoggle_spec.lua +++ b/test/functional/options/pastetoggle_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local feed = helpers.feed -local execute = helpers.execute +local command = helpers.command local eq = helpers.eq local eval = helpers.eval local sleep = helpers.sleep @@ -10,8 +10,8 @@ local sleep = helpers.sleep describe("'pastetoggle' option", function() before_each(function() clear() - execute('set nopaste') - execute('set pastetoggle=a') + command('set nopaste') + command('set pastetoggle=a') end) it("toggles 'paste'", function() eq(eval('&paste'), 0) @@ -23,8 +23,8 @@ describe("'pastetoggle' option", function() it("multiple key 'pastetoggle' is waited for", function() eq(eval('&paste'), 0) local pastetoggle = 'lllll' - execute('set pastetoggle=' .. pastetoggle) - execute('set timeoutlen=1', 'set ttimoutlen=10000') + command('set pastetoggle=' .. pastetoggle) + command('set timeoutlen=1 ttimeoutlen=10000') feed(pastetoggle:sub(0, 2)) -- sleep() for long enough that vgetorpeek() is gotten into, but short -- enough that ttimeoutlen is not reached. diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua index 22e8a39b79..99a574ec46 100644 --- a/test/functional/options/shortmess_spec.lua +++ b/test/functional/options/shortmess_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, execute = helpers.clear, helpers.execute +local clear, feed_command = helpers.clear, helpers.feed_command if helpers.pending_win32(pending) then return end @@ -19,7 +19,7 @@ describe("'shortmess'", function() describe('"F" flag', function() it('hides messages about the files read', function() - execute('e test') + feed_command('e test') screen:expect([[ ^ | ~ | @@ -27,8 +27,8 @@ describe("'shortmess'", function() ~ | "test" is a directory | ]]) - execute('set shortmess=F') - execute('e test') + feed_command('set shortmess=F') + feed_command('e test') screen:expect([[ ^ | ~ | diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 52dc008707..644cd46092 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -1,6 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local plugin_helpers = require('test.functional.plugin.helpers') +local command = helpers.command + describe('health.vim', function() before_each(function() plugin_helpers.reset() @@ -8,7 +10,7 @@ describe('health.vim', function() -- health#broken#check() -- health#success1#check() -- health#success2#check() - helpers.execute("set runtimepath+=test/functional/fixtures") + command("set runtimepath+=test/functional/fixtures") end) it("reports", function() @@ -43,7 +45,7 @@ describe('health.vim', function() describe(":CheckHealth", function() it("concatenates multiple reports", function() - helpers.execute("CheckHealth success1 success2") + command("CheckHealth success1 success2") helpers.expect([[ health#success1#check @@ -62,7 +64,7 @@ describe('health.vim', function() end) it("gracefully handles broken healthcheck", function() - helpers.execute("CheckHealth broken") + command("CheckHealth broken") helpers.expect([[ health#broken#check @@ -74,7 +76,7 @@ describe('health.vim', function() end) it("gracefully handles invalid healthcheck", function() - helpers.execute("CheckHealth non_existent_healthcheck") + command("CheckHealth non_existent_healthcheck") helpers.expect([[ health#non_existent_healthcheck#check diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua index 3e1ab70daf..51ec7e4870 100644 --- a/test/functional/plugin/matchparen_spec.lua +++ b/test/functional/plugin/matchparen_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local plugin_helpers = require('test.functional.plugin.helpers') local Screen = require('test.functional.ui.screen') -local execute = helpers.execute +local command = helpers.command local meths = helpers.meths local feed = helpers.feed local eq = helpers.eq @@ -23,7 +23,7 @@ describe('matchparen', function() end) it('uses correct column after i_<Up>. Vim patch 7.4.1296', function() - execute('set noautoindent nosmartindent nocindent laststatus=0') + command('set noautoindent nosmartindent nocindent laststatus=0') eq(1, meths.get_var('loaded_matchparen')) feed('ivoid f_test()<cr>') feed('{<cr>') diff --git a/test/functional/spell/spellfile_spec.lua b/test/functional/spell/spellfile_spec.lua new file mode 100644 index 0000000000..e7cd10d2ac --- /dev/null +++ b/test/functional/spell/spellfile_spec.lua @@ -0,0 +1,108 @@ +local helpers = require('test.functional.helpers')(after_each) +local lfs = require('lfs') + +local eq = helpers.eq +local clear = helpers.clear +local meths = helpers.meths +local exc_exec = helpers.exc_exec +local write_file = helpers.write_file + +local testdir = 'Xtest-functional-spell-spellfile.d' + +describe('spellfile', function() + before_each(function() + clear() + lfs.mkdir(testdir) + lfs.mkdir(testdir .. '/spell') + end) + after_each(function() + lfs.rmdir(testdir) + end) + -- ┌ Magic string (#VIMSPELLMAGIC) + -- │ ┌ Spell file version (#VIMSPELLVERSION) + local spellheader = 'VIMspell\050' + it('errors out when prefcond section is truncated', function() + meths.set_option('runtimepath', testdir) + write_file(testdir .. '/spell/en.ascii.spl', + -- ┌ Section identifier (#SN_PREFCOND) + -- │ ┌ Section flags (#SNF_REQUIRED or zero) + -- │ │ ┌ Section length (4 bytes, MSB first) + spellheader .. '\003\001\000\000\000\003' + -- ┌ Number of regexes in section (2 bytes, MSB first) + -- │ ┌ Condition length (1 byte) + -- │ │ ┌ Condition regex (missing!) + .. '\000\001\001') + meths.set_option('spelllang', 'en') + eq('Vim(set):E758: Truncated spell file', + exc_exec('set spell')) + end) + it('errors out when prefcond regexp contains NUL byte', function() + meths.set_option('runtimepath', testdir) + write_file(testdir .. '/spell/en.ascii.spl', + -- ┌ Section identifier (#SN_PREFCOND) + -- │ ┌ Section flags (#SNF_REQUIRED or zero) + -- │ │ ┌ Section length (4 bytes, MSB first) + spellheader .. '\003\001\000\000\000\008' + -- ┌ Number of regexes in section (2 bytes, MSB first) + -- │ ┌ Condition length (1 byte) + -- │ │ ┌ Condition regex + -- │ │ │ ┌ End of sections marker + .. '\000\001\005ab\000cd\255' + -- ┌ LWORDTREE tree length (4 bytes) + -- │ ┌ KWORDTREE tree length (4 bytes) + -- │ │ ┌ PREFIXTREE tree length + .. '\000\000\000\000\000\000\000\000\000\000\000\000') + meths.set_option('spelllang', 'en') + eq('Vim(set):E759: Format error in spell file', + exc_exec('set spell')) + end) + it('errors out when region contains NUL byte', function() + meths.set_option('runtimepath', testdir) + write_file(testdir .. '/spell/en.ascii.spl', + -- ┌ Section identifier (#SN_REGION) + -- │ ┌ Section flags (#SNF_REQUIRED or zero) + -- │ │ ┌ Section length (4 bytes, MSB first) + spellheader .. '\000\001\000\000\000\008' + -- ┌ Regions ┌ End of sections marker + .. '01234\00067\255' + -- ┌ LWORDTREE tree length (4 bytes) + -- │ ┌ KWORDTREE tree length (4 bytes) + -- │ │ ┌ PREFIXTREE tree length + .. '\000\000\000\000\000\000\000\000\000\000\000\000') + meths.set_option('spelllang', 'en') + eq('Vim(set):E759: Format error in spell file', + exc_exec('set spell')) + end) + it('errors out when SAL section contains NUL byte', function() + meths.set_option('runtimepath', testdir) + write_file(testdir .. '/spell/en.ascii.spl', + -- ┌ Section identifier (#SN_SAL) + -- │ ┌ Section flags (#SNF_REQUIRED or zero) + -- │ │ ┌ Section length (4 bytes, MSB first) + spellheader .. '\005\001\000\000\000\008' + -- ┌ salflags + -- │ ┌ salcount (2 bytes, MSB first) + -- │ │ ┌ salfromlen (1 byte) + -- │ │ │ ┌ Special character + -- │ │ │ │┌ salfrom (should not contain NUL) + -- │ │ │ ││ ┌ saltolen + -- │ │ │ ││ │ ┌ salto + -- │ │ │ ││ │ │┌ End of sections marker + .. '\000\000\001\0024\000\0017\255' + -- ┌ LWORDTREE tree length (4 bytes) + -- │ ┌ KWORDTREE tree length (4 bytes) + -- │ │ ┌ PREFIXTREE tree length + .. '\000\000\000\000\000\000\000\000\000\000\000\000') + meths.set_option('spelllang', 'en') + eq('Vim(set):E759: Format error in spell file', + exc_exec('set spell')) + end) + it('errors out when spell header contains NUL bytes', function() + meths.set_option('runtimepath', testdir) + write_file(testdir .. '/spell/en.ascii.spl', + spellheader:sub(1, -3) .. '\000\000') + meths.set_option('spelllang', 'en') + eq('Vim(set):E757: This does not look like a spell file', + exc_exec('set spell')) + end) +end) diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 129390a7a5..48b8512bf0 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local wait = helpers.wait -local eval, execute, source = helpers.eval, helpers.execute, helpers.source +local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source local eq, neq = helpers.eq, helpers.neq local write_file = helpers.write_file @@ -13,7 +13,7 @@ describe('terminal buffer', function() before_each(function() clear() - execute('set modifiable swapfile undolevels=20') + feed_command('set modifiable swapfile undolevels=20') wait() screen = thelpers.screen_setup() end) @@ -86,7 +86,7 @@ describe('terminal buffer', function() it('sends data to the terminal when the "put" operator is used', function() feed('<c-\\><c-n>gg"ayj') - execute('let @a = "appended " . @a') + feed_command('let @a = "appended " . @a') feed('"ap"ap') screen:expect([[ ^tty ready | @@ -112,8 +112,8 @@ describe('terminal buffer', function() it('sends data to the terminal when the ":put" command is used', function() feed('<c-\\><c-n>gg"ayj') - execute('let @a = "appended " . @a') - execute('put a') + feed_command('let @a = "appended " . @a') + feed_command('put a') screen:expect([[ ^tty ready | appended tty ready | @@ -124,7 +124,7 @@ describe('terminal buffer', function() :put a | ]]) -- line argument is only used to move the cursor - execute('6put a') + feed_command('6put a') screen:expect([[ tty ready | appended tty ready | @@ -147,7 +147,7 @@ describe('terminal buffer', function() {4:~ }| :bd! | ]]) - execute('bnext') + feed_command('bnext') screen:expect([[ ^ | {4:~ }| @@ -162,7 +162,7 @@ describe('terminal buffer', function() it('handles loss of focus gracefully', function() -- Change the statusline to avoid printing the file name, which varies. nvim('set_option', 'statusline', '==========') - execute('set laststatus=0') + feed_command('set laststatus=0') -- Save the buffer number of the terminal for later testing. local tbuf = eval('bufnr("%")') @@ -191,16 +191,16 @@ describe('terminal buffer', function() ]]) neq(tbuf, eval('bufnr("%")')) - execute('quit!') -- Should exit the new window, not the terminal. + feed_command('quit!') -- Should exit the new window, not the terminal. eq(tbuf, eval('bufnr("%")')) - execute('set laststatus=1') -- Restore laststatus to the default. + feed_command('set laststatus=1') -- Restore laststatus to the default. end) it('term_close() use-after-free #4393', function() - execute('terminal yes') + feed_command('terminal yes') feed([[<C-\><C-n>]]) - execute('bdelete!') + feed_command('bdelete!') end) end) @@ -217,12 +217,12 @@ describe('No heap-buffer-overflow when using', function() end) it('termopen(echo) #3161', function() - execute('edit ' .. testfilename) + feed_command('edit ' .. testfilename) -- Move cursor away from the beginning of the line feed('$') -- Let termopen() modify the buffer - execute('call termopen("echo")') + feed_command('call termopen("echo")') wait() - execute('bdelete!') + feed_command('bdelete!') end) end) diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 84f14585fa..84d0322f12 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -2,7 +2,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim -local nvim_dir, execute = helpers.nvim_dir, helpers.execute +local nvim_dir, command = helpers.nvim_dir, helpers.command +local feed_command = helpers.feed_command local hide_cursor = thelpers.hide_cursor local show_cursor = thelpers.show_cursor @@ -138,7 +139,8 @@ describe('cursor with customized highlighting', function() [3] = {bold = true}, }) screen:attach({rgb=false}) - execute('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') + command('call termopen(["'..nvim_dir..'/tty-test"])') + feed_command('startinsert') end) it('overrides the default highlighting', function() diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 9bb683f25f..154374cda9 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq -local execute, eval = helpers.execute, helpers.eval +local feed_command, eval = helpers.feed_command, helpers.eval if helpers.pending_win32(pending) then return end @@ -23,11 +23,11 @@ describe(':terminal', function() echomsg "msg3" ]]) -- Invoke a command that emits frequent terminal activity. - execute([[terminal while true; do echo X; done]]) + feed_command([[terminal while true; do echo X; done]]) helpers.feed([[<C-\><C-N>]]) wait() helpers.sleep(10) -- Let some terminal activity happen. - execute("messages") + feed_command("messages") screen:expect([[ msg1 | msg2 | @@ -37,14 +37,14 @@ describe(':terminal', function() end) it("in normal-mode :split does not move cursor", function() - execute([[terminal while true; do echo foo; sleep .1; done]]) + feed_command([[terminal while true; do echo foo; sleep .1; done]]) helpers.feed([[<C-\><C-N>M]]) -- move cursor away from last line wait() eq(3, eval("line('$')")) -- window height eq(2, eval("line('.')")) -- cursor is in the middle - execute('vsplit') + feed_command('vsplit') eq(2, eval("line('.')")) -- cursor stays where we put it - execute('split') + feed_command('split') eq(2, eval("line('.')")) -- cursor stays where we put it end) @@ -65,7 +65,7 @@ describe(':terminal (with fake shell)', function() -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints -- the {cmd} and exits immediately . local function terminal_with_fake_shell(cmd) - execute("terminal "..(cmd and cmd or "")) + feed_command("terminal "..(cmd and cmd or "")) end it('with no argument, acts like termopen()', function() @@ -157,7 +157,7 @@ describe(':terminal (with fake shell)', function() end) it('works with findfile()', function() - execute('terminal') + feed_command('terminal') eq('term://', string.match(eval('bufname("%")'), "^term://")) eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")')) end) @@ -173,7 +173,7 @@ describe(':terminal (with fake shell)', function() ]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) helpers.feed([[<C-\><C-N>]]) - execute([[find */shadacat.py]]) + feed_command([[find */shadacat.py]]) eq('scripts/shadacat.py', eval('bufname("%")')) end) diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua index 934c01e3bf..3b04d17705 100644 --- a/test/functional/terminal/helpers.lua +++ b/test/functional/terminal/helpers.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(nil) local Screen = require('test.functional.ui.screen') local nvim_dir = helpers.nvim_dir -local execute, nvim = helpers.execute, helpers.nvim +local feed_command, nvim = helpers.feed_command, helpers.nvim local function feed_data(data) nvim('set_var', 'term_data', data) @@ -58,15 +58,15 @@ local function screen_setup(extra_rows, command, cols) screen:attach({rgb=false}) - execute('enew | call termopen('..command..')') + feed_command('enew | call termopen('..command..')') nvim('input', '<CR>') local vim_errmsg = nvim('eval', 'v:errmsg') if vim_errmsg and "" ~= vim_errmsg then error(vim_errmsg) end - execute('setlocal scrollback=10') - execute('startinsert') + feed_command('setlocal scrollback=10') + feed_command('startinsert') -- tty-test puts the terminal into raw mode and echoes input. Tests work by -- feeding termcodes to control the display and asserting by screen:expect. diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 0fe463401e..bb40770235 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim -local nvim_dir, execute = helpers.nvim_dir, helpers.execute +local nvim_dir, command = helpers.nvim_dir, helpers.command local eq, eval = helpers.eq, helpers.eval if helpers.pending_win32(pending) then return end @@ -27,7 +27,8 @@ describe('terminal window highlighting', function() [11] = {background = 11}, }) screen:attach({rgb=false}) - execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') + command('enew | call termopen(["'..nvim_dir..'/tty-test"])') + feed('i') screen:expect([[ tty ready | {10: } | @@ -130,7 +131,8 @@ describe('terminal window highlighting with custom palette', function() }) screen:attach({rgb=true}) nvim('set_var', 'terminal_color_3', '#123456') - execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') + command('enew | call termopen(["'..nvim_dir..'/tty-test"])') + feed('i') screen:expect([[ tty ready | {7: } | @@ -164,9 +166,9 @@ describe('synIDattr()', function() before_each(function() clear() screen = Screen.new(50, 7) - execute('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black') + command('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black') -- Salmon #fa8072 Maroon #800000 - execute('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon') + command('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon') end) it('returns cterm-color if RGB-capable UI is _not_ attached', function() @@ -213,8 +215,8 @@ describe('fg/bg special colors', function() before_each(function() clear() screen = Screen.new(50, 7) - execute('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black') - execute('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg') + command('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black') + command('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg') end) it('resolve to "Normal" values', function() @@ -251,7 +253,7 @@ describe('fg/bg special colors', function() screen:attach({rgb=true}) local new_guibg = '#282c34' local new_guifg = '#abb2bf' - execute('highlight Normal guifg='..new_guifg..' guibg='..new_guibg) + command('highlight Normal guifg='..new_guifg..' guibg='..new_guibg) eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")')) eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")')) eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")')) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 4ead288a19..32f25d4086 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -2,7 +2,7 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf -local feed, nvim_dir, execute = helpers.feed, helpers.nvim_dir, helpers.execute +local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command local eval = helpers.eval local command = helpers.command local wait = helpers.wait @@ -339,7 +339,7 @@ describe('terminal prints more lines than the screen height and exits', function clear() local screen = Screen.new(30, 7) screen:attach({rgb=false}) - execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert') + feed_command('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert') wait() screen:expect([[ line6 | @@ -451,7 +451,7 @@ describe("'scrollback' option", function() it(':setlocal in a normal buffer is an error', function() command('new') - execute('setlocal scrollback=42') + feed_command('setlocal scrollback=42') feed('<CR>') eq('E474:', string.match(eval("v:errmsg"), "E%d*:")) eq(-1, curbufmeths.get_option('scrollback')) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 90051b8cd5..b14bceecdd 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -2,9 +2,10 @@ -- as a simple way to send keys and assert screen state. local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') -local feed = thelpers.feed_data -local execute = helpers.execute +local feed_data = thelpers.feed_data +local feed_command = helpers.feed_command local nvim_dir = helpers.nvim_dir +local retry = helpers.retry if helpers.pending_win32(pending) then return end @@ -34,7 +35,7 @@ describe('tui', function() end) it('accepts basic utf-8 input', function() - feed('iabc\ntest1\ntest2') + feed_data('iabc\ntest1\ntest2') screen:expect([[ abc | test1 | @@ -44,7 +45,7 @@ describe('tui', function() {3:-- INSERT --} | {3:-- TERMINAL --} | ]]) - feed('\027') + feed_data('\027') screen:expect([[ abc | test1 | @@ -59,8 +60,8 @@ describe('tui', function() it('interprets leading <Esc> byte as ALT modifier in normal-mode', function() local keys = 'dfghjkl' for c in keys:gmatch('.') do - execute('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>') - feed('\027'..c) + feed_command('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>') + feed_data('\027'..c) end screen:expect([[ alt-j | @@ -71,7 +72,7 @@ describe('tui', function() | {3:-- TERMINAL --} | ]]) - feed('gg') + feed_data('gg') screen:expect([[ {1:a}lt-d | alt-f | @@ -90,7 +91,7 @@ describe('tui', function() -- Example: for input ALT+j: -- * Vim (Nvim prior to #3982) sets high-bit, inserts "ê". -- * Nvim (after #3982) inserts "j". - feed('i\027j') + feed_data('i\027j') screen:expect([[ j{1: } | {4:~ }| @@ -103,10 +104,10 @@ describe('tui', function() end) it('accepts ascii control sequences', function() - feed('i') - feed('\022\007') -- ctrl+g - feed('\022\022') -- ctrl+v - feed('\022\013') -- ctrl+m + feed_data('i') + feed_data('\022\007') -- ctrl+g + feed_data('\022\022') -- ctrl+v + feed_data('\022\013') -- ctrl+m screen:expect([[ {9:^G^V^M}{1: } | {4:~ }| @@ -119,7 +120,7 @@ describe('tui', function() end) it('automatically sends <Paste> for bracketed paste sequences', function() - feed('i\027[200~') + feed_data('i\027[200~') screen:expect([[ {1: } | {4:~ }| @@ -129,7 +130,7 @@ describe('tui', function() {3:-- INSERT (paste) --} | {3:-- TERMINAL --} | ]]) - feed('pasted from terminal') + feed_data('pasted from terminal') screen:expect([[ pasted from terminal{1: } | {4:~ }| @@ -139,7 +140,7 @@ describe('tui', function() {3:-- INSERT (paste) --} | {3:-- TERMINAL --} | ]]) - feed('\027[201~') + feed_data('\027[201~') screen:expect([[ pasted from terminal{1: } | {4:~ }| @@ -152,12 +153,12 @@ describe('tui', function() end) it('can handle arbitrarily long bursts of input', function() - execute('set ruler') + feed_command('set ruler') local t = {} for i = 1, 3000 do t[i] = 'item ' .. tostring(i) end - feed('i\027[200~'..table.concat(t, '\n')..'\027[201~') + feed_data('i\027[200~'..table.concat(t, '\n')..'\027[201~') screen:expect([[ item 2997 | item 2998 | @@ -180,7 +181,7 @@ describe('tui with non-tty file descriptors', function() it('can handle pipes as stdout and stderr', function() local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog ..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"') - feed(':w testF\n:q\n') + feed_data(':w testF\n:q\n') screen:expect([[ :w testF | :q | @@ -200,12 +201,13 @@ describe('tui focus event handling', function() helpers.clear() screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]') - execute('autocmd FocusGained * echo "gained"') - execute('autocmd FocusLost * echo "lost"') + feed_data(":autocmd FocusGained * echo 'gained'\n") + feed_data(":autocmd FocusLost * echo 'lost'\n") + feed_data("\034\016") -- CTRL-\ CTRL-N end) it('can handle focus events in normal mode', function() - feed('\027[I') + feed_data('\027[I') screen:expect([[ {1: } | {4:~ }| @@ -216,7 +218,7 @@ describe('tui focus event handling', function() {3:-- TERMINAL --} | ]]) - feed('\027[O') + feed_data('\027[O') screen:expect([[ {1: } | {4:~ }| @@ -229,9 +231,9 @@ describe('tui focus event handling', function() end) it('can handle focus events in insert mode', function() - execute('set noshowmode') - feed('i') - feed('\027[I') + feed_command('set noshowmode') + feed_data('i') + feed_data('\027[I') screen:expect([[ {1: } | {4:~ }| @@ -241,7 +243,7 @@ describe('tui focus event handling', function() gained | {3:-- TERMINAL --} | ]]) - feed('\027[O') + feed_data('\027[O') screen:expect([[ {1: } | {4:~ }| @@ -254,8 +256,8 @@ describe('tui focus event handling', function() end) it('can handle focus events in cmdline mode', function() - feed(':') - feed('\027[I') + feed_data(':') + feed_data('\027[I') screen:expect([[ | {4:~ }| @@ -265,7 +267,7 @@ describe('tui focus event handling', function() g{1:a}ined | {3:-- TERMINAL --} | ]]) - feed('\027[O') + feed_data('\027[O') screen:expect([[ | {4:~ }| @@ -278,30 +280,36 @@ describe('tui focus event handling', function() end) it('can handle focus events in terminal mode', function() - execute('set shell='..nvim_dir..'/shell-test') - execute('set laststatus=0') - execute('set noshowmode') - execute('terminal') - feed('\027[I') - screen:expect([[ - ready $ | - [Process exited 0]{1: } | - | - | - | - gained | - {3:-- TERMINAL --} | - ]]) - feed('\027[O') - screen:expect([[ - ready $ | - [Process exited 0]{1: } | - | - | - | - lost | - {3:-- TERMINAL --} | - ]]) + feed_data(':set shell='..nvim_dir..'/shell-test\n') + feed_data(':set noshowmode laststatus=0\n') + + retry(2, 3 * screen.timeout, function() + feed_data(':terminal\n') + feed_data('\027[I') + screen:expect([[ + ready $ | + [Process exited 0]{1: } | + | + | + | + gained | + {3:-- TERMINAL --} | + ]]) + feed_data('\027[O') + screen:expect([[ + ready $ | + [Process exited 0]{1: } | + | + | + | + lost | + {3:-- TERMINAL --} | + ]]) + + -- If retry is needed... + feed_data("\034\016") -- CTRL-\ CTRL-N + feed_data(':bwipeout!\n') + end) end) end) diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index d3386a641e..4867e0d9fa 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear = helpers.clear local feed, nvim = helpers.feed, helpers.nvim -local execute = helpers.execute +local feed_command = helpers.feed_command if helpers.pending_win32(pending) then return end @@ -26,7 +26,7 @@ describe('terminal', function() it('resets its size when entering terminal window', function() feed('<c-\\><c-n>') - execute('2split') + feed_command('2split') screen:expect([[ rows: 2, cols: 50 | {2:^ } | @@ -39,7 +39,7 @@ describe('terminal', function() ========== | :2split | ]]) - execute('wincmd p') + feed_command('wincmd p') screen:expect([[ tty ready | rows: 2, cols: 50 | @@ -52,7 +52,7 @@ describe('terminal', function() ========== | :wincmd p | ]]) - execute('wincmd p') + feed_command('wincmd p') screen:expect([[ rows: 2, cols: 50 | {2:^ } | diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 53fe303762..e1e11203e0 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -1,7 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') + local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, request, neq = helpers.execute, helpers.request, helpers.neq +local command, request, neq = helpers.command, helpers.request, helpers.neq if helpers.pending_win32(pending) then return end @@ -11,7 +12,7 @@ describe('Buffer highlighting', function() before_each(function() clear() - execute("syntax on") + command('syntax on') screen = Screen.new(40, 8) screen:attach() screen:set_default_attr_ids({ @@ -106,7 +107,7 @@ describe('Buffer highlighting', function() combining highlights from different sources]]) - execute("hi ImportantWord gui=bold cterm=bold") + command("hi ImportantWord gui=bold cterm=bold") id1 = add_hl(0, "ImportantWord", 0, 2, 8) add_hl(id1, "ImportantWord", 1, 12, -1) add_hl(id1, "ImportantWord", 2, 0, 9) @@ -131,7 +132,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - :hi ImportantWord gui=bold cterm=bold | + | ]]) end) @@ -145,7 +146,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - :hi ImportantWord gui=bold cterm=bold | + | ]]) end) @@ -159,7 +160,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - :hi ImportantWord gui=bold cterm=bold | + | ]]) end) @@ -175,7 +176,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - :hi ImportantWord gui=bold cterm=bold | + | ]]) end) @@ -192,7 +193,7 @@ describe('Buffer highlighting', function() | ]]) - execute(':3move 4') + command(':3move 4') screen:expect([[ a {5:longer} example | | @@ -201,7 +202,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - ::3move 4 | + | ]]) end) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 05cf3231ea..5f8fafef07 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local os = require('os') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, request, eq = helpers.execute, helpers.request, helpers.eq +local feed_command, request, eq = helpers.feed_command, helpers.request, helpers.eq if helpers.pending_win32(pending) then return end @@ -41,18 +41,18 @@ describe('manual syntax highlight', function() end) it("works with buffer switch and 'hidden'", function() - execute('e tmp1.vim') - execute('e Xtest-functional-ui-highlight.tmp.vim') - execute('filetype on') - execute('syntax manual') - execute('set ft=vim') - execute('set syntax=ON') + feed_command('e tmp1.vim') + feed_command('e Xtest-functional-ui-highlight.tmp.vim') + feed_command('filetype on') + feed_command('syntax manual') + feed_command('set ft=vim') + feed_command('set syntax=ON') feed('iecho 1<esc>0') - execute('set hidden') - execute('w') - execute('bn') - execute('bp') + feed_command('set hidden') + feed_command('w') + feed_command('bn') + feed_command('bp') screen:expect([[ {1:^echo} 1 | {0:~ }| @@ -63,18 +63,18 @@ describe('manual syntax highlight', function() end) it("works with buffer switch and 'nohidden'", function() - execute('e tmp1.vim') - execute('e Xtest-functional-ui-highlight.tmp.vim') - execute('filetype on') - execute('syntax manual') - execute('set ft=vim') - execute('set syntax=ON') + feed_command('e tmp1.vim') + feed_command('e Xtest-functional-ui-highlight.tmp.vim') + feed_command('filetype on') + feed_command('syntax manual') + feed_command('set ft=vim') + feed_command('set syntax=ON') feed('iecho 1<esc>0') - execute('set nohidden') - execute('w') - execute('bn') - execute('bp') + feed_command('set nohidden') + feed_command('w') + feed_command('bn') + feed_command('bp') screen:expect([[ {1:^echo} 1 | {0:~ }| @@ -107,7 +107,7 @@ describe('Default highlight groups', function() [1] = {reverse = true, bold = true}, -- StatusLine [2] = {reverse = true} -- StatusLineNC }) - execute('sp', 'vsp', 'vsp') + feed_command('sp', 'vsp', 'vsp') screen:expect([[ ^ {2:|} {2:|} | {0:~ }{2:|}{0:~ }{2:|}{0:~ }| @@ -235,7 +235,7 @@ describe('Default highlight groups', function() it('can be cleared and linked to other highlight groups', function() screen:try_resize(53, 4) - execute('highlight clear ModeMsg') + feed_command('highlight clear ModeMsg') feed('i') screen:expect([[ ^ | @@ -245,8 +245,8 @@ describe('Default highlight groups', function() ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {bold=true}}) feed('<esc>') - execute('highlight CustomHLGroup guifg=red guibg=green') - execute('highlight link ModeMsg CustomHLGroup') + feed_command('highlight CustomHLGroup guifg=red guibg=green') + feed_command('highlight link ModeMsg CustomHLGroup') feed('i') screen:expect([[ ^ | @@ -259,8 +259,8 @@ describe('Default highlight groups', function() it('can be cleared by assigning NONE', function() screen:try_resize(53, 4) - execute('syn keyword TmpKeyword neovim') - execute('hi link TmpKeyword ErrorMsg') + feed_command('syn keyword TmpKeyword neovim') + feed_command('hi link TmpKeyword ErrorMsg') insert('neovim') screen:expect([[ {1:neovi^m} | @@ -271,7 +271,7 @@ describe('Default highlight groups', function() [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {foreground = Screen.colors.White, background = Screen.colors.Red} }) - execute("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE" + feed_command("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE" .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE") screen:expect([[ neovi^m | @@ -283,8 +283,8 @@ describe('Default highlight groups', function() it('Whitespace highlight', function() screen:try_resize(53, 4) - execute('highlight NonText gui=NONE guifg=#FF0000') - execute('set listchars=space:.,tab:>-,trail:*,eol:¬ list') + feed_command('highlight NonText gui=NONE guifg=#FF0000') + feed_command('set listchars=space:.,tab:>-,trail:*,eol:¬ list') insert(' ne \t o\tv im ') screen:expect([[ ne{0:.>----.}o{0:>-----}v{0:..}im{0:*^*¬} | @@ -295,7 +295,7 @@ describe('Default highlight groups', function() [0] = {foreground=Screen.colors.Red}, [1] = {foreground=Screen.colors.Blue}, }) - execute('highlight Whitespace gui=NONE guifg=#0000FF') + feed_command('highlight Whitespace gui=NONE guifg=#0000FF') screen:expect([[ ne{1:.>----.}o{1:>-----}v{1:..}im{1:*^*}{0:¬} | {0:~ }| @@ -318,19 +318,19 @@ describe('guisp (special/undercurl)', function() end) it('can be set and is applied like foreground or background', function() - execute('syntax on') - execute('syn keyword TmpKeyword neovim') - execute('syn keyword TmpKeyword1 special') - execute('syn keyword TmpKeyword2 specialwithbg') - execute('syn keyword TmpKeyword3 specialwithfg') - execute('hi! Awesome guifg=red guibg=yellow guisp=red') - execute('hi! Awesome1 guisp=red') - execute('hi! Awesome2 guibg=yellow guisp=red') - execute('hi! Awesome3 guifg=red guisp=red') - execute('hi link TmpKeyword Awesome') - execute('hi link TmpKeyword1 Awesome1') - execute('hi link TmpKeyword2 Awesome2') - execute('hi link TmpKeyword3 Awesome3') + feed_command('syntax on') + feed_command('syn keyword TmpKeyword neovim') + feed_command('syn keyword TmpKeyword1 special') + feed_command('syn keyword TmpKeyword2 specialwithbg') + feed_command('syn keyword TmpKeyword3 specialwithfg') + feed_command('hi! Awesome guifg=red guibg=yellow guisp=red') + feed_command('hi! Awesome1 guisp=red') + feed_command('hi! Awesome2 guibg=yellow guisp=red') + feed_command('hi! Awesome3 guifg=red guisp=red') + feed_command('hi link TmpKeyword Awesome') + feed_command('hi link TmpKeyword1 Awesome1') + feed_command('hi link TmpKeyword2 Awesome2') + feed_command('hi link TmpKeyword3 Awesome3') insert([[ neovim awesome neovim @@ -382,8 +382,8 @@ describe("'listchars' highlight", function() [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {background=Screen.colors.Grey90} }) - execute('highlight clear ModeMsg') - execute('set cursorline') + feed_command('highlight clear ModeMsg') + feed_command('set cursorline') feed('i') screen:expect([[ {1:^ }| @@ -408,7 +408,7 @@ describe("'listchars' highlight", function() {0:~ }| | ]]) - execute('set nocursorline') + feed_command('set nocursorline') screen:expect([[ abcdefg | kkasd^f | @@ -432,8 +432,8 @@ describe("'listchars' highlight", function() ^f | | ]]) - execute('set cursorline') - execute('set cursorcolumn') + feed_command('set cursorline') + feed_command('set cursorcolumn') feed('kkiabcdefghijk<esc>hh') screen:expect([[ kkasd {1: } | @@ -472,11 +472,11 @@ describe("'listchars' highlight", function() foreground=Screen.colors.Red, }, }) - execute('highlight clear ModeMsg') - execute('highlight Whitespace guifg=#FF0000') - execute('set cursorline') - execute('set tabstop=8') - execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') + feed_command('highlight clear ModeMsg') + feed_command('highlight Whitespace guifg=#FF0000') + feed_command('set cursorline') + feed_command('set tabstop=8') + feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') feed('i\t abcd <cr>\t abcd <cr><esc>k') screen:expect([[ {5:>-------.}abcd{5:*}{4:¬} | @@ -493,7 +493,7 @@ describe("'listchars' highlight", function() {4:~ }| | ]]) - execute('set nocursorline') + feed_command('set nocursorline') screen:expect([[ {5:^>-------.}abcd{5:*}{4:¬} | {5:>-------.}abcd{5:*}{4:¬} | @@ -501,7 +501,7 @@ describe("'listchars' highlight", function() {4:~ }| :set nocursorline | ]]) - execute('set nowrap') + feed_command('set nowrap') feed('ALorem ipsum dolor sit amet<ESC>0') screen:expect([[ {5:^>-------.}abcd{5:.}Lorem{4:>}| @@ -510,7 +510,7 @@ describe("'listchars' highlight", function() {4:~ }| | ]]) - execute('set cursorline') + feed_command('set cursorline') screen:expect([[ {2:^>-------.}{1:abcd}{2:.}{1:Lorem}{4:>}| {5:>-------.}abcd{5:*}{4:¬} | @@ -568,12 +568,12 @@ describe("'listchars' highlight", function() bold=true, }, }) - execute('highlight clear ModeMsg') - execute('highlight Whitespace guifg=#FF0000') - execute('set cursorline') - execute('set tabstop=8') - execute('set nowrap') - execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') + feed_command('highlight clear ModeMsg') + feed_command('highlight Whitespace guifg=#FF0000') + feed_command('set cursorline') + feed_command('set tabstop=8') + feed_command('set nowrap') + feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') feed('i\t abcd <cr>\t abcd Lorem ipsum dolor sit amet<cr><esc>kkk0') screen:expect([[ {2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }| @@ -615,10 +615,10 @@ describe("'listchars' highlight", function() [2] = {foreground=Screen.colors.Red}, [3] = {foreground=Screen.colors.Green1}, }) - execute('highlight clear ModeMsg') - execute('highlight Whitespace guifg=#FF0000') - execute('highlight Error guifg=#00FF00') - execute('set nowrap') + feed_command('highlight clear ModeMsg') + feed_command('highlight Whitespace guifg=#FF0000') + feed_command('highlight Error guifg=#00FF00') + feed_command('set nowrap') feed('ia \t bc \t <esc>') screen:expect([[ a bc ^ | @@ -627,7 +627,7 @@ describe("'listchars' highlight", function() {0:~ }| | ]]) - execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') + feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') screen:expect([[ a{2:.>-----.}bc{2:*>---*^*}{0:¬} | {0:~ }| @@ -635,7 +635,7 @@ describe("'listchars' highlight", function() {0:~ }| | ]]) - execute('match Error /\\s\\+$/') + feed_command('match Error /\\s\\+$/') screen:expect([[ a{2:.>-----.}bc{3:*>---*^*}{0:¬} | {0:~ }| diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 3b31da0397..b7a33cb64d 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -4,7 +4,7 @@ local clear = helpers.clear local curbufmeths = helpers.curbufmeths local eq = helpers.eq local eval = helpers.eval -local execute = helpers.execute +local feed_command = helpers.feed_command local expect = helpers.expect local feed = helpers.feed local insert = helpers.insert @@ -21,9 +21,9 @@ local default_text = [[ local function common_setup(screen, inccommand, text) if screen then - execute("syntax on") - execute("set nohlsearch") - execute("hi Substitute guifg=red guibg=yellow") + feed_command("syntax on") + feed_command("set nohlsearch") + feed_command("hi Substitute guifg=red guibg=yellow") screen:attach() screen:set_default_attr_ids({ [1] = {foreground = Screen.colors.Fuchsia}, @@ -46,7 +46,7 @@ local function common_setup(screen, inccommand, text) }) end - execute("set inccommand=" .. (inccommand and inccommand or "")) + feed_command("set inccommand=" .. (inccommand and inccommand or "")) if text then insert(text) @@ -91,8 +91,8 @@ describe(":substitute, 'inccommand' preserves", function() local screen = Screen.new(30,10) common_setup(screen, "split", "ABC") - execute("%s/AB/BA/") - execute("ls") + feed_command("%s/AB/BA/") + feed_command("ls") screen:expect([[ {15:~ }| @@ -111,25 +111,25 @@ describe(":substitute, 'inccommand' preserves", function() for _, case in pairs{"", "split", "nosplit"} do it("various delimiters (inccommand="..case..")", function() insert(default_text) - execute("set inccommand=" .. case) + feed_command("set inccommand=" .. case) local delims = { '/', '#', ';', '%', ',', '@', '!', ''} for _,delim in pairs(delims) do - execute("%s"..delim.."lines"..delim.."LINES"..delim.."g") + feed_command("%s"..delim.."lines"..delim.."LINES"..delim.."g") expect([[ Inc substitution on two LINES ]]) - execute("undo") + feed_command("undo") end end) end for _, case in pairs{"", "split", "nosplit"} do it("'undolevels' (inccommand="..case..")", function() - execute("set undolevels=139") - execute("setlocal undolevels=34") - execute("set inccommand=" .. case) + feed_command("set undolevels=139") + feed_command("setlocal undolevels=34") + feed_command("set inccommand=" .. case) insert("as") feed(":%s/as/glork/<enter>") eq(meths.get_option('undolevels'), 139) @@ -139,8 +139,8 @@ describe(":substitute, 'inccommand' preserves", function() for _, case in ipairs({"", "split", "nosplit"}) do it("empty undotree() (inccommand="..case..")", function() - execute("set undolevels=1000") - execute("set inccommand=" .. case) + feed_command("set undolevels=1000") + feed_command("set inccommand=" .. case) local expected_undotree = eval("undotree()") -- Start typing an incomplete :substitute command. @@ -157,8 +157,8 @@ describe(":substitute, 'inccommand' preserves", function() for _, case in ipairs({"", "split", "nosplit"}) do it("undotree() with branches (inccommand="..case..")", function() - execute("set undolevels=1000") - execute("set inccommand=" .. case) + feed_command("set undolevels=1000") + feed_command("set inccommand=" .. case) -- Make some changes. feed([[isome text 1<C-\><C-N>]]) feed([[osome text 2<C-\><C-N>]]) @@ -192,7 +192,7 @@ describe(":substitute, 'inccommand' preserves", function() for _, case in pairs{"", "split", "nosplit"} do it("b:changedtick (inccommand="..case..")", function() - execute("set inccommand=" .. case) + feed_command("set inccommand=" .. case) feed([[isome text 1<C-\><C-N>]]) feed([[osome text 2<C-\><C-N>]]) local expected_tick = eval("b:changedtick") @@ -271,18 +271,18 @@ describe(":substitute, 'inccommand' preserves undo", function() local function test_sub(substring, split, redoable) clear() - execute("set inccommand=" .. split) + feed_command("set inccommand=" .. split) insert("1") feed("o2<esc>") - execute("undo") + feed_command("undo") feed("o3<esc>") if redoable then feed("o4<esc>") - execute("undo") + feed_command("undo") end feed(substring.. "<enter>") - execute("undo") + feed_command("undo") feed("g-") expect([[ @@ -297,15 +297,15 @@ describe(":substitute, 'inccommand' preserves undo", function() local function test_notsub(substring, split, redoable) clear() - execute("set inccommand=" .. split) + feed_command("set inccommand=" .. split) insert("1") feed("o2<esc>") - execute("undo") + feed_command("undo") feed("o3<esc>") if redoable then feed("o4<esc>") - execute("undo") + feed_command("undo") end feed(substring .. "<esc>") @@ -331,7 +331,7 @@ describe(":substitute, 'inccommand' preserves undo", function() local function test_threetree(substring, split) clear() - execute("set inccommand=" .. split) + feed_command("set inccommand=" .. split) insert("1") feed("o2<esc>") @@ -424,22 +424,22 @@ describe(":substitute, 'inccommand' preserves undo", function() for _, case in pairs(cases) do clear() common_setup(nil, case, default_text) - execute("set undolevels=0") + feed_command("set undolevels=0") feed("1G0") insert("X") feed(":%s/tw/MO/<esc>") - execute("undo") + feed_command("undo") expect(default_text) - execute("undo") + feed_command("undo") expect(default_text:gsub("Inc", "XInc")) - execute("undo") + feed_command("undo") - execute("%s/tw/MO/g") + feed_command("%s/tw/MO/g") expect(default_text:gsub("tw", "MO")) - execute("undo") + feed_command("undo") expect(default_text) - execute("undo") + feed_command("undo") expect(default_text:gsub("tw", "MO")) end end) @@ -450,7 +450,7 @@ describe(":substitute, 'inccommand' preserves undo", function() for _, case in pairs(cases) do clear() common_setup(screen, case, default_text) - execute("set undolevels=1") + feed_command("set undolevels=1") feed("1G0") insert("X") @@ -508,7 +508,7 @@ describe(":substitute, 'inccommand' preserves undo", function() for _, case in pairs(cases) do clear() common_setup(screen, case, default_text) - execute("set undolevels=2") + feed_command("set undolevels=2") feed("2GAx<esc>") feed("Ay<esc>") @@ -601,7 +601,7 @@ describe(":substitute, 'inccommand' preserves undo", function() clear() common_setup(screen, case, default_text) - execute("set undolevels=-1") + feed_command("set undolevels=-1") feed(":%s/tw/MO/g<enter>") -- using execute("undo") here will result in a "Press ENTER" prompt feed("u") @@ -637,7 +637,7 @@ describe(":substitute, 'inccommand' preserves undo", function() clear() common_setup(screen, case, default_text) - execute("set undolevels=-1") + feed_command("set undolevels=-1") feed("1G") feed("IL<esc>") feed(":%s/tw/MO/g<esc>") @@ -676,7 +676,7 @@ describe(":substitute, inccommand=split", function() end) it("preserves 'modified' buffer flag", function() - execute("set nomodified") + feed_command("set nomodified") feed(":%s/tw") screen:expect([[ Inc substitution on | @@ -825,7 +825,7 @@ describe(":substitute, inccommand=split", function() end) it("'hlsearch' is active, 'cursorline' is not", function() - execute("set hlsearch cursorline") + feed_command("set hlsearch cursorline") feed("gg") -- Assert that 'cursorline' is active. @@ -917,7 +917,7 @@ describe(":substitute, inccommand=split", function() feed("gg") feed("2yy") feed("2000p") - execute("1,1000s/tw/BB/g") + feed_command("1,1000s/tw/BB/g") feed(":%s/tw/X") screen:expect([[ @@ -983,9 +983,9 @@ describe(":substitute, inccommand=split", function() -- Assert that 'inccommand' is ENABLED initially. eq("split", eval("&inccommand")) -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. - execute("set redrawtime=1 nowrap") + feed_command("set redrawtime=1 nowrap") -- Load a big file. - execute("silent edit! test/functional/fixtures/bigfile.txt") + feed_command("silent edit! test/functional/fixtures/bigfile.txt") -- Start :substitute with a slow pattern. feed([[:%s/B.*N/x]]) wait() @@ -1018,7 +1018,7 @@ describe(":substitute, inccommand=split", function() it("clears preview if non-previewable command is edited #5585", function() -- Put a non-previewable command in history. - execute("echo 'foo'") + feed_command("echo 'foo'") -- Start an incomplete :substitute command. feed(":1,2s/t/X") @@ -1079,7 +1079,7 @@ describe("inccommand=nosplit", function() end) it("works with :smagic, :snomagic", function() - execute("set hlsearch") + feed_command("set hlsearch") insert("Line *.3.* here") feed(":%smagic/3.*/X") -- start :smagic command @@ -1114,7 +1114,7 @@ describe("inccommand=nosplit", function() end) it('never shows preview buffer', function() - execute("set hlsearch") + feed_command("set hlsearch") feed(":%s/tw") screen:expect([[ @@ -1175,7 +1175,7 @@ describe("inccommand=nosplit", function() it("clears preview if non-previewable command is edited", function() -- Put a non-previewable command in history. - execute("echo 'foo'") + feed_command("echo 'foo'") -- Start an incomplete :substitute command. feed(":1,2s/t/X") @@ -1224,7 +1224,7 @@ describe(":substitute, 'inccommand' with a failing expression", function() it('in the pattern does nothing', function() for _, case in pairs(cases) do refresh(case) - execute("set inccommand=" .. case) + feed_command("set inccommand=" .. case) feed(":silent! %s/tw\\(/LARD/<enter>") expect(default_text) end @@ -1236,10 +1236,10 @@ describe(":substitute, 'inccommand' with a failing expression", function() local replacements = { "\\='LARD", "\\=xx_novar__xx" } for _, repl in pairs(replacements) do - execute("set inccommand=" .. case) + feed_command("set inccommand=" .. case) feed(":silent! %s/tw/" .. repl .. "/<enter>") expect(default_text:gsub("tw", "")) - execute("undo") + feed_command("undo") end end end) @@ -1295,10 +1295,10 @@ describe("'inccommand' and :cnoremap", function() for i = 1, string.len(command) do local c = string.sub(command, i, i) - execute("cnoremap ".. c .. " " .. c) + feed_command("cnoremap ".. c .. " " .. c) end - execute(command) + feed_command(command) expect([[ Inc substitution on two LINES @@ -1309,7 +1309,7 @@ describe("'inccommand' and :cnoremap", function() it('work when mappings move the cursor', function() for _, case in pairs(cases) do refresh(case) - execute("cnoremap ,S LINES/<left><left><left><left><left><left>") + feed_command("cnoremap ,S LINES/<left><left><left><left><left><left>") feed(":%s/lines/,Sor three <enter>") expect([[ @@ -1317,21 +1317,21 @@ describe("'inccommand' and :cnoremap", function() two or three LINES ]]) - execute("cnoremap ;S /X/<left><left><left>") + feed_command("cnoremap ;S /X/<left><left><left>") feed(":%s/;SI<enter>") expect([[ Xnc substitution on two or three LXNES ]]) - execute("cnoremap ,T //Y/<left><left><left>") + feed_command("cnoremap ,T //Y/<left><left><left>") feed(":%s,TX<enter>") expect([[ Ync substitution on two or three LYNES ]]) - execute("cnoremap ;T s//Z/<left><left><left>") + feed_command("cnoremap ;T s//Z/<left><left><left>") feed(":%;TY<enter>") expect([[ Znc substitution on @@ -1343,7 +1343,7 @@ describe("'inccommand' and :cnoremap", function() it('does not work with a failing mapping', function() for _, case in pairs(cases) do refresh(case) - execute("cnoremap <expr> x execute('bwipeout!')[-1].'x'") + feed_command("cnoremap <expr> x execute('bwipeout!')[-1].'x'") feed(":%s/tw/tox<enter>") @@ -1356,7 +1356,7 @@ describe("'inccommand' and :cnoremap", function() it('work when temporarily moving the cursor', function() for _, case in pairs(cases) do refresh(case) - execute("cnoremap <expr> x cursor(1, 1)[-1].'x'") + feed_command("cnoremap <expr> x cursor(1, 1)[-1].'x'") feed(":%s/tw/tox/g<enter>") expect(default_text:gsub("tw", "tox")) @@ -1366,7 +1366,7 @@ describe("'inccommand' and :cnoremap", function() it("work when a mapping disables 'inccommand'", function() for _, case in pairs(cases) do refresh(case) - execute("cnoremap <expr> x execute('set inccommand=')[-1]") + feed_command("cnoremap <expr> x execute('set inccommand=')[-1]") feed(":%s/tw/toxa/g<enter>") expect(default_text:gsub("tw", "toa")) @@ -1440,7 +1440,7 @@ describe("'inccommand' autocommands", function() local function register_autocmd(event) meths.set_var(event .. "_fired", {}) - execute("autocmd " .. event .. " * call add(g:" .. event .. "_fired, expand('<abuf>'))") + feed_command("autocmd " .. event .. " * call add(g:" .. event .. "_fired, expand('<abuf>'))") end it('are not fired when splitting', function() @@ -1493,8 +1493,8 @@ describe("'inccommand' split windows", function() refresh() feed("gg") - execute("vsplit") - execute("split") + feed_command("vsplit") + feed_command("split") feed(":%s/tw") screen:expect([[ Inc substitution on {10:|}Inc substitution on| @@ -1530,9 +1530,9 @@ describe("'inccommand' split windows", function() ]]) feed("<esc>") - execute("only") - execute("split") - execute("vsplit") + feed_command("only") + feed_command("split") + feed_command("vsplit") feed(":%s/tw") screen:expect([[ @@ -1581,7 +1581,7 @@ describe("'inccommand' split windows", function() it("are not affected by various settings", function() for _, setting in pairs(settings) do refresh() - execute("set " .. setting) + feed_command("set " .. setting) feed(":%s/tw") diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index cec19250d2..29d974b709 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim +local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim local feed, next_message, eq = helpers.feed, helpers.next_message, helpers.eq local expect = helpers.expect local Screen = require('test.functional.ui.screen') @@ -12,7 +12,7 @@ describe('mappings', function() local add_mapping = function(mapping, send) local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '" ..send:gsub('<', '<lt>').."')<cr>" - execute(cmd) + feed_command(cmd) end local check_mapping = function(mapping, expected) @@ -57,7 +57,7 @@ describe('feeding large chunks of input with <Paste>', function() clear() screen = Screen.new() screen:attach() - execute('set ruler') + feed_command('set ruler') end) it('ok', function() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index ecbd5642d1..35af34015d 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths -local insert, execute = helpers.insert, helpers.execute +local insert, feed_command = helpers.insert, helpers.feed_command local eq, funcs = helpers.eq, helpers.funcs if helpers.pending_win32(pending) then return end @@ -123,9 +123,9 @@ describe('ui/mouse/input', function() end) it('in tabline on filler space moves tab to the end', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -160,9 +160,9 @@ describe('ui/mouse/input', function() return end - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -190,9 +190,9 @@ describe('ui/mouse/input', function() end) it('in tabline to the right moves tab right', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -220,9 +220,9 @@ describe('ui/mouse/input', function() end) it('out of tabline under filler space moves tab to the end', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -265,9 +265,9 @@ describe('ui/mouse/input', function() return end - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -303,9 +303,9 @@ describe('ui/mouse/input', function() end) it('out of tabline to the right moves tab right', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -352,9 +352,9 @@ describe('ui/mouse/input', function() end) it('left click in default tabline (position 4) switches to tab', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -375,9 +375,9 @@ describe('ui/mouse/input', function() it('left click in default tabline (position 24) closes tab', function() meths.set_option('hidden', true) - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -398,9 +398,9 @@ describe('ui/mouse/input', function() it('double click in default tabline (position 4) opens new tab', function() meths.set_option('hidden', true) - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| @@ -421,13 +421,13 @@ describe('ui/mouse/input', function() describe('%@ label', function() before_each(function() - execute([[ + feed_command([[ function Test(...) let g:reply = a:000 return copy(a:000) " Check for memory leaks: return should be freed endfunction ]]) - execute([[ + feed_command([[ function Test2(...) return call('Test', a:000 + [2]) endfunction @@ -533,9 +533,9 @@ describe('ui/mouse/input', function() fill = { reverse=true }, vis = { background=Screen.colors.LightGrey } }) - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') - execute('tabprevious') -- go to first tab + feed_command('tabprevious') -- go to first tab screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| mouse | @@ -641,7 +641,7 @@ describe('ui/mouse/input', function() mouse scrolling ]]) screen:try_resize(53, 14) - execute('sp', 'vsp') + feed_command('sp', 'vsp') screen:expect([[ lines {4:|}lines | to {4:|}to | @@ -754,12 +754,12 @@ describe('ui/mouse/input', function() }) feed('ggdG') - execute('set concealcursor=n') - execute('set nowrap') - execute('syntax match NonText "\\<amet\\>" conceal') - execute('syntax match NonText "\\cs\\|g." conceal cchar=X') - execute('syntax match NonText "\\%(lo\\|cl\\)." conceal') - execute('syntax match NonText "Lo" conceal cchar=Y') + feed_command('set concealcursor=n') + feed_command('set nowrap') + feed_command('syntax match NonText "\\<amet\\>" conceal') + feed_command('syntax match NonText "\\cs\\|g." conceal cchar=X') + feed_command('syntax match NonText "\\%(lo\\|cl\\)." conceal') + feed_command('syntax match NonText "Lo" conceal cchar=Y') insert([[ Lorem ipsum dolor sit amet, consetetur sadipscing elitr. @@ -770,7 +770,7 @@ describe('ui/mouse/input', function() end) it('(level 1) click on non-wrapped lines', function() - execute('let &conceallevel=1', 'echo') + feed_command('let &conceallevel=1', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ @@ -818,7 +818,7 @@ describe('ui/mouse/input', function() end) -- level 1 - non wrapped it('(level 1) click on wrapped lines', function() - execute('let &conceallevel=1', 'let &wrap=1', 'echo') + feed_command('let &conceallevel=1', 'let &wrap=1', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ @@ -867,7 +867,7 @@ describe('ui/mouse/input', function() it('(level 2) click on non-wrapped lines', function() - execute('let &conceallevel=2', 'echo') + feed_command('let &conceallevel=2', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ @@ -915,7 +915,7 @@ describe('ui/mouse/input', function() end) -- level 2 - non wrapped it('(level 2) click on wrapped lines', function() - execute('let &conceallevel=2', 'let &wrap=1', 'echo') + feed_command('let &conceallevel=2', 'let &wrap=1', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ @@ -964,7 +964,7 @@ describe('ui/mouse/input', function() it('(level 3) click on non-wrapped lines', function() - execute('let &conceallevel=3', 'echo') + feed_command('let &conceallevel=3', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ @@ -1012,7 +1012,7 @@ describe('ui/mouse/input', function() end) -- level 3 - non wrapped it('(level 3) click on wrapped lines', function() - execute('let &conceallevel=3', 'let &wrap=1', 'echo') + feed_command('let &conceallevel=3', 'let &wrap=1', 'echo') feed('<esc><LeftMouse><0,0>') screen:expect([[ diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua index 29b28fe9f0..b0d89ee3b6 100644 --- a/test/functional/ui/quickfix_spec.lua +++ b/test/functional/ui/quickfix_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths -local insert, execute = helpers.insert, helpers.execute +local insert, command = helpers.insert, helpers.command describe('quickfix selection highlight', function() @@ -28,8 +28,8 @@ describe('quickfix selection highlight', function() }) meths.set_option('errorformat', '%m %l') - execute('syntax on') - execute('highlight Search guibg=Green') + command('syntax on') + command('highlight Search guibg=Green') insert([[ Line 1 @@ -39,7 +39,7 @@ describe('quickfix selection highlight', function() Line 5 ]]) - execute('cad') + command('cad') feed('gg') screen:expect([[ @@ -52,12 +52,12 @@ describe('quickfix selection highlight', function() {1:~ }| {1:~ }| {1:~ }| - :cad | + | ]]) end) it('using default Search highlight group', function() - execute('copen') + command('copen') screen:expect([[ Line 1 | @@ -69,10 +69,10 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) - execute('cnext') + command('cnext') screen:expect([[ Line 1 | @@ -84,14 +84,14 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :cnext | + | ]]) end) it('using QuickFixLine highlight group', function() - execute('highlight QuickFixLine guibg=Red') + command('highlight QuickFixLine guibg=Red') - execute('copen') + command('copen') screen:expect([[ Line 1 | @@ -103,10 +103,10 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) - execute('cnext') + command('cnext') screen:expect([[ Line 1 | @@ -118,16 +118,16 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :cnext | + | ]]) end) it('combines with CursorLine', function() - execute('set cursorline') - execute('highlight QuickFixLine guifg=Red') - execute('highlight CursorLine guibg=Fuchsia') + command('set cursorline') + command('highlight QuickFixLine guifg=Red') + command('highlight CursorLine guibg=Fuchsia') - execute('copen') + command('copen') screen:expect([[ {9:Line 1 }| @@ -139,7 +139,7 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) feed('j') @@ -154,16 +154,16 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) end) it('QuickFixLine background takes precedence over CursorLine', function() - execute('set cursorline') - execute('highlight QuickFixLine guibg=Red') - execute('highlight CursorLine guibg=Fuchsia') + command('set cursorline') + command('highlight QuickFixLine guibg=Red') + command('highlight CursorLine guibg=Fuchsia') - execute('copen') + command('copen') screen:expect([[ {9:Line 1 }| @@ -175,7 +175,7 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) feed('j') @@ -190,7 +190,7 @@ describe('quickfix selection highlight', function() |{3:5}| Line | || | {4:[Quickfix List] }| - :copen | + | ]]) end) end) diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 21953ba294..8182190b5f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear -local feed, execute = helpers.feed, helpers.execute +local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval @@ -75,7 +75,7 @@ describe('Screen', function() local function check() eq(true, screen.suspended) end - execute('suspend') + command('suspend') screen:expect(check) screen.suspended = false feed('<c-z>') @@ -91,7 +91,7 @@ describe('Screen', function() eq(false, screen.visual_bell) end) screen.bell = false - execute('set visualbell') + command('set visualbell') feed('<left>') screen:expect(function() eq(true, screen.visual_bell) @@ -103,8 +103,8 @@ describe('Screen', function() describe(':set title', function() it('is forwarded to the UI', function() local expected = 'test-title' - execute('set titlestring='..expected) - execute('set title') + command('set titlestring='..expected) + command('set title') screen:expect(function() eq(expected, screen.title) end) @@ -112,7 +112,7 @@ describe('Screen', function() it('has correct default title with unnamed file', function() local expected = '[No Name] - NVIM' - execute('set title') + command('set title') screen:expect(function() eq(expected, screen.title) end) @@ -120,8 +120,8 @@ describe('Screen', function() it('has correct default title with named file', function() local expected = 'myfile (/mydir) - NVIM' - execute('set title') - execute('file /mydir/myfile') + command('set title') + command('file /mydir/myfile') screen:expect(function() eq(expected, screen.title) end) @@ -131,8 +131,8 @@ describe('Screen', function() describe(':set icon', function() it('is forwarded to the UI', function() local expected = 'test-icon' - execute('set iconstring='..expected) - execute('set icon') + command('set iconstring='..expected) + command('set icon') screen:expect(function() eq(expected, screen.icon) end) @@ -142,7 +142,7 @@ describe('Screen', function() describe('window', function() describe('split', function() it('horizontal', function() - execute('sp') + command('sp') screen:expect([[ ^ | {0:~ }| @@ -157,13 +157,13 @@ describe('Screen', function() {0:~ }| {0:~ }| {3:[No Name] }| - :sp | + | ]]) end) it('horizontal and resize', function() - execute('sp') - execute('resize 8') + command('sp') + command('resize 8') screen:expect([[ ^ | {0:~ }| @@ -178,12 +178,14 @@ describe('Screen', function() {0:~ }| {0:~ }| {3:[No Name] }| - :resize 8 | + | ]]) end) it('horizontal and vertical', function() - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') screen:expect([[ ^ {3:|} {3:|} | {0:~ }{3:|}{0:~ }{3:|}{0:~ }| @@ -223,7 +225,9 @@ describe('Screen', function() describe('tabnew', function() it('creates a new buffer', function() - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') insert('hello') screen:expect([[ hell^o {3:|}hello {3:|}hello | @@ -241,7 +245,7 @@ describe('Screen', function() {3:[No Name] [+] }| | ]]) - execute('tabnew') + command('tabnew') insert('hello2') feed('h') screen:expect([[ @@ -260,7 +264,7 @@ describe('Screen', function() {0:~ }| | ]]) - execute('tabprevious') + command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| hell^o {3:|}hello {3:|}hello | @@ -305,9 +309,9 @@ describe('Screen', function() describe('normal mode', function() -- https://code.google.com/p/vim/issues/detail?id=339 it("setting 'ruler' doesn't reset the preferred column", function() - execute('set virtualedit=') + command('set virtualedit=') feed('i0123456<cr>789<esc>kllj') - execute('set ruler') + command('set ruler') feed('k') screen:expect([[ 0123^456 | @@ -323,7 +327,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :set ruler 1,5 All | + 1,5 All | ]]) end) end) @@ -388,7 +392,9 @@ describe('Screen', function() split windows ]]) - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') screen:expect([[ and {3:|}and {3:|}and | clearing {3:|}clearing {3:|}clearing | diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 3914648e8f..11b18d015f 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute = helpers.execute +local feed_command = helpers.feed_command if helpers.pending_win32(pending) then return end @@ -22,7 +22,7 @@ describe('search highlighting', function() end) it('is disabled by ":set nohlsearch"', function() - execute('set nohlsearch') + feed_command('set nohlsearch') insert("some text\nmore text") feed("gg/text<cr>") screen:expect([[ @@ -79,7 +79,7 @@ describe('search highlighting', function() /\<text\> | ]]) - execute("nohlsearch") + feed_command("nohlsearch") screen:expect([[ some text | more textstuff | @@ -92,8 +92,8 @@ describe('search highlighting', function() end) it('works with incsearch', function() - execute('set hlsearch') - execute('set incsearch') + feed_command('set hlsearch') + feed_command('set incsearch') insert([[ the first line in a little file @@ -156,8 +156,8 @@ describe('search highlighting', function() end) it('works with incsearch and offset', function() - execute('set hlsearch') - execute('set incsearch') + feed_command('set hlsearch') + feed_command('set incsearch') insert([[ not the match you're looking for the match is here]]) @@ -198,7 +198,7 @@ describe('search highlighting', function() end) it('works with multiline regexps', function() - execute('set hlsearch') + feed_command('set hlsearch') feed('4oa repeated line<esc>') feed('/line\\na<cr>') screen:expect([[ @@ -234,19 +234,19 @@ describe('search highlighting', function() [6] = {italic = true, background = colors.Magenta}, [7] = {bold = true, background = colors.Yellow}, } ) - execute('set hlsearch') + feed_command('set hlsearch') insert([[ very special text ]]) - execute("syntax on") - execute("highlight MyGroup guibg=Green gui=bold") - execute("highlight MyGroup2 guibg=Magenta gui=italic") - execute("call matchadd('MyGroup', 'special')") - execute("call matchadd('MyGroup2', 'text', 0)") + feed_command("syntax on") + feed_command("highlight MyGroup guibg=Green gui=bold") + feed_command("highlight MyGroup2 guibg=Magenta gui=italic") + feed_command("call matchadd('MyGroup', 'special')") + feed_command("call matchadd('MyGroup2', 'text', 0)") -- searchhl and matchadd matches are exclusive, only the higest priority -- is used (and matches with lower priorities are not combined) - execute("/ial te") + feed_command("/ial te") screen:expect([[ very {5:spec^ial}{2: te}{6:xt} | | @@ -257,7 +257,7 @@ describe('search highlighting', function() {4:search hit BOTTOM, continuing at TOP} | ]]) - execute("call clearmatches()") + feed_command("call clearmatches()") screen:expect([[ very spec{2:^ial te}xt | | @@ -270,7 +270,7 @@ describe('search highlighting', function() -- searchhl has priority over syntax, but in this case -- nonconflicting attributes are combined - execute("syntax keyword MyGroup special") + feed_command("syntax keyword MyGroup special") screen:expect([[ very {5:spec}{7:^ial}{2: te}xt | | diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index d02fc83809..e5c96f2ec0 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local clear, feed, command = helpers.clear, helpers.feed, helpers.command if helpers.pending_win32(pending) then return end @@ -25,11 +25,11 @@ describe('Signs', function() describe(':sign place', function() it('shadows previously placed signs', function() feed('ia<cr>b<cr>c<cr><esc>') - execute('sign define piet text=>> texthl=Search') - execute('sign define pietx text=>! texthl=Search') - execute('sign place 1 line=1 name=piet buffer=1') - execute('sign place 2 line=3 name=piet buffer=1') - execute('sign place 3 line=1 name=pietx buffer=1') + command('sign define piet text=>> texthl=Search') + command('sign define pietx text=>! texthl=Search') + command('sign place 1 line=1 name=piet buffer=1') + command('sign place 2 line=3 name=piet buffer=1') + command('sign place 3 line=1 name=pietx buffer=1') screen:expect([[ {1:>!}a | {2: }b | @@ -44,7 +44,7 @@ describe('Signs', function() {2: }{0:~ }| {2: }{0:~ }| {2: }{0:~ }| - :sign place 3 line=1 name=pietx buffer=1 | + | ]]) end) end) diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index ee3e4fa32a..28a104360d 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local clear, feed, command = helpers.clear, helpers.feed, helpers.command local insert = helpers.insert if helpers.pending_win32(pending) then return end @@ -25,7 +25,7 @@ describe('Screen', function() describe("match and conceal", function() before_each(function() - execute("let &conceallevel=1") + command("let &conceallevel=1") end) describe("multiple", function() @@ -38,7 +38,7 @@ describe('Screen', function() && && ]]) - execute("syn match dAmpersand '[&][&]' conceal cchar=∧") + command("syn match dAmpersand '[&][&]' conceal cchar=∧") end) it("double characters.", function() @@ -52,7 +52,7 @@ describe('Screen', function() ^ | {0:~ }| {0:~ }| - :syn match dAmpersand '[&][&]' conceal cchar=∧ | + | ]]) end) @@ -68,7 +68,7 @@ describe('Screen', function() | {0:~ }| {0:~ }| - :syn match dAmpersand '[&][&]' conceal cchar=∧ | + | ]]) end) @@ -84,7 +84,7 @@ describe('Screen', function() | {0:~ }| {0:~ }| - :syn match dAmpersand '[&][&]' conceal cchar=∧ | + | ]]) end) @@ -100,7 +100,7 @@ describe('Screen', function() | {0:~ }| {0:~ }| - :syn match dAmpersand '[&][&]' conceal cchar=∧ | + | ]]) end) @@ -116,15 +116,15 @@ describe('Screen', function() ^ | {0:~ }| {0:~ }| - :syn match dAmpersand '[&][&]' conceal cchar=∧ | + | ]]) end) end) -- multiple it("keyword instances in initially in the document.", function() feed("2ilambda<cr><ESC>") - execute("let &conceallevel=1") - execute("syn keyword kLambda lambda conceal cchar=λ") + command("let &conceallevel=1") + command("syn keyword kLambda lambda conceal cchar=λ") screen:expect([[ {1:λ} | {1:λ} | @@ -135,7 +135,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :syn keyword kLambda lambda conceal cchar=λ | + | ]]) end) -- Keyword @@ -144,11 +144,11 @@ describe('Screen', function() before_each(function() feed("2") insert("<r> a region of text </r>\n") - execute("let &conceallevel=1") + command("let &conceallevel=1") end) it('initially and conceal it.', function() - execute("syn region rText start='<r>' end='</r>' conceal cchar=R") + command("syn region rText start='<r>' end='</r>' conceal cchar=R") screen:expect([[ {1:R} | {1:R} | @@ -166,7 +166,7 @@ describe('Screen', function() it('initially and conceal its start tag and end tag.', function() -- concealends has a known bug (todo.txt) where the first match won't -- be replaced with cchar. - execute("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") + command("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") screen:expect([[ {1: } a region of text {1:-} | {1: } a region of text {1:-} | @@ -182,7 +182,7 @@ describe('Screen', function() end) it('that are nested and conceal the nested region\'s start and end tags.', function() - execute("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") + command("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n") screen:expect([[ {1: } a region of text {1:-} | @@ -201,10 +201,10 @@ describe('Screen', function() describe("a region of text", function() before_each(function() - execute("syntax conceal on") + command("syntax conceal on") feed("2") insert("<r> a region of text </r>\n") - execute("syn region rText start='<r>' end='</r>' cchar=-") + command("syn region rText start='<r>' end='</r>' cchar=-") end) it("and turn on implicit concealing", function() @@ -218,15 +218,15 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :syn region rText start='<r>' end='</r>' cchar=- | + | ]]) end) it("and then turn on, then off, and then back on implicit concealing.", function() - execute("syntax conceal off") + command("syntax conceal off") feed("2") insert("<i> italian text </i>\n") - execute("syn region iText start='<i>' end='</i>' cchar=*") + command("syn region iText start='<i>' end='</i>' cchar=*") screen:expect([[ {1:-} | {1:-} | @@ -237,10 +237,10 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :syn region iText start='<i>' end='</i>' cchar=* | + | ]]) - execute("syntax conceal on") - execute("syn region iText start='<i>' end='</i>' cchar=*") + command("syntax conceal on") + command("syn region iText start='<i>' end='</i>' cchar=*") screen:expect([[ {1:-} | {1:-} | @@ -251,7 +251,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :syn region iText start='<i>' end='</i>' cchar=* | + | ]]) end) end) -- a region of text (implicit concealing) @@ -262,13 +262,13 @@ describe('Screen', function() insert("// No Conceal\n") insert('"Conceal without a cchar"\n') insert("+ With cchar\n\n") - execute("syn match noConceal '^//.*$'") - execute("syn match concealNoCchar '\".\\{-}\"$' conceal") - execute("syn match concealWCchar '^+.\\{-}$' conceal cchar=C") + command("syn match noConceal '^//.*$'") + command("syn match concealNoCchar '\".\\{-}\"$' conceal") + command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C") end) it("0. No concealing.", function() - execute("let &conceallevel=0") + command("let &conceallevel=0") screen:expect([[ // No Conceal | "Conceal without a cchar" | @@ -279,12 +279,12 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :let &conceallevel=0 | + | ]]) end) it("1. Conceal using cchar or reference listchars.", function() - execute("let &conceallevel=1") + command("let &conceallevel=1") screen:expect([[ // No Conceal | {1: } | @@ -295,12 +295,12 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :let &conceallevel=1 | + | ]]) end) it("2. Hidden unless cchar is set.", function() - execute("let &conceallevel=2") + command("let &conceallevel=2") screen:expect([[ // No Conceal | | @@ -311,12 +311,12 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :let &conceallevel=2 | + | ]]) end) it("3. Hide all concealed text.", function() - execute("let &conceallevel=3") + command("let &conceallevel=3") screen:expect([[ // No Conceal | | @@ -327,7 +327,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :let &conceallevel=3 | + | ]]) end) end) -- conceallevel diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 6a6dc99c3d..6639bf272d 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local clear, feed, command = helpers.clear, helpers.feed, helpers.command local funcs = helpers.funcs if helpers.pending_win32(pending) then return end @@ -20,8 +20,8 @@ describe("'wildmode'", function() describe("'wildmenu'", function() it(':sign <tab> shows wildmenu completions', function() - execute('set wildmode=full') - execute('set wildmenu') + command('set wildmode=full') + command('set wildmenu') feed(':sign <tab>') screen:expect([[ | @@ -50,10 +50,10 @@ describe('command line completion', function() it('lists directories with empty PATH', function() local tmp = funcs.tempname() - execute('e '.. tmp) - execute('cd %:h') - execute("call mkdir('Xtest-functional-viml-compl-dir')") - execute('let $PATH=""') + command('e '.. tmp) + command('cd %:h') + command("call mkdir('Xtest-functional-viml-compl-dir')") + command('let $PATH=""') feed(':!<tab><bs>') screen:expect([[ | diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 5a37cb8f43..b35e8d4f94 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq -local execute, source, expect = helpers.execute, helpers.source, helpers.expect +local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect local meths = helpers.meths if helpers.pending_win32(pending) then return end @@ -67,25 +67,25 @@ describe('completion', function() it('is readonly', function() screen:try_resize(80, 8) feed('ifoo<ESC>o<C-x><C-n><ESC>') - execute('let v:completed_item.word = "bar"') + feed_command('let v:completed_item.word = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.abbr = "bar"') + feed_command('let v:completed_item.abbr = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.menu = "bar"') + feed_command('let v:completed_item.menu = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.info = "bar"') + feed_command('let v:completed_item.info = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.kind = "bar"') + feed_command('let v:completed_item.kind = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') end) it('returns expected dict in omni completion', function() source([[ @@ -125,7 +125,7 @@ describe('completion', function() end) it('inserts the first candidate if default', function() - execute('set completeopt+=menuone') + feed_command('set completeopt+=menuone') feed('ifoo<ESC>o') screen:expect([[ foo | @@ -176,7 +176,7 @@ describe('completion', function() eq('foo', eval('getline(3)')) end) it('selects the first candidate if noinsert', function() - execute('set completeopt+=menuone,noinsert') + feed_command('set completeopt+=menuone,noinsert') feed('ifoo<ESC>o<C-x><C-n>') screen:expect([[ foo | @@ -216,7 +216,7 @@ describe('completion', function() eq('foo', eval('getline(3)')) end) it('does not insert the first candidate if noselect', function() - execute('set completeopt+=menuone,noselect') + feed_command('set completeopt+=menuone,noselect') feed('ifoo<ESC>o<C-x><C-n>') screen:expect([[ foo | @@ -256,7 +256,7 @@ describe('completion', function() eq('bar', eval('getline(3)')) end) it('does not select/insert the first candidate if noselect and noinsert', function() - execute('set completeopt+=menuone,noselect,noinsert') + feed_command('set completeopt+=menuone,noselect,noinsert') feed('ifoo<ESC>o<C-x><C-n>') screen:expect([[ foo | @@ -305,14 +305,14 @@ describe('completion', function() eq('', eval('getline(3)')) end) it('does not change modified state if noinsert', function() - execute('set completeopt+=menuone,noinsert') - execute('setlocal nomodified') + feed_command('set completeopt+=menuone,noinsert') + feed_command('setlocal nomodified') feed('i<C-r>=TestComplete()<CR><ESC>') eq(0, eval('&l:modified')) end) it('does not change modified state if noselect', function() - execute('set completeopt+=menuone,noselect') - execute('setlocal nomodified') + feed_command('set completeopt+=menuone,noselect') + feed_command('setlocal nomodified') feed('i<C-r>=TestComplete()<CR><ESC>') eq(0, eval('&l:modified')) end) @@ -326,8 +326,8 @@ describe('completion', function() return '' endfunction ]]) - execute('set completeopt+=noselect,noinsert') - execute('inoremap <right> <c-r>=TestComplete()<cr>') + feed_command('set completeopt+=noselect,noinsert') + feed_command('inoremap <right> <c-r>=TestComplete()<cr>') end) local tests = { @@ -541,7 +541,7 @@ describe('completion', function() return '' endfunction ]]) - execute("set completeopt=menuone,noselect") + feed_command("set completeopt=menuone,noselect") end) it("works", function() @@ -707,7 +707,7 @@ describe('completion', function() it('disables folding during completion', function () - execute("set foldmethod=indent") + feed_command("set foldmethod=indent") feed('i<Tab>foo<CR><Tab>bar<Esc>gg') screen:expect([[ ^foo | @@ -734,7 +734,7 @@ describe('completion', function() end) it('popupmenu is not interrupted by events', function () - execute("set complete=.") + feed_command("set complete=.") feed('ifoobar fooegg<cr>f<c-p>') screen:expect([[ @@ -852,8 +852,8 @@ describe('completion', function() end) it("'ignorecase' 'infercase' CTRL-X CTRL-N #6451", function() - execute('set ignorecase infercase') - execute('edit BACKERS.md') + feed_command('set ignorecase infercase') + feed_command('edit BACKERS.md') feed('oX<C-X><C-N>') screen:expect([[ # Bountysource Backers | diff --git a/test/functional/viml/lang_spec.lua b/test/functional/viml/lang_spec.lua index a27e18f695..3ba9221aef 100644 --- a/test/functional/viml/lang_spec.lua +++ b/test/functional/viml/lang_spec.lua @@ -1,13 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq -local execute, source = helpers.execute, helpers.source +local exc_exec, source = helpers.exc_exec, helpers.source describe('viml', function() before_each(clear) it('parses `<SID>` with turkish locale', function() - execute('lang ctype tr_TR.UTF-8') - if string.find(eval('v:errmsg'), '^E197: ') then + if exc_exec('lang ctype tr_TR.UTF-8') ~= 0 then pending("Locale tr_TR.UTF-8 not supported") return end diff --git a/test/helpers.lua b/test/helpers.lua index eaf7f4cff4..a348e75a85 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -17,18 +17,28 @@ local ok = function(res) return assert.is_true(res) end +-- initial_path: directory to recurse into +-- re: include pattern (string) +-- exc_re: exclude pattern(s) (string or table) local function glob(initial_path, re, exc_re) + exc_re = type(exc_re) == 'table' and exc_re or { exc_re } local paths_to_check = {initial_path} local ret = {} local checked_files = {} + local function is_excluded(path) + for _, pat in pairs(exc_re) do + if path:match(pat) then return true end + end + return false + end + while #paths_to_check > 0 do local cur_path = paths_to_check[#paths_to_check] paths_to_check[#paths_to_check] = nil for e in lfs.dir(cur_path) do local full_path = cur_path .. '/' .. e local checked_path = full_path:sub(#initial_path + 1) - if ((not exc_re or not checked_path:match(exc_re)) - and e:sub(1, 1) ~= '.') then + if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then local attrs = lfs.attributes(full_path) if attrs then local check_key = attrs.dev .. ':' .. tostring(attrs.ino) @@ -106,13 +116,20 @@ local uname = (function() end) end)() +local function tmpdir_get() + return os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP') +end + +-- Is temp directory `dir` defined local to the project workspace? +local function tmpdir_is_local(dir) + return not not (dir and string.find(dir, 'Xtest')) +end + local tmpname = (function() local seq = 0 - local tmpdir = os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP') - -- Is $TMPDIR defined local to the project workspace? - local in_workspace = not not (tmpdir and string.find(tmpdir, 'Xtest')) + local tmpdir = tmpdir_get() return (function() - if in_workspace then + if tmpdir_is_local(tmpdir) then -- Cannot control os.tmpname() dir, so hack our own tmpname() impl. seq = seq + 1 local fname = tmpdir..'/nvim-test-lua-'..seq @@ -162,33 +179,34 @@ end local tests_skipped = 0 -local function check_cores(app) +local function check_cores(app, force) app = app or 'build/bin/nvim' local initial_path, re, exc_re local gdb_db_cmd = 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"' local lldb_db_cmd = 'lldb -Q -o "bt all" -f "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"' local random_skip = false + local local_tmpdir = tmpdir_is_local(tmpdir_get()) and tmpdir_get() or nil local db_cmd if hasenv('NVIM_TEST_CORE_GLOB_DIRECTORY') then initial_path = os.getenv('NVIM_TEST_CORE_GLOB_DIRECTORY') re = os.getenv('NVIM_TEST_CORE_GLOB_RE') - exc_re = os.getenv('NVIM_TEST_CORE_EXC_RE') + exc_re = { os.getenv('NVIM_TEST_CORE_EXC_RE'), local_tmpdir } db_cmd = os.getenv('NVIM_TEST_CORE_DB_CMD') or gdb_db_cmd random_skip = os.getenv('NVIM_TEST_CORE_RANDOM_SKIP') elseif os.getenv('TRAVIS_OS_NAME') == 'osx' then initial_path = '/cores' re = nil - exc_re = nil + exc_re = { local_tmpdir } db_cmd = lldb_db_cmd else initial_path = '.' re = '/core[^/]*$' - exc_re = '^/%.deps$' + exc_re = { '^/%.deps$', local_tmpdir } db_cmd = gdb_db_cmd random_skip = true end -- Finding cores takes too much time on linux - if random_skip and math.random() < 0.9 then + if not force and random_skip and math.random() < 0.9 then tests_skipped = tests_skipped + 1 return end diff --git a/test/unit/eval/decode_spec.lua b/test/unit/eval/decode_spec.lua index 0b2a423cd6..0c444b33f2 100644 --- a/test/unit/eval/decode_spec.lua +++ b/test/unit/eval/decode_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.unit.helpers')(after_each) local itp = helpers.gen_itp(it) local cimport = helpers.cimport -local to_cstr = helpers.to_cstr local eq = helpers.eq local neq = helpers.neq local ffi = helpers.ffi @@ -72,7 +71,7 @@ describe('json_decode_string()', function() end itp('does not overflow in error messages', function() - local saved_p_enc = decode.p_enc + collectgarbage('restart') check_failure(']test', 1, 'E474: No container to close: ]') check_failure('[}test', 2, 'E474: Closing list with curly bracket: }') check_failure('{]test', 2, @@ -105,10 +104,6 @@ describe('json_decode_string()', function() check_failure('"\194"test', 3, 'E474: Only UTF-8 strings allowed: \194"') check_failure('"\252\144\128\128\128\128"test', 8, 'E474: Only UTF-8 code points up to U+10FFFF are allowed to appear unescaped: \252\144\128\128\128\128"') check_failure('"test', 1, 'E474: Expected string end: "') - decode.p_enc = to_cstr('latin1') - check_failure('"\\uABCD"test', 8, - 'E474: Failed to convert string "ꯍ" from UTF-8') - decode.p_enc = saved_p_enc check_failure('-test', 1, 'E474: Missing number after minus sign: -') check_failure('-1.test', 3, 'E474: Missing number after decimal dot: -1.') check_failure('-1.0etest', 5, 'E474: Missing exponent: -1.0e') diff --git a/test/unit/eval/helpers.lua b/test/unit/eval/helpers.lua index fa76113756..5bc482216e 100644 --- a/test/unit/eval/helpers.lua +++ b/test/unit/eval/helpers.lua @@ -468,7 +468,7 @@ local function tbl2callback(tbl) data={funcref=eval.xstrdup(tbl.fref)}}}) elseif tbl.type == 'pt' then local pt = ffi.gc(ffi.cast('partial_T*', - eval.xcalloc(1, ffi.sizeof('partial_T'))), eval.partial_unref) + eval.xcalloc(1, ffi.sizeof('partial_T'))), nil) ret = ffi.new('Callback[1]', {{type=eval.kCallbackPartial, data={partial=populate_partial(pt, tbl.pt, {})}}}) else diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua index 258b5c4c1f..a1edfcfb7c 100644 --- a/test/unit/eval/typval_spec.lua +++ b/test/unit/eval/typval_spec.lua @@ -47,6 +47,15 @@ local lib = cimport('./src/nvim/eval/typval.h', './src/nvim/memory.h', './src/nvim/eval.h', './src/nvim/vim.h', './src/nvim/globals.h') +local function vimconv_alloc() + return ffi.gc( + ffi.cast('vimconv_T*', lib.xcalloc(1, ffi.sizeof('vimconv_T'))), + function(vc) + lib.convert_setup(vc, nil, nil) + lib.xfree(vc) + end) +end + local function list_watch_alloc(li) return ffi.cast('listwatch_T*', ffi.new('listwatch_T[1]', {{lw_item=li}})) end @@ -237,24 +246,33 @@ describe('typval.c', function() list_watch(l, lis[4]), list_watch(l, lis[7]), } + alloc_log:check({ + a.list(l), + a.li(lis[1]), + a.li(lis[2]), + a.li(lis[3]), + a.li(lis[4]), + a.li(lis[5]), + a.li(lis[6]), + a.li(lis[7]), + }) lib.tv_list_item_remove(l, lis[4]) - ffi.gc(lis[4], lib.tv_list_item_free) + alloc_log:check({a.freed(lis[4])}) eq({lis[1], lis[5], lis[7]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item}) lib.tv_list_item_remove(l, lis[2]) - ffi.gc(lis[2], lib.tv_list_item_free) + alloc_log:check({a.freed(lis[2])}) eq({lis[1], lis[5], lis[7]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item}) lib.tv_list_item_remove(l, lis[7]) - ffi.gc(lis[7], lib.tv_list_item_free) + alloc_log:check({a.freed(lis[7])}) eq({lis[1], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil}) lib.tv_list_item_remove(l, lis[1]) - ffi.gc(lis[1], lib.tv_list_item_free) + alloc_log:check({a.freed(lis[1])}) eq({lis[3], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil}) - alloc_log:clear() lib.tv_list_watch_remove(l, lws[2]) lib.tv_list_watch_remove(l, lws[3]) lib.tv_list_watch_remove(l, lws[1]) @@ -460,6 +478,10 @@ describe('typval.c', function() eq(empty_list, typvalt2lua(l_tv)) eq({true, true, true}, {lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil}) + lib.tv_list_watch_remove(l, lws[1]) + lib.tv_list_watch_remove(l, lws[2]) + lib.tv_list_watch_remove(l, lws[3]) + alloc_log:check({}) end) end) @@ -730,10 +752,8 @@ describe('typval.c', function() collectgarbage() end) itp('copies list correctly and converts items', function() - local vc = ffi.gc(ffi.new('vimconv_T[1]'), function(vc) - lib.convert_setup(vc, nil, nil) - end) - -- UTF-8 ↔ latin1 conversions need no iconv + local vc = vimconv_alloc() + -- UTF-8 ↔ latin1 conversions needs no iconv eq(OK, lib.convert_setup(vc, to_cstr('utf-8'), to_cstr('latin1'))) local v = {{['«']='»'}, {'„'}, 1, '“', null_string, null_list, null_dict} @@ -1087,12 +1107,16 @@ describe('typval.c', function() end) end) describe('join()', function() - local function list_join(l, sep, ret) + local function list_join(l, sep, join_ret) local ga = ga_alloc() - eq(ret or OK, lib.tv_list_join(ga, l, sep)) - if ga.ga_data == nil then return '' - else return ffi.string(ga.ga_data) + eq(join_ret or OK, lib.tv_list_join(ga, l, sep)) + local ret = '' + if ga.ga_data ~= nil then + ret = ffi.string(ga.ga_data) end + -- For some reason this is not working well in GC + lib.ga_clear(ffi.gc(ga, nil)) + return ret end itp('works', function() local l @@ -1508,7 +1532,7 @@ describe('typval.c', function() eq(s:sub(1, len), ffi.string(di.di_key)) alloc_log:check({a.di(di, len)}) if tv then - di.di_tv = tv + di.di_tv = ffi.gc(tv, nil) else di.di_tv.v_type = lib.VAR_UNKNOWN end @@ -1539,7 +1563,7 @@ describe('typval.c', function() alloc_log:check({a.dict(d)}) local di = ffi.gc(lib.tv_dict_item_alloc(''), nil) local tv = lua2typvalt('test') - di.di_tv = tv + di.di_tv = ffi.gc(tv, nil) alloc_log:check({a.di(di, ''), a.str(tv.vval.v_string, 'test')}) eq(OK, lib.tv_dict_add(d, di)) alloc_log:check({}) @@ -2131,9 +2155,7 @@ describe('typval.c', function() collectgarbage() end) itp('copies dict correctly and converts items', function() - local vc = ffi.gc(ffi.new('vimconv_T[1]'), function(vc) - lib.convert_setup(vc, nil, nil) - end) + local vc = vimconv_alloc() -- UTF-8 ↔ latin1 conversions need no iconv eq(OK, lib.convert_setup(vc, to_cstr('utf-8'), to_cstr('latin1'))) @@ -2659,7 +2681,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 0}, {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2687,7 +2710,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 0}, {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = {v[4], not not emsg} @@ -2721,7 +2745,8 @@ describe('typval.c', function() {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', -1}, }) do lib.curwin.w_cursor.lnum = 46 - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2749,7 +2774,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, 'E907: Using a special value as a Float', 0}, {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_float(UNKNOWN)', 0}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2780,7 +2806,9 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 'false'}, {lib.VAR_UNKNOWN, nil, 'E908: using an invalid value as a String', ''}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr in place of Neovim allocated string, cannot + -- tv_clear() that. + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2821,7 +2849,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 'false'}, {lib.VAR_UNKNOWN, nil, 'E908: using an invalid value as a String', nil}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2861,7 +2890,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 'false'}, {lib.VAR_UNKNOWN, nil, 'E908: using an invalid value as a String', ''}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] @@ -2902,7 +2932,8 @@ describe('typval.c', function() {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarFalse}, nil, 'false'}, {lib.VAR_UNKNOWN, nil, 'E908: using an invalid value as a String', nil}, }) do - local tv = typvalt(v[1], v[2]) + -- Using to_cstr, cannot free with tv_clear + local tv = ffi.gc(typvalt(v[1], v[2]), nil) alloc_log:check({}) local emsg = v[3] local ret = v[4] diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 74f214a231..4b9f185156 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -632,8 +632,9 @@ local function itp_child(wr, func) collectgarbage('stop') child_sethook(wr) local err, emsg = pcall(func) - debug.sethook() collectgarbage('restart') + collectgarbage() + debug.sethook() emsg = tostring(emsg) sc.write(wr, trace_end_msg) if not err then @@ -654,6 +655,7 @@ end local function check_child_err(rd) local trace = {} + local did_traceline = false while true do local traceline = sc.read(rd, hook_msglen) if #traceline ~= hook_msglen then @@ -664,6 +666,7 @@ local function check_child_err(rd) end end if traceline == trace_end_msg then + did_traceline = true break end trace[#trace + 1] = traceline @@ -679,6 +682,13 @@ local function check_child_err(rd) error = error .. trace[i] end end + if not did_traceline then + error = error .. '\nNo end of trace occurred' + end + local cc_err, cc_emsg = pcall(check_cores, Paths.test_luajit_prg, true) + if not cc_err then + error = error .. '\ncheck_cores failed: ' .. cc_emsg + end assert.just_fail(error) end if res == '+\n' then @@ -764,11 +774,6 @@ local module = { child_cleanup_once = child_cleanup_once, sc = sc, } -return function(after_each) - if after_each then - after_each(function() - check_cores(Paths.test_luajit_prg) - end) - end +return function() return module end diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake index 9ea96b7cc5..7312b6f91b 100644 --- a/third-party/cmake/BuildLuarocks.cmake +++ b/third-party/cmake/BuildLuarocks.cmake @@ -137,7 +137,7 @@ if(USE_BUNDLED_BUSTED) endif() add_custom_command(OUTPUT ${BUSTED_EXE} COMMAND ${LUAROCKS_BINARY} - ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc11-0/busted-2.0.rc11-0.rockspec ${LUAROCKS_BUILDARGS} + ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc12-1/busted-2.0.rc12-1.rockspec ${LUAROCKS_BUILDARGS} DEPENDS penlight) add_custom_target(busted DEPENDS ${BUSTED_EXE}) |