From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- test/old/testdir/vim9.vim | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 test/old/testdir/vim9.vim (limited to 'test/old/testdir/vim9.vim') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim new file mode 100644 index 0000000000..2cc3d88aa8 --- /dev/null +++ b/test/old/testdir/vim9.vim @@ -0,0 +1,116 @@ + +" Use a different file name for each run. +let s:sequence = 1 + +func CheckScriptFailure(lines, error, lnum = -3) + if get(a:lines, 0, '') ==# 'vim9script' + return + endif + let cwd = getcwd() + let fname = 'XScriptFailure' .. s:sequence + let s:sequence += 1 + call writefile(a:lines, fname) + try + call assert_fails('so ' .. fname, a:error, a:lines, a:lnum) + finally + call chdir(cwd) + call delete(fname) + endtry +endfunc + +func CheckScriptSuccess(lines) + if get(a:lines, 0, '') ==# 'vim9script' + return + endif + let cwd = getcwd() + let fname = 'XScriptSuccess' .. s:sequence + let s:sequence += 1 + call writefile(a:lines, fname) + try + exe 'so ' .. fname + finally + call chdir(cwd) + call delete(fname) + endtry +endfunc + +func CheckDefExecAndScriptFailure(lines, error, lnum = -3) + return +endfunc + +" Check that "lines" inside a legacy function has no error. +func CheckLegacySuccess(lines) + let cwd = getcwd() + let fname = 'XlegacySuccess' .. s:sequence + let s:sequence += 1 + call writefile(['func Func()'] + a:lines + ['endfunc'], fname) + try + exe 'so ' .. fname + call Func() + finally + delfunc! Func + call chdir(cwd) + call delete(fname) + endtry +endfunc + +" Check that "lines" inside a legacy function results in the expected error +func CheckLegacyFailure(lines, error) + let cwd = getcwd() + let fname = 'XlegacyFails' .. s:sequence + let s:sequence += 1 + call writefile(['func Func()'] + a:lines + ['endfunc', 'call Func()'], fname) + try + call assert_fails('so ' .. fname, a:error) + finally + delfunc! Func + call chdir(cwd) + call delete(fname) + endtry +endfunc + +" Execute "lines" in a legacy function, translated as in +" CheckLegacyAndVim9Success() +func CheckTransLegacySuccess(lines) + let legacylines = a:lines->deepcopy()->map({_, v -> + \ v->substitute('\', 'let', 'g') + \ ->substitute('\', 'let', 'g') + \ ->substitute('\', '{', 'g') + \ ->substitute('\', '->', 'g') + \ ->substitute('\', '}', 'g') + \ ->substitute('\', '1', 'g') + \ ->substitute('\', '0', 'g') + \ ->substitute('#"', ' "', 'g') + \ }) + call CheckLegacySuccess(legacylines) +endfunc + +" Execute "lines" in a legacy function +" Use 'VAR' for a declaration. +" Use 'LET' for an assignment +" Use ' #"' for a comment +" Use LSTART arg LMIDDLE expr LEND for lambda +" Use 'TRUE' for 1 +" Use 'FALSE' for 0 +func CheckLegacyAndVim9Success(lines) + call CheckTransLegacySuccess(a:lines) +endfunc + +" Execute "lines" in a legacy function +" Use 'VAR' for a declaration. +" Use 'LET' for an assignment +" Use ' #"' for a comment +func CheckLegacyAndVim9Failure(lines, error) + if type(a:error) == type('string') + let legacyError = a:error + else + let legacyError = a:error[0] + endif + + let legacylines = a:lines->deepcopy()->map({_, v -> + \ v->substitute('\', 'let', 'g') + \ ->substitute('\', 'let', 'g') + \ ->substitute('#"', ' "', 'g') + \ }) + call CheckLegacyFailure(legacylines, legacyError) +endfunc -- cgit From f04125a93554103ff6c24f12506050112679a33a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 16:40:22 +0800 Subject: vim-patch:8.2.3856: Vim9: not enough tests Problem: Vim9: not enough tests. Solution: Run more expression tests also with Vim9. Fix an uncovered problem. https://github.com/vim/vim/commit/fea43e44c008a7ca73b506ddab0f47b63b5d2126 Co-authored-by: Bram Moolenaar --- test/old/testdir/vim9.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/old/testdir/vim9.vim') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim index 2cc3d88aa8..7b9ec4bfc4 100644 --- a/test/old/testdir/vim9.vim +++ b/test/old/testdir/vim9.vim @@ -34,6 +34,14 @@ func CheckScriptSuccess(lines) endtry endfunc +func CheckDefAndScriptSuccess(lines) + return +endfunc + +func CheckDefAndScriptFailure(lines, error, lnum = -3) + return +endfunc + func CheckDefExecAndScriptFailure(lines, error, lnum = -3) return endfunc @@ -85,6 +93,14 @@ func CheckTransLegacySuccess(lines) call CheckLegacySuccess(legacylines) endfunc +func CheckTransDefSuccess(lines) + return +endfunc + +func CheckTransVim9Success(lines) + return +endfunc + " Execute "lines" in a legacy function " Use 'VAR' for a declaration. " Use 'LET' for an assignment -- cgit From 7abfb1f86e25efcbe6ec31c8d3f196a60d718123 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 12 Jun 2023 12:48:14 +0800 Subject: vim-patch:8.2.2949: tests failing because no error for float to string conversion Problem: Tests failing because there is no error for float to string conversion. Solution: Change the check for failure to check for correct result. Make some conversions strict in Vim9 script. https://github.com/vim/vim/commit/3cfa5b16b06bcc034f6de77070fa779d698ab5e9 Co-authored-by: Bram Moolenaar --- test/old/testdir/vim9.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/old/testdir/vim9.vim') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim index 7b9ec4bfc4..ba0ef53e67 100644 --- a/test/old/testdir/vim9.vim +++ b/test/old/testdir/vim9.vim @@ -2,6 +2,10 @@ " Use a different file name for each run. let s:sequence = 1 +func CheckDefExecFailure(lines, error, lnum = -3) + return +endfunc + func CheckScriptFailure(lines, error, lnum = -3) if get(a:lines, 0, '') ==# 'vim9script' return -- cgit From 8d8ac15ed99c8ce12519e6bda43069f2bbb9ddf7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 12 Jun 2023 15:16:44 +0800 Subject: vim-patch:8.2.3202: Vim9: tests are only executed for legacy script Problem: Vim9: tests are only executed for legacy script. Solution: Run more tests also for Vim9 script. Fix uncovered problems. https://github.com/vim/vim/commit/5dd839ce20466eea52e59ecf86456f1ab370d2bd Co-authored-by: Bram Moolenaar --- test/old/testdir/vim9.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/old/testdir/vim9.vim') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim index ba0ef53e67..1b436d7b3c 100644 --- a/test/old/testdir/vim9.vim +++ b/test/old/testdir/vim9.vim @@ -2,6 +2,10 @@ " Use a different file name for each run. let s:sequence = 1 +func CheckDefFailure(lines, error, lnum = -3) + return +endfunc + func CheckDefExecFailure(lines, error, lnum = -3) return endfunc -- cgit From 3117dc70f1e60569f5c3cc0eee5f5005081722b5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 11:08:21 +0800 Subject: vim-patch:1b884a005398 Update runtime files. https://github.com/vim/vim/commit/1b884a0053982335f644eec6c71027706bf3c522 Co-authored-by: Bram Moolenaar --- test/old/testdir/vim9.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/old/testdir/vim9.vim') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim index 1b436d7b3c..825f01c9d6 100644 --- a/test/old/testdir/vim9.vim +++ b/test/old/testdir/vim9.vim @@ -88,7 +88,7 @@ endfunc " Execute "lines" in a legacy function, translated as in " CheckLegacyAndVim9Success() func CheckTransLegacySuccess(lines) - let legacylines = a:lines->deepcopy()->map({_, v -> + let legacylines = a:lines->mapnew({_, v -> \ v->substitute('\', 'let', 'g') \ ->substitute('\', 'let', 'g') \ ->substitute('\', '{', 'g') @@ -131,7 +131,7 @@ func CheckLegacyAndVim9Failure(lines, error) let legacyError = a:error[0] endif - let legacylines = a:lines->deepcopy()->map({_, v -> + let legacylines = a:lines->mapnew({_, v -> \ v->substitute('\', 'let', 'g') \ ->substitute('\', 'let', 'g') \ ->substitute('#"', ' "', 'g') -- cgit