diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-10-10 16:48:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 16:48:24 -0400 |
commit | b3e0d6708eca3cd22695d364ba2aca7401cc0f8c (patch) | |
tree | e2742ee0a6b33161887d9dab6069357e337aa302 /test | |
parent | 62eec98d5feee9173ea2decb2d7cb72971c24f8b (diff) | |
parent | a8504638cd2497b3bdd0daf27dcc50903e1e2bb9 (diff) | |
download | rneovim-b3e0d6708eca3cd22695d364ba2aca7401cc0f8c.tar.gz rneovim-b3e0d6708eca3cd22695d364ba2aca7401cc0f8c.tar.bz2 rneovim-b3e0d6708eca3cd22695d364ba2aca7401cc0f8c.zip |
Merge pull request #15502 from seandewar/vim-8.1.1921
Add method call support for more built-ins: vim-patch:8.1.{1336,1952,1961,1984}
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/delete_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/legacy/expand_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/file_perm_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/legacy/fnamemodify_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/lua/luaeval_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/vimscript/json_functions_spec.lua | 8 |
6 files changed, 22 insertions, 22 deletions
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index f2ced8942d..141d9583e6 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) @@ -38,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')")) @@ -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/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 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 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) diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua index 255e99032f..0675ec9abd 100644 --- a/test/functional/lua/luaeval_spec.lua +++ b/test/functional/lua/luaeval_spec.lua @@ -86,14 +86,15 @@ describe('luaeval()', function() -- meaningful later. it('correctly evaluates scalars', function() + -- Also test method call (->) syntax eq(1, funcs.luaeval('1')) - eq(0, eval('type(luaeval("1"))')) + eq(0, eval('"1"->luaeval()->type()')) eq(1.5, funcs.luaeval('1.5')) - eq(5, eval('type(luaeval("1.5"))')) + eq(5, eval('"1.5"->luaeval()->type()')) eq("test", funcs.luaeval('"test"')) - eq(1, eval('type(luaeval("\'test\'"))')) + eq(1, eval('"\'test\'"->luaeval()->type()')) eq('', funcs.luaeval('""')) eq('\000', funcs.luaeval([['\0']])) diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index c3b607b544..5d1597f53d 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -168,7 +168,8 @@ describe('json_decode() function', function() end) it('parses floating-point numbers', function() - eq('100000.0', eval('string(json_decode("100000.0"))')) + -- Also test method call (->) syntax + eq('100000.0', eval('"100000.0"->json_decode()->string()')) eq(100000.5, funcs.json_decode('100000.5')) eq(-100000.5, funcs.json_decode('-100000.5')) eq(-100000.5e50, funcs.json_decode('-100000.5e50')) @@ -549,11 +550,12 @@ describe('json_encode() function', function() end) it('dumps floats', function() - eq('0.0', eval('json_encode(0.0)')) + -- Also test method call (->) syntax + eq('0.0', eval('0.0->json_encode()')) eq('10.5', funcs.json_encode(10.5)) eq('-10.5', funcs.json_encode(-10.5)) eq('-1.0e-5', funcs.json_encode(-1e-5)) - eq('1.0e50', eval('json_encode(1.0e50)')) + eq('1.0e50', eval('1.0e50->json_encode()')) end) it('fails to dump NaN and infinite values', function() |