Compare commits

...

60 Commits

Author SHA1 Message Date
Bram Moolenaar
14ddd226da patch 8.2.1369: MS-Windows: autocommand test sometimes fails
Problem:    MS-Windows: autocommand test sometimes fails.
Solution:   Do not rely on the cat command.
2020-08-05 12:02:40 +02:00
Bram Moolenaar
ff1cd39cfe patch 8.2.1368: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around <, !=, etc.
2020-08-05 11:51:30 +02:00
Bram Moolenaar
b4caa163ff patch 8.2.1367: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around *, / and %.
2020-08-05 11:36:52 +02:00
Bram Moolenaar
a6296200bd patch 8.2.1366: test 49 is old style
Problem:    Test 49 is old style.
Solution:   Convert several tests to new style. (Yegappan Lakshmanan,
            closes #6629)
2020-08-05 11:23:13 +02:00
Bram Moolenaar
bb1b5e24ec patch 8.2.1365: Vim9: no error for missing white space around operator
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space. (closes #6618)
2020-08-05 10:53:21 +02:00
Bram Moolenaar
282f9c64e5 patch 8.2.1364: invalid memory access when searching for raw string
Problem:    Invalid memory access when searching for raw string.
Solution:   Check for delimiter match before following quote. (closes #6578)
2020-08-04 21:46:18 +02:00
Bram Moolenaar
e46a2ed0d8 patch 8.2.1363: test trying to run terminal when it is not supported
Problem:    Test trying to run terminal when it is not supported.
Solution:   Check if Vim can be run in a terminal.
2020-08-04 21:04:57 +02:00
Bram Moolenaar
ecd34bf55d patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Problem:    Last entry of ":set term=xxx" overwritten by error message when
            'cmdheight' is two or more. (Tony Mechelynck)
Solution:   Output extra line breaks.
2020-08-04 20:17:31 +02:00
Bram Moolenaar
6a25026262 patch 8.2.1361: error for white space after expression in assignment
Problem:    Error for white space after expression in assignment.
Solution:   Skip over white space. (closes #6617)
2020-08-04 15:53:01 +02:00
Bram Moolenaar
f96e9dec63 patch 8.2.1360: stray error for white space after expression
Problem:    Stray error for white space after expression.
Solution:   Ignore trailing white space. (closes #6608)
2020-08-03 22:39:28 +02:00
Bram Moolenaar
8314454648 patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Problem:    Vim9: cannot assign to / register in Vim9 script.
Solution:   Adjust check for assignment in Vim9 script. (closes #6567)
2020-08-02 20:40:43 +02:00
Bram Moolenaar
434d72cbf2 patch 8.2.1358: Vim9: test fails with +dnd is not available
Problem:    Vim9: test fails with +dnd is not available.
Solution:   Add condition.
2020-08-02 20:03:25 +02:00
Bram Moolenaar
658217276f patch 8.2.1357: Vim9: cannot assign to / register
Problem:    Vim9: cannot assign to / register.
Solution:   Adjust check for assignment.
2020-08-02 18:58:54 +02:00
Bram Moolenaar
7226e5b19b patch 8.2.1356: Vim9: cannot get the percent register
Problem:    Vim9: cannot get the percent register.
Solution:   Check for readable registers instead of writable. (closes #6566)
2020-08-02 17:33:26 +02:00
Bram Moolenaar
c2ee44cc38 patch 8.2.1355: Vim9: no error using :let for options and registers
Problem:    Vim9: no error using :let for options and registers.
Solution:   Give an error. (closes #6568)
2020-08-02 16:59:00 +02:00
Bram Moolenaar
aa970abd0a patch 8.2.1354: test 59 is old style
Problem:    Test 59 is old style.
Solution:   Convert into a new style test. (Yegappan Lakshmanan, closes #6604)
2020-08-02 16:10:39 +02:00
Bram Moolenaar
8b89614e69 patch 8.2.1353: crash when drawing double-wide character in terminal window
Problem:    Crash when drawing double-wide character in terminal window.
            (Masato Nishihata)
Solution:   Check getcell() returning NULL. (issue #6141)
2020-08-02 15:05:05 +02:00
Bram Moolenaar
ad486a0f0d patch 8.2.1352: Vim9: no error for shadowing a script-local function
Problem:    Vim9: no error for shadowing a script-local function by a nested
            function.
Solution:   Check for script-local function. (closes #6586)
2020-08-01 23:22:18 +02:00
Bram Moolenaar
bcbf41395f patch 8.2.1351: Vim9: no proper error if using namespace for nested function
Problem:    Vim9: no proper error if using namespace for nested function.
Solution:   Specifically check for a namespace. (closes #6582)
2020-08-01 22:35:13 +02:00
Bram Moolenaar
b9a2cac3ef patch 8.2.1350: Vim9: no test for error message when redefining function
Problem:    Vim9: no test for error message when redefining function.
Solution:   Add a test.
2020-08-01 22:23:20 +02:00
Bram Moolenaar
eef2102e20 patch 8.2.1349: Vim9: can define a function with the name of an import
Problem:    Vim9: can define a function with the name of an import.
Solution:   Disallow using an existing name. (closes #6585)
2020-08-01 22:16:43 +02:00
Bram Moolenaar
e4218b9416 patch 8.2.1348: build failure without the eval feature
Problem:    Build failure without the eval feature.
Solution:   Add #ifdef.
2020-08-01 21:11:38 +02:00
Bram Moolenaar
909443028b patch 8.2.1347: cannot easily get the script ID
Problem:    Cannot easily get the script ID.
Solution:   Support expand('<SID>').
2020-08-01 20:45:11 +02:00
Bram Moolenaar
491799be50 patch 8.2.1346: small build fails
Problem:    Small build fails.
Solution:   Add #ifdef.
2020-08-01 19:23:43 +02:00
Bram Moolenaar
f8992d47cd patch 8.2.1345: Redraw error when using visual block and scroll
Problem:    Redraw error when using visual block and scroll.
Solution:   Add check for w_topline. ( closes #6597)
2020-08-01 19:14:13 +02:00
Bram Moolenaar
2c79e9d14d patch 8.2.1344: Vim9: No test for trying to redefine global function
Problem:    Vim9: No test for trying to redefine global function.
Solution:   Add a test.
2020-08-01 18:57:52 +02:00
Bram Moolenaar
333894b195 patch 8.2.1343: Vim9: cannot find global function when using g:
Problem:    Vim9: cannot find global function when using g: when local
            function with the same name exists.
Solution:   Find global function when using g:.
2020-08-01 18:53:07 +02:00
Bram Moolenaar
f5a48010ef patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Problem:    Vim9: accidentally using "x" gives a confusing error.
Solution:   Disallow using ":t" in Vim9 script. (issue #6399)
2020-08-01 17:00:03 +02:00
Bram Moolenaar
2ec208172c patch 8.2.1341: build failures
Problem:    Build failures.
Solution:   Add missing error message.
2020-08-01 16:35:08 +02:00
Bram Moolenaar
b86abadf87 patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Problem:    Some tests fail on Cirrus CI and/or with FreeBSD.
Solution:   Make 'backupskip' empty. Do not run tests as root. Check for
            directory when using viminfo. (Ozaki Kiichi, closes #6596)
2020-08-01 16:08:19 +02:00
Bram Moolenaar
2caa1594e7 patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Problem:    Vim9: assigning to global dict variable doesn't work.
Solution:   Guess variable type based in index type. (issue #6591)
2020-08-01 15:53:19 +02:00
Bram Moolenaar
8e4c8c853e patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Problem:    Vim9: assigning to script-local variable doesn't check type.
Solution:   Use the type. (issue #6591)
2020-08-01 15:38:38 +02:00
Bram Moolenaar
586268721d patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Problem:    Vim9: cannot use empty key in dict assignment.
Solution:   Allow empty key. (closes #6591)
2020-08-01 14:06:38 +02:00
Bram Moolenaar
af50e899e7 patch 8.2.1336: build failure on non-Unix systems
Problem:    Build failure on non-Unix systems.
Solution:   Add #ifdef.
2020-08-01 13:22:10 +02:00
Bram Moolenaar
4e1d8bd79b patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Problem:    CTRL-C in the GUI doesn't interrupt. (Sergey Vlasov)
Solution:   Recognize "C" with CTRL modifier as CTRL-C. (issue #6565)
2020-08-01 13:10:14 +02:00
Bram Moolenaar
b53da7918c patch 8.2.1334: Github workflow timeout needs tuning
Problem:    Github workflow timeout needs tuning
Solution:   Use a 10 minute timeout. Fail when timing out. (Ken Takata,
            closes #6590)
2020-08-01 12:26:04 +02:00
Bram Moolenaar
af8edbb8dc patch 8.2.1333: Vim9: memory leak when using nested global function
Problem:    Vim9: memory leak when using nested global function.
Solution:   Swap from and to when copying the lines.
2020-08-01 00:03:09 +02:00
Bram Moolenaar
ce6583568f patch 8.2.1332: Vim9: memory leak when using nested global function
Problem:    Vim9: memory leak when using nested global function.
Solution:   Delete the function when deleting the instruction.  Disable test
            that still causes a leak.
2020-07-31 23:47:12 +02:00
Bram Moolenaar
badd8486f7 patch 8.2.1331: Vim9: :echo with two lists doesn't work
Problem:    Vim9: :echo with two lists doesn't work.
Solution:   Do not skip white space before []. (closes #6552)
2020-07-31 22:38:17 +02:00
Bram Moolenaar
3a53ec8bdd patch 8.2.1330: Github workflow takes longer than needed
Problem:    Github workflow takes longer than needed.
Solution:   Do two test runs in parallel instead of sequentially. (Ken Takata,
            closes #6579)
2020-07-31 22:17:32 +02:00
Bram Moolenaar
38ddf333f6 patch 8.2.1329: Vim9: cannot define global function inside :def function
Problem:    Vim9: cannot define global function inside :def function.
Solution:   Assign to global variable instead of local. (closes #6584)
2020-07-31 22:05:04 +02:00
Bram Moolenaar
4d4d1cd5c8 patch 8.2.1328: no space allowed before comma in list
Problem:    No space allowed before comma in list.
Solution:   Legacy Vim script allows it. (closes #6577)
2020-07-30 22:14:33 +02:00
Bram Moolenaar
f4ee528086 patch 8.2.1327: Mac: configure can't find Tcl libraries
Problem:    Mac: configure can't find Tcl libraries.
Solution:   Adjust configure check. (closes #6575)
2020-07-30 20:18:08 +02:00
Bram Moolenaar
9d48956681 patch 8.2.1326: Vim9: skipping over white space after list
Problem:    Vim9: skipping over white space after list.
Solution:   Do not skip white space, a following [] would be misinterpreted.
            (closes #6552)  Fix a few side effects.
2020-07-30 20:08:50 +02:00
Bram Moolenaar
ea2d8d2571 patch 8.2.1325: Vim9: using Vim9 script for autaload not tested
Problem:    Vim9: using Vim9 script for autaload not tested.
Solution:   Add a test.  Update help.
2020-07-29 22:11:05 +02:00
Bram Moolenaar
c7e44a7e4c patch 8.2.1324: Vim9: line break after "=" does not work
Problem:    Vim9: line break after "=" does not work.
Solution:   Also allow for NUL after "=". (closes #6549)
2020-07-29 21:37:43 +02:00
Bram Moolenaar
696ba23149 patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Problem:    Vim9: invalid operators only rejected in :def function.
Solution:   Also reject them at script level. (closes #6564)
2020-07-29 21:20:41 +02:00
Bram Moolenaar
1040956292 patch 8.2.1322: Vim9: method on double quoted string doesn't work
Problem:    Vim9: method on double quoted string doesn't work.
Solution:   Recognize double quoted string. (closes #6562)
2020-07-29 20:00:38 +02:00
Bram Moolenaar
7b7f78f51d patch 8.2.1321: GitHub CI also runs on tag push
Problem:    GitHub CI also runs on tag push.
Solution:   Skip CI on push. (Ken Takata, closes #6571)
2020-07-29 19:29:23 +02:00
Bram Moolenaar
33afa2447b patch 8.2.1320: Vim9: cannot declare some single letter variables
Problem:    Vim9: cannot declare some single letter variables.
Solution:   Do not recognize a colon for a namespace for single letter
            variables. (closes #6547)
2020-07-29 19:18:00 +02:00
Bram Moolenaar
ac7bf8c4bf patch 8.2.1319: status badge for Github CI has wrong link
Problem:    Status badge for Github CI has wrong link.
Solution:   Rename and use the right link
2020-07-29 17:43:55 +02:00
Bram Moolenaar
ed3c7e6339 patch 8.2.1318: no status badge for Github CI
Problem:    No status badge for Github CI.
Solution:   Add a badge.
2020-07-29 17:34:33 +02:00
Bram Moolenaar
f9a343f8bd patch 8.2.1317: MS-Windows tests on AppVeyor are slow
Problem:    MS-Windows tests on AppVeyor are slow.
Solution:   Use GitHub Actions. (Ken Takata, closes #6569)
2020-07-29 16:32:21 +02:00
Bram Moolenaar
b61ef01cce patch 8.2.1316: test 42 is still old style
Problem:    Test 42 is still old style.
Solution:   Turn it into a new style test. (Yegappan Lakshmanan, closes #6561)
2020-07-29 16:08:21 +02:00
Bram Moolenaar
45df2a01a7 patch 8.2.1315: MS-Windows: test log contains escape sequences
Problem:    MS-Windows: test log contains escape sequences.
Solution:   Do not use t_md and t_me but ANSI escape sequences. (Ken Takata,
            closes #6559)
2020-07-29 15:03:01 +02:00
Bram Moolenaar
9898107f54 patch 8.2.1314: Vim9: rule for comment after :function is confusing
Problem:    Vim9: rule for comment after :function is confusing.
Solution:   Allow double quoted comment after :function in vim9script.
            (closes #6556)
2020-07-29 14:40:25 +02:00
Bram Moolenaar
b5ed266037 patch 8.2.1313: Vim9 script: cannot assign to environment variable
Problem:    Vim9 script: cannot assign to environment variable.
Solution:   Recognize environment variable assignment. (closes #6548)
            Also options and registers.
2020-07-28 22:38:37 +02:00
Bram Moolenaar
066b12e36c patch 8.2.1312: MS-Windows: terminal test may fail if dir.exe exists
Problem:    MS-Windows: terminal test may fail if dir.exe exists.
Solution:   Use dir.com. (Ken Takata, closes #6557)
2020-07-28 21:40:27 +02:00
Bram Moolenaar
68e30449a2 patch 8.2.1311: test failures with legacy Vim script
Problem:    Test failures with legacy Vim script.
Solution:   Actually check for Vim9 script.
2020-07-28 21:15:07 +02:00
Bram Moolenaar
bd7f7c123d patch 8.2.1310: configure with Xcode 12 fails to check for tgetent
Problem:    Configure with Xcode 12 fails to check for tgetent.
Solution:   Declare tgetent(). (Ozaki Kiichi, closes #6558)
2020-07-28 21:03:37 +02:00
79 changed files with 4510 additions and 3169 deletions

View File

@@ -11,6 +11,9 @@ freebsd_12_task:
- NPROC=$(getconf _NPROCESSORS_ONLN)
- ./configure --with-features=${FEATURES}
- make -j${NPROC}
- src/vim --version
test_script:
- make test
- src/vim --version
# run tests as user "cirrus" instead of root
- pw useradd cirrus -m
- chown -R cirrus:cirrus .
- sudo -u cirrus make test

227
.github/workflows/ci-windows.yaml vendored Normal file
View File

@@ -0,0 +1,227 @@
name: GitHub CI
on:
push:
branches:
- '*'
pull_request:
env:
VCVARSALL: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
# Interfaces
# Lua
LUA_VER: 54
LUA_VER_DOT: '5.4'
LUA_RELEASE: 5.4.0
LUA32_URL: https://downloads.sourceforge.net/luabinaries/lua-%LUA_RELEASE%_Win32_dllw6_lib.zip
LUA64_URL: https://downloads.sourceforge.net/luabinaries/lua-%LUA_RELEASE%_Win64_dllw6_lib.zip
LUA_DIR: D:\Lua
# Python 2
PYTHON_VER: 27
PYTHON_VER_DOT: '2.7'
# Python 3
PYTHON3_VER: 38
PYTHON3_VER_DOT: '3.8'
# Other dependencies
# winpty
WINPTY_URL: https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip
# Escape sequences
COL_RED: "\x1b[31m"
COL_GREEN: "\x1b[32m"
COL_YELLOW: "\x1b[33m"
COL_RESET: "\x1b[m"
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
toolchain: [msvc, mingw]
arch: [x64, x86]
features: [HUGE, NORMAL]
include:
- arch: x64
vcarch: amd64
warch: x64
bits: 64
msystem: MINGW64
cygreg: registry
pyreg: ""
- arch: x86
vcarch: x86
warch: ia32
bits: 32
msystem: MINGW32
cygreg: registry32
pyreg: "-32"
exclude:
- toolchain: msvc
arch: x64
features: NORMAL
- toolchain: mingw
arch: x86
features: NORMAL
steps:
- name: Initalize
id: init
shell: bash
run: |
git config --global core.autocrlf input
python_dir=$(cat "/proc/${{ matrix.cygreg }}/HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${PYTHON_VER_DOT}/InstallPath/@")
python3_dir=$(cat "/proc/${{ matrix.cygreg }}/HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${PYTHON3_VER_DOT}${{ matrix.pyreg }}/InstallPath/@")
echo "::set-env name=PYTHON_DIR::$python_dir"
echo "::set-env name=PYTHON3_DIR::$python3_dir"
- uses: msys2/setup-msys2@v2
if: matrix.toolchain == 'mingw'
with:
msystem: ${{ matrix.msystem }}
release: false
- uses: actions/checkout@v2
- name: Create a list of download URLs
shell: cmd
run: |
type NUL > urls.txt
echo %LUA_RELEASE%>> urls.txt
echo %WINPTY_URL%>> urls.txt
- name: Cache downloaded files
uses: actions/cache@v2
with:
path: downloads
key: ${{ runner.os }}-${{ matrix.bits }}-${{ hashFiles('urls.txt') }}
- name: Download dependencies
shell: cmd
run: |
path C:\Program Files\7-Zip;%path%
if not exist downloads mkdir downloads
echo %COL_GREEN%Download Lua%COL_RESET%
call :downloadfile %LUA${{ matrix.bits }}_URL% downloads\lua.zip
7z x downloads\lua.zip -o%LUA_DIR% > nul || exit 1
echo %COL_GREEN%Download winpty%COL_RESET%
call :downloadfile %WINPTY_URL% downloads\winpty.zip
7z x -y downloads\winpty.zip -oD:\winpty > nul || exit 1
copy /Y D:\winpty\${{ matrix.warch }}\bin\winpty.dll src\winpty${{ matrix.bits }}.dll
copy /Y D:\winpty\${{ matrix.warch }}\bin\winpty-agent.exe src\
goto :eof
:downloadfile
:: call :downloadfile <URL> <localfile>
if not exist %2 (
curl -f -L %1 -o %2
)
if ERRORLEVEL 1 (
rem Retry once.
curl -f -L %1 -o %2 || exit 1
)
goto :eof
- name: Build (MSVC)
if: matrix.toolchain == 'msvc'
shell: cmd
run: |
call "%VCVARSALL%" ${{ matrix.vcarch }}
cd src
:: Filter out the progress bar from the build log
sed -e "s/@<<$/@<< | sed -e 's#.*\\\\r.*##'/" Make_mvc.mak > Make_mvc2.mak
if "${{ matrix.features }}"=="HUGE" (
nmake -nologo -f Make_mvc2.mak ^
FEATURES=${{ matrix.features }} ^
GUI=yes IME=yes ICONV=yes VIMDLL=yes ^
DYNAMIC_LUA=yes LUA=%LUA_DIR% ^
DYNAMIC_PYTHON=yes PYTHON=%PYTHON_DIR% ^
DYNAMIC_PYTHON3=yes PYTHON3=%PYTHON3_DIR%
) else (
nmake -nologo -f Make_mvc2.mak ^
FEATURES=${{ matrix.features }} ^
GUI=yes IME=yes ICONV=yes VIMDLL=yes
)
if not exist vim${{ matrix.bits }}.dll (
echo %COL_RED%Build failure.%COL_RESET%
exit 1
)
- name: Build (MinGW)
if: matrix.toolchain == 'mingw'
shell: msys2 {0}
run: |
cd src
if [ "${{ matrix.features }}" = "HUGE" ]; then
mingw32-make -f Make_ming.mak -j2 \
FEATURES=${{ matrix.features }} \
GUI=yes IME=yes ICONV=yes VIMDLL=yes \
DYNAMIC_LUA=yes LUA=${LUA_DIR} \
DYNAMIC_PYTHON=yes PYTHON=${PYTHON_DIR} \
DYNAMIC_PYTHON3=yes PYTHON3=${PYTHON3_DIR} \
STATIC_STDCPLUS=yes
else
mingw32-make -f Make_ming.mak -j2 \
FEATURES=${{ matrix.features }} \
GUI=yes IME=yes ICONV=yes VIMDLL=yes \
STATIC_STDCPLUS=yes
fi
# - name: Prepare Artifact
# shell: cmd
# run: |
# mkdir artifacts
# copy src\*vim.exe artifacts
# copy src\vim*.dll artifacts
#
# - name: Upload Artifact
# uses: actions/upload-artifact@v1
# with:
# name: vim${{ matrix.bits }}-${{ matrix.toolchain }}
# path: ./artifacts
- name: Test
shell: cmd
timeout-minutes: 20
run: |
PATH %LUA_DIR%;C:\msys64\${{ matrix.msystem }}\bin;%PATH%;%PYTHON3_DIR%
call "%VCVARSALL%" ${{ matrix.vcarch }}
cd src
echo.
echo %COL_GREEN%vim version:%COL_RESET%
.\vim --version || exit 1
mkdir ..\src2
xcopy testdir ..\src2\testdir\ /E > nul || exit 1
copy evalfunc.c ..\src2 > nul
echo %COL_GREEN%Start testing vim in background.%COL_RESET%
start cmd /c "cd ..\src2\testdir & nmake -nologo -f Make_dos.mak VIMPROG=..\..\src\vim > nul & echo done>done.txt"
echo %COL_GREEN%Test gvim:%COL_RESET%
cd testdir
nmake -nologo -f Make_dos.mak VIMPROG=..\gvim || exit 1
cd ..
echo %COL_GREEN%Wait for vim tests to finish.%COL_RESET%
cd ..\src2\testdir
:: Wait about 10 minutes.
for /L %%i in (1,1,600) do (
if exist done.txt goto exitloop
ping -n 2 localhost > nul
)
set timeout=1
:exitloop
echo %COL_GREEN%Test results of vim:%COL_RESET%
if exist messages type messages
nmake -nologo -f Make_dos.mak report VIMPROG=..\..\src\vim || exit 1
if "%timeout%"=="1" (
echo %COL_RED%Timed out.%COL_RESET%
exit 1
)

View File

@@ -9,6 +9,7 @@ SRC_ALL = \
.lgtm.yml \
.travis.yml \
.cirrus.yml \
.github/workflows/ci-windows.yaml \
appveyor.yml \
ci/appveyor.bat \
ci/if_ver*.vim \

View File

@@ -2,6 +2,7 @@
[![Travis Build Status](https://travis-ci.org/vim/vim.svg?branch=master)](https://travis-ci.org/vim/vim)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/o2qht2kjm02sgghk?svg=true)](https://ci.appveyor.com/project/chrisbra/vim)
[![Github Build status](https://github.com/vim/vim/workflows/GitHub%20CI/badge.svg)](https://github.com/vim/vim/actions?query=workflow%3A%22GitHub+CI%22)
[![Cirrus Build Status](https://api.cirrus-ci.com/github/vim/vim.svg)](https://cirrus-ci.com/github/vim/vim)
[![Coverage Status](https://codecov.io/gh/vim/vim/coverage.svg?branch=master)](https://codecov.io/gh/vim/vim?branch=master)
[![Coverity Scan](https://scan.coverity.com/projects/241/badge.svg)](https://scan.coverity.com/projects/vim)

View File

@@ -5,16 +5,17 @@ skip_tags: true
environment:
matrix:
- FEATURE: HUGE
- FEATURE: NORMAL
# disabled
# - FEATURE: TINY
# - FEATURE: SMALL
# - FEATURE: NORMAL
# - FEATURE: BIG
matrix:
fast_finish: true
before_build:
# Use Windows SDK 7.1 (= MSVC 2010)
- '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release'
- 'set INCLUDE=%INCLUDE%C:\Program Files (x86)\Windows Kits\8.1\Include\um'
@@ -25,9 +26,9 @@ test_script:
- cd src/testdir
# Testing with MSVC gvim
- path C:\Python35-x64;%PATH%
- nmake -f Make_dos.mak POSTSCRIPT=yes VIMPROG=..\gvim
- nmake -f Make_dos.mak VIMPROG=..\gvim
- nmake -f Make_dos.mak clean
# Testing with MingW console version
- nmake -f Make_dos.mak POSTSCRIPT=yes VIMPROG=..\vim
# Testing with MSVC console version
- nmake -f Make_dos.mak VIMPROG=..\vim
# vim: sw=2 sts=2 et ts=8 sr

View File

@@ -5,48 +5,32 @@ setlocal ENABLEDELAYEDEXPANSION
cd %APPVEYOR_BUILD_FOLDER%
cd src
echo "Building MinGW 32bit console version"
set PATH=c:\msys64\mingw32\bin;%PATH%
mingw32-make.exe -f Make_ming.mak GUI=no OPTIMIZE=speed IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
.\vim -u NONE -c "redir @a | ver |0put a | wq" ver_ming.txt
:: Save vim.exe before Make clean, moved back below.
copy vim.exe testdir
mingw32-make.exe -f Make_ming.mak clean
:: Build Mingw huge version with python and channel support, or
:: with specified features without python.
echo "Building MinGW 32bit GUI version"
if "%FEATURE%" == "HUGE" (
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed CHANNEL=yes GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35 FEATURES=%FEATURE% || exit 1
) ELSE (
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
)
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_ming_gui.txt
:: Filter out the progress bar from the build log
sed -e "s/@<<$/@<< | sed -e 's#.*\\\\r.*##'/" Make_mvc.mak > Make_mvc2.mak
echo "Building MSVC 64bit console Version"
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=no IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
:: The executable is not used
nmake -f Make_mvc2.mak clean
nmake -f Make_mvc2.mak CPU=AMD64 ^
OLE=no GUI=no IME=yes ICONV=yes DEBUG=no ^
FEATURES=%FEATURE% || exit 1
:: build MSVC huge version with python and channel support
:: GUI needs to be last, so that testing works
echo "Building MSVC 64bit GUI Version"
if "%FEATURE%" == "HUGE" (
nmake -f Make_mvc2.mak DIRECTX=yes CPU=AMD64 CHANNEL=yes OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak CPU=AMD64 ^
OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no POSTSCRIPT=yes ^
PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 ^
PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 ^
FEATURES=%FEATURE% || exit 1
) ELSE (
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak CPU=AMD64 ^
OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no ^
FEATURES=%FEATURE% || exit 1
)
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_msvc.txt
:: Restore vim.exe, tests will run with this.
move /Y testdir\vim.exe .
echo "version output MinGW"
type ver_ming.txt
echo "version output MinGW GUI"
type ver_ming_gui.txt
echo "version output MVC"
echo "version output MSVC console"
.\vim --version
echo "version output MSVC GUI"
type ver_msvc.txt
cd ..

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.2. Last change: 2020 Jul 21
*eval.txt* For Vim version 8.2. Last change: 2020 Aug 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -4273,6 +4273,8 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()*
line number
<sflnum> script file line number, also when in
a function
<SID> "<SNR>123_" where "123" is the
current script ID |<SID>|
<cword> word under the cursor
<cWORD> WORD under the cursor
<client> the {clientid} of the last received
@@ -12129,7 +12131,8 @@ text...
{endmarker}
Set internal variable {var-name} to a |List|
containing the lines of text bounded by the string
{endmarker}.
{endmarker}. The lines of text is used as a
|literal-string|.
{endmarker} must not contain white space.
{endmarker} cannot start with a lower case character.
The last line should end only with the {endmarker}

View File

@@ -1167,6 +1167,10 @@ When executing an autocommand or a user command, it will run in the context of
the script it was defined in. This makes it possible that the command calls a
local function or uses a local mapping.
In case the value is used in a context where <SID> cannot be correctly
expanded, use the expand() function: >
let &includexpr = expand('<SID>') .. 'My_includeexpr()'
Otherwise, using "<SID>" outside of a script context is an error.
If you need to get the script number to use in a complicated script, you can

View File

@@ -118,9 +118,13 @@ Functions and variables are script-local by default ~
*vim9-scopes*
When using `:function` or `:def` to specify a new function at the script level
in a Vim9 script, the function is local to the script, as if "s:" was
prefixed. Using the "s:" prefix is optional.
To define or use a global function or variable the "g:" prefix must be used.
prefixed. Using the "s:" prefix is optional. To define or use a global
function or variable the "g:" prefix must be used. For functions in an
autoload script the "name#" prefix is sufficient. >
def ThisFunction() # script-local
def s:ThisFunction() # script-local
def g:ThatFunction() # global
def scriptname#function() # autoload
When using `:function` or `:def` to specify a new function inside a function,
the function is local to the function. It is not possible to define a
@@ -186,8 +190,8 @@ To intentionally avoid a variable being available later, a block can be used:
An existing variable cannot be assigned to with `:let`, since that implies a
declaration. Global, window, tab, buffer and Vim variables can only be used
without `:let`, because they are are not really declared, they can also be
deleted with `:unlet`.
without `:let`, because they are not really declared, they can also be deleted
with `:unlet`.
Variables cannot shadow previously defined variables.
Variables may shadow Ex commands, rename the variable if needed.
@@ -348,10 +352,11 @@ No curly braces expansion ~
|curly-braces-names| cannot be used.
No :xit, :append, :change or :insert ~
No :xit, :t, :append, :change or :insert ~
These commands are too easily confused with local variable names. Instead of
`:x` or `:xit` you can use `:exit`.
These commands are too easily confused with local variable names.
Instead of `:x` or `:xit` you can use `:exit`.
Instead of `:t` you can use `:copy`.
Comparators ~

View File

@@ -2310,7 +2310,7 @@ test_libvterm:
# Run individual OLD style test.
# These do not depend on the executable, compile it when needed.
test1 test42 test49 test59:
test1 test49:
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.

7
src/auto/configure vendored
View File

@@ -7417,7 +7417,7 @@ $as_echo_n "checking for location of Tcl include... " >&6; }
if test "x$MACOS_X" != "xyes"; then
tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver"
else
tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /System/Library/Frameworks/Tcl.framework/Headers `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework/Versions/Current/Headers"
fi
TCL_INC=
for try in $tclinc; do
@@ -7440,7 +7440,8 @@ $as_echo_n "checking for location of tclConfig.sh script... " >&6; }
tclcnf=`echo $tclinc | sed s/include/lib/g`
tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
else
tclcnf="/System/Library/Frameworks/Tcl.framework"
tclcnf=`echo $tclinc | sed s/include/lib/g`
tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
fi
for try in $tclcnf; do
if test -f "$try/tclConfig.sh"; then
@@ -12106,7 +12107,7 @@ if test "x$olibs" = "x$LIBS"; then
$as_echo_n "checking for tgetent()... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int tgetent(char *, const char *);
int
main ()
{

View File

@@ -1820,8 +1820,10 @@ if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
if test "x$MACOS_X" != "xyes"; then
tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver"
else
dnl For all macOS, use the value from TCL in case use of, say, homebrew
dnl For Mac OS X 10.3, use the OS-provided framework location
tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /System/Library/Frameworks/Tcl.framework/Headers `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework/Versions/Current/Headers"
fi
TCL_INC=
for try in $tclinc; do
@@ -1841,8 +1843,11 @@ if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
tclcnf=`echo $tclinc | sed s/include/lib/g`
tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
else
dnl For all macOS, use the value from TCL in case use of, say, homebrew
dnl For Mac OS X 10.3, use the OS-provided framework location
tclcnf="/System/Library/Frameworks/Tcl.framework"
dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
tclcnf=`echo $tclinc | sed s/include/lib/g`
tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
fi
for try in $tclcnf; do
if test -f "$try/tclConfig.sh"; then
@@ -3510,7 +3515,7 @@ fi
if test "x$olibs" = "x$LIBS"; then
AC_MSG_CHECKING([for tgetent()])
AC_TRY_LINK([],
AC_TRY_LINK([int tgetent(char *, const char *);],
[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
AC_MSG_RESULT(yes),
AC_MSG_ERROR([NOT FOUND!

View File

@@ -838,6 +838,10 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
: eval1(arg, &tvkey, evalarg)) == FAIL) // recursive!
goto failret;
// the colon should come right after the key, but this wasn't checked
// previously, so only require it in Vim9 script.
if (!vim9script)
*arg = skipwhite(*arg);
if (**arg != ':')
{
if (evaluate)
@@ -891,7 +895,10 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
}
clear_tv(&tvkey);
// the comma must come after the value
// the comma should come right after the value, but this wasn't checked
// previously, so only require it in Vim9 script.
if (!vim9script)
*arg = skipwhite(*arg);
had_comma = **arg == ',';
if (had_comma)
{

View File

@@ -1659,10 +1659,13 @@ win_update(win_T *wp)
#endif
)
{
if (mod_top != 0 && wp->w_topline == mod_top)
if (mod_top != 0
&& wp->w_topline == mod_top
&& (!wp->w_lines[0].wl_valid
|| wp->w_topline == wp->w_lines[0].wl_lnum))
{
// w_topline is the first changed line, the scrolling will be done
// further down.
// w_topline is the first changed line and window is not scrolled,
// the scrolling from changed lines will be done further down.
}
else if (wp->w_lines[0].wl_valid
&& (wp->w_topline < wp->w_lines[0].wl_lnum

View File

@@ -300,7 +300,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
s = skipwhite(s);
if (eval1_emsg(&s, rettv, NULL) == FAIL)
return FAIL;
if (*s != NUL) // check for trailing chars after expr
if (*skipwhite(s) != NUL) // check for trailing chars after expr
{
clear_tv(rettv);
semsg(_(e_invexpr2), s);
@@ -903,6 +903,7 @@ get_lval(
clear_tv(&var1);
return NULL;
}
p = skipwhite(p);
}
// Optionally get the second index [ :expr].
@@ -1913,27 +1914,28 @@ eval_func(
char_u *
eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
{
char_u *p = skipwhite(arg);
*getnext = FALSE;
if (in_vim9script()
&& evalarg != NULL
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
&& (*arg == NUL || (VIM_ISWHITE(arg[-1])
&& vim9_comment_start(arg))))
&& (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p))))
{
char_u *p;
char_u *next;
if (evalarg->eval_cookie != NULL)
p = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
else
p = peek_next_line_from_context(evalarg->eval_cctx);
next = peek_next_line_from_context(evalarg->eval_cctx);
if (p != NULL)
if (next != NULL)
{
*getnext = TRUE;
return skipwhite(p);
return skipwhite(next);
}
}
return arg;
return p;
}
/*
@@ -2039,6 +2041,7 @@ eval0(
p = skipwhite(arg);
ret = eval1(&p, rettv, evalarg);
p = skipwhite(p);
if (ret == FAIL || !ends_excmd2(arg, p))
{
@@ -2107,6 +2110,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext)
*arg = eval_next_line(evalarg_used);
else
*arg = p;
result = FALSE;
if (evaluate)
@@ -2142,6 +2147,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
}
if (getnext)
*arg = eval_next_line(evalarg_used);
else
*arg = p;
/*
* Get the third variable. Recursive!
@@ -2234,6 +2241,8 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
if (getnext)
*arg = eval_next_line(evalarg_used);
else
*arg = p;
/*
* Get the second variable.
@@ -2349,6 +2358,8 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
if (getnext)
*arg = eval_next_line(evalarg_used);
else
*arg = p;
/*
* Get the second variable.
@@ -2411,7 +2422,7 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* var1 isnot var2
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2420,9 +2431,9 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
char_u *p;
int getnext;
int i;
exptype_T type = EXPR_UNKNOWN;
int len = 2;
int type_is = FALSE;
/*
* Get the first variable.
@@ -2431,44 +2442,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
return FAIL;
p = eval_next_non_blank(*arg, evalarg, &getnext);
switch (p[0])
{
case '=': if (p[1] == '=')
type = EXPR_EQUAL;
else if (p[1] == '~')
type = EXPR_MATCH;
break;
case '!': if (p[1] == '=')
type = EXPR_NEQUAL;
else if (p[1] == '~')
type = EXPR_NOMATCH;
break;
case '>': if (p[1] != '=')
{
type = EXPR_GREATER;
len = 1;
}
else
type = EXPR_GEQUAL;
break;
case '<': if (p[1] != '=')
{
type = EXPR_SMALLER;
len = 1;
}
else
type = EXPR_SEQUAL;
break;
case 'i': if (p[1] == 's')
{
if (p[2] == 'n' && p[3] == 'o' && p[4] == 't')
len = 5;
i = p[len];
if (!isalnum(i) && i != '_')
type = len == 2 ? EXPR_IS : EXPR_ISNOT;
}
break;
}
type = get_compare_type(p, &len, &type_is);
/*
* If there is a comparative operator, use it.
@@ -2478,9 +2452,24 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
typval_T var2;
int ic;
int vim9script = in_vim9script();
int evaluate = evalarg == NULL
? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
{
error_white_both(p, len);
clear_tv(rettv);
return FAIL;
}
if (vim9script && type_is && (p[len] == '?' || p[len] == '#'))
{
semsg(_(e_invexpr2), p);
clear_tv(rettv);
return FAIL;
}
// extra question mark appended: ignore case
if (p[len] == '?')
@@ -2501,13 +2490,19 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(p + len, evalarg);
if (eval5(arg, &var2, evalarg) == FAIL)
{
clear_tv(rettv);
return FAIL;
}
if (evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE))
if (evaluate)
{
int ret;
@@ -2571,7 +2566,7 @@ eval_addlist(typval_T *tv1, typval_T *tv2)
* .. string concatenation
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2593,6 +2588,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
int getnext;
char_u *p;
int op;
int oplen;
int concat;
typval_T var2;
@@ -2603,9 +2599,20 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (op != '+' && op != '-' && !concat)
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
oplen = (concat && p[1] == '.') ? 2 : 1;
if (getnext)
*arg = eval_next_line(evalarg);
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, oplen);
clear_tv(rettv);
return FAIL;
}
*arg = p;
}
if ((op != '+' || (rettv->v_type != VAR_LIST
&& rettv->v_type != VAR_BLOB))
#ifdef FEAT_FLOAT
@@ -2630,9 +2637,13 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
if (op == '.' && *(*arg + 1) == '.') // .. string concatenation
++*arg;
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
{
error_white_both(p, oplen);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
if (eval6(arg, &var2, evalarg, op == '.') == FAIL)
{
clear_tv(rettv);
@@ -2757,7 +2768,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* % number modulo
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2786,6 +2797,7 @@ eval6(
int evaluate;
int getnext;
typval_T var2;
char_u *p;
int op;
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
@@ -2793,19 +2805,30 @@ eval6(
#endif
int error;
op = *eval_next_non_blank(*arg, evalarg, &getnext);
p = eval_next_non_blank(*arg, evalarg, &getnext);
op = *p;
if (op != '*' && op != '/' && op != '%')
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = p;
}
#ifdef FEAT_FLOAT
f1 = 0;
f2 = 0;
#endif
error = FALSE;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (evaluate)
{
#ifdef FEAT_FLOAT
@@ -2828,7 +2851,13 @@ eval6(
/*
* Get the second variable.
*/
*arg = skipwhite(*arg + 1);
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
{
error_white_both(p, 1);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (eval7(arg, &var2, evalarg, FALSE) == FAIL)
return FAIL;
@@ -2941,7 +2970,7 @@ eval6(
* trailing ->name() method call
*
* "arg" must point to the first non-white of the expression.
* "arg" is advanced to the next non-white after the recognized expression.
* "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -3145,8 +3174,6 @@ eval7(
vim_free(alias);
}
*arg = skipwhite(*arg);
// Handle following '[', '(' and '.' for expr[expr], expr.name,
// expr(expr), expr->name(expr)
if (ret == OK)
@@ -3373,6 +3400,7 @@ eval_method(
}
else
{
*arg = skipwhite(*arg);
if (**arg != '(')
{
if (verbose)
@@ -4856,7 +4884,7 @@ get_env_len(char_u **arg)
/*
* Get the length of the name of a function or internal variable.
* "arg" is advanced to the first non-white character after the name.
* "arg" is advanced to after the name.
* Return 0 if something is wrong.
*/
int
@@ -4882,7 +4910,7 @@ get_id_len(char_u **arg)
return 0;
len = (int)(p - *arg);
*arg = skipwhite(p);
*arg = p;
return len;
}
@@ -5182,7 +5210,7 @@ handle_subscript(
p = eval_next_non_blank(*arg, evalarg, &getnext);
if (getnext
&& ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
|| (*p == '-' && p[1] == '>'
|| (p[0] == '-' && p[1] == '>'
&& (p[2] == '{' || ASCII_ISALPHA(p[2])))))
{
*arg = eval_next_line(evalarg);
@@ -5208,8 +5236,9 @@ handle_subscript(
dict_unref(selfdict);
selfdict = NULL;
}
else if (**arg == '-' && (*arg)[1] == '>')
else if (p[0] == '-' && p[1] == '>')
{
*arg = p;
if (ret == OK)
{
if ((*arg)[2] == '{')

View File

@@ -801,13 +801,13 @@ ex_let(exarg_T *eap)
else
++expr;
if (vim9script && (!VIM_ISWHITE(*argend) || !VIM_ISWHITE(*expr)))
if (vim9script && (!VIM_ISWHITE(*argend)
|| !IS_WHITE_OR_NUL(*expr)))
{
vim_strncpy(op, expr - len, len);
semsg(_(e_white_both), op);
i = FAIL;
}
expr = skipwhite(expr);
if (eap->skip)
++emsg_skip;
@@ -818,6 +818,7 @@ ex_let(exarg_T *eap)
evalarg.eval_getline = eap->getline;
evalarg.eval_cookie = eap->cookie;
}
expr = skipwhite_and_linebreak(expr, &evalarg);
i = eval0(expr, &rettv, eap, &evalarg);
if (eap->skip)
--emsg_skip;
@@ -1136,6 +1137,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
}
else
{
arg = skipwhite(arg);
if (tofree != NULL)
name = tofree;
if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
@@ -1218,6 +1220,13 @@ ex_let_one(
int opt_flags;
char_u *tofree = NULL;
if (in_vim9script() && (flags & LET_NO_COMMAND) == 0
&& vim_strchr((char_u *)"$@&", *arg) != NULL)
{
vim9_declare_error(arg);
return NULL;
}
// ":let $VAR = expr": Set environment variable.
if (*arg == '$')
{
@@ -1226,11 +1235,6 @@ ex_let_one(
emsg(_("E996: Cannot lock an environment variable"));
return NULL;
}
if (in_vim9script() && (flags & LET_NO_COMMAND) == 0)
{
vim9_declare_error(arg);
return NULL;
}
// Find the end of the name.
++arg;
@@ -2426,7 +2430,7 @@ eval_variable(
else
{
scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ import->imp_var_vals_idx;
tv = sv->sv_tv;
}
@@ -3355,6 +3359,7 @@ assert_error(garray_T *gap)
int
var_exists(char_u *var)
{
char_u *arg = var;
char_u *name;
char_u *tofree;
typval_T tv;
@@ -3363,7 +3368,7 @@ var_exists(char_u *var)
// get_name_len() takes care of expanding curly braces
name = var;
len = get_name_len(&var, &tofree, TRUE, FALSE);
len = get_name_len(&arg, &tofree, TRUE, FALSE);
if (len > 0)
{
if (tofree != NULL)
@@ -3372,12 +3377,13 @@ var_exists(char_u *var)
if (n)
{
// handle d.key, l[idx], f(expr)
n = (handle_subscript(&var, &tv, &EVALARG_EVALUATE, FALSE) == OK);
arg = skipwhite(arg);
n = (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, FALSE) == OK);
if (n)
clear_tv(&tv);
}
}
if (*var != NUL)
if (*arg != NUL)
n = FALSE;
vim_free(tofree);

View File

@@ -1710,7 +1710,7 @@ do_one_cmd(
char_u *cmd;
int starts_with_colon = FALSE;
#ifdef FEAT_EVAL
int starts_with_quote;
int may_have_range;
int vim9script = in_vim9script();
#endif
@@ -1773,8 +1773,9 @@ do_one_cmd(
*/
cmd = ea.cmd;
#ifdef FEAT_EVAL
starts_with_quote = vim9script && !starts_with_colon && *ea.cmd == '\'';
if (!starts_with_quote)
// In Vim9 script a colon is required before the range.
may_have_range = !vim9script || starts_with_colon;
if (may_have_range)
#endif
ea.cmd = skip_range(ea.cmd, NULL);
if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
@@ -1783,7 +1784,10 @@ do_one_cmd(
#ifdef FEAT_EVAL
if (vim9script && !starts_with_colon)
{
if (ea.cmd > cmd)
if (ea.cmd == cmd + 1 && *cmd == '$')
// should be "$VAR = val"
--ea.cmd;
else if (ea.cmd > cmd)
{
emsg(_(e_colon_required));
goto doend;
@@ -1876,7 +1880,7 @@ do_one_cmd(
ea.cmd = cmd;
#ifdef FEAT_EVAL
if (!starts_with_quote)
if (may_have_range)
#endif
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
goto doend;
@@ -3267,81 +3271,95 @@ find_ex_command(
* "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
*/
p = eap->cmd;
if (lookup != NULL && (vim_strchr((char_u *)"{('[", *p) != NULL
|| ((p = to_name_const_end(eap->cmd)) > eap->cmd
&& *p != NUL)))
if (lookup != NULL)
{
int oplen;
int heredoc;
// Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
? eap->cmd + 1 : eap->cmd;
if (
// "(..." is an expression.
// "funcname(" is always a function call.
*p == '('
|| (p == eap->cmd
? (
// "{..." is an dict expression.
*eap->cmd == '{'
// "'string'->func()" is an expression.
|| *eap->cmd == '\''
// "g:varname" is an expression.
|| eap->cmd[1] == ':'
)
: (
// "varname[]" is an expression.
*p == '['
// "varname->func()" is an expression.
|| (*p == '-' && p[1] == '>')
// "varname.expr" is an expression.
|| (*p == '.' && ASCII_ISALPHA(p[1]))
)))
if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{
eap->cmdidx = CMD_eval;
return eap->cmd;
}
int oplen;
int heredoc;
// "[...]->Method()" is a list expression, but "[a, b] = Func()" is
// an assignment.
// If there is no line break inside the "[...]" then "p" is advanced to
// after the "]" by to_name_const_end(): check if a "=" follows.
// If "[...]" has a line break "p" still points at the "[" and it can't
// be an assignment.
if (*eap->cmd == '[')
{
p = to_name_const_end(eap->cmd);
if (p == eap->cmd || *skipwhite(p) != '=')
if (
// "(..." is an expression.
// "funcname(" is always a function call.
*p == '('
|| (p == eap->cmd
? (
// "{..." is an dict expression.
*eap->cmd == '{'
// "'string'->func()" is an expression.
|| *eap->cmd == '\''
// '"string"->func()' is an expression.
|| *eap->cmd == '"'
// "g:varname" is an expression.
|| eap->cmd[1] == ':'
)
: (
// "varname[]" is an expression.
*p == '['
// "varname->func()" is an expression.
|| (*p == '-' && p[1] == '>')
// "varname.expr" is an expression.
|| (*p == '.' && ASCII_ISALPHA(p[1]))
)))
{
eap->cmdidx = CMD_eval;
return eap->cmd;
}
if (p > eap->cmd && *skipwhite(p) == '=')
// "[...]->Method()" is a list expression, but "[a, b] = Func()" is
// an assignment.
// If there is no line break inside the "[...]" then "p" is
// advanced to after the "]" by to_name_const_end(): check if a "="
// follows.
// If "[...]" has a line break "p" still points at the "[" and it
// can't be an assignment.
if (*eap->cmd == '[')
{
eap->cmdidx = CMD_let;
p = to_name_const_end(eap->cmd);
if (p == eap->cmd || *skipwhite(p) != '=')
{
eap->cmdidx = CMD_eval;
return eap->cmd;
}
if (p > eap->cmd && *skipwhite(p) == '=')
{
eap->cmdidx = CMD_let;
return eap->cmd;
}
}
// Recognize an assignment if we recognize the variable name:
// "g:var = expr"
// "var = expr" where "var" is a local var name.
if (*eap->cmd == '@')
p = eap->cmd + 2;
oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0)
{
if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
|| *eap->cmd == '&'
|| *eap->cmd == '$'
|| *eap->cmd == '@'
|| lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
{
eap->cmdidx = CMD_let;
return eap->cmd;
}
}
// Recognize using a type for a w:, b:, t: or g: variable:
// "w:varname: number = 123".
if (eap->cmd[1] == ':' && *p == ':')
{
eap->cmdidx = CMD_eval;
return eap->cmd;
}
}
// Recognize an assignment if we recognize the variable name:
// "g:var = expr"
// "var = expr" where "var" is a local var name.
oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0)
{
if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
|| lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
{
eap->cmdidx = CMD_let;
return eap->cmd;
}
}
// Recognize using a type for a w:, b:, t: or g: variable:
// "w:varname: number = 123".
if (eap->cmd[1] == ':' && *p == ':')
{
eap->cmdidx = CMD_eval;
return eap->cmd;
}
}
#endif
@@ -7260,6 +7278,10 @@ ex_copymove(exarg_T *eap)
{
long n;
#ifdef FEAT_EVAL
if (not_in_vim9(eap) == FAIL)
return;
#endif
n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
if (eap->arg == NULL) // error detected
{
@@ -8282,9 +8304,11 @@ find_cmdline_var(char_u *src, int *usedlen)
#define SPEC_AMATCH (SPEC_ABUF + 1)
"<sflnum>", // script file line number
#define SPEC_SFLNUM (SPEC_AMATCH + 1)
"<SID>", // script ID: <SNR>123_
#define SPEC_SID (SPEC_SFLNUM + 1)
#ifdef FEAT_CLIENTSERVER
"<client>"
# define SPEC_CLIENT (SPEC_SFLNUM + 1)
# define SPEC_CLIENT (SPEC_SID + 1)
#endif
};
@@ -8559,6 +8583,16 @@ eval_vars(
(long)(current_sctx.sc_lnum + SOURCING_LNUM));
result = strbuf;
break;
case SPEC_SID:
if (current_sctx.sc_sid <= 0)
{
*errormsg = _(e_usingsid);
return NULL;
}
sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid);
result = strbuf;
break;
#endif
#ifdef FEAT_CLIENTSERVER

View File

@@ -1684,6 +1684,7 @@ EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox:
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
EXTERN char e_dictnull[] INIT(= N_("E1103: Dictionary not set"));
EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld"));
EXTERN char e_blobidx[] INIT(= N_("E979: Blob index out of range: %ld"));
EXTERN char e_invalblob[] INIT(= N_("E978: Invalid operation for Blob"));
@@ -1745,6 +1746,7 @@ EXTERN char e_missing_dict_colon[] INIT(= N_("E720: Missing colon in Dictionary:
EXTERN char e_duplicate_key[] INIT(= N_("E721: Duplicate key in Dictionary: \"%s\""));
EXTERN char e_missing_dict_comma[] INIT(= N_("E722: Missing comma in Dictionary: %s"));
EXTERN char e_missing_dict_end[] INIT(= N_("E723: Missing end of Dictionary '}': %s"));
EXTERN char e_already_defined[] INIT(= N_("E1073: name already defined: %s"));
#endif
#ifdef FEAT_CLIENTSERVER
EXTERN char e_invexprmsg[] INIT(= N_("E449: Invalid expression received"));

View File

@@ -5575,3 +5575,27 @@ gui_handle_drop(
entered = FALSE;
}
#endif
/*
* Check if "key" is to interrupt us. Handles a key that has not had modifiers
* applied yet.
* Return the key with modifiers applied if so, NUL if not.
*/
int
check_for_interrupt(int key, int modifiers_arg)
{
int modifiers = modifiers_arg;
int c = merge_modifyOtherKeys(key, &modifiers);
if ((c == Ctrl_C && ctrl_c_interrupts)
#ifdef UNIX
|| (intr_char != Ctrl_C && c == intr_char)
#endif
)
{
got_int = TRUE;
return c;
}
return NUL;
}

View File

@@ -1254,11 +1254,16 @@ key_press_event(GtkWidget *widget UNUSED,
add_to_input_buf(string2, 3);
}
if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
|| (string[0] == intr_char && intr_char != Ctrl_C)))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(key, modifiers);
if (int_ch != NUL)
{
trash_input_buf();
string[0] = int_ch;
len = 1;
}
}
add_to_input_buf(string, len);

View File

@@ -596,11 +596,17 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
string[ len++ ] = ch;
}
if (len == 1 && ((ch == Ctrl_C && ctrl_c_interrupts)
|| ch == intr_char))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(ch, modifiers);
if (int_ch != NUL)
{
ch = int_ch;
string[0] = ch;
len = 1;
trash_input_buf();
}
}
if (len == 1 && string[0] == CSI)

View File

@@ -970,14 +970,16 @@ gui_x11_key_hit_cb(
add_to_input_buf(string2, 3);
}
if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
#ifdef UNIX
|| (intr_char != 0 && string[0] == intr_char)
#endif
))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(key, modifiers);
if (int_ch != NUL)
{
trash_input_buf();
string[0] = int_ch;
len = 1;
}
}
add_to_input_buf(string, len);

View File

@@ -186,7 +186,12 @@ static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
cell->chars[i] = 0;
for(col = 1; col < info->width; col++)
getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1;
{
ScreenCell *onecell = getcell(screen, pos.row, pos.col + col);
if (onecell == NULL)
break;
onecell->chars[0] = (uint32_t)-1;
}
rect.start_row = pos.row;
rect.end_row = pos.row+1;

View File

@@ -1194,12 +1194,15 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
else
clear_tv(&tv);
}
// Legacy Vim script allowed a space before the comma.
if (!vim9script)
*arg = skipwhite(*arg);
// the comma must come after the value
had_comma = **arg == ',';
if (had_comma)
{
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
{
semsg(_(e_white_after), ",");
goto failret;
@@ -1231,7 +1234,7 @@ failret:
return FAIL;
}
*arg = skipwhite(*arg + 1);
*arg += 1;
if (evaluate)
rettv_list_set(rettv, l);

View File

@@ -2027,6 +2027,41 @@ ga_clear_strings(garray_T *gap)
ga_clear(gap);
}
/*
* Copy a growing array that contains a list of strings.
*/
int
ga_copy_strings(garray_T *from, garray_T *to)
{
int i;
ga_init2(to, sizeof(char_u *), 1);
if (ga_grow(to, from->ga_len) == FAIL)
return FAIL;
for (i = 0; i < from->ga_len; ++i)
{
char_u *orig = ((char_u **)from->ga_data)[i];
char_u *copy;
if (orig == NULL)
copy = NULL;
else
{
copy = vim_strsave(orig);
if (copy == NULL)
{
to->ga_len = i;
ga_clear_strings(to);
return FAIL;
}
}
((char_u **)to->ga_data)[i] = copy;
}
to->ga_len = from->ga_len;
return OK;
}
/*
* Initialize a growing array. Don't forget to set ga_itemsize and
* ga_growsize! Or use ga_init2().

View File

@@ -65,4 +65,5 @@ void gui_update_screen(void);
char_u *get_find_dialog_text(char_u *arg, int *wwordp, int *mcasep);
int gui_do_findrepl(int flags, char_u *find_text, char_u *repl_text, int down);
void gui_handle_drop(int x, int y, int_u modifiers, char_u **fnames, int count);
int check_for_interrupt(int key, int modifiers_arg);
/* vim: set ft=c : */

View File

@@ -56,6 +56,7 @@ char_u *vim_strrchr(char_u *string, int c);
int vim_isspace(int x);
void ga_clear(garray_T *gap);
void ga_clear_strings(garray_T *gap);
int ga_copy_strings(garray_T *from, garray_T *to);
void ga_init(garray_T *gap);
void ga_init2(garray_T *gap, int itemsize, int growsize);
int ga_grow(garray_T *gap, int n);

View File

@@ -9,7 +9,9 @@ char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, int no_au
void emsg_funcname(char *ermsg, char_u *name);
int get_func_tv(char_u *name, int len, typval_T *rettv, char_u **arg, evalarg_T *evalarg, funcexe_T *funcexe);
char_u *fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error);
ufunc_T *find_func_even_dead(char_u *name, int is_global, cctx_T *cctx);
ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx);
void copy_func(char_u *lambda, char_u *global);
int call_user_func_check(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, funcexe_T *funcexe, dict_T *selfdict);
void save_funccal(funccal_entry_T *entry);
void restore_funccal(void);

View File

@@ -16,6 +16,8 @@ int vim9_comment_start(char_u *p);
char_u *peek_next_line_from_context(cctx_T *cctx);
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
char_u *to_name_const_end(char_u *arg);
exptype_T get_compare_type(char_u *p, int *len, int *type_is);
void error_white_both(char_u *op, int len);
int assignment_len(char_u *p, int *heredoc);
void vim9_declare_error(char_u *name);
int check_vim9_unlet(char_u *name);

View File

@@ -1928,8 +1928,8 @@ find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)
{
if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col)
break;
if (*p == ')' && p[delim_len + 1] == '"'
&& STRNCMP(delim_copy, p + 1, delim_len) == 0)
if (*p == ')' && STRNCMP(delim_copy, p + 1, delim_len) == 0
&& p[delim_len + 1] == '"')
{
found = TRUE;
break;

View File

@@ -1546,6 +1546,7 @@ typedef enum {
/*
* Structure to hold info for a user function.
* When adding a field check copy_func().
*/
typedef struct
{
@@ -1618,6 +1619,7 @@ typedef struct
#define FC_NOARGS 0x200 // no a: variables in lambda
#define FC_VIM9 0x400 // defined in vim9 script file
#define FC_CFUNC 0x800 // defined as Lua C func
#define FC_COPY 0x1000 // copy of another function by copy_func()
#define MAX_FUNC_ARGS 20 // maximum number of function arguments
#define VAR_SHORT_LEN 20 // short variable name length

View File

@@ -1763,6 +1763,7 @@ get_term_entries(int *height, int *width)
report_term_error(char *error_msg, char_u *term)
{
struct builtin_term *termp;
int i;
mch_errmsg("\r\n");
if (error_msg != NULL)
@@ -1787,6 +1788,10 @@ report_term_error(char *error_msg, char_u *term)
mch_errmsg("\r\n");
}
}
// Output extra 'cmdheight' line breaks to avoid that the following error
// message overwrites the last terminal name.
for (i = 1; i < p_ch; ++i)
mch_errmsg("\r\n");
}
static void

View File

@@ -11,7 +11,7 @@ NO_INITS = -U NONE $(NO_PLUGINS)
SCRIPTS_FIRST = test1.out
# Tests that run on all systems.
SCRIPTS_ALL = test42.out
SCRIPTS_ALL =
# Tests that run on most systems, but not on Amiga.
SCRIPTS_MORE1 =
@@ -20,7 +20,7 @@ SCRIPTS_MORE1 =
SCRIPTS_MORE2 = test49.out
# Tests that run on most systems, but not on VMS
SCRIPTS_MORE4 = test59.out
SCRIPTS_MORE4 =
# Tests specifically for MS-Windows.
SCRIPTS_WIN32 =
@@ -242,6 +242,7 @@ NEW_TESTS = \
test_source \
test_source_utf8 \
test_spell \
test_spell_utf8 \
test_spellfile \
test_startup \
test_startup_utf8 \
@@ -464,6 +465,7 @@ NEW_TESTS_RES = \
test_sound.res \
test_source.res \
test_spell.res \
test_spell_utf8.res \
test_spellfile.res \
test_startup.res \
test_stat.res \

View File

@@ -10,10 +10,7 @@ default: nongui
!include Make_all.mak
# Omitted:
# test2 "\\tmp" doesn't work.
# test10 'errorformat' is different
# test49 fails in various ways
# test97 \{ and \$ are not escaped characters.
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4)

View File

@@ -28,11 +28,6 @@ default: vimall
include Make_all.mak
# Omitted:
# test2 "\\tmp" doesn't work.
# test10 'errorformat' is different
# test97 \{ and \$ are not escaped characters
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
SCRIPTS_BENCH = test_bench_regexp.res

View File

@@ -32,22 +32,6 @@
# and directory handling.
# WANT_UNIX = YES
# Comment out if you want to run Win32 specific tests as well, but please
# be aware, that on OpenVMS will fail, because of cat, rm, etc commands
# and directory handling.
# WANT_WIN = YES
# Comment out if you want to run spell checker tests.
# They fail because VMS does not support file names.
# WANT_SPELL = YES
# Comment out if you want to run mzschema tests.
# It fails because VMS does not support this feature yet.
# WANT_MZSCH = YES
# Comment out if you have ODS-5 file system
# HAVE_ODS5 = YES
# Comment out if you have gzip on your system
# HAVE_GZIP = YES
@@ -73,14 +57,7 @@ VIMPROG = <->vim.exe
.SUFFIXES : .out .in
SCRIPT = test1.out \
test42.out test49.out test77a.out
# Known problems:
#
# test59: Failed/Hangs - VMS does not support spell files (file names
# with too many dots).
#
SCRIPT = test1.out test49.out test77a.out
.IFDEF WANT_GUI
GUI_OPTION = -g
@@ -90,10 +67,6 @@ GUI_OPTION = -g
SCRIPT_UNIX = test49.out
.ENDIF
.IFDEF WANT_SPELL
SCRIPT_SPELL = test59.out
.ENDIF
.in.out :
-@ !clean up before doing the test
-@ if "''F$SEARCH("test.out.*")'" .NES. "" then delete/noconfirm/nolog test.out.*
@@ -114,8 +87,7 @@ SCRIPT_SPELL = test59.out
-@ if "''F$SEARCH("Xdotest.*")'" .NES. "" then delete/noconfirm/nolog Xdotest.*.*
-@ if "''F$SEARCH("Xtest.*")'" .NES. "" then delete/noconfirm/nolog Xtest.*.*
all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_UNIX) $(SCRIPT_SPELL) \
nolog
all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_UNIX) nolog
-@ write sys$output " "
-@ write sys$output "-----------------------------------------------"
-@ write sys$output " All done"
@@ -140,10 +112,6 @@ nolog :
-@ write sys$output "MAKE_VMS.MMS options:"
-@ write sys$output " WANT_GUI = ""$(WANT_GUI)"" "
-@ write sys$output " WANT_UNIX = ""$(WANT_UNIX)"" "
-@ write sys$output " WANT_WIN = ""$(WANT_WIN)"" "
-@ write sys$output " WANT_SPELL = ""$(WANT_SPELL)"" "
-@ write sys$output " WANT_MZSCH = ""$(WANT_MZSCH)"" "
-@ write sys$output " HAVE_ODS5 = ""$(HAVE_ODS5)"" "
-@ write sys$output " HAVE_GZIP = ""$(HAVE_GZIP)"" "
-@ write sys$output " HAVE_GDIFF = ""$(HAVE_GDIFF)"" "
-@ write sys$output " HAVE_ICONV = ""$(HAVE_ICONV)"" "

View File

@@ -0,0 +1,7 @@
|{+0&#e0e0e08| | +0&#ffffff0@72
|}+0&#e0e0e08| | +0&#ffffff0@72
|{+0&#e0e0e08| | +0&#ffffff0@72
|f+0&#e0e0e08| | +0&#ffffff0@72
>g| +0&#e0e0e08| +0&#ffffff0@72
|}| @73
|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@29|7| @8|1@1|,|1| @9|B|o|t|

View File

@@ -123,6 +123,12 @@ let s:srcdir = expand('%:p:h:h')
if has('win32')
" avoid prompt that is long or contains a line break
let $PROMPT = '$P$G'
" On MS-Windows t_md and t_me are Vim specific escape sequences.
let s:t_bold = "\x1b[1m"
let s:t_normal = "\x1b[m"
else
let s:t_bold = &t_md
let s:t_normal = &t_me
endif
" Prepare for calling test_garbagecollect_now().
@@ -239,11 +245,11 @@ func RunTheTest(test)
let message ..= repeat(' ', 50 - len(message))
let time = reltime(func_start)
if has('float') && reltimefloat(time) > 0.1
let message = &t_md .. message
let message = s:t_bold .. message
endif
let message ..= ' in ' .. reltimestr(time) .. ' seconds'
if has('float') && reltimefloat(time) > 0.1
let message ..= &t_me
let message ..= s:t_normal
endif
endif
call add(s:messages, message)
@@ -312,9 +318,9 @@ func FinishTesting()
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
endif
if s:done > 0 && has('reltime')
let message = &t_md .. message .. repeat(' ', 40 - len(message))
let message = s:t_bold .. message .. repeat(' ', 40 - len(message))
let message ..= ' in ' .. reltimestr(reltime(s:start_time)) .. ' seconds'
let message ..= &t_me
let message ..= s:t_normal
endif
echo message
call add(s:messages, message)

View File

@@ -0,0 +1,9 @@
vim9script
func auto9#getsome()
return 'some'
endfunc
def auto9#add42(count: number): number
return count + 42
enddef

View File

@@ -0,0 +1,69 @@
" Functions shared by the tests for Vim Script
" Commands to track the execution path of a script
com! XpathINIT let g:Xpath = ''
com! -nargs=1 -bar Xpath let g:Xpath ..= <args>
com! XloopINIT let g:Xloop = 1
com! -nargs=1 -bar Xloop let g:Xpath ..= <args> .. g:Xloop
com! XloopNEXT let g:Xloop += 1
" MakeScript() - Make a script file from a function. {{{2
"
" Create a script that consists of the body of the function a:funcname.
" Replace any ":return" by a ":finish", any argument variable by a global
" variable, and every ":call" by a ":source" for the next following argument
" in the variable argument list. This function is useful if similar tests are
" to be made for a ":return" from a function call or a ":finish" in a script
" file.
func MakeScript(funcname, ...)
let script = tempname()
execute "redir! >" . script
execute "function" a:funcname
redir END
execute "edit" script
" Delete the "function" and the "endfunction" lines. Do not include the
" word "function" in the pattern since it might be translated if LANG is
" set. When MakeScript() is being debugged, this deletes also the debugging
" output of its line 3 and 4.
exec '1,/.*' . a:funcname . '(.*)/d'
/^\d*\s*endfunction\>/,$d
%s/^\d*//e
%s/return/finish/e
%s/\<a:\(\h\w*\)/g:\1/ge
normal gg0
let cnt = 0
while search('\<call\s*\%(\u\|s:\)\w*\s*(.*)', 'W') > 0
let cnt = cnt + 1
s/\<call\s*\%(\u\|s:\)\w*\s*(.*)/\='source ' . a:{cnt}/
endwhile
g/^\s*$/d
write
bwipeout
return script
endfunc
" ExecAsScript - Source a temporary script made from a function. {{{2
"
" Make a temporary script file from the function a:funcname, ":source" it, and
" delete it afterwards. However, if an exception is thrown the file may remain,
" the caller should call DeleteTheScript() afterwards.
let s:script_name = ''
function! ExecAsScript(funcname)
" Make a script from the function passed as argument.
let s:script_name = MakeScript(a:funcname)
" Source and delete the script.
exec "source" s:script_name
call delete(s:script_name)
let s:script_name = ''
endfunction
function! DeleteTheScript()
if s:script_name
call delete(s:script_name)
let s:script_name = ''
endif
endfunc
com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)

Binary file not shown.

Binary file not shown.

View File

@@ -1,25 +1,4 @@
Results of test49.vim:
*** Test 18: OK (67224583)
*** Test 19: OK (69275973)
*** Test 20: OK (1874575085)
*** Test 21: OK (147932225)
*** Test 22: OK (4161)
*** Test 23: OK (49)
*** Test 24: OK (41)
*** Test 27: OK (1996459)
*** Test 28: OK (1996459)
*** Test 29: OK (170428555)
*** Test 30: OK (190905173)
*** Test 31: OK (190905173)
*** Test 34: OK (2146584868)
*** Test 35: OK (2146584868)
*** Test 36: OK (1071644672)
*** Test 37: OK (1071644672)
*** Test 38: OK (357908480)
*** Test 39: OK (357908480)
*** Test 40: OK (357908480)
*** Test 49: OK (179000669)
*** Test 50: OK (363550045)
*** Test 52: OK (1247112011)
*** Test 53: OK (131071)
*** Test 54: OK (2047)

File diff suppressed because it is too large Load Diff

View File

@@ -1,626 +0,0 @@
Tests for spell checking with 'encoding' set to "utf-8". vim: set ft=vim :
STARTTEST
:so small.vim
:so mbyte.vim
:"
:" Don't want to depend on the locale from the environment. The .aff and .dic
:" text is in latin1, the test text is utf-8.
:set enc=latin1
:e!
:set enc=utf-8
:set fenc=
:"
:" Function to test .aff/.dic with list of good and bad words.
:func TestOne(aff, dic)
set spellfile=
$put =''
$put ='test '. a:aff . '-' . a:dic
" Generate a .spl file from a .dic and .aff file.
exe '1;/^' . a:aff . 'affstart/+1,/^' . a:aff . 'affend/-1w! Xtest.aff'
exe '1;/^' . a:dic . 'dicstart/+1,/^' . a:dic . 'dicend/-1w! Xtest.dic'
mkspell! Xtest Xtest
" use that spell file
set spl=Xtest.utf-8.spl spell
" list all valid words
spelldump
%yank
quit
$put
$put ='-------'
" find all bad words and suggestions for them
exe '1;/^' . a:aff . 'good:'
normal 0f:]s
let prevbad = ''
while 1
let [bad, a] = spellbadword()
if bad == '' || bad == prevbad || bad == 'badend'
break
endif
let prevbad = bad
let lst = spellsuggest(bad, 3)
normal mm
$put =bad
$put =string(lst)
normal `m]s
endwhile
endfunc
:"
:call TestOne('1', '1')
:$put =soundfold('goobledygoook')
:$put =soundfold('kóopërÿnôven')
:$put =soundfold('oeverloos gezwets edale')
:"
:"
:" and now with SAL instead of SOFO items; test automatic reloading
gg:/^affstart_sal/+1,/^affend_sal/-1w! Xtest.aff
:mkspell! Xtest Xtest
:$put =soundfold('goobledygoook')
:$put =soundfold('kóopërÿnôven')
:$put =soundfold('oeverloos gezwets edale')
:"
:" also use an addition file
gg:/^addstart/+1,/^addend/-1w! Xtest.utf-8.add
:mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add
:set spellfile=Xtest.utf-8.add
/^test2:
]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_us.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_gb.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_nz.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_ca.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:unlet str a
:"
:" Postponed prefixes
:call TestOne('2', '1')
:"
:" Compound words
:call TestOne('3', '3')
:call TestOne('4', '4')
:call TestOne('5', '5')
:call TestOne('6', '6')
:call TestOne('7', '7')
:"
:" clean up for valgrind
:delfunc TestOne
:set spl= enc=latin1
:"
gg:/^test output:/,$wq! test.out
ENDTEST
1affstart
SET ISO8859-1
TRY esianrtolcdugmphbyfvkwjkqxz-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'ESIANRTOLCDUGMPHBYFVKWJKQXZ
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<59><5A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޿
SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
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<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
1affend
affstart_sal
SET ISO8859-1
TRY esianrtolcdugmphbyfvkwjkqxz-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'ESIANRTOLCDUGMPHBYFVKWJKQXZ
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
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<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
SAL AH(AEIOUY)-^ *H
SAL AR(AEIOUY)-^ *R
SAL A(HR)^ *
SAL A^ *
SAL AH(AEIOUY)- H
SAL AR(AEIOUY)- R
SAL A(HR) _
SAL <20>^ *
SAL <20>^ *
SAL BB- _
SAL B B
SAL CQ- _
SAL CIA X
SAL CH X
SAL C(EIY)- S
SAL CK K
SAL COUGH^ KF
SAL CC< C
SAL C K
SAL DG(EIY) K
SAL DD- _
SAL D T
SAL <20>< E
SAL EH(AEIOUY)-^ *H
SAL ER(AEIOUY)-^ *R
SAL E(HR)^ *
SAL ENOUGH^$ *NF
SAL E^ *
SAL EH(AEIOUY)- H
SAL ER(AEIOUY)- R
SAL E(HR) _
SAL FF- _
SAL F F
SAL GN^ N
SAL GN$ N
SAL GNS$ NS
SAL GNED$ N
SAL GH(AEIOUY)- K
SAL GH _
SAL GG9 K
SAL G K
SAL H H
SAL IH(AEIOUY)-^ *H
SAL IR(AEIOUY)-^ *R
SAL I(HR)^ *
SAL I^ *
SAL ING6 N
SAL IH(AEIOUY)- H
SAL IR(AEIOUY)- R
SAL I(HR) _
SAL J K
SAL KN^ N
SAL KK- _
SAL K K
SAL LAUGH^ LF
SAL LL- _
SAL L L
SAL MB$ M
SAL MM M
SAL M M
SAL NN- _
SAL N N
SAL OH(AEIOUY)-^ *H
SAL OR(AEIOUY)-^ *R
SAL O(HR)^ *
SAL O^ *
SAL OH(AEIOUY)- H
SAL OR(AEIOUY)- R
SAL O(HR) _
SAL PH F
SAL PN^ N
SAL PP- _
SAL P P
SAL Q K
SAL RH^ R
SAL ROUGH^ RF
SAL RR- _
SAL R R
SAL SCH(EOU)- SK
SAL SC(IEY)- S
SAL SH X
SAL SI(AO)- X
SAL SS- _
SAL S S
SAL TI(AO)- X
SAL TH @
SAL TCH-- _
SAL TOUGH^ TF
SAL TT- _
SAL T T
SAL UH(AEIOUY)-^ *H
SAL UR(AEIOUY)-^ *R
SAL U(HR)^ *
SAL U^ *
SAL UH(AEIOUY)- H
SAL UR(AEIOUY)- R
SAL U(HR) _
SAL V^ W
SAL V F
SAL WR^ R
SAL WH^ W
SAL W(AEIOU)- W
SAL X^ S
SAL X KS
SAL Y(AEIOU)- Y
SAL ZZ- _
SAL Z S
affend_sal
2affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PFXPOSTPONE
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
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<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
2affend
1dicstart
123456
test/NO
# comment
wrong
Comment
OK
uk
put/ISO
the end
deol
d<EFBFBD><EFBFBD>r
1dicend
addstart
/regions=usgbnz
elequint/2
elekwint/3
addend
1good: wrong OK puts. Test the end
bad: inputs comment ok Ok. test déôl end the
badend
2good: puts
bad: inputs comment ok Ok end the. test déôl
badend
Test rules for compounding.
3affstart
SET ISO8859-1
COMPOUNDMIN 3
COMPOUNDRULE m*
NEEDCOMPOUND x
3affend
3dicstart
1234
foo/m
bar/mx
m<EFBFBD>/m
la/mx
3dicend
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
Tests for compounding.
4affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMPOUNDRULE m+
COMPOUNDRULE sm*e
COMPOUNDRULE sm+
COMPOUNDMIN 3
COMPOUNDWORDMAX 3
COMPOUNDFORBIDFLAG t
COMPOUNDSYLMAX 5
SYLLABLE a<>e<EFBFBD>i<EFBFBD>o<EFBFBD><6F><EFBFBD>u<EFBFBD><75><EFBFBD>y/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui
MAP 9
MAP a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
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 .
4affend
4dicstart
1234
word/mP
util/am
pro/xq
tomato/m
bork/mp
start/s
end/e
4dicend
4good: word util bork prebork start end wordutil wordutils pro-ok
bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork
tomato tomatotomato startend startword startwordword startwordend
startwordwordend startwordwordwordend prebork preborkbork
preborkborkbork
nouword
bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato
endstart endend startstart wordend wordstart
preborkprebork preborkpreborkbork
startwordwordwordwordend borkpreborkpreborkbork
utilsbork startnouword
badend
test2:
elequint test elekwint test elekwent asdf
Test affix flags with two characters
5affstart
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 .
5affend
5dicstart
1234
foo/a1a<31>!!
bar/zz13ee
start/ss
end/eeyy
middle/mmxx
5dicend
5good: fooa1 fooaé bar prebar barbork prebarbork startprebar
start end startend startmiddleend nouend
bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart
startprobar startnouend
badend
6affstart
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 .
6affend
6dicstart
1234
mee/A1A<31>A!
bar/ZzN3Ee
lead/s
end/Ee
middle/MmXx
6dicend
6good: meea1 meeaé bar prebar barbork prebarbork leadprebar
lead end leadend leadmiddleend
bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead
leadprobar
badend
7affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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 .
7affend
7dicstart
1234
mee/391,111,9999
bar/17,61003,123
lead/2
tail/123
middle/77,1
7dicend
7good: meea1 meeaé bar prebar barmeat prebarmeat leadprebar
lead tail leadtail leadmiddletail
bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead
leadprobar
badend
test output:

View File

@@ -1,270 +0,0 @@
test output:
test 1-1
# file: Xtest.utf-8.spl
Comment
deol
déôr
input
OK
output
outputs
outtest
put
puts
test
testen
testn
the end
uk
wrong
-------
bad
['put', 'uk', 'OK']
inputs
['input', 'puts', 'outputs']
comment
['Comment', 'outtest', 'the end']
ok
['OK', 'uk', 'put']
Ok
['OK', 'Uk', 'Put']
test
['Test', 'testn', 'testen']
déôl
['deol', 'déôr', 'test']
end
['put', 'uk', 'test']
the
['put', 'uk', 'test']
gebletegek
kepereneven
everles gesvets etele
kbltykk
kprnfn
*fls kswts tl
elekwent
elequint
elekwint
elekwint
elekwent
elequint
elekwent
elequint
elekwint
test 2-1
# file: Xtest.utf-8.spl
Comment
deol
déôr
OK
put
input
output
puts
outputs
test
outtest
testen
testn
the end
uk
wrong
-------
bad
['put', 'uk', 'OK']
inputs
['input', 'puts', 'outputs']
comment
['Comment']
ok
['OK', 'uk', 'put']
Ok
['OK', 'Uk', 'Put']
end
['put', 'uk', 'deol']
the
['put', 'uk', 'test']
test
['Test', 'testn', 'testen']
déôl
['deol', 'déôr', 'test']
test 3-3
# file: Xtest.utf-8.spl
foo
-------
bad
['foo', 'mï']
bar
['barfoo', 'foobar', 'foo']
la
['mï', 'foo']
foomï
['foo mï', 'foo', 'foofoo']
barmï
['barfoo', 'mï', 'barbar']
mïfoo
['mï foo', 'foo', 'foofoo']
mïbar
['foobar', 'barbar', 'mï']
mïmï
['mï mï', 'mï']
lala
[]
mïla
['mï', 'mï mï']
lamï
['mï', 'mï mï']
foola
['foo', 'foobar', 'foofoo']
labar
['barbar', 'foobar']
test 4-4
# file: Xtest.utf-8.spl
bork
prebork
end
pro-ok
start
tomato
util
utilize
utils
word
nouword
-------
bad
['end', 'bork', 'word']
wordutilize
['word utilize', 'wordutils', 'wordutil']
pro
['bork', 'word', 'end']
borkborkborkborkborkbork
['bork borkborkborkborkbork', 'borkbork borkborkborkbork', 'borkborkbork borkborkbork']
tomatotomatotomato
['tomato tomatotomato', 'tomatotomato tomato', 'tomato tomato tomato']
endstart
['end start', 'start']
endend
['end end', 'end']
startstart
['start start']
wordend
['word end', 'word', 'wordword']
wordstart
['word start', 'bork start']
preborkprebork
['prebork prebork', 'preborkbork', 'preborkborkbork']
preborkpreborkbork
['prebork preborkbork', 'preborkborkbork', 'preborkborkborkbork']
startwordwordwordwordend
['startwordwordwordword end', 'startwordwordwordword', 'start wordwordwordword end']
borkpreborkpreborkbork
['bork preborkpreborkbork', 'bork prebork preborkbork', 'bork preborkprebork bork']
utilsbork
['utilbork', 'utils bork', 'util bork']
startnouword
['start nouword', 'startword', 'startborkword']
test 5-5
# file: Xtest.utf-8.spl
bar
barbork
end
fooa1
fooaé
nouend
prebar
prebarbork
start
-------
bad
['bar', 'end', 'fooa1']
foo
['fooa1', 'fooaé', 'bar']
fooa2
['fooa1', 'fooaé', 'bar']
prabar
['prebar', 'bar', 'bar bar']
probarbirk
['prebarbork']
middle
[]
startmiddle
['startmiddleend', 'startmiddlebar']
middleend
[]
endstart
['end start', 'start']
startprobar
['startprebar', 'start prebar', 'startbar']
startnouend
['start nouend', 'startend']
test 6-6
# file: Xtest.utf-8.spl
bar
barbork
end
lead
meea1
meeaé
prebar
prebarbork
-------
bad
['bar', 'end', 'lead']
mee
['meea1', 'meeaé', 'bar']
meea2
['meea1', 'meeaé', 'lead']
prabar
['prebar', 'bar', 'leadbar']
probarbirk
['prebarbork']
middle
[]
leadmiddle
['leadmiddleend', 'leadmiddlebar']
middleend
[]
endlead
['end lead', 'lead', 'end end']
leadprobar
['leadprebar', 'lead prebar', 'leadbar']
test 7-7
# file: Xtest.utf-8.spl
bar
barmeat
lead
meea1
meeaé
prebar
prebarmeat
tail
-------
bad
['bar', 'lead', 'tail']
mee
['meea1', 'meeaé', 'bar']
meea2
['meea1', 'meeaé', 'lead']
prabar
['prebar', 'bar', 'leadbar']
probarmaat
['prebarmeat']
middle
[]
leadmiddle
['leadmiddlebar']
middletail
[]
taillead
['tail lead', 'tail']
leadprobar
['leadprebar', 'lead prebar', 'leadbar']

View File

@@ -1618,7 +1618,7 @@ func Test_change_mark_in_autocmds()
write
au! BufWritePre
if executable('cat')
if has('unix')
write XtestFilter
write >> XtestFilter

View File

@@ -17,3 +17,8 @@ func Test_source_autoload()
source sautest/autoload/sourced.vim
call assert_equal(1, g:loaded_sourced_vim)
endfunc
func Test_autoload_vim9script()
call assert_equal('some', auto9#getsome())
call assert_equal(49, auto9#add42(7))
endfunc

View File

@@ -19,6 +19,22 @@ func Test_backup()
call delete('Xbackup.txt~')
endfunc
func Test_backup_backupskip()
set backup backupdir=. backupskip=*.txt
new
call setline(1, ['line1', 'line2'])
:f Xbackup.txt
:w! Xbackup.txt
" backup file is only created after
" writing a second time (before overwriting)
:w! Xbackup.txt
call assert_false(filereadable('Xbackup.txt~'))
bw!
set backup&vim backupdir&vim backupskip&vim
call delete('Xbackup.txt')
call delete('Xbackup.txt~')
endfunc
func Test_backup2()
set backup backupdir=.// backupskip=
new
@@ -30,7 +46,7 @@ func Test_backup2()
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
let f = expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
@@ -50,7 +66,7 @@ func Test_backup2_backupcopy()
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
let f = expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
@@ -61,14 +77,11 @@ endfunc
" Test for using a non-existing directory as a backup directory
func Test_non_existing_backupdir()
CheckNotBSD
let save_backup = &backupdir
set backupdir=./non_existing_dir
set backupdir=./non_existing_dir backupskip=
call writefile(['line1'], 'Xfile')
new Xfile
" TODO: write doesn't fail in Cirrus FreeBSD CI test
call assert_fails('write', 'E510:')
let &backupdir = save_backup
set backupdir&vim backupskip&vim
call delete('Xfile')
endfunc

View File

@@ -220,3 +220,26 @@ func Test_unprintable_fileformats()
call delete('Xmac.txt')
call delete(filename)
endfunc
" Test for scrolling that modifies buffer during visual block
func Test_visual_block_scroll()
CheckScreendump
let lines =<< trim END
source $VIMRUNTIME/plugin/matchparen.vim
set scrolloff=1
call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'])
call cursor(5, 1)
END
let filename = 'Xvisualblockmodifiedscroll'
call writefile(lines, filename)
let buf = RunVimInTerminal('-S '.filename, #{rows: 7})
call term_sendkeys(buf, "V\<C-D>\<C-D>")
call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {})
call StopVimInTerminal(buf)
call delete(filename)
endfunc

View File

@@ -1682,7 +1682,6 @@ endfunc
" Test for editing a file without read permission
func Test_edit_file_no_read_perm()
CheckUnix
CheckNotBSD
call writefile(['one', 'two'], 'Xfile')
call setfperm('Xfile', '-w-------')
new

View File

@@ -1,5 +1,7 @@
" Tests for expand()
source shared.vim
let s:sfile = expand('<sfile>')
let s:slnum = str2nr(expand('<slnum>'))
let s:sflnum = str2nr(expand('<sflnum>'))
@@ -18,20 +20,20 @@ endfunc
" This test depends on the location in the test file, put it first.
func Test_expand_sflnum()
call assert_equal(5, s:sflnum)
call assert_equal(22, str2nr(expand('<sflnum>')))
call assert_equal(7, s:sflnum)
call assert_equal(24, str2nr(expand('<sflnum>')))
" Line-continuation
call assert_equal(
\ 25,
\ 27,
\ str2nr(expand('<sflnum>')))
" Call in script-local function
call assert_equal(16, s:expand_sflnum())
call assert_equal(18, s:expand_sflnum())
" Call in command
command Flnum echo expand('<sflnum>')
call assert_equal(34, str2nr(trim(execute('Flnum'))))
call assert_equal(36, str2nr(trim(execute('Flnum'))))
delcommand Flnum
endfunc
@@ -60,7 +62,7 @@ func Test_expand_sfile_and_stack()
endfunc
func Test_expand_slnum()
call assert_equal(4, s:slnum)
call assert_equal(6, s:slnum)
call assert_equal(2, str2nr(expand('<slnum>')))
" Line-continuation
@@ -86,6 +88,17 @@ func Test_expand()
quit
endfunc
func s:sid_test()
return 'works'
endfunc
func Test_expand_SID()
let sid = expand('<SID>')
execute 'let g:sid_result = ' .. sid .. 'sid_test()'
call assert_equal('works', g:sid_result)
endfunc
" Test for 'wildignore' with expand()
func Test_expand_wildignore()
set wildignore=*.vim

View File

@@ -55,6 +55,9 @@ func Test_dict()
let d['a'] = 'aaa'
call assert_equal('none', d[''])
call assert_equal('aaa', d['a'])
let d[ 'b' ] = 'bbb'
call assert_equal('bbb', d[ 'b' ])
endfunc
func Test_strgetchar()

View File

@@ -11,6 +11,7 @@ func Test_filter_map_list_expr_string()
call assert_equal([2, 4, 6, 8], map([1, 2, 3, 4], 'v:val * 2'))
call assert_equal([0, 2, 4, 6], map([1, 2, 3, 4], 'v:key * 2'))
call assert_equal([9, 9, 9, 9], map([1, 2, 3, 4], 9))
call assert_equal([7, 7, 7], map([1, 2, 3], ' 7 '))
endfunc
" dict with expression string

View File

@@ -1355,7 +1355,7 @@ func Test_input_func()
func! Tcomplete(arglead, cmdline, pos)
return "item1\nitem2\nitem3"
endfunc
call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\<CR>"
\ .. "\<C-A>\<CR>", 'xt')
delfunc Tcomplete
call assert_equal('item1 item2 item3', c)

View File

@@ -120,7 +120,7 @@ func Test_gn_command()
sil! %d_
" search using the \zs atom
call setline(1, [' nnoremap', '' , 'nnoremap'])
call setline(1, [' nnoremap', '', 'nnoremap'])
set wrapscan&vim
let @/ = '\_s\zsnnoremap'
$

View File

@@ -23,6 +23,9 @@ func Test_list_create()
call assert_equal(10, x)
endfunc
" This was allowed in legacy Vim script
let s:list_with_spaces = [1 , 2 , 3]
" List slices
func Test_list_slice()
let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
@@ -202,6 +205,10 @@ func Test_dict()
call assert_fails("let d={'k' : i}", 'E121:')
endfunc
" This was allowed in legacy Vim script
let s:dict_with_spaces = {'one' : 1 , 'two' : 2 , 'three' : 3}
let s:dict_with_spaces_lit = #{one : 1 , two : 2 , three : 3}
" Dictionary identity
func Test_dict_identity()
let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}

View File

@@ -588,7 +588,7 @@ func Test_popup_drag_termwin()
call setline(1, range(100))
for nr in range(7)
call setline(nr * 12 + 1, "fold {{{")
call setline(nr * 12 + 11 , "end }}}")
call setline(nr * 12 + 11, "end }}}")
endfor
%foldclose
set shell=/bin/sh noruler

View File

@@ -0,0 +1,768 @@
" Test for spell checking with 'encoding' set to utf-8
source check.vim
CheckFeature spell
scriptencoding utf-8
func TearDown()
set nospell
call delete('Xtest.aff')
call delete('Xtest.dic')
call delete('Xtest.utf-8.add')
call delete('Xtest.utf-8.add.spl')
call delete('Xtest.utf-8.spl')
call delete('Xtest.utf-8.sug')
endfunc
let g:test_data_aff1 = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
\"",
\"FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ",
\"LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ",
\"UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ",
\"",
\"SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xBF",
\"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
\"",
\"MIDWORD\t'-",
\"",
\"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\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF"
\ ]
let g:test_data_dic1 = [
\"123456",
\"test/NO",
\"# comment",
\"wrong",
\"Comment",
\"OK",
\"uk",
\"put/ISO",
\"the end",
\"deol",
\"d\xE9\xF4r",
\ ]
let g:test_data_aff2 = [
\"SET ISO8859-1",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"PFXPOSTPONE",
\"",
\"MIDWORD\t'-",
\"",
\"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\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\ ]
let g:test_data_aff3 = [
\"SET ISO8859-1",
\"",
\"COMPOUNDMIN 3",
\"COMPOUNDRULE m*",
\"NEEDCOMPOUND x",
\ ]
let g:test_data_dic3 = [
\"1234",
\"foo/m",
\"bar/mx",
\"m\xEF/m",
\"la/mx",
\ ]
let g:test_data_aff4 = [
\"SET ISO8859-1",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"COMPOUNDRULE m+",
\"COMPOUNDRULE sm*e",
\"COMPOUNDRULE sm+",
\"COMPOUNDMIN 3",
\"COMPOUNDWORDMAX 3",
\"COMPOUNDFORBIDFLAG t",
\"",
\"COMPOUNDSYLMAX 5",
\"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
\"",
\"MAP 9",
\"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\"",
\"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 .",
\ ]
let g:test_data_dic4 = [
\"1234",
\"word/mP",
\"util/am",
\"pro/xq",
\"tomato/m",
\"bork/mp",
\"start/s",
\"end/e",
\ ]
let g:test_data_aff5 = [
\"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\xE9 Y 1",
\"SFX a\xE9 0 a\xE9 .",
\"",
\"PFX zz Y 1",
\"PFX zz 0 pre/pp .",
\"",
\"PFX yy Y 1",
\"PFX yy 0 nou .",
\ ]
let g:test_data_dic5 = [
\"1234",
\"foo/a1a\xE9!!",
\"bar/zz13ee",
\"start/ss",
\"end/eeyy",
\"middle/mmxx",
\ ]
let g:test_data_aff6 = [
\"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\xE9 Y 1",
\"SFX A\xE9 0 a\xE9 .",
\"",
\"PFX Zz Y 1",
\"PFX Zz 0 pre/p .",
\ ]
let g:test_data_dic6 = [
\"1234",
\"mee/A1A\xE9A!",
\"bar/ZzN3Ee",
\"lead/s",
\"end/Ee",
\"middle/MmXx",
\ ]
let g:test_data_aff7 = [
\"SET ISO8859-1",
\"",
\"FLAG num",
\"",
\"NEEDAFFIX 9999",
\"",
\"COMPOUNDRULE 2,77*123",
\"",
\"NEEDCOMPOUND 1",
\"COMPOUNDPERMITFLAG 432",
\"",
\"SFX 61003 Y 1",
\"SFX 61003 0 meat .",
\"",
\"SFX 0 Y 1",
\"SFX 0 0 zero .",
\"",
\"SFX 391 Y 1",
\"SFX 391 0 a1 .",
\"",
\"SFX 111 Y 1",
\"SFX 111 0 a\xE9 .",
\"",
\"PFX 17 Y 1",
\"PFX 17 0 pre/432 .",
\ ]
let g:test_data_dic7 = [
\"1234",
\"mee/0,391,111,9999",
\"bar/17,61003,123",
\"lead/2",
\"tail/123",
\"middle/77,1",
\ ]
let g:test_data_aff8 = [
\"SET ISO8859-1",
\"",
\"NOSPLITSUGS",
\ ]
let g:test_data_dic8 = [
\"1234",
\"foo",
\"bar",
\"faabar",
\ ]
let g:test_data_aff9 = [
\ ]
let g:test_data_dic9 = [
\"1234",
\"foo",
\"bar",
\ ]
let g:test_data_aff10 = [
\"COMPOUNDRULE se",
\"COMPOUNDPERMITFLAG p",
\"",
\"SFX A Y 1",
\"SFX A 0 able/Mp .",
\"",
\"SFX M Y 1",
\"SFX M 0 s .",
\ ]
let g:test_data_dic10 = [
\"1234",
\"drink/As",
\"table/e",
\ ]
let g:test_data_aff_sal = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"MIDWORD\t'-",
\"",
\"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\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\"",
\"SAL AH(AEIOUY)-^ *H",
\"SAL AR(AEIOUY)-^ *R",
\"SAL A(HR)^ *",
\"SAL A^ *",
\"SAL AH(AEIOUY)- H",
\"SAL AR(AEIOUY)- R",
\"SAL A(HR) _",
\"SAL \xC0^ *",
\"SAL \xC5^ *",
\"SAL BB- _",
\"SAL B B",
\"SAL CQ- _",
\"SAL CIA X",
\"SAL CH X",
\"SAL C(EIY)- S",
\"SAL CK K",
\"SAL COUGH^ KF",
\"SAL CC< C",
\"SAL C K",
\"SAL DG(EIY) K",
\"SAL DD- _",
\"SAL D T",
\"SAL \xC9< E",
\"SAL EH(AEIOUY)-^ *H",
\"SAL ER(AEIOUY)-^ *R",
\"SAL E(HR)^ *",
\"SAL ENOUGH^$ *NF",
\"SAL E^ *",
\"SAL EH(AEIOUY)- H",
\"SAL ER(AEIOUY)- R",
\"SAL E(HR) _",
\"SAL FF- _",
\"SAL F F",
\"SAL GN^ N",
\"SAL GN$ N",
\"SAL GNS$ NS",
\"SAL GNED$ N",
\"SAL GH(AEIOUY)- K",
\"SAL GH _",
\"SAL GG9 K",
\"SAL G K",
\"SAL H H",
\"SAL IH(AEIOUY)-^ *H",
\"SAL IR(AEIOUY)-^ *R",
\"SAL I(HR)^ *",
\"SAL I^ *",
\"SAL ING6 N",
\"SAL IH(AEIOUY)- H",
\"SAL IR(AEIOUY)- R",
\"SAL I(HR) _",
\"SAL J K",
\"SAL KN^ N",
\"SAL KK- _",
\"SAL K K",
\"SAL LAUGH^ LF",
\"SAL LL- _",
\"SAL L L",
\"SAL MB$ M",
\"SAL MM M",
\"SAL M M",
\"SAL NN- _",
\"SAL N N",
\"SAL OH(AEIOUY)-^ *H",
\"SAL OR(AEIOUY)-^ *R",
\"SAL O(HR)^ *",
\"SAL O^ *",
\"SAL OH(AEIOUY)- H",
\"SAL OR(AEIOUY)- R",
\"SAL O(HR) _",
\"SAL PH F",
\"SAL PN^ N",
\"SAL PP- _",
\"SAL P P",
\"SAL Q K",
\"SAL RH^ R",
\"SAL ROUGH^ RF",
\"SAL RR- _",
\"SAL R R",
\"SAL SCH(EOU)- SK",
\"SAL SC(IEY)- S",
\"SAL SH X",
\"SAL SI(AO)- X",
\"SAL SS- _",
\"SAL S S",
\"SAL TI(AO)- X",
\"SAL TH @",
\"SAL TCH-- _",
\"SAL TOUGH^ TF",
\"SAL TT- _",
\"SAL T T",
\"SAL UH(AEIOUY)-^ *H",
\"SAL UR(AEIOUY)-^ *R",
\"SAL U(HR)^ *",
\"SAL U^ *",
\"SAL UH(AEIOUY)- H",
\"SAL UR(AEIOUY)- R",
\"SAL U(HR) _",
\"SAL V^ W",
\"SAL V F",
\"SAL WR^ R",
\"SAL WH^ W",
\"SAL W(AEIOU)- W",
\"SAL X^ S",
\"SAL X KS",
\"SAL Y(AEIOU)- Y",
\"SAL ZZ- _",
\"SAL Z S",
\ ]
func LoadAffAndDic(aff_contents, dic_contents)
set enc=utf-8
set spellfile=
call writefile(a:aff_contents, "Xtest.aff")
call writefile(a:dic_contents, "Xtest.dic")
" Generate a .spl file from a .dic and .aff file.
mkspell! Xtest Xtest
" use that spell file
set spl=Xtest.utf-8.spl spell
endfunc
func ListWords()
spelldump
%yank
quit
return split(@", "\n")
endfunc
func TestGoodBadBase()
exe '1;/^good:'
normal 0f:]s
let prevbad = ''
let result = []
while 1
let [bad, a] = spellbadword()
if bad == '' || bad == prevbad || bad == 'badend'
break
endif
let prevbad = bad
let lst = bad->spellsuggest(3)
normal mm
call add(result, [bad, lst])
normal `m]s
endwhile
return result
endfunc
func RunGoodBad(good, bad, expected_words, expected_bad_words)
%bwipe!
call setline(1, ['', "good: ", a:good, a:bad, " badend "])
let words = ListWords()
call assert_equal(a:expected_words, words[1:-1])
let bad_words = TestGoodBadBase()
call assert_equal(a:expected_bad_words, bad_words)
%bwipe!
endfunc
func Test_spell_basic()
call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
call RunGoodBad("wrong OK puts. Test the end",
\ "bad: inputs comment ok Ok. test d\u00E9\u00F4l end the",
\["Comment", "deol", "d\u00E9\u00F4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
\ "test", "testen", "testn", "the end", "uk", "wrong"],
\[
\ ["bad", ["put", "uk", "OK"]],
\ ["inputs", ["input", "puts", "outputs"]],
\ ["comment", ["Comment", "outtest", "the end"]],
\ ["ok", ["OK", "uk", "put"]],
\ ["Ok", ["OK", "Uk", "Put"]],
\ ["test", ["Test", "testn", "testen"]],
\ ["d\u00E9\u00F4l", ["deol", "d\u00E9\u00F4r", "test"]],
\ ["end", ["put", "uk", "test"]],
\ ["the", ["put", "uk", "test"]],
\ ]
\ )
call assert_equal("gebletegek", soundfold('goobledygoook'))
call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
endfunc
" Postponed prefixes
func Test_spell_prefixes()
call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
call RunGoodBad("puts",
\ "bad: inputs comment ok Ok end the. test d\u00E9\u00F4l",
\ ["Comment", "deol", "d\u00E9\u00F4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
\ [
\ ["bad", ["put", "uk", "OK"]],
\ ["inputs", ["input", "puts", "outputs"]],
\ ["comment", ["Comment"]],
\ ["ok", ["OK", "uk", "put"]],
\ ["Ok", ["OK", "Uk", "Put"]],
\ ["end", ["put", "uk", "deol"]],
\ ["the", ["put", "uk", "test"]],
\ ["test", ["Test", "testn", "testen"]],
\ ["d\u00E9\u00F4l", ["deol", "d\u00E9\u00F4r", "test"]],
\ ])
endfunc
"Compound words
func Test_spell_compound()
call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
call RunGoodBad("foo m\u00EF foobar foofoobar barfoo barbarfoo",
\ "bad: bar la foom\u00EF barm\u00EF m\u00EFfoo m\u00EFbar m\u00EFm\u00EF lala m\u00EFla lam\u00EF foola labar",
\ ["foo", "m\u00EF"],
\ [
\ ["bad", ["foo", "m\u00EF"]],
\ ["bar", ["barfoo", "foobar", "foo"]],
\ ["la", ["m\u00EF", "foo"]],
\ ["foom\u00EF", ["foo m\u00EF", "foo", "foofoo"]],
\ ["barm\u00EF", ["barfoo", "m\u00EF", "barbar"]],
\ ["m\u00EFfoo", ["m\u00EF foo", "foo", "foofoo"]],
\ ["m\u00EFbar", ["foobar", "barbar", "m\u00EF"]],
\ ["m\u00EFm\u00EF", ["m\u00EF m\u00EF", "m\u00EF"]],
\ ["lala", []],
\ ["m\u00EFla", ["m\u00EF", "m\u00EF m\u00EF"]],
\ ["lam\u00EF", ["m\u00EF", "m\u00EF m\u00EF"]],
\ ["foola", ["foo", "foobar", "foofoo"]],
\ ["labar", ["barbar", "foobar"]],
\ ])
call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
call RunGoodBad("word util bork prebork start end wordutil wordutils pro-ok bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork tomato tomatotomato startend startword startwordword startwordend startwordwordend startwordwordwordend prebork preborkbork preborkborkbork nouword",
\ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
\ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
\ [
\ ["bad", ["end", "bork", "word"]],
\ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
\ ["pro", ["bork", "word", "end"]],
\ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
\ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
\ ["endstart", ["end start", "start"]],
\ ["endend", ["end end", "end"]],
\ ["startstart", ["start start"]],
\ ["wordend", ["word end", "word", "wordword"]],
\ ["wordstart", ["word start", "bork start"]],
\ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
\ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
\ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
\ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
\ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
\ ["startnouword", ["start nouword", "startword", "startborkword"]],
\ ])
endfunc
" Test affix flags with two characters
func Test_spell_affix()
call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
call RunGoodBad("fooa1 fooa\u00E9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
\ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
\ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"],
\ [
\ ["bad", ["bar", "end", "fooa1"]],
\ ["foo", ["fooa1", "fooa\u00E9", "bar"]],
\ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]],
\ ["prabar", ["prebar", "bar", "bar bar"]],
\ ["probarbirk", ["prebarbork"]],
\ ["middle", []],
\ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
\ ["middleend", []],
\ ["endstart", ["end start", "start"]],
\ ["startprobar", ["startprebar", "start prebar", "startbar"]],
\ ["startnouend", ["start nouend", "startend"]],
\ ])
call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
call RunGoodBad("meea1 meea\u00E9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
\ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
\ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"],
\ [
\ ["bad", ["bar", "end", "lead"]],
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
\ ["prabar", ["prebar", "bar", "leadbar"]],
\ ["probarbirk", ["prebarbork"]],
\ ["middle", []],
\ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
\ ["middleend", []],
\ ["endlead", ["end lead", "lead", "end end"]],
\ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
\ ])
call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
call RunGoodBad("meea1 meezero meea\u00E9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
\ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
\ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"],
\ [
\ ["bad", ["bar", "lead", "tail"]],
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
\ ["prabar", ["prebar", "bar", "leadbar"]],
\ ["probarmaat", ["prebarmeat"]],
\ ["middle", []],
\ ["leadmiddle", ["leadmiddlebar"]],
\ ["middletail", []],
\ ["taillead", ["tail lead", "tail"]],
\ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
\ ])
endfunc
func Test_spell_NOSLITSUGS()
call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
\ ["bar", "faabar", "foo"],
\ [
\ ["bad", ["bar", "foo"]],
\ ["foobar", ["faabar", "foo bar", "bar"]],
\ ["barfoo", ["bar foo", "bar", "foo"]],
\ ])
endfunc
" Numbers
func Test_spell_Numbers()
call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
call RunGoodBad("0b1011 0777 1234 0x01ff", "",
\ ["bar", "foo"],
\ [
\ ])
endfunc
" Affix flags
func Test_spell_affix_flags()
call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
\ "bad: drinks drinkstable drinkablestable",
\ ["drink", "drinkable", "drinkables", "table"],
\ [['bad', []],
\ ['drinks', ['drink']],
\ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
\ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
\ ])
endfunc
function FirstSpellWord()
call feedkeys("/^start:\n", 'tx')
normal ]smm
let [str, a] = spellbadword()
return str
endfunc
function SecondSpellWord()
normal `m]s
let [str, a] = spellbadword()
return str
endfunc
" Test with SAL instead of SOFO items; test automatic reloading
func Test_spell_sal_and_addition()
set spellfile=
call writefile(g:test_data_dic1, "Xtest.dic")
call writefile(g:test_data_aff_sal, "Xtest.aff")
mkspell! Xtest Xtest
set spl=Xtest.utf-8.spl spell
call assert_equal('kbltykk', soundfold('goobledygoook'))
call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
"also use an addition file
call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.utf-8.add")
mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add
bwipe!
call setline(1, ["start: elequint test elekwint test elekwent asdf"])
set spellfile=Xtest.utf-8.add
call assert_equal("elekwent", FirstSpellWord())
set spl=Xtest_us.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
set spl=Xtest_gb.utf-8.spl
call assert_equal("elekwint", FirstSpellWord())
call assert_equal("elekwent", SecondSpellWord())
set spl=Xtest_nz.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwent", SecondSpellWord())
set spl=Xtest_ca.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
endfunc
func Test_spellfile_value()
set spellfile=Xdir/Xtest.utf-8.add
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -350,7 +350,7 @@ function Test_tabpage_with_tabprevious()
call Check_tab_count(6, cmd . ' 3', 3)
call Check_tab_count(6, cmd . ' 8', 4)
for n in range(2)
for c in ['0', '.+3', '+', '+2' , '-', '-2' , '$', '+99', '-99']
for c in ['0', '.+3', '+', '+2', '-', '-2', '$', '+99', '-99']
if n == 0 " pre count
let entire_cmd = c . cmd
let err_code = 'E16:'

View File

@@ -7,6 +7,8 @@ CheckUnix
source shared.vim
source mouse.vim
source view_util.vim
source term_util.vim
func Test_term_mouse_left_click()
new
@@ -1893,6 +1895,18 @@ func Test_get_termcode()
set ttybuiltin
endfunc
func Test_list_builtin_terminals()
CheckRunVimInTerminal
let buf = RunVimInTerminal('', #{rows: 14})
call term_sendkeys(buf, ":set cmdheight=3\<CR>")
call term_wait(buf, 100)
call term_sendkeys(buf, ":set term=xxx\<CR>")
call term_wait(buf, 100)
call assert_match('builtin_dumb', term_getline(buf, 11))
call assert_match('Not found in termcap', term_getline(buf, 12))
call StopVimInTerminal(buf)
endfunc
func GetEscCodeCSI27(key, modifier)
let key = printf("%d", char2nr(a:key))
let mod = printf("%d", a:modifier)

View File

@@ -258,6 +258,21 @@ func Test_terminal_scrape_multibyte()
call delete('Xtext')
endfunc
func Test_terminal_one_column()
" This creates a terminal, displays a double-wide character and makes the
" window one column wide. This used to cause a crash.
let width = &columns
botright vert term
let buf = bufnr('$')
call term_wait(buf, 100)
exe "set columns=" .. (width / 2)
redraw
call term_sendkeys(buf, "キ")
call term_wait(buf, 10)
exe "set columns=" .. width
exe buf . 'bwipe!'
endfunc
func Test_terminal_scroll()
call writefile(range(1, 200), 'Xtext')
if has('win32')

View File

@@ -43,15 +43,18 @@ func Test_terminal_shell_option()
bwipe!
elseif has('win32')
" dir is a shell builtin command, should fail without a shell.
" However, if dir.exe (which might be provided by Cygwin/MSYS2) exists in
" the %PATH%, "term dir" succeeds unintentionally. Use dir.com instead.
try
term dir /b runtest.vim
call WaitForAssert({-> assert_match('job failed\|cannot access .*: No such file or directory', term_getline(bufnr(), 1))})
term dir.com /b runtest.vim
call WaitForAssert({-> assert_match('job failed', term_getline(bufnr(), 1))})
catch /CreateProcess/
" ignore
endtry
bwipe!
term ++shell dir /b runtest.vim
" This should execute the dir builtin command even with ".com".
term ++shell dir.com /b runtest.vim
call WaitForAssert({-> assert_match('runtest.vim', term_getline(bufnr(), 1))})
bwipe!
endif

View File

@@ -201,28 +201,28 @@ func Test_match()
call assert_equal("c", matchstr("abcd", ".", 2, 0))
call assert_equal("a", matchstr("abcd", ".", 0, -1))
call assert_equal(-1, match("abcd", ".", 0, 5))
call assert_equal(0 , match("abcd", ".", 0, -1))
call assert_equal(0 , match('abc', '.', 0, 1))
call assert_equal(1 , match('abc', '.', 0, 2))
call assert_equal(2 , match('abc', '.', 0, 3))
call assert_equal(0, match("abcd", ".", 0, -1))
call assert_equal(0, match('abc', '.', 0, 1))
call assert_equal(1, match('abc', '.', 0, 2))
call assert_equal(2, match('abc', '.', 0, 3))
call assert_equal(-1, match('abc', '.', 0, 4))
call assert_equal(1 , match('abc', '.', 1, 1))
call assert_equal(2 , match('abc', '.', 2, 1))
call assert_equal(1, match('abc', '.', 1, 1))
call assert_equal(2, match('abc', '.', 2, 1))
call assert_equal(-1, match('abc', '.', 3, 1))
call assert_equal(3 , match('abc', '$', 0, 1))
call assert_equal(3, match('abc', '$', 0, 1))
call assert_equal(-1, match('abc', '$', 0, 2))
call assert_equal(3 , match('abc', '$', 1, 1))
call assert_equal(3 , match('abc', '$', 2, 1))
call assert_equal(3 , match('abc', '$', 3, 1))
call assert_equal(3, match('abc', '$', 1, 1))
call assert_equal(3, match('abc', '$', 2, 1))
call assert_equal(3, match('abc', '$', 3, 1))
call assert_equal(-1, match('abc', '$', 4, 1))
call assert_equal(0 , match('abc', '\zs', 0, 1))
call assert_equal(1 , match('abc', '\zs', 0, 2))
call assert_equal(2 , match('abc', '\zs', 0, 3))
call assert_equal(3 , match('abc', '\zs', 0, 4))
call assert_equal(0, match('abc', '\zs', 0, 1))
call assert_equal(1, match('abc', '\zs', 0, 2))
call assert_equal(2, match('abc', '\zs', 0, 3))
call assert_equal(3, match('abc', '\zs', 0, 4))
call assert_equal(-1, match('abc', '\zs', 0, 5))
call assert_equal(1 , match('abc', '\zs', 1, 1))
call assert_equal(2 , match('abc', '\zs', 2, 1))
call assert_equal(3 , match('abc', '\zs', 3, 1))
call assert_equal(1, match('abc', '\zs', 1, 1))
call assert_equal(2, match('abc', '\zs', 2, 1))
call assert_equal(3, match('abc', '\zs', 3, 1))
call assert_equal(-1, match('abc', '\zs', 4, 1))
endfunc

View File

@@ -1219,7 +1219,7 @@ func Test_prop_func_invalid_args()
call assert_fails('call prop_find({}, "x")', 'E474:')
call assert_fails('call prop_find({"lnum" : -2})', 'E16:')
call assert_fails('call prop_list(1, [])', 'E715:')
call assert_fails('call prop_list(-1 , {})', 'E16:')
call assert_fails('call prop_list(-1, {})', 'E16:')
call assert_fails('call prop_remove([])', 'E474:')
call assert_fails('call prop_remove({}, -2)', 'E16:')
call assert_fails('call prop_remove({})', 'E968:')

View File

@@ -699,6 +699,24 @@ def Test_disassemble_lambda()
instr)
enddef
def NestedOuter()
def g:Inner()
echomsg "inner"
enddef
enddef
def Test_nested_func()
let instr = execute('disassemble NestedOuter')
assert_match('NestedOuter\_s*' ..
'def g:Inner()\_s*' ..
'echomsg "inner"\_s*' ..
'enddef\_s*' ..
'\d NEWFUNC <lambda>\d\+ Inner\_s*' ..
'\d PUSHNR 0\_s*' ..
'\d RETURN',
instr)
enddef
def AndOr(arg: any): string
if arg == 1 && arg != 2 || arg == 4
return 'yes'

View File

@@ -726,6 +726,38 @@ def Test_expr4_vimscript()
set noignorecase
END
CheckScriptSuccess(lines)
# check missing white space
lines =<< trim END
vim9script
echo 2>3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2 >3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2> 3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2!=3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2 !=3
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 2!= 3
END
CheckScriptFailure(lines, 'E1004:')
enddef
func Test_expr4_fails()
@@ -831,7 +863,7 @@ def Test_expr5()
enddef
def Test_expr5_vim9script()
# only checks line continuation
# check line continuation
let lines =<< trim END
vim9script
let var = 11
@@ -841,6 +873,15 @@ def Test_expr5_vim9script()
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 +
77 -
22
assert_equal(66, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 'one'
@@ -848,6 +889,63 @@ def Test_expr5_vim9script()
assert_equal('onetwo', var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
echo 'abc' is# 'abc'
END
CheckScriptFailure(lines, 'E15:')
lines =<< trim END
vim9script
echo 'abc' is? 'abc'
END
CheckScriptFailure(lines, 'E15:')
lines =<< trim END
vim9script
echo 'abc' isnot# 'abc'
END
CheckScriptFailure(lines, 'E15:')
lines =<< trim END
vim9script
echo 'abc' isnot? 'abc'
END
CheckScriptFailure(lines, 'E15:')
# check white space
lines =<< trim END
vim9script
echo 5+6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5 +6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5+ 6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a'..'b'
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a' ..'b'
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 'a'.. 'b'
END
CheckScriptFailure(lines, 'E1004:')
enddef
def Test_expr5_float()
@@ -942,7 +1040,7 @@ def Test_expr6()
enddef
def Test_expr6_vim9script()
# only checks line continuation
# check line continuation
let lines =<< trim END
vim9script
let var = 11
@@ -959,6 +1057,32 @@ def Test_expr6_vim9script()
assert_equal(5, var)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let var = 11 *
22 /
3
assert_equal(80, var)
END
CheckScriptSuccess(lines)
# check white space
lines =<< trim END
vim9script
echo 5*6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5 *6
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
echo 5* 6
END
CheckScriptFailure(lines, 'E1004:')
enddef
def Test_expr6_float()
@@ -1152,6 +1276,10 @@ def Test_expr7_list()
assert_equal(g:list_mixed, [1, 'b', false,])
assert_equal('b', g:list_mixed[1])
echo [1,
2] [3,
4]
call CheckDefExecFailure(["let x = g:anint[3]"], 'E714:')
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
call CheckDefFailure(["let x = [1,2,3]"], 'E1069:')
@@ -1169,6 +1297,10 @@ def Test_expr7_list_vim9script()
22,
]
assert_equal([11, 22], l)
echo [1,
2] [3,
4]
END
CheckScriptSuccess(lines)
@@ -1398,6 +1530,22 @@ enddef
def Test_expr7_register()
@a = 'register a'
assert_equal('register a', @a)
let fname = expand('%')
assert_equal(fname, @%)
feedkeys(":echo 'some'\<CR>", "xt")
assert_equal("echo 'some'", @:)
normal axyz
assert_equal("xyz", @.)
call CheckDefFailure(["@. = 'yes'"], 'E354:')
@/ = 'slash'
assert_equal('slash', @/)
@= = 'equal'
assert_equal('equal', @=)
enddef
def Test_expr7_namespace()
@@ -1638,8 +1786,9 @@ enddef
def Test_expr7_method_call()
new
setline(1, ['first', 'last'])
eval 'second'->append(1)
assert_equal(['first', 'second', 'last'], getline(1, '$'))
'second'->append(1)
"third"->append(2)
assert_equal(['first', 'second', 'third', 'last'], getline(1, '$'))
bwipe!
let bufnr = bufnr()

View File

@@ -131,6 +131,8 @@ def Test_nested_function()
CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:')
CheckDefFailure(['func Nested()', 'endfunc'], 'E1086:')
CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:')
CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:')
enddef
func Test_call_default_args_from_func()
@@ -139,6 +141,70 @@ func Test_call_default_args_from_func()
call assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
endfunc
def Test_nested_global_function()
let lines =<< trim END
vim9script
def Outer()
def g:Inner(): string
return 'inner'
enddef
enddef
defcompile
Outer()
assert_equal('inner', g:Inner())
delfunc g:Inner
Outer()
assert_equal('inner', g:Inner())
delfunc g:Inner
Outer()
assert_equal('inner', g:Inner())
delfunc g:Inner
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
def Outer()
def g:Inner(): string
return 'inner'
enddef
enddef
defcompile
Outer()
Outer()
END
CheckScriptFailure(lines, "E122:")
lines =<< trim END
vim9script
def Func()
echo 'script'
enddef
def Outer()
def Func()
echo 'inner'
enddef
enddef
defcompile
END
CheckScriptFailure(lines, "E1073:")
enddef
def Test_global_local_function()
let lines =<< trim END
vim9script
def g:Func(): string
return 'global'
enddef
def Func(): string
return 'local'
enddef
assert_equal('global', g:Func())
assert_equal('local', Func())
END
CheckScriptSuccess(lines)
enddef
func TakesOneArg(arg)
echo a:arg
endfunc
@@ -502,8 +568,11 @@ def Test_vim9script_call()
assert_equal('some', var)
# line starting with single quote is not a mark
# line starting with double quote can be a method call
'asdfasdf'->MyFunc()
assert_equal('asdfasdf', var)
"xyz"->MyFunc()
assert_equal('xyz', var)
def UseString()
'xyork'->MyFunc()
@@ -511,6 +580,12 @@ def Test_vim9script_call()
UseString()
assert_equal('xyork', var)
def UseString2()
"knife"->MyFunc()
enddef
UseString2()
assert_equal('knife', var)
# prepending a colon makes it a mark
new
setline(1, ['aaa', 'bbb', 'ccc'])
@@ -1195,7 +1270,7 @@ enddef
def TreeWalk(dir: string): list<any>
return readdir(dir)->map({_, val ->
fnamemodify(dir .. '/' .. val, ':p')->isdirectory()
? {val : TreeWalk(dir .. '/' .. val)}
? {val: TreeWalk(dir .. '/' .. val)}
: val
})
enddef

View File

@@ -61,6 +61,14 @@ def Test_assignment()
assert_equal('foobar', $ENVVAR)
$ENVVAR = ''
let lines =<< trim END
vim9script
$ENVVAR = 'barfoo'
assert_equal('barfoo', $ENVVAR)
$ENVVAR = ''
END
call CheckScriptSuccess(lines)
s:appendToMe ..= 'yyy'
assert_equal('xxxyyy', s:appendToMe)
s:addToMe += 222
@@ -80,6 +88,15 @@ def Test_assignment()
set ts=10
&ts %= 4
assert_equal(2, &ts)
lines =<< trim END
vim9script
&ts = 6
&ts += 3
assert_equal(9, &ts)
END
call CheckScriptSuccess(lines)
call CheckDefFailure(['&notex += 3'], 'E113:')
call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
call CheckDefFailure(['&ts = [7]'], 'E1013:')
@@ -92,6 +109,9 @@ def Test_assignment()
call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
&ts = 8
call CheckDefFailure(['let s:var = 123'], 'E1101:')
call CheckDefFailure(['let s:var: number'], 'E1101:')
g:inc_counter += 1
assert_equal(2, g:inc_counter)
@@ -106,11 +126,41 @@ def Test_assignment()
call CheckDefFailure(['@a += "more"'], 'E1013:')
call CheckDefFailure(['@a += 123'], 'E1013:')
lines =<< trim END
vim9script
@c = 'areg'
@c ..= 'add'
assert_equal('aregadd', @c)
END
call CheckScriptSuccess(lines)
v:errmsg = 'none'
v:errmsg ..= 'again'
assert_equal('noneagain', v:errmsg)
call CheckDefFailure(['v:errmsg += "more"'], 'E1013:')
call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
# single letter variables
a = 123
assert_equal(123, a)
let b: number
b = 123
assert_equal(123, b)
let g: number
g = 123
assert_equal(123, g)
let s: number
s = 123
assert_equal(123, s)
let t: number
t = 123
assert_equal(123, t)
let v: number
v = 123
assert_equal(123, v)
let w: number
w = 123
assert_equal(123, w)
enddef
def Test_vim9_single_char_vars()
@@ -194,10 +244,60 @@ def Test_assignment_dict()
# overwrite
dict3['key'] = 'another'
call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
# empty key can be used
let dd = {}
dd[""] = 6
assert_equal({'': 6}, dd)
# type becomes dict<any>
let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
# assignment to script-local dict
let lines =<< trim END
vim9script
let test: dict<any> = {}
def FillDict(): dict<any>
test['a'] = 43
return test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let test: dict<any>
def FillDict(): dict<any>
test['a'] = 43
return test
enddef
FillDict()
END
call CheckScriptFailure(lines, 'E1103:')
# assignment to global dict
lines =<< trim END
vim9script
g:test = {}
def FillDict(): dict<any>
g:test['a'] = 43
return g:test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
# assignment to buffer dict
lines =<< trim END
vim9script
b:test = {}
def FillDict(): dict<any>
b:test['a'] = 43
return b:test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
enddef
def Test_assignment_local()
@@ -308,6 +408,42 @@ def Test_assignment_var_list()
assert_equal(['three'], vrem)
enddef
def Test_assignment_vim9script()
let lines =<< trim END
vim9script
def Func(): list<number>
return [1, 2]
enddef
let var1: number
let var2: number
[var1, var2] =
Func()
assert_equal(1, var1)
assert_equal(2, var2)
let ll =
Func()
assert_equal([1, 2], ll)
@/ = 'text'
assert_equal('text', @/)
@0 = 'zero'
assert_equal('zero', @0)
@1 = 'one'
assert_equal('one', @1)
@9 = 'nine'
assert_equal('nine', @9)
@- = 'minus'
assert_equal('minus', @-)
if has('clipboard_working')
@* = 'star'
assert_equal('star', @*)
@+ = 'plus'
assert_equal('plus', @+)
endif
END
CheckScriptSuccess(lines)
enddef
def Mess(): string
v:foldstart = 123
return 'xxx'
@@ -344,13 +480,22 @@ def Test_assignment_failure()
'[x, y; z] = [1]'], 'E1093:')
call CheckDefFailure(['let somevar'], "E1022:")
call CheckDefFailure(['let &option'], 'E1052:')
call CheckDefFailure(['let &tabstop = 4'], 'E1052:')
call CheckDefFailure(['&g:option = 5'], 'E113:')
call CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
call CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
call CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
call CheckDefFailure(['let @~ = 5'], 'E354:')
if has('dnd')
call CheckDefFailure(['let @~ = 5'], 'E1066:')
else
call CheckDefFailure(['let @~ = 5'], 'E354:')
call CheckDefFailure(['@~ = 5'], 'E354:')
endif
call CheckDefFailure(['let @a = 5'], 'E1066:')
call CheckDefFailure(['let @/ = "x"'], 'E1066:')
call CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
call CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
call CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
@@ -714,13 +859,6 @@ def Test_try_catch()
endtry
assert_equal(300, n)
try
d[''] = 3
catch /E713:/
n = 311
endtry
assert_equal(311, n)
try
unlet g:does_not_exist
catch /E108:/
@@ -1506,6 +1644,52 @@ def Test_import_compile_error()
delete('Ximport.vim')
enddef
def Test_func_overrules_import_fails()
let export_lines =<< trim END
vim9script
export def Func()
echo 'imported'
enddef
END
writefile(export_lines, 'XexportedFunc.vim')
let lines =<< trim END
vim9script
import Func from './XexportedFunc.vim'
def Func()
echo 'local to function'
enddef
END
CheckScriptFailure(lines, 'E1073:')
lines =<< trim END
vim9script
import Func from './XexportedFunc.vim'
def Outer()
def Func()
echo 'local to function'
enddef
enddef
defcompile
END
CheckScriptFailure(lines, 'E1073:')
delete('XexportedFunc.vim')
enddef
def Test_func_redefine_fails()
let lines =<< trim END
vim9script
def Func()
echo 'one'
enddef
def Func()
echo 'two'
enddef
END
CheckScriptFailure(lines, 'E1073:')
enddef
def Test_fixed_size_list()
# will be allocated as one piece of memory, check that changes work
let l = [1, 2, 3, 4]
@@ -1516,18 +1700,21 @@ def Test_fixed_size_list()
enddef
def Test_no_insert_xit()
call CheckDefExecFailure(['x = 1'], 'E1100:')
call CheckDefExecFailure(['a = 1'], 'E1100:')
call CheckDefExecFailure(['i = 1'], 'E1100:')
call CheckDefExecFailure(['c = 1'], 'E1100:')
call CheckDefExecFailure(['i = 1'], 'E1100:')
call CheckDefExecFailure(['t = 1'], 'E1100:')
call CheckDefExecFailure(['x = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'a = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'a'], 'E1100:')
CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'i'], 'E1100:')
CheckScriptFailure(['vim9script', 'c = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'c'], 'E1100:')
CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'i'], 'E1100:')
CheckScriptFailure(['vim9script', 't'], 'E1100:')
CheckScriptFailure(['vim9script', 't = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
enddef
def IfElse(what: number): string
@@ -2259,6 +2446,10 @@ def Test_vim9_comment()
'vim9script',
'function # comment',
])
CheckScriptFailure([
'vim9script',
'function " comment',
], 'E129:')
CheckScriptFailure([
'vim9script',
'function# comment',
@@ -2308,11 +2499,11 @@ def Test_vim9_comment()
'func Test() " comment',
'endfunc',
])
CheckScriptFailure([
CheckScriptSuccess([
'vim9script',
'func Test() " comment',
'endfunc',
], 'E488:')
])
CheckScriptSuccess([
'def Test() # comment',

View File

@@ -807,7 +807,7 @@ func Test_viminfo_perm()
" Try to write the viminfo to a directory
call mkdir('Xdir')
call assert_fails('wviminfo Xdir', 'E886:')
call assert_fails('wviminfo Xdir', 'E137:')
call delete('Xdir', 'rf')
endfunc

File diff suppressed because it is too large Load Diff

View File

@@ -136,9 +136,7 @@ func Test_writefile_sync_arg()
endfunc
func Test_writefile_sync_dev_stdout()
if !has('unix')
return
endif
CheckUnix
if filewritable('/dev/stdout')
" Just check that this doesn't cause an error.
call writefile(['one'], '/dev/stdout')
@@ -371,13 +369,10 @@ endfunc
" Test for writing to a readonly file
func Test_write_readonly()
" In Cirrus-CI, the freebsd tests are run under a root account. So this test
" doesn't fail.
CheckNotBSD
call writefile([], 'Xfile')
call setfperm('Xfile', "r--------")
edit Xfile
set noreadonly
set noreadonly backupskip=
call assert_fails('write', 'E505:')
let save_cpo = &cpo
set cpo+=W
@@ -386,37 +381,32 @@ func Test_write_readonly()
call setline(1, ['line1'])
write!
call assert_equal(['line1'], readfile('Xfile'))
set backupskip&
call delete('Xfile')
endfunc
" Test for 'patchmode'
func Test_patchmode()
CheckNotBSD
call writefile(['one'], 'Xfile')
set patchmode=.orig nobackup writebackup
set patchmode=.orig nobackup backupskip= writebackup
new Xfile
call setline(1, 'two')
" first write should create the .orig file
write
" TODO: Xfile.orig is not created in Cirrus FreeBSD CI test
call assert_equal(['one'], readfile('Xfile.orig'))
call setline(1, 'three')
" subsequent writes should not create/modify the .orig file
write
call assert_equal(['one'], readfile('Xfile.orig'))
set patchmode& backup& writebackup&
set patchmode& backup& backupskip& writebackup&
call delete('Xfile')
call delete('Xfile.orig')
endfunc
" Test for writing to a file in a readonly directory
func Test_write_readonly_dir()
if !has('unix') || has('bsd')
" On MS-Windows, modifying files in a read-only directory is allowed.
" In Cirrus-CI for Freebsd, tests are run under a root account where
" modifying files in a read-only directory are allowed.
return
endif
" On MS-Windows, modifying files in a read-only directory is allowed.
CheckUnix
call mkdir('Xdir')
call writefile(['one'], 'Xdir/Xfile1')
call setfperm('Xdir', 'r-xr--r--')
@@ -426,12 +416,12 @@ func Test_write_readonly_dir()
call assert_fails('write', 'E212:')
" try to create a backup file in the directory
edit! Xdir/Xfile1
set backupdir=./Xdir
set backupdir=./Xdir backupskip=
set patchmode=.orig
call assert_fails('write', 'E509:')
call setfperm('Xdir', 'rwxr--r--')
call delete('Xdir', 'rf')
set backupdir& patchmode&
set backupdir& backupskip& patchmode&
endfunc
" Test for writing a file using invalid file encoding
@@ -556,4 +546,132 @@ func Test_write_file_encoding()
%bw!
endfunc
" Test for writing and reading a file starting with a BOM.
" Byte Order Mark (BOM) character for various encodings is below:
" UTF-8 : EF BB BF
" UTF-16 (BE): FE FF
" UTF-16 (LE): FF FE
" UTF-32 (BE): 00 00 FE FF
" UTF-32 (LE): FF FE 00 00
func Test_readwrite_file_with_bom()
let utf8_bom = "\xEF\xBB\xBF"
let utf16be_bom = "\xFE\xFF"
let utf16le_bom = "\xFF\xFE"
let utf32be_bom = "\n\n\xFE\xFF"
let utf32le_bom = "\xFF\xFE\n\n"
let save_fileencoding = &fileencoding
set cpoptions+=S
" Check that editing a latin1 file doesn't see a BOM
call writefile(["\xFE\xFElatin-1"], 'Xtest1')
edit Xtest1
call assert_equal('latin1', &fileencoding)
call assert_equal(0, &bomb)
set fenc=latin1
write Xfile2
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xfile2', 'b'))
set bomb fenc=latin1
write Xtest3
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xtest3', 'b'))
set bomb&
" Check utf-8 BOM
%bw!
call writefile([utf8_bom .. "utf-8"], 'Xtest1')
edit! Xtest1
call assert_equal('utf-8', &fileencoding)
call assert_equal(1, &bomb)
call assert_equal('utf-8', getline(1))
set fenc=latin1
write! Xfile2
call assert_equal(['utf-8', ''], readfile('Xfile2', 'b'))
set fenc=utf-8
w! Xtest3
call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xtest3', 'b'))
" Check utf-8 with an error (will fall back to latin-1)
%bw!
call writefile([utf8_bom .. "utf-8\x80err"], 'Xtest1')
edit! Xtest1
call assert_equal('latin1', &fileencoding)
call assert_equal(0, &bomb)
call assert_equal("\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", getline(1))
set fenc=latin1
write! Xfile2
call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xfile2', 'b'))
set fenc=utf-8
w! Xtest3
call assert_equal(["\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", ''],
\ readfile('Xtest3', 'b'))
" Check ucs-2 BOM
%bw!
call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xtest1')
edit! Xtest1
call assert_equal('utf-16', &fileencoding)
call assert_equal(1, &bomb)
call assert_equal('ucs-2', getline(1))
set fenc=latin1
write! Xfile2
call assert_equal(["ucs-2", ''], readfile('Xfile2', 'b'))
set fenc=ucs-2
w! Xtest3
call assert_equal([utf16be_bom .. "\nu\nc\ns\n-\n2\n", ''],
\ readfile('Xtest3', 'b'))
" Check ucs-2le BOM
%bw!
call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xtest1')
" Need to add a NUL byte after the NL byte
call writefile(0z00, 'Xtest1', 'a')
edit! Xtest1
call assert_equal('utf-16le', &fileencoding)
call assert_equal(1, &bomb)
call assert_equal('ucs-2le', getline(1))
set fenc=latin1
write! Xfile2
call assert_equal(["ucs-2le", ''], readfile('Xfile2', 'b'))
set fenc=ucs-2le
w! Xtest3
call assert_equal([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n", "\n"],
\ readfile('Xtest3', 'b'))
" Check ucs-4 BOM
%bw!
call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xtest1')
edit! Xtest1
call assert_equal('ucs-4', &fileencoding)
call assert_equal(1, &bomb)
call assert_equal('ucs-4', getline(1))
set fenc=latin1
write! Xfile2
call assert_equal(["ucs-4", ''], readfile('Xfile2', 'b'))
set fenc=ucs-4
w! Xtest3
call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xtest3', 'b'))
" Check ucs-4le BOM
%bw!
call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xtest1')
" Need to add three NUL bytes after the NL byte
call writefile(0z000000, 'Xtest1', 'a')
edit! Xtest1
call assert_equal('ucs-4le', &fileencoding)
call assert_equal(1, &bomb)
call assert_equal('ucs-4le', getline(1))
set fenc=latin1
write! Xfile2
call assert_equal(["ucs-4le", ''], readfile('Xfile2', 'b'))
set fenc=ucs-4le
w! Xtest3
call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b'))
set cpoptions-=S
let &fileencoding = save_fileencoding
call delete('Xtest1')
call delete('Xtest2')
call delete('Xtest3')
%bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -366,7 +366,7 @@ register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state)
if (fp == NULL)
return NULL;
fp->uf_dfunc_idx = UF_NOT_COMPILED;
fp->uf_def_status = UF_NOT_COMPILED;
fp->uf_refcount = 1;
fp->uf_varargs = TRUE;
fp->uf_flags = FC_CFUNC;
@@ -642,6 +642,10 @@ get_func_tv(
break;
}
++argcount;
// The comma should come right after the argument, but this wasn't
// checked previously, thus only enforce it in Vim9 script.
if (!in_vim9script())
argp = skipwhite(argp);
if (*argp != ',')
break;
}
@@ -776,7 +780,7 @@ find_func_with_sid(char_u *name, int sid)
* When "is_global" is true don't find script-local or imported functions.
* Return NULL for unknown function.
*/
static ufunc_T *
ufunc_T *
find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
{
hashitem_T *hi;
@@ -785,9 +789,10 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
if (!is_global)
{
char_u *after_script = NULL;
int vim9script = in_vim9script();
char_u *after_script = NULL;
if (in_vim9script())
if (vim9script)
{
// Find script-local function before global one.
func = find_func_with_sid(name, current_sctx.sc_sid);
@@ -795,7 +800,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
return func;
}
if (!in_vim9script()
if (!vim9script
&& name[0] == K_SPECIAL
&& name[1] == KS_EXTRA
&& name[2] == KE_SNR)
@@ -811,7 +816,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
else
after_script = NULL;
}
if (in_vim9script() || after_script != NULL)
if (vim9script || after_script != NULL)
{
// Find imported function before global one.
imported = find_imported(
@@ -1065,7 +1070,8 @@ func_remove(ufunc_T *fp)
{
// When there is a def-function index do not actually remove the
// function, so we can find the index when defining the function again.
if (fp->uf_def_status == UF_COMPILED)
// Do remove it when it's a copy.
if (fp->uf_def_status == UF_COMPILED && (fp->uf_flags & FC_COPY) == 0)
fp->uf_flags |= FC_DEAD;
else
hash_remove(&func_hashtab, hi);
@@ -1118,7 +1124,8 @@ func_clear(ufunc_T *fp, int force)
// clear this function
func_clear_items(fp);
funccal_unref(fp->uf_scoped, fp, force);
clear_def_function(fp);
if ((fp->uf_flags & FC_COPY) == 0)
clear_def_function(fp);
}
/*
@@ -1146,12 +1153,83 @@ func_free(ufunc_T *fp, int force)
func_clear_free(ufunc_T *fp, int force)
{
func_clear(fp, force);
if (force || fp->uf_dfunc_idx == 0)
if (force || fp->uf_dfunc_idx == 0 || (fp->uf_flags & FC_COPY))
func_free(fp, force);
else
fp->uf_flags |= FC_DEAD;
}
/*
* Copy already defined function "lambda" to a new function with name "global".
* This is for when a compiled function defines a global function.
*/
void
copy_func(char_u *lambda, char_u *global)
{
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
ufunc_T *fp;
if (ufunc == NULL)
semsg(_("E1102: lambda function not found: %s"), lambda);
else
{
// TODO: handle ! to overwrite
fp = find_func(global, TRUE, NULL);
if (fp != NULL)
{
semsg(_(e_funcexts), global);
return;
}
fp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(global) + 1);
if (fp == NULL)
return;
fp->uf_varargs = ufunc->uf_varargs;
fp->uf_flags = (ufunc->uf_flags & ~FC_VIM9) | FC_COPY;
fp->uf_def_status = ufunc->uf_def_status;
fp->uf_dfunc_idx = ufunc->uf_dfunc_idx;
if (ga_copy_strings(&ufunc->uf_args, &fp->uf_args) == FAIL
|| ga_copy_strings(&ufunc->uf_def_args, &fp->uf_def_args)
== FAIL
|| ga_copy_strings(&ufunc->uf_lines, &fp->uf_lines) == FAIL)
goto failed;
fp->uf_name_exp = ufunc->uf_name_exp == NULL ? NULL
: vim_strsave(ufunc->uf_name_exp);
if (ufunc->uf_arg_types != NULL)
{
fp->uf_arg_types = ALLOC_MULT(type_T *, fp->uf_args.ga_len);
if (fp->uf_arg_types == NULL)
goto failed;
mch_memmove(fp->uf_arg_types, ufunc->uf_arg_types,
sizeof(type_T *) * fp->uf_args.ga_len);
}
if (ufunc->uf_def_arg_idx != NULL)
{
fp->uf_def_arg_idx = ALLOC_MULT(int, fp->uf_def_args.ga_len + 1);
if (fp->uf_def_arg_idx == NULL)
goto failed;
mch_memmove(fp->uf_def_arg_idx, ufunc->uf_def_arg_idx,
sizeof(int) * fp->uf_def_args.ga_len + 1);
}
if (ufunc->uf_va_name != NULL)
{
fp->uf_va_name = vim_strsave(ufunc->uf_va_name);
if (fp->uf_va_name == NULL)
goto failed;
}
fp->uf_refcount = 1;
STRCPY(fp->uf_name, global);
hash_add(&func_hashtab, UF2HIKEY(fp));
}
return;
failed:
func_clear_free(fp, TRUE);
}
/*
* Call a user function.
@@ -1682,7 +1760,7 @@ delete_script_functions(int sid)
{
hashitem_T *hi;
ufunc_T *fp;
long_u todo;
long_u todo = 1;
char_u buf[30];
size_t len;
@@ -1692,18 +1770,27 @@ delete_script_functions(int sid)
sprintf((char *)buf + 3, "%d_", sid);
len = STRLEN(buf);
todo = func_hashtab.ht_used;
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
fp = HI2UF(hi);
if (STRNCMP(fp->uf_name, buf, len) == 0)
while (todo > 0)
{
todo = func_hashtab.ht_used;
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
fp->uf_flags |= FC_DEAD;
func_clear(fp, TRUE);
fp = HI2UF(hi);
if (STRNCMP(fp->uf_name, buf, len) == 0)
{
int changed = func_hashtab.ht_changed;
fp->uf_flags |= FC_DEAD;
func_clear(fp, TRUE);
// When clearing a function another function can be cleared
// as a side effect. When that happens start over.
if (changed != func_hashtab.ht_changed)
break;
}
--todo;
}
--todo;
}
}
}
#if defined(EXITFREE) || defined(PROTO)
@@ -2000,10 +2087,14 @@ call_func(
if (error == FCERR_NONE && funcexe->evaluate)
{
char_u *rfname = fname;
int is_global = FALSE;
// Ignore "g:" before a function name.
// Skip "g:" before a function name.
if (fp == NULL && fname[0] == 'g' && fname[1] == ':')
{
is_global = TRUE;
rfname = fname + 2;
}
rettv->v_type = VAR_NUMBER; // default rettv is number zero
rettv->vval.v_number = 0;
@@ -2015,7 +2106,7 @@ call_func(
* User defined function.
*/
if (fp == NULL)
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
// Trigger FuncUndefined event, may load the function.
if (fp == NULL
@@ -2024,13 +2115,13 @@ call_func(
&& !aborting())
{
// executed an autocommand, search for the function again
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
}
// Try loading a package.
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
{
// loaded a package, search for the function again
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
}
if (fp == NULL)
{
@@ -2039,7 +2130,7 @@ call_func(
// If using Vim9 script try not local to the script.
// TODO: should not do this if the name started with "s:".
if (p != NULL)
fp = find_func(p, FALSE, NULL);
fp = find_func(p, is_global, NULL);
}
if (fp != NULL && (fp->uf_flags & FC_DELETED))
@@ -2089,6 +2180,7 @@ call_func(
*/
error = call_internal_func(fname, argcount, argvars, rettv);
}
/*
* The function call (or "FuncUndefined" autocommand sequence) might
* have been aborted by an error, an interrupt, or an explicitly thrown
@@ -2517,6 +2609,8 @@ list_functions(regmatch_T *regmatch)
/*
* ":function" also supporting nested ":def".
* When "name_arg" is not NULL this is a nested function, using "name_arg" for
* the function name.
* Returns a pointer to the function or NULL if no function defined.
*/
ufunc_T *
@@ -2558,6 +2652,7 @@ def_function(exarg_T *eap, char_u *name_arg)
char_u *skip_until = NULL;
char_u *heredoc_trimmed = NULL;
int vim9script = in_vim9script();
imported_T *import = NULL;
/*
* ":function" without argument: list functions.
@@ -2832,7 +2927,8 @@ def_function(exarg_T *eap, char_u *name_arg)
if (*p == '\n')
line_arg = p + 1;
else if (*p != NUL
&& !(*p == '"' && !(vim9script || eap->cmdidx == CMD_def))
&& !(*p == '"' && (!vim9script || eap->cmdidx == CMD_function)
&& eap->cmdidx != CMD_def)
&& !(*p == '#' && (vim9script || eap->cmdidx == CMD_def))
&& !eap->skip
&& !did_emsg)
@@ -3140,17 +3236,29 @@ def_function(exarg_T *eap, char_u *name_arg)
}
fp = find_func_even_dead(name, is_global, NULL);
if (fp != NULL)
if (vim9script)
{
int dead = fp->uf_flags & FC_DEAD;
char_u *uname = untrans_function_name(name);
import = find_imported(uname == NULL ? name : uname, 0, NULL);
}
if (fp != NULL || import != NULL)
{
int dead = fp != NULL && (fp->uf_flags & FC_DEAD);
// Function can be replaced with "function!" and when sourcing the
// same script again, but only once.
if (!dead && !eap->forceit
// A name that is used by an import can not be overruled.
if (import != NULL
|| (!dead && !eap->forceit
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))
{
emsg_funcname(e_funcexts, name);
if (vim9script)
emsg_funcname(e_already_defined, name);
else
emsg_funcname(e_funcexts, name);
goto erret;
}
if (fp->uf_calls > 0)

View File

@@ -754,6 +754,126 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1369,
/**/
1368,
/**/
1367,
/**/
1366,
/**/
1365,
/**/
1364,
/**/
1363,
/**/
1362,
/**/
1361,
/**/
1360,
/**/
1359,
/**/
1358,
/**/
1357,
/**/
1356,
/**/
1355,
/**/
1354,
/**/
1353,
/**/
1352,
/**/
1351,
/**/
1350,
/**/
1349,
/**/
1348,
/**/
1347,
/**/
1346,
/**/
1345,
/**/
1344,
/**/
1343,
/**/
1342,
/**/
1341,
/**/
1340,
/**/
1339,
/**/
1338,
/**/
1337,
/**/
1336,
/**/
1335,
/**/
1334,
/**/
1333,
/**/
1332,
/**/
1331,
/**/
1330,
/**/
1329,
/**/
1328,
/**/
1327,
/**/
1326,
/**/
1325,
/**/
1324,
/**/
1323,
/**/
1322,
/**/
1321,
/**/
1320,
/**/
1319,
/**/
1318,
/**/
1317,
/**/
1316,
/**/
1315,
/**/
1314,
/**/
1313,
/**/
1312,
/**/
1311,
/**/
1310,
/**/
1309,
/**/

View File

@@ -79,6 +79,7 @@ typedef enum {
ISN_PCALL_END, // cleanup after ISN_PCALL with cpf_top set
ISN_RETURN, // return, result is on top of stack
ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref
ISN_NEWFUNC, // create a global function from a lambda function
// expression operations
ISN_JUMP, // jump if condition is matched isn_arg.jump
@@ -237,6 +238,12 @@ typedef struct {
int fr_var_idx; // variable to store partial
} funcref_T;
// arguments to ISN_NEWFUNC
typedef struct {
char_u *nf_lambda; // name of the lambda already defined
char_u *nf_global; // name of the global function to be created
} newfunc_T;
// arguments to ISN_CHECKLEN
typedef struct {
int cl_min_len; // minimum length
@@ -281,6 +288,7 @@ struct isn_S {
script_T script;
unlet_T unlet;
funcref_T funcref;
newfunc_T newfunc;
checklen_T checklen;
shuffle_T shuffle;
} isn_arg;

View File

@@ -291,14 +291,21 @@ lookup_script(char_u *name, size_t len)
int
check_defined(char_u *p, size_t len, cctx_T *cctx)
{
int c = p[len];
p[len] = NUL;
if (lookup_script(p, len) == OK
|| (cctx != NULL
&& (lookup_local(p, len, cctx) != NULL
|| find_imported(p, len, cctx) != NULL)))
|| lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK))
|| find_imported(p, len, cctx) != NULL
|| find_func_even_dead(p, FALSE, cctx) != NULL)
{
semsg("E1073: imported name already defined: %s", p);
p[len] = c;
semsg(_(e_already_defined), p);
return FAIL;
}
p[len] = c;
return OK;
}
@@ -1522,6 +1529,27 @@ generate_FUNCREF(cctx_T *cctx, int dfunc_idx)
return OK;
}
/*
* Generate an ISN_NEWFUNC instruction.
*/
static int
generate_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name)
{
isn_T *isn;
char_u *name;
RETURN_OK_IF_SKIP(cctx);
name = vim_strsave(lambda_name);
if (name == NULL)
return FAIL;
if ((isn = generate_instr(cctx, ISN_NEWFUNC)) == NULL)
return FAIL;
isn->isn_arg.newfunc.nf_lambda = name;
isn->isn_arg.newfunc.nf_global = func_name;
return OK;
}
/*
* Generate an ISN_JUMP instruction.
*/
@@ -3537,7 +3565,7 @@ compile_get_register(char_u **arg, cctx_T *cctx)
semsg(_(e_syntax_at), *arg - 1);
return FAIL;
}
if (!valid_yank_reg(**arg, TRUE))
if (!valid_yank_reg(**arg, FALSE))
{
emsg_invreg(**arg);
return FAIL;
@@ -3633,7 +3661,7 @@ get_vim_constant(char_u **arg, typval_T *rettv)
}
}
static exptype_T
exptype_T
get_compare_type(char_u *p, int *len, int *type_is)
{
exptype_T type = EXPR_UNKNOWN;
@@ -3834,7 +3862,7 @@ compile_subscript(
return FAIL;
}
}
else if (*p == '[')
else if (**arg == '[')
{
garray_T *stack = &cctx->ctx_type_stack;
type_T **typep;
@@ -4215,6 +4243,18 @@ compile_expr7(
return OK;
}
/*
* Give the "white on both sides" error, taking the operator from "p[len]".
*/
void
error_white_both(char_u *op, int len)
{
char_u buf[10];
vim_strncpy(buf, op, len);
semsg(_(e_white_both), buf);
}
/*
* * number multiplication
* / number division
@@ -4247,10 +4287,7 @@ compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[1]))
{
char_u buf[3];
vim_strncpy(buf, op, 1);
semsg(_(e_white_both), buf);
error_white_both(op, 1);
return FAIL;
}
*arg = skipwhite(op + 1);
@@ -4326,10 +4363,7 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen]))
{
char_u buf[3];
vim_strncpy(buf, op, oplen);
semsg(_(e_white_both), buf);
error_white_both(op, oplen);
return FAIL;
}
@@ -4458,10 +4492,7 @@ compile_expr4(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[len]))
{
char_u buf[7];
vim_strncpy(buf, p, len);
semsg(_(e_white_both), buf);
error_white_both(p, len);
return FAIL;
}
@@ -4875,18 +4906,30 @@ exarg_getline(
static char_u *
compile_nested_function(exarg_T *eap, cctx_T *cctx)
{
int is_global = *eap->arg == 'g' && eap->arg[1] == ':';
char_u *name_start = eap->arg;
char_u *name_end = to_name_end(eap->arg, FALSE);
char_u *name = get_lambda_name();
char_u *name_end = to_name_end(eap->arg, TRUE);
char_u *lambda_name;
lvar_T *lvar;
ufunc_T *ufunc;
int r;
// Only g:Func() can use a namespace.
if (name_start[1] == ':' && !is_global)
{
semsg(_(e_namespace), name_start);
return NULL;
}
if (check_defined(name_start, name_end - name_start, cctx) == FAIL)
return NULL;
eap->arg = name_end;
eap->getline = exarg_getline;
eap->cookie = cctx;
eap->skip = cctx->ctx_skip == SKIP_YES;
eap->forceit = FALSE;
ufunc = def_function(eap, name);
lambda_name = get_lambda_name();
ufunc = def_function(eap, lambda_name);
if (ufunc == NULL)
return NULL;
@@ -4894,16 +4937,30 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
&& compile_def_function(ufunc, TRUE, cctx) == FAIL)
return NULL;
// Define a local variable for the function reference.
lvar = reserve_local(cctx, name_start, name_end - name_start,
TRUE, ufunc->uf_func_type);
if (is_global)
{
char_u *func_name = vim_strnsave(name_start + 2,
name_end - name_start - 2);
if (generate_FUNCREF(cctx, ufunc->uf_dfunc_idx) == FAIL
|| generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL) == FAIL)
return NULL;
if (func_name == NULL)
r = FAIL;
else
r = generate_NEWFUNC(cctx, lambda_name, func_name);
}
else
{
// Define a local variable for the function reference.
lvar = reserve_local(cctx, name_start, name_end - name_start,
TRUE, ufunc->uf_func_type);
if (lvar == NULL)
return NULL;
if (generate_FUNCREF(cctx, ufunc->uf_dfunc_idx) == FAIL)
return NULL;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
}
// TODO: warning for trailing text?
return (char_u *)"";
return r == FAIL ? NULL : (char_u *)"";
}
/*
@@ -5013,7 +5070,12 @@ vim9_declare_error(char_u *name)
case 'w': scope = _("window"); break;
case 't': scope = _("tab"); break;
case 'v': scope = "v:"; break;
case '$': semsg(_(e_declare_env_var), name); return;
case '$': semsg(_(e_declare_env_var), name);
return;
case '&': semsg(_("E1052: Cannot declare an option: %s"), name);
return;
case '@': semsg(_("E1066: Cannot declare a register: %s"), name);
return;
default: return;
}
semsg(_(e_declare_var), scope, name);
@@ -5035,6 +5097,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
char_u *ret = NULL;
int var_count = 0;
int var_idx;
int scriptvar_sid = 0;
int scriptvar_idx = -1;
int semicolon = 0;
garray_T *instr = &cctx->ctx_instr;
garray_T *stack = &cctx->ctx_type_stack;
@@ -5071,10 +5135,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (oplen > 0 && (!VIM_ISWHITE(*sp) || !VIM_ISWHITE(op[oplen])))
{
char_u buf[4];
vim_strncpy(buf, op, oplen);
semsg(_(e_white_both), buf);
error_white_both(op, oplen);
return NULL;
}
@@ -5153,9 +5214,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
int has_index = FALSE;
int instr_count = -1;
p = (*var_start == '&' || *var_start == '$'
|| *var_start == '@') ? var_start + 1 : var_start;
p = to_name_end(p, TRUE);
if (*var_start == '@')
p = var_start + 2;
else
{
p = (*var_start == '&' || *var_start == '$')
? var_start + 1 : var_start;
p = to_name_end(p, TRUE);
}
// "a: type" is declaring variable "a" with a type, not "a:".
if (is_decl && var_end == var_start + 2 && var_end[-1] == ':')
@@ -5173,6 +5239,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (cctx->ctx_skip != SKIP_YES)
{
int declare_error = FALSE;
if (*var_start == '&')
{
int cc;
@@ -5184,11 +5252,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
emsg(_(e_const_option));
goto theend;
}
if (is_decl)
{
semsg(_("E1052: Cannot declare an option: %s"), var_start);
goto theend;
}
declare_error = is_decl;
p = var_start;
p = find_option_end(&p, &opt_flags);
if (p == NULL)
@@ -5216,64 +5280,40 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
dest = dest_env;
type = &t_string;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (*var_start == '@')
{
if (!valid_yank_reg(var_start[1], TRUE))
if (!valid_yank_reg(var_start[1], FALSE) || var_start[1] == '.')
{
emsg_invreg(var_start[1]);
goto theend;
}
dest = dest_reg;
type = &t_string;
if (is_decl)
{
semsg(_("E1066: Cannot declare a register: %s"), name);
goto theend;
}
declare_error = is_decl;
}
else if (STRNCMP(var_start, "g:", 2) == 0)
else if (varlen > 1 && STRNCMP(var_start, "g:", 2) == 0)
{
dest = dest_global;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (STRNCMP(var_start, "b:", 2) == 0)
else if (varlen > 1 && STRNCMP(var_start, "b:", 2) == 0)
{
dest = dest_buffer;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (STRNCMP(var_start, "w:", 2) == 0)
else if (varlen > 1 && STRNCMP(var_start, "w:", 2) == 0)
{
dest = dest_window;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (STRNCMP(var_start, "t:", 2) == 0)
else if (varlen > 1 && STRNCMP(var_start, "t:", 2) == 0)
{
dest = dest_tab;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (STRNCMP(var_start, "v:", 2) == 0)
else if (varlen > 1 && STRNCMP(var_start, "v:", 2) == 0)
{
typval_T *vtv;
int di_flags;
@@ -5290,15 +5330,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
dest = dest_vimvar;
vtv = get_vim_var_tv(vimvaridx);
type = typval2type_vimvar(vtv, cctx->ctx_type_list);
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else
{
int idx;
int idx;
imported_T *import = NULL;
for (idx = 0; reserved[idx] != NULL; ++idx)
if (STRCMP(reserved[idx], name) == 0)
@@ -5337,17 +5374,38 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
goto theend;
}
}
else if (STRNCMP(var_start, "s:", 2) == 0
else if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0)
|| lookup_script(var_start, varlen) == OK
|| find_imported(var_start, varlen, cctx) != NULL)
|| (import = find_imported(var_start, varlen, cctx))
!= NULL)
{
dest = dest_script;
char_u *rawname = name + (name[1] == ':' ? 2 : 0);
if (is_decl)
{
semsg(_("E1054: Variable already declared in the script: %s"),
if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0))
semsg(_("E1101: Cannot declare a script variable in a function: %s"),
name);
else
semsg(_("E1054: Variable already declared in the script: %s"),
name);
goto theend;
}
dest = dest_script;
// existing script-local variables should have a type
scriptvar_sid = current_sctx.sc_sid;
if (import != NULL)
scriptvar_sid = import->imp_sid;
scriptvar_idx = get_script_item_idx(scriptvar_sid,
rawname, TRUE);
if (scriptvar_idx >= 0)
{
scriptitem_T *si = SCRIPT_ITEM(scriptvar_sid);
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ scriptvar_idx;
type = sv->sv_type;
}
}
else if (name[1] == ':' && name[2] != NUL)
{
@@ -5361,6 +5419,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
goto theend;
}
}
if (declare_error)
{
vim9_declare_error(name);
goto theend;
}
}
// handle "a:name" as a name, not index "name" on "a"
@@ -5427,11 +5491,9 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
has_index = TRUE;
if (type->tt_member == NULL)
{
semsg(_("E1088: cannot use an index on %s"), name);
goto theend;
}
member_type = type->tt_member;
member_type = &t_any;
else
member_type = type->tt_member;
}
else
{
@@ -5660,6 +5722,18 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
emsg(_(e_missbrac));
goto theend;
}
if (type == &t_any)
{
type_T *idx_type = ((type_T **)stack->ga_data)[
stack->ga_len - 1];
// Index on variable of unknown type: guess the type from the
// index type: number is dict, otherwise dict.
// TODO: should do the assignment at runtime
if (idx_type->tt_type == VAR_NUMBER)
type = &t_list_any;
else
type = &t_dict_any;
}
if (type->tt_type == VAR_DICT
&& may_generate_2STRING(-1, cctx) == FAIL)
goto theend;
@@ -5727,21 +5801,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
break;
case dest_script:
{
char_u *rawname = name + (name[1] == ':' ? 2 : 0);
imported_T *import = NULL;
int sid = current_sctx.sc_sid;
int idx;
if (name[1] != ':')
{
import = find_imported(name, 0, cctx);
if (import != NULL)
sid = import->imp_sid;
}
idx = get_script_item_idx(sid, rawname, TRUE);
// TODO: specific type
if (idx < 0)
if (scriptvar_idx < 0)
{
char_u *name_s = name;
@@ -5757,14 +5817,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
vim_snprintf((char *)name_s, len,
"s:%s", name);
}
generate_OLDSCRIPT(cctx, ISN_STORES, name_s, sid,
&t_any);
generate_OLDSCRIPT(cctx, ISN_STORES, name_s,
scriptvar_sid, type);
if (name_s != name)
vim_free(name_s);
}
else
generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
sid, idx, &t_any);
scriptvar_sid, scriptvar_idx, type);
}
break;
case dest_local:
@@ -7192,7 +7252,10 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
int oplen;
int heredoc;
var_end = find_name_end(pskip, NULL, NULL,
if (ea.cmd[0] == '@')
var_end = ea.cmd + 2;
else
var_end = find_name_end(pskip, NULL, NULL,
FNE_CHECK_START | FNE_INCL_BR);
oplen = assignment_len(skipwhite(var_end), &heredoc);
if (oplen > 0)
@@ -7412,6 +7475,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
goto erret;
@@ -7637,6 +7701,24 @@ delete_instr(isn_T *isn)
}
break;
case ISN_NEWFUNC:
{
char_u *lambda = isn->isn_arg.newfunc.nf_lambda;
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
if (ufunc != NULL)
{
// Clear uf_dfunc_idx so that the function is deleted.
clear_def_function(ufunc);
ufunc->uf_dfunc_idx = 0;
func_ptr_unref(ufunc);
}
vim_free(lambda);
vim_free(isn->isn_arg.newfunc.nf_global);
}
break;
case ISN_2BOOL:
case ISN_2STRING:
case ISN_ADDBLOB:

View File

@@ -723,7 +723,10 @@ call_def_function(
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
if (dfunc->df_instr == NULL)
{
iemsg("using call_def_function() on not compiled function");
return FAIL;
}
}
CLEAR_FIELD(ectx);
@@ -1419,11 +1422,13 @@ call_def_function(
dict_T *dict = tv_dict->vval.v_dict;
dictitem_T *di;
if (key == NULL || *key == NUL)
if (dict == NULL)
{
emsg(_(e_emptykey));
emsg(_(e_dictnull));
goto on_error;
}
if (key == NULL)
key = (char_u *)"";
tv = STACK_TV_BOT(-3);
di = dict_find(dict, key, -1);
if (di != NULL)
@@ -1726,6 +1731,15 @@ call_def_function(
}
break;
// Create a global function from a lambda.
case ISN_NEWFUNC:
{
newfunc_T *newfunc = &iptr->isn_arg.newfunc;
copy_func(newfunc->nf_lambda, newfunc->nf_global);
}
break;
// jump if a condition is met
case ISN_JUMP:
{
@@ -2912,6 +2926,15 @@ ex_disassemble(exarg_T *eap)
}
break;
case ISN_NEWFUNC:
{
newfunc_T *newfunc = &iptr->isn_arg.newfunc;
smsg("%4d NEWFUNC %s %s", current,
newfunc->nf_lambda, newfunc->nf_global);
}
break;
case ISN_JUMP:
{
char *when = "?";

View File

@@ -64,16 +64,18 @@ ex_vim9script(exarg_T *eap)
int
not_in_vim9(exarg_T *eap)
{
switch (eap->cmdidx)
{
case CMD_insert:
case CMD_append:
case CMD_change:
case CMD_xit:
semsg(_("E1100: Missing :let: %s"), eap->cmd);
return FAIL;
default: break;
}
if (in_vim9script())
switch (eap->cmdidx)
{
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_t:
case CMD_xit:
semsg(_("E1100: Missing :let: %s"), eap->cmd);
return FAIL;
default: break;
}
return OK;
}

View File

@@ -3007,6 +3007,7 @@ read_viminfo(
{
FILE *fp;
char_u *fname;
stat_T st; // mch_stat() of existing viminfo file
if (no_viminfo())
return FAIL;
@@ -3031,6 +3032,11 @@ read_viminfo(
vim_free(fname);
if (fp == NULL)
return FAIL;
if (mch_fstat(fileno(fp), &st) < 0 || S_ISDIR(st.st_mode))
{
fclose(fp);
return FAIL;
}
viminfo_errcnt = 0;
do_viminfo(fp, NULL, flags);
@@ -3054,12 +3060,12 @@ write_viminfo(char_u *file, int forceit)
FILE *fp_out = NULL; // output viminfo file
char_u *tempname = NULL; // name of temp viminfo file
stat_T st_new; // mch_stat() of potential new file
stat_T st_old; // mch_stat() of existing viminfo file
#if defined(UNIX) || defined(VMS)
mode_t umask_save;
#endif
#ifdef UNIX
int shortname = FALSE; // use 8.3 file name
stat_T st_old; // mch_stat() of existing viminfo file
#endif
#ifdef MSWIN
int hidden = FALSE;
@@ -3097,20 +3103,20 @@ write_viminfo(char_u *file, int forceit)
// write the new viminfo into, in the same directory as the
// existing viminfo file, which will be renamed once all writing is
// successful.
if (mch_fstat(fileno(fp_in), &st_old) < 0
|| S_ISDIR(st_old.st_mode)
#ifdef UNIX
// For Unix we check the owner of the file. It's not very nice to
// overwrite a user's viminfo file after a "su root", with a
// viminfo file that the user can't read.
st_old.st_dev = (dev_t)0;
st_old.st_ino = 0;
st_old.st_mode = 0600;
if (mch_stat((char *)fname, &st_old) == 0
&& getuid() != ROOT_UID
&& !(st_old.st_uid == getuid()
? (st_old.st_mode & 0200)
: (st_old.st_gid == getgid()
? (st_old.st_mode & 0020)
: (st_old.st_mode & 0002))))
// For Unix we check the owner of the file. It's not very nice
// to overwrite a user's viminfo file after a "su root", with a
// viminfo file that the user can't read.
|| (getuid() != ROOT_UID
&& !(st_old.st_uid == getuid()
? (st_old.st_mode & 0200)
: (st_old.st_gid == getgid()
? (st_old.st_mode & 0020)
: (st_old.st_mode & 0002))))
#endif
)
{
int tt = msg_didany;
@@ -3120,7 +3126,6 @@ write_viminfo(char_u *file, int forceit)
fclose(fp_in);
goto end;
}
#endif
#ifdef MSWIN
// Get the file attributes of the existing viminfo file.
hidden = mch_ishidden(fname);