mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
eval,functests: Fix tests and complete() and setline() behaviour
This commit is contained in:
@@ -7496,7 +7496,7 @@ static void f_complete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
if (!undo_allowed())
|
if (!undo_allowed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL) {
|
if (argvars[1].v_type != VAR_LIST) {
|
||||||
EMSG(_(e_invarg));
|
EMSG(_(e_invarg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -14540,20 +14540,19 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
line = tv_get_string_chk(&argvars[1]);
|
line = tv_get_string_chk(&argvars[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default result is zero == OK */
|
// Default result is zero == OK.
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
if (l != NULL) {
|
|
||||||
// List argument, get next string.
|
// List argument, get next string.
|
||||||
if (li == NULL) {
|
if (li == NULL) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
line = tv_get_string_chk(TV_LIST_ITEM_TV(li));
|
|
||||||
li = TV_LIST_ITEM_NEXT(l, li);
|
|
||||||
}
|
|
||||||
|
|
||||||
rettv->vval.v_number = 1; /* FAIL */
|
|
||||||
if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
line = tv_get_string_chk(TV_LIST_ITEM_TV(li));
|
||||||
|
li = TV_LIST_ITEM_NEXT(l, li);
|
||||||
|
|
||||||
|
rettv->vval.v_number = 1; // FAIL
|
||||||
|
if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* When coming here from Insert mode, sync undo, so that this can be
|
/* When coming here from Insert mode, sync undo, so that this can be
|
||||||
* undone separately from what was previously inserted. */
|
* undone separately from what was previously inserted. */
|
||||||
|
@@ -67,6 +67,9 @@ describe('NULL', function()
|
|||||||
null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function()
|
null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function()
|
||||||
eq({''}, curbufmeths.get_lines(0, -1, false))
|
eq({''}, curbufmeths.get_lines(0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
null_expr_test('does not crash setline()', 'setline(1, L)', 0, 0, function()
|
||||||
|
eq({''}, curbufmeths.get_lines(0, -1, false))
|
||||||
|
end)
|
||||||
null_expr_test('is identical to itself', 'L is L', 0, 1)
|
null_expr_test('is identical to itself', 'L is L', 0, 1)
|
||||||
null_expr_test('can be sliced', 'L[:]', 0, {})
|
null_expr_test('can be sliced', 'L[:]', 0, {})
|
||||||
null_expr_test('can be copied', 'copy(L)', 0, {})
|
null_expr_test('can be copied', 'copy(L)', 0, {})
|
||||||
@@ -99,17 +102,20 @@ describe('NULL', function()
|
|||||||
null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 1)
|
null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 1)
|
||||||
null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1)
|
null_expr_test('makes filter() return v:_null_list', 'filter(L, "1") is# L', 0, 1)
|
||||||
null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items')
|
null_test('is treated by :let as empty list', ':let [l] = L', 'Vim(let):E688: More targets than List items')
|
||||||
null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]', 0, 0)
|
null_expr_test('is accepted as an empty list by inputlist()', '[feedkeys("\\n"), inputlist(L)]',
|
||||||
|
'Type number and <Enter> or click with mouse (empty cancels): ', {0, 0})
|
||||||
null_expr_test('is accepted as an empty list by writefile()',
|
null_expr_test('is accepted as an empty list by writefile()',
|
||||||
('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname),
|
('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname),
|
||||||
0, {0, {}})
|
0, {0, {}})
|
||||||
-- FIXME fix test results
|
|
||||||
null_expr_test('does not crash add()', 'add(L, 0)', 0, 1)
|
null_expr_test('does not crash add()', 'add(L, 0)', 0, 1)
|
||||||
null_expr_test('makes insert() error out', 'insert(L, 1)', '', nil)
|
null_expr_test('makes insert() error out', 'insert(L, 1)',
|
||||||
null_expr_test('does not crash remove()', 'remove(L, 0)', 0, 0)
|
'E742: Cannot change value of insert() argument', 0)
|
||||||
null_expr_test('makes reverse() error out', 'reverse(L)', '', nil)
|
null_expr_test('does not crash remove()', 'remove(L, 0)',
|
||||||
null_expr_test('is accepted by sort()', 'sort(L)', 0, 0)
|
'E742: Cannot change value of remove() argument', 0)
|
||||||
null_expr_test('makes sort() return itself', 'sort(L) is L', 0, 0)
|
null_expr_test('makes reverse() error out', 'reverse(L)',
|
||||||
|
'E742: Cannot change value of reverse() argument', 0)
|
||||||
|
null_expr_test('makes sort() error out', 'sort(L)',
|
||||||
|
'E742: Cannot change value of sort() argument', 0)
|
||||||
null_expr_test('does not crash extend()', 'extend(L, [1])', 'E742: Cannot change value of extend() argument', 0)
|
null_expr_test('does not crash extend()', 'extend(L, [1])', 'E742: Cannot change value of extend() argument', 0)
|
||||||
null_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, {1})
|
null_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, {1})
|
||||||
null_expr_test('makes join() return empty string', 'join(L, "")', 0, '')
|
null_expr_test('makes join() return empty string', 'join(L, "")', 0, '')
|
||||||
@@ -117,9 +123,12 @@ describe('NULL', function()
|
|||||||
null_expr_test('does not crash system()', 'system("cat", L)', 0, '')
|
null_expr_test('does not crash system()', 'system("cat", L)', 0, '')
|
||||||
null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0)
|
null_expr_test('does not crash setreg', 'setreg("x", L)', 0, 0)
|
||||||
null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {})
|
null_expr_test('does not crash systemlist()', 'systemlist("cat", L)', 0, {})
|
||||||
null_expr_test('does not crash setline', 'setline(1, L)', 0, 0)
|
|
||||||
null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0)
|
null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0)
|
||||||
-- FIXME Add test for complete(, L)
|
null_expr_test('does not make complete() crash or error out',
|
||||||
|
'execute(":normal i\\<C-r>=complete(1, L)[-1]\\n")',
|
||||||
|
'', '\n', function()
|
||||||
|
eq({''}, curbufmeths.get_lines(0, -1, false))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
describe('dict', function()
|
describe('dict', function()
|
||||||
it('does not crash when indexing NULL dict', function()
|
it('does not crash when indexing NULL dict', function()
|
||||||
|
Reference in New Issue
Block a user