From 02b31110d31e995326080807716e79e38fe501df Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 31 Aug 2019 22:16:38 +0200 Subject: patch 8.1.1954: more functions can be used as a method Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method. --- src/testdir/test_arglist.vim | 2 +- src/testdir/test_functions.vim | 10 +++++----- src/testdir/test_json.vim | 8 ++++---- src/testdir/test_lispwords.vim | 3 +++ src/testdir/test_listener.vim | 8 ++++---- src/testdir/test_lua.vim | 2 +- src/testdir/test_utf8.vim | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src/testdir') diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim index daed3d4218..c486b18e2f 100644 --- a/src/testdir/test_arglist.vim +++ b/src/testdir/test_arglist.vim @@ -88,7 +88,7 @@ func Test_argadd_empty_curbuf() argadd Xargadd call assert_equal(curbuf, bufnr('%')) call assert_equal('', bufname('%')) - call assert_equal(1, line('$')) + call assert_equal(1, '$'->line()) rew call assert_notequal(curbuf, '%'->bufnr()) call assert_equal('Xargadd', '%'->bufname()) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 2ffdc24fb7..926713e87a 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -883,7 +883,7 @@ func Test_byte2line_line2byte() call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1], \ map(range(-1, 8), 'v:val->byte2line()')) call assert_equal([-1, -1, 1, 3, 6, 8, -1], - \ map(range(-1, 5), 'line2byte(v:val)')) + \ map(range(-1, 5), 'v:val->line2byte()')) set fileformat=dos call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1], @@ -1351,17 +1351,17 @@ func Test_libcall_libcallnr() endif if has('win32') - call assert_equal($USERPROFILE, libcall(libc, 'getenv', 'USERPROFILE')) + call assert_equal($USERPROFILE, 'USERPROFILE'->libcall(libc, 'getenv')) else - call assert_equal($HOME, libcall(libc, 'getenv', 'HOME')) + call assert_equal($HOME, 'HOME'->libcall(libc, 'getenv')) endif " If function returns NULL, libcall() should return an empty string. call assert_equal('', libcall(libc, 'getenv', 'X_ENV_DOES_NOT_EXIT')) " Test libcallnr() with string and integer argument. - call assert_equal(4, libcallnr(libc, 'strlen', 'abcd')) - call assert_equal(char2nr('A'), libcallnr(libc, 'toupper', char2nr('a'))) + call assert_equal(4, 'abcd'->libcallnr(libc, 'strlen')) + call assert_equal(char2nr('A'), char2nr('a')->libcallnr(libc, 'toupper')) call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", 'E364:') call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", 'E364:') diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim index 8f85a58cf0..94481d9305 100644 --- a/src/testdir/test_json.vim +++ b/src/testdir/test_json.vim @@ -70,7 +70,7 @@ let s:varvals = [v:true, v:false, v:null, v:null] func Test_json_encode() call assert_equal(s:json1, json_encode(s:var1)) call assert_equal(s:json2, json_encode(s:var2)) - call assert_equal(s:json3, json_encode(s:var3)) + call assert_equal(s:json3, s:var3->json_encode()) call assert_equal(s:json4, json_encode(s:var4)) call assert_equal(s:json5, json_encode(s:var5)) @@ -110,7 +110,7 @@ endfunc func Test_json_decode() call assert_equal(s:var1, json_decode(s:json1)) call assert_equal(s:var2, json_decode(s:json2)) - call assert_equal(s:var3, json_decode(s:json3)) + call assert_equal(s:var3, s:json3->json_decode()) call assert_equal(s:var4, json_decode(s:json4)) call assert_equal(s:var5, json_decode(s:json5)) @@ -188,7 +188,7 @@ let s:varl5 = [7, v:none, v:none] func Test_js_encode() call assert_equal(s:json1, js_encode(s:var1)) call assert_equal(s:json2, js_encode(s:var2)) - call assert_equal(s:json3, js_encode(s:var3)) + call assert_equal(s:json3, s:var3->js_encode()) call assert_equal(s:json4, js_encode(s:var4)) call assert_equal(s:json5, js_encode(s:var5)) @@ -226,7 +226,7 @@ endfunc func Test_js_decode() call assert_equal(s:var1, js_decode(s:json1)) call assert_equal(s:var2, js_decode(s:json2)) - call assert_equal(s:var3, js_decode(s:json3)) + call assert_equal(s:var3, s:json3->js_decode()) call assert_equal(s:var4, js_decode(s:json4)) call assert_equal(s:var5, js_decode(s:json5)) diff --git a/src/testdir/test_lispwords.vim b/src/testdir/test_lispwords.vim index 4c05504cf1..aa5a738bdf 100644 --- a/src/testdir/test_lispwords.vim +++ b/src/testdir/test_lispwords.vim @@ -43,6 +43,9 @@ func Test_lisp_indent() \ ',@body', \ '(princ "")))' \ ]) + call assert_equal(7, lispindent(2)) + call assert_equal(5, 6->lispindent()) + set lisp set lispwords& let save_copt = &cpoptions diff --git a/src/testdir/test_listener.vim b/src/testdir/test_listener.vim index 6a68ae64b5..3aadeaa96d 100644 --- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -59,10 +59,10 @@ func Test_listening() " a change above a previous change without a line number change is reported " together call setline(1, ['one one', 'two']) - call listener_flush() + call listener_flush(bufnr()) call append(2, 'two two') call setline(1, 'something') - call listener_flush() + call bufnr()->listener_flush() call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) @@ -134,7 +134,7 @@ func Test_listening() redraw call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list3) - call listener_remove(id) + eval id->listener_remove() bwipe! endfunc @@ -214,7 +214,7 @@ func Test_listening_other_buf() call setline(1, ['one', 'two']) let bufnr = bufnr('') normal ww - let id = listener_add(function('s:StoreBufList'), bufnr) + let id = bufnr->listener_add(function('s:StoreBufList')) let s:list = [] call setbufline(bufnr, 1, 'hello') redraw diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim index 65753dc4a6..cb5b95d010 100644 --- a/src/testdir/test_lua.vim +++ b/src/testdir/test_lua.vim @@ -36,7 +36,7 @@ func Test_eval() " lua.eval with a string lua v = vim.eval('"abc"') - call assert_equal('string', luaeval('vim.type(v)')) + call assert_equal('string', 'vim.type(v)'->luaeval()) call assert_equal('abc', luaeval('v')) " lua.eval with a list diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim index ab1616aed7..9470855afb 100644 --- a/src/testdir/test_utf8.vim +++ b/src/testdir/test_utf8.vim @@ -77,7 +77,7 @@ func Test_list2str_str2list_utf8() let s = "\u304b\u3099\u3044" let l = [0x304b, 0x3099, 0x3044] call assert_equal(l, str2list(s, 1)) - call assert_equal(s, list2str(l, 1)) + call assert_equal(s, l->list2str(1)) if &enc ==# 'utf-8' call assert_equal(str2list(s), str2list(s, 1)) call assert_equal(list2str(l), list2str(l, 1)) -- cgit v1.2.3