diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_bufwintabinfo.vim | 1 | ||||
-rw-r--r-- | test/old/testdir/test_cd.vim | 1 | ||||
-rw-r--r-- | test/old/testdir/test_eval_stuff.vim | 18 | ||||
-rw-r--r-- | test/old/testdir/test_execute_func.vim | 16 | ||||
-rw-r--r-- | test/old/testdir/test_expr.vim | 27 | ||||
-rw-r--r-- | test/old/testdir/test_filter_map.vim | 6 | ||||
-rw-r--r-- | test/old/testdir/test_functions.vim | 26 | ||||
-rw-r--r-- | test/old/testdir/test_getvar.vim | 6 | ||||
-rw-r--r-- | test/old/testdir/test_let.vim | 18 | ||||
-rw-r--r-- | test/old/testdir/test_listdict.vim | 18 | ||||
-rw-r--r-- | test/old/testdir/test_messages.vim | 15 | ||||
-rw-r--r-- | test/old/testdir/test_partial.vim | 49 | ||||
-rw-r--r-- | test/old/testdir/test_quickfix.vim | 10 | ||||
-rw-r--r-- | test/old/testdir/test_vimscript.vim | 8 |
14 files changed, 201 insertions, 18 deletions
diff --git a/test/old/testdir/test_bufwintabinfo.vim b/test/old/testdir/test_bufwintabinfo.vim index 326aefb731..63f4fe6bb0 100644 --- a/test/old/testdir/test_bufwintabinfo.vim +++ b/test/old/testdir/test_bufwintabinfo.vim @@ -42,6 +42,7 @@ function Test_getbufwintabinfo() sign undefine Mark enew! endif + call assert_notequal([], getbufinfo(v:_null_dict)) only let w1_id = win_getid() diff --git a/test/old/testdir/test_cd.vim b/test/old/testdir/test_cd.vim index 2b37f2c7c0..cffba99451 100644 --- a/test/old/testdir/test_cd.vim +++ b/test/old/testdir/test_cd.vim @@ -106,6 +106,7 @@ func Test_chdir_func() call assert_equal("", d) " Should not crash call chdir(d) + call assert_equal('', chdir([])) only | tabonly call chdir(topdir) diff --git a/test/old/testdir/test_eval_stuff.vim b/test/old/testdir/test_eval_stuff.vim index 46482c34a1..90e3942c4d 100644 --- a/test/old/testdir/test_eval_stuff.vim +++ b/test/old/testdir/test_eval_stuff.vim @@ -39,6 +39,9 @@ func Test_mkdir_p() call assert_fails('call mkdir("Xfile", "p")', 'E739') call delete('Xfile') call delete('Xmkdir', 'rf') + call assert_equal(0, mkdir(v:_null_string)) + call assert_fails('call mkdir([])', 'E730') + call assert_fails('call mkdir("abc", [], [])', 'E745') endfunc func Test_line_continuation() @@ -205,6 +208,21 @@ func Test_vvar_scriptversion1() call assert_equal(511, 0o777) endfunc +func Test_execute_cmd_with_null() + call assert_fails('execute v:_null_list', 'E730:') + call assert_fails('execute v:_null_dict', 'E731:') + call assert_fails('execute v:_null_blob', 'E976:') + execute v:_null_string + " Nvim doesn't have null partials + " call assert_fails('execute test_null_partial()', 'E729:') + " Nvim doesn't have test_unknown() + " call assert_fails('execute test_unknown()', 'E908:') + if has('job') + call assert_fails('execute test_null_job()', 'E908:') + call assert_fails('execute test_null_channel()', 'E908:') + endif +endfunc + func Test_number_max_min_size() " This will fail on systems without 64 bit number support or when not " configured correctly. diff --git a/test/old/testdir/test_execute_func.vim b/test/old/testdir/test_execute_func.vim index 16cc20e9a7..cc294b7316 100644 --- a/test/old/testdir/test_execute_func.vim +++ b/test/old/testdir/test_execute_func.vim @@ -41,8 +41,6 @@ func Test_execute_string() call assert_equal("\nsomething", execute('echo "something"', 'silent!')) call assert_equal("", execute('burp', 'silent!')) call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:') - - call assert_equal("", execute("")) endfunc func Test_execute_list() @@ -53,7 +51,6 @@ func Test_execute_list() call assert_equal("\n0\n1\n2\n3", execute(l)) call assert_equal("", execute([])) - call assert_equal("", execute(v:_null_list)) endfunc func Test_execute_does_not_change_col() @@ -173,4 +170,17 @@ func Test_win_execute_visual_redraw() bwipe! endfunc +func Test_execute_cmd_with_null() + call assert_equal("", execute(v:_null_string)) + call assert_equal("", execute(v:_null_list)) + call assert_fails('call execute(v:_null_dict)', 'E731:') + call assert_fails('call execute(v:_null_blob)', 'E976:') + " Nvim doesn't have null partials + " call assert_fails('call execute(test_null_partial())','E729:') + if has('job') + call assert_fails('call execute(test_null_job())', 'E908:') + call assert_fails('call execute(test_null_channel())', 'E908:') + endif +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_expr.vim b/test/old/testdir/test_expr.vim index 1810cf6741..1a00a85b0f 100644 --- a/test/old/testdir/test_expr.vim +++ b/test/old/testdir/test_expr.vim @@ -22,6 +22,11 @@ func Test_equal() call assert_false([base.method] == [instance.other]) call assert_fails('echo base.method > instance.method') + " Nvim doesn't have null functions + " call assert_equal(0, test_null_function() == function('min')) + " call assert_equal(1, test_null_function() == test_null_function()) + " Nvim doesn't have test_unknown() + " call assert_fails('eval 10 == test_unknown()', 'E685:') endfunc func Test_version() @@ -134,7 +139,7 @@ func Test_loop_over_null_list() endfor endfunc -func Test_set_reg_null_list() +func Test_setreg_null_list() call setreg('x', v:_null_list) endfunc @@ -712,4 +717,24 @@ func Test_expr_eval_error() call assert_fails("let v = -{}", 'E728:') endfunc +" Test for float value comparison +func Test_float_compare() + CheckFeature float + call assert_true(1.2 == 1.2) + call assert_true(1.0 != 1.2) + call assert_true(1.2 > 1.0) + call assert_true(1.2 >= 1.2) + call assert_true(1.0 < 1.2) + call assert_true(1.2 <= 1.2) + call assert_true(+0.0 == -0.0) + " two NaNs (not a number) are not equal + call assert_true(sqrt(-4.01) != (0.0 / 0.0)) + " two inf (infinity) are equal + call assert_true((1.0 / 0) == (2.0 / 0)) + " two -inf (infinity) are equal + call assert_true(-(1.0 / 0) == -(2.0 / 0)) + " +infinity != -infinity + call assert_true((1.0 / 0) != -(2.0 / 0)) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_filter_map.vim b/test/old/testdir/test_filter_map.vim index c75177ea39..e2216e4d68 100644 --- a/test/old/testdir/test_filter_map.vim +++ b/test/old/testdir/test_filter_map.vim @@ -93,6 +93,12 @@ func Test_map_filter_fails() call assert_equal(v:_null_dict, filter(v:_null_dict, 0)) call assert_equal(v:_null_list, map(v:_null_list, '"> " .. v:val')) call assert_equal(v:_null_dict, map(v:_null_dict, '"> " .. v:val')) + " Nvim doesn't have null functions + " call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_function())) + call assert_fails("let l = filter([1, 2], function('min'))", 'E118:') + " Nvim doesn't have null partials + " call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial())) + call assert_fails("let l = filter([1, 2], {a, b, c -> 1})", 'E119:') endfunc func Test_map_and_modify() diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 4ed1187a19..94c7e20264 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -990,6 +990,7 @@ func Test_matchstrpos() call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8)) call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing')) call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img')) + call assert_equal(['', -1, -1], matchstrpos(v:_null_list, '\a')) endfunc func Test_nextnonblank_prevnonblank() @@ -1284,6 +1285,7 @@ func Test_hlexists() syntax off endfunc +" Test for the col() function func Test_col() new call setline(1, 'abcdef') @@ -1435,6 +1437,8 @@ func Test_inputlist() call assert_equal(-2, c) call assert_fails('call inputlist("")', 'E686:') + " Nvim accepts null list as empty list + " call assert_fails('call inputlist(v:_null_list)', 'E686:') endfunc func Test_range_inputlist() @@ -2357,6 +2361,16 @@ func Test_garbagecollect_now_fails() let v:testing = 1 endfunc +" Test for echo highlighting +func Test_echohl() + echohl Search + echo 'Vim' + call assert_equal('Vim', Screenline(&lines)) + " TODO: How to check the highlight group used by echohl? + " ScreenAttrs() returns all zeros. + echohl None +endfunc + " Test for the eval() function func Test_eval() call assert_fails("call eval('5 a')", 'E488:') @@ -2515,6 +2529,18 @@ func Test_glob() call assert_fails("call glob('*', 0, {})", 'E728:') endfunc +" Test for browse() +func Test_browse() + CheckFeature browse + call assert_fails('call browse([], "open", "x", "a.c")', 'E745:') +endfunc + +" Test for browsedir() +func Test_browsedir() + CheckFeature browse + call assert_fails('call browsedir("open", [])', 'E730:') +endfunc + func HasDefault(msg = 'msg') return a:msg endfunc diff --git a/test/old/testdir/test_getvar.vim b/test/old/testdir/test_getvar.vim index e6b6341fce..331f3cfe8a 100644 --- a/test/old/testdir/test_getvar.vim +++ b/test/old/testdir/test_getvar.vim @@ -150,6 +150,12 @@ func Test_get_func() call assert_equal({'func has': 'no dict'}, get(l:F, 'dict', {'func has': 'no dict'})) call assert_equal(0, get(l:F, 'dict')) call assert_equal([], get(l:F, 'args')) + " Nvim doesn't have null functions + " let NF = test_null_function() + " call assert_equal('', get(NF, 'name')) + " call assert_equal(NF, get(NF, 'func')) + " call assert_equal(0, get(NF, 'dict')) + " call assert_equal([], get(NF, 'args')) endfunc " get({partial}, {what} [, {default}]) - in test_partial.vim diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index fe7633cf11..6fbf305624 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -85,6 +85,24 @@ func Test_let() let l:Test_Local_Var = {'k' : 5} call assert_match("\nl:Test_Local_Var {'k': 5}", execute('let l:')) call assert_match("v:errors []", execute('let v:')) + + " Test for assigning multiple list items + let l = [1, 2, 3] + let [l[0], l[1]] = [10, 20] + call assert_equal([10, 20, 3], l) + + " Test for errors in conditional expression + call assert_fails('let val = [] ? 1 : 2', 'E745:') + call assert_fails('let val = 1 ? 5+ : 6', 'E121:') + call assert_fails('let val = 1 ? 0 : 5+', 'E15:') + call assert_false(exists('val')) + + " Test for errors in logical operators + let @a = 'if [] || 0 | let val = 2 | endif' + call assert_fails('exe @a', 'E745:') + call assert_fails('call feedkeys(":let val = 0 || []\<cr>", "xt")', 'E745:') + call assert_fails('exe "let val = [] && 5"', 'E745:') + call assert_fails('exe "let val = 6 && []"', 'E745:') endfunc func s:set_arg1(a) abort diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim index a6a1c736c4..ba95e2ea9a 100644 --- a/test/old/testdir/test_listdict.vim +++ b/test/old/testdir/test_listdict.vim @@ -794,6 +794,7 @@ func Test_listdict_compare_complex() call assert_true(dict4 == dict4copy) endfunc +" Test for extending lists and dictionaries func Test_listdict_extend() " Test extend() with lists @@ -1028,6 +1029,9 @@ func Test_listdict_index() call assert_fails("let l[1.1] = 4", 'E806:') call assert_fails("let l[:i] = [4, 5]", 'E121:') call assert_fails("let l[:3.2] = [4, 5]", 'E806:') + " Nvim doesn't have test_unknown() + " let t = test_unknown() + " call assert_fails("echo t[0]", 'E685:') endfunc " Test for a null list @@ -1079,8 +1083,20 @@ func Test_null_dict() call assert_equal(0, values(d)) call assert_false(has_key(d, 'k')) call assert_equal('{}', string(d)) - call assert_fails('let x = v:_null_dict[10]') + call assert_fails('let x = d[10]') call assert_equal({}, {}) + call assert_equal(0, len(copy(d))) + call assert_equal(0, count(d, 'k')) + call assert_equal({}, deepcopy(d)) + call assert_equal(20, get(d, 'k', 20)) + call assert_equal(0, min(d)) + call assert_equal(0, max(d)) + call assert_equal(0, remove(d, 'k')) + call assert_equal('{}', string(d)) + " call assert_equal(0, extend(d, d, 0)) + lockvar d + call assert_equal(1, islocked('d')) + unlockvar d endfunc " Test for the indexof() function diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim index bfdebdac79..a20571807b 100644 --- a/test/old/testdir/test_messages.vim +++ b/test/old/testdir/test_messages.vim @@ -403,6 +403,21 @@ func Test_ask_yesno() call StopVimInTerminal(buf) endfunc +func Test_null() + echom v:_null_list + echom v:_null_dict + echom v:_null_blob + echom v:_null_string + " Nvim doesn't have NULL functions + " echom test_null_function() + " Nvim doesn't have NULL partials + " echom test_null_partial() + if has('job') + echom test_null_job() + echom test_null_channel() + endif +endfunc + func Test_mapping_at_hit_return_prompt() nnoremap <C-B> :echo "hit ctrl-b"<CR> call feedkeys(":ls\<CR>", "xt") diff --git a/test/old/testdir/test_partial.vim b/test/old/testdir/test_partial.vim index 3020668f1b..302bc22d93 100644 --- a/test/old/testdir/test_partial.vim +++ b/test/old/testdir/test_partial.vim @@ -63,16 +63,18 @@ endfunc func Test_partial_dict() let dict = {'name': 'hello'} let Cb = function('MyDictFunc', ["foo", "bar"], dict) + call test_garbagecollect_now() call assert_equal("hello/foo/bar", Cb()) call assert_fails('Cb("xxx")', 'E492:') + let Cb = function('MyDictFunc', ["foo"], dict) + call assert_equal("hello/foo/xxx", Cb("xxx")) + call assert_fails('Cb()', 'E492:') + let Cb = function('MyDictFunc', [], dict) call assert_equal("hello/ttt/xxx", Cb("ttt", "xxx")) call assert_fails('Cb("yyy")', 'E492:') - let Cb = function('MyDictFunc', ["foo"], dict) - call assert_equal("hello/foo/xxx", Cb("xxx")) - call assert_fails('Cb()', 'E492:') let Cb = function('MyDictFunc', dict) call assert_equal("hello/xxx/yyy", Cb("xxx", "yyy")) call assert_fails('Cb("fff")', 'E492:') @@ -192,6 +194,10 @@ func Test_partial_string() call assert_equal("function('MyFunc', {'one': 1})", string(F)) let F = function('MyFunc', ['foo'], d) call assert_equal("function('MyFunc', ['foo'], {'one': 1})", string(F)) + " Nvim doesn't have null functions + " call assert_equal("function('')", string(test_null_function())) + " Nvim doesn't have null partials + " call assert_equal("function('')", string(test_null_partial())) endfunc func Test_func_unref() @@ -238,17 +244,22 @@ endfunc func Ignored(job1, job2, status) endfunc -" func Test_cycle_partial_job() -" let job = job_start('echo') -" call job_setoptions(job, {'exit_cb': function('Ignored', [job])}) -" unlet job -" endfunc +func Test_cycle_partial_job() + if has('job') + let job = job_start('echo') + call job_setoptions(job, {'exit_cb': function('Ignored', [job])}) + unlet job + endif +endfunc -" func Test_ref_job_partial_dict() -" let g:ref_job = job_start('echo') -" let d = {'a': 'b'} -" call job_setoptions(g:ref_job, {'exit_cb': function('string', [], d)}) -" endfunc +func Test_ref_job_partial_dict() + if has('job') + let g:ref_job = job_start('echo') + let d = {'a': 'b'} + call job_setoptions(g:ref_job, {'exit_cb': function('string', [], d)}) + call test_garbagecollect_now() + endif +endfunc func Test_auto_partial_rebind() let dict1 = {'name': 'dict1'} @@ -356,6 +367,18 @@ func Test_compare_partials() call assert_true(F1 isnot# F2) " Different functions call assert_true(F1 isnot# F1d1) " Partial /= non-partial call assert_true(d1.f1 isnot# d1.f1) " handle_subscript creates new partial each time + + " compare two null partials + " Nvim doesn't have null partials + " let N1 = test_null_partial() + let N1 = function('min') + let N2 = N1 + call assert_true(N1 is N2) + call assert_true(N1 == N2) + + " compare a partial and a null partial + call assert_false(N1 == F1) + call assert_false(F1 is N1) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_quickfix.vim b/test/old/testdir/test_quickfix.vim index fedc486e62..838c4b1c15 100644 --- a/test/old/testdir/test_quickfix.vim +++ b/test/old/testdir/test_quickfix.vim @@ -2425,6 +2425,16 @@ func Xproperty_tests(cchar) call assert_equal(246, d.context) " set other Vim data types as context call g:Xsetlist([], 'a', {'context' : v:_null_blob}) + if has('channel') + call g:Xsetlist([], 'a', {'context' : test_null_channel()}) + endif + if has('job') + call g:Xsetlist([], 'a', {'context' : test_null_job()}) + endif + " Nvim doesn't have null functions + " call g:Xsetlist([], 'a', {'context' : test_null_function()}) + " Nvim doesn't have null partials + " call g:Xsetlist([], 'a', {'context' : test_null_partial()}) call g:Xsetlist([], 'a', {'context' : ''}) call test_garbagecollect_now() if a:cchar == 'l' diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim index 5988d6ed71..b5578f7f68 100644 --- a/test/old/testdir/test_vimscript.vim +++ b/test/old/testdir/test_vimscript.vim @@ -6508,9 +6508,17 @@ func Test_type() call assert_equal(v:t_float, type(0.0)) call assert_equal(v:t_bool, type(v:false)) call assert_equal(v:t_bool, type(v:true)) + " call assert_equal(v:t_none, type(v:none)) + " call assert_equal(v:t_none, type(v:null)) call assert_equal(v:t_string, type(v:_null_string)) call assert_equal(v:t_list, type(v:_null_list)) call assert_equal(v:t_dict, type(v:_null_dict)) + if has('job') + call assert_equal(v:t_job, type(test_null_job())) + endif + if has('channel') + call assert_equal(v:t_channel, type(test_null_channel())) + endif call assert_equal(v:t_blob, type(v:_null_blob)) call assert_equal(0, 0 + v:false) |