mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #7477 from FlorianGit/empty-lists-dicts-strings
This commit is contained in:
commit
aec81f44d1
@ -8457,11 +8457,13 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map)
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
if (argvars[0].v_type == VAR_LIST) {
|
if (argvars[0].v_type == VAR_LIST) {
|
||||||
|
tv_copy(&argvars[0], rettv);
|
||||||
if ((l = argvars[0].vval.v_list) == NULL
|
if ((l = argvars[0].vval.v_list) == NULL
|
||||||
|| (!map && tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE))) {
|
|| (!map && tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (argvars[0].v_type == VAR_DICT) {
|
} else if (argvars[0].v_type == VAR_DICT) {
|
||||||
|
tv_copy(&argvars[0], rettv);
|
||||||
if ((d = argvars[0].vval.v_dict) == NULL
|
if ((d = argvars[0].vval.v_dict) == NULL
|
||||||
|| (!map && tv_check_lock(d->dv_lock, arg_errmsg, TV_TRANSLATE))) {
|
|| (!map && tv_check_lock(d->dv_lock, arg_errmsg, TV_TRANSLATE))) {
|
||||||
return;
|
return;
|
||||||
@ -8542,8 +8544,6 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map)
|
|||||||
|
|
||||||
did_emsg |= save_did_emsg;
|
did_emsg |= save_did_emsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
tv_copy(&argvars[0], rettv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_map_one(typval_T *tv, typval_T *expr, int map, int *remp)
|
static int filter_map_one(typval_T *tv, typval_T *expr, int map, int *remp)
|
||||||
|
@ -42,14 +42,6 @@ describe('NULL', function()
|
|||||||
describe('list', function()
|
describe('list', function()
|
||||||
-- Incorrect behaviour
|
-- Incorrect behaviour
|
||||||
|
|
||||||
-- FIXME map() should not return 0 without error
|
|
||||||
null_expr_test('does not crash map()', 'map(L, "v:val")', 0, 0)
|
|
||||||
-- FIXME map() should not return 0 without error
|
|
||||||
null_expr_test('does not crash filter()', 'filter(L, "1")', 0, 0)
|
|
||||||
-- FIXME map() should at least return L
|
|
||||||
null_expr_test('makes map() return v:_null_list', 'map(L, "v:val") is# L', 0, 0)
|
|
||||||
-- FIXME filter() should at least return L
|
|
||||||
null_expr_test('makes filter() return v:_null_list', 'map(L, "1") is# L', 0, 0)
|
|
||||||
-- FIXME add() should not return 1 at all
|
-- FIXME add() should not return 1 at all
|
||||||
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('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)
|
||||||
@ -111,6 +103,8 @@ describe('NULL', function()
|
|||||||
null_expr_test('does not crash line()', 'line(L)', 0, 0)
|
null_expr_test('does not crash line()', 'line(L)', 0, 0)
|
||||||
null_expr_test('does not crash count()', 'count(L, 1)', 0, 0)
|
null_expr_test('does not crash count()', 'count(L, 1)', 0, 0)
|
||||||
null_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1)
|
null_expr_test('does not crash cursor()', 'cursor(L)', 'E474: Invalid argument', -1)
|
||||||
|
null_expr_test('does not crash map()', 'map(L, "v:val")', 0, {})
|
||||||
|
null_expr_test('does not crash filter()', 'filter(L, "1")', 0, {})
|
||||||
null_expr_test('is empty', 'empty(L)', 0, 1)
|
null_expr_test('is empty', 'empty(L)', 0, 1)
|
||||||
null_expr_test('does not crash get()', 'get(L, 1, 10)', 0, 10)
|
null_expr_test('does not crash get()', 'get(L, 1, 10)', 0, 10)
|
||||||
null_expr_test('has zero length', 'len(L)', 0, 0)
|
null_expr_test('has zero length', 'len(L)', 0, 0)
|
||||||
@ -126,6 +120,8 @@ describe('NULL', function()
|
|||||||
null_expr_test('is equal to itself', 'L == L', 0, 1)
|
null_expr_test('is equal to itself', 'L == L', 0, 1)
|
||||||
null_expr_test('is not not equal to itself', 'L != L', 0, 0)
|
null_expr_test('is not not equal to itself', 'L != L', 0, 0)
|
||||||
null_expr_test('counts correctly', 'count([L], L)', 0, 1)
|
null_expr_test('counts correctly', 'count([L], 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)
|
||||||
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()
|
||||||
@ -134,5 +130,9 @@ describe('NULL', function()
|
|||||||
end)
|
end)
|
||||||
null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0)
|
null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0)
|
||||||
null_expr_test('makes extend do nothing', 'extend({1: 2}, D)', 0, {['1']=2})
|
null_expr_test('makes extend do nothing', 'extend({1: 2}, D)', 0, {['1']=2})
|
||||||
|
null_expr_test('does not crash map()', 'map(D, "v:val")', 0, {})
|
||||||
|
null_expr_test('does not crash filter()', 'filter(D, "1")', 0, {})
|
||||||
|
null_expr_test('makes map() return v:_null_dict', 'map(D, "v:val") is# D', 0, 1)
|
||||||
|
null_expr_test('makes filter() return v:_null_dict', 'filter(D, "1") is# D', 0, 1)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user