From 0193b3a3917d426bb5798759c3629e9d4f3eb7a8 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 27 Aug 2021 22:07:34 +0100 Subject: vim-patch:8.1.1336: some eval functionality is not covered by tests Problem: Some eval functionality is not covered by tests. Solution: Add a few more test cases. (Masato Nishihata, closes vim/vim#4374) https://github.com/vim/vim/commit/17aca707f92235b6f962e637e8073162d18e6de2 Test_expand() changes are required for v8.1.1921. Test_call() and Test_cindent_func() are already ported. --- test/functional/legacy/delete_spec.lua | 7 +++++++ test/functional/legacy/fnamemodify_spec.lua | 11 ----------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index f2ced8942d..b4ed8ff136 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source local eq, eval, command = helpers.eq, helpers.eval, helpers.command +local exc_exec = helpers.exc_exec describe('Test for delete()', function() before_each(clear) @@ -114,4 +115,10 @@ describe('Test for delete()', function() eq(0, eval("delete('Xdir4/Xfile')")) eq(0, eval("delete('Xdir4', 'd')")) end) + + it('gives correct emsgs', function() + eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')")) + eq('Vim(call):E15: Invalid expression: 0', + exc_exec("call delete('foo', 0)")) + end) end) diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua index 7e859bf0cf..6a5538c26f 100644 --- a/test/functional/legacy/fnamemodify_spec.lua +++ b/test/functional/legacy/fnamemodify_spec.lua @@ -60,12 +60,6 @@ describe('filename modifiers', function() call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S')) endif endfunc - - func Test_expand() - new - call assert_equal("", expand('%:S')) - quit - endfunc ]=]) end) @@ -73,9 +67,4 @@ describe('filename modifiers', function() call('Test_fnamemodify') expected_empty() end) - - it('works for :S in an unnamed buffer', function() - call('Test_expand') - expected_empty() - end) end) -- cgit From 6110480c290011d96af37c0cba1e7309ef645efb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 8 Aug 2021 16:07:40 +0100 Subject: feat(eval/method): partially port v8.1.1921 Adds method call support for all functions in the patch, but it cannot be fully ported due to missing tests for: - filereadable(): requires v8.1.1378 for Test_delete_rf(), but there appears to have been some trouble porting it. (#12784) - confirm(): requires v8.1.0832 for Test_confirm() and v8.1.0815 for feedkeys()'s "L" flag. (I did attempt to port the test using nvim_input() instead, but seems that input handling for confirm() doesn't work in --headless mode?) Note that confirm() was actually added as a method in v8.1.1915. Uncomment use of method call syntax in Test_Executable() previously included instead from v8.2.2259. --- test/functional/legacy/expand_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/expand_spec.lua b/test/functional/legacy/expand_spec.lua index f238128b31..cd3713eabe 100644 --- a/test/functional/legacy/expand_spec.lua +++ b/test/functional/legacy/expand_spec.lua @@ -81,7 +81,7 @@ describe('expand file name', function() call assert_equal('e Xfile1', expandcmd('e %')) edit Xfile2 edit Xfile1 - call assert_equal('e Xfile2', expandcmd('e #')) + call assert_equal('e Xfile2', 'e #'->expandcmd()) edit Xfile2 edit Xfile3 edit Xfile4 -- cgit From 3137c7d63574a86ddc44f11c839e8e58c2994bf9 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 27 Aug 2021 21:09:37 +0100 Subject: feat(eval/method): partially port v8.1.1925 Adds method call support for all functions in the patch, but it cannot be fully ported due to missing tests for: - getcwd(): requires chdir() and Test_chdir_func() from v8.1.1291. Note that the method call tests for getreg() and getregtype() were removed in v8.2.1547, which has already been ported, but doesn't seem to have been replaced with a new test... This patch also makes getchangelist()'s argument optional (defaults to the current buffer). eval.txt includes a typo for gettabwinvar(), which is fixed in v8.1.1952. --- test/functional/legacy/file_perm_spec.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua index 8fdee95e91..ccdbfe0534 100644 --- a/test/functional/legacy/file_perm_spec.lua +++ b/test/functional/legacy/file_perm_spec.lua @@ -3,7 +3,7 @@ require('os') local helpers = require('test.functional.helpers')(after_each) local clear, call, eq = helpers.clear, helpers.call, helpers.eq -local neq, exc_exec = helpers.neq, helpers.exc_exec +local neq, exc_exec, eval = helpers.neq, helpers.exc_exec, helpers.eval describe('Test getting and setting file permissions', function() local tempfile = helpers.tmpname() @@ -14,11 +14,12 @@ describe('Test getting and setting file permissions', function() end) it('file permissions', function() + -- eval() is used to test VimL method syntax for setfperm() and getfperm() eq('', call('getfperm', tempfile)) - eq(0, call('setfperm', tempfile, 'r--------')) + eq(0, eval("'" .. tempfile .. "'->setfperm('r--------')")) call('writefile', {'one'}, tempfile) - eq(9, call('len', call('getfperm', tempfile))) + eq(9, eval("len('" .. tempfile .. "'->getfperm())")) eq(1, call('setfperm', tempfile, 'rwx------')) if helpers.is_os('win') then -- cgit From 59c8a1fd5158886cb13b56070ebf15259d12eba2 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 31 Aug 2021 22:51:29 +0100 Subject: feat(eval/method): partially port v8.1.1953 Adds method call support for all functions in the patch, but it cannot be fully ported due to missing tests for: - index(): requires Blobs from v8.1.0735. Note that index() was already added as a method in v8.1.1803; this patch only adds a test. - iconv(): requires v8.1.1136 for test_termcodes.vim. Nvim deprecated inputdialog(), so it no longer has an eval.txt entry. Keep the test for hlexists() commented-out, just like previously. (Nvim always defines the Number group, so it always returns 1 instead) Cannot include both changes to test_syn_attr.vim as Nvim doesn't support ":hi term=..."; however, both test the same ->hlID() syntax anyway. --- test/functional/legacy/delete_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index b4ed8ff136..141d9583e6 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -39,7 +39,7 @@ describe('Test for delete()', function() eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')")) eq(1, eval("isdirectory('Xdir1/subdir')")) eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')")) - eq(1, eval("isdirectory('Xdir1/empty')")) + eq(1, eval("'Xdir1/empty'->isdirectory()")) eq(0, eval("delete('Xdir1', 'rf')")) eq(0, eval("isdirectory('Xdir1')")) eq(-1, eval("delete('Xdir1', 'd')")) -- cgit